Skip to content

Commit

Permalink
import cm telephony and RIL support
Browse files Browse the repository at this point in the history
  • Loading branch information
codenamedroid authored and knzy committed Sep 13, 2012
1 parent cdec141 commit e6a4f7c
Show file tree
Hide file tree
Showing 40 changed files with 5,796 additions and 92 deletions.
7 changes: 7 additions & 0 deletions telephony/java/android/telephony/PhoneNumberUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,13 @@ public static String formatNumber(
* @hide
*/
public static String normalizeNumber(String phoneNumber) {
// chop off CLIR prefix
if (phoneNumber.startsWith(CLIR_ON)) {
phoneNumber = phoneNumber.substring(CLIR_ON.length() - 1);
} else if (phoneNumber.startsWith(CLIR_OFF)) {
phoneNumber = phoneNumber.substring(CLIR_OFF.length() - 1);
}

StringBuilder sb = new StringBuilder();
int len = phoneNumber.length();
for (int i = 0; i < len; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public byte[] buildAdnString(int recordSize) {
private void
parseRecord(byte[] record) {
try {
alphaTag = IccUtils.adnStringFieldToString(
alphaTag = IccUtils.adnStringFieldToStringKsc5601Support(
record, 0, record.length - FOOTER_SIZE_BYTES);

int footerOffset = record.length - FOOTER_SIZE_BYTES;
Expand Down
25 changes: 25 additions & 0 deletions telephony/java/com/android/internal/telephony/CallManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,31 @@ public void setAudioMode() {
}
break;
}

// Set additional audio parameters needed for incall audio
String[] audioParams = context.getResources().getStringArray(com.android.internal.R.array.config_telephony_set_audioparameters);
String[] aPValues;

for (String parameter : audioParams) {
aPValues = parameter.split("=");

if(aPValues[1] == null || aPValues[1].length() == 0) {
aPValues[1] = "on";
}

if(aPValues[2] == null || aPValues[2].length() == 0) {
aPValues[2] = "off";
}

if (audioManager.getMode() == AudioManager.MODE_IN_CALL) {
Log.d(LOG_TAG, "setAudioMode(): " + aPValues[0] + "=" + aPValues[1]);
audioManager.setParameters(aPValues[0] + "=" + aPValues[1]);
} else if (audioManager.getMode() == AudioManager.MODE_NORMAL) {
Log.d(LOG_TAG, "setAudioMode(): " + aPValues[0] + "=" + aPValues[2]);
audioManager.setParameters(aPValues[0] + "=" + aPValues[2]);
}
}

}

private Context getContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1576,4 +1576,10 @@ public void setupDataCall(String radioTechnology, String profile,
* Notifiy that we are testing an emergency call
*/
public void testingEmergencyCall();

/**
* @hide
* CM-specific: Ask the RIL about the presence of back-compat flags
*/
public boolean needsOldRilFeature(String feature);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public String toString() {
.append(" retry=").append(suggestedRetryTime)
.append(" cid=").append(cid)
.append(" active=").append(active)
.append(" type=").append(type)
.append(" type='").append(type)
.append("' ifname='").append(ifname);
sb.append("' addresses=[");
for (String addr : addresses) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,27 @@ private void notifyDisconnectCompleted(DisconnectParams dp, boolean sendAll) {
if (DBG) log("NotifyDisconnectCompleted DisconnectParams=" + dp);
}

protected boolean needsOldRilFeature(String feature) {
String[] features = SystemProperties.get("ro.telephony.ril.v3", "").split(",");
for (String found: features) {
if (found.equals(feature))
return true;
}
return false;
}

protected int getRilRadioTechnology(int defaultRilRadioTechnology) {
int rilRadioTechnology;
if (mRilVersion < 6) {
rilRadioTechnology = defaultRilRadioTechnology;
} else {
rilRadioTechnology = phone.getServiceState().getRilRadioTechnology() + 2;
if (needsOldRilFeature("usehcradio") ) {
rilRadioTechnology = phone.getServiceState().getRilRadioTechnology() - 2;
if (rilRadioTechnology != 1) // in reality if it is not 1 something is wrong for hc ??
rilRadioTechnology = 1;
}
else
rilRadioTechnology = phone.getServiceState().getRilRadioTechnology() + 2;
}
return rilRadioTechnology;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ public enum Activity {
public static final int DISABLED = 0;
public static final int ENABLED = 1;

/**
* Constants for the data connection activity:
* physical link down/up
*/
protected static final int DATA_CONNECTION_ACTIVE_PH_LINK_INACTIVE = 0;
protected static final int DATA_CONNECTION_ACTIVE_PH_LINK_DOWN = 1;
protected static final int DATA_CONNECTION_ACTIVE_PH_LINK_UP = 2;

public static final String APN_TYPE_KEY = "apnType";

/** Delay between APN attempts.
Expand Down
227 changes: 227 additions & 0 deletions telephony/java/com/android/internal/telephony/HTCQualcommRIL.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
/*
* Copyright (C) 2012 The CyanogenMod Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.android.internal.telephony;

import static com.android.internal.telephony.RILConstants.*;

import android.content.Context;
import android.os.AsyncResult;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Parcel;
import android.text.TextUtils;
import android.util.Log;

import java.util.ArrayList;

/**
* Qualcomm RIL class for basebands that do not send the SIM status
* piggybacked in RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED. Instead,
* these radios will send radio state and we have to query for SIM
* status separately.
*
* {@hide}
*/
public class HTCQualcommRIL extends QualcommSharedRIL implements CommandsInterface {
private final int RIL_INT_RADIO_OFF = 0;
private final int RIL_INT_RADIO_UNAVAILABLE = 1;
private final int RIL_INT_RADIO_ON = 13;

public HTCQualcommRIL(Context context, int networkMode, int cdmaSubscription) {
super(context, networkMode, cdmaSubscription);
}

@Override
protected Object
responseIccCardStatus(Parcel p) {
IccCardApplication ca;

// use old needsOldRilFeature method for feature. it would be redundant to make
// a new method just for naming sake.
boolean subscriptionFromSource = needsOldRilFeature("subscriptionFromSource");
boolean oldRil = needsOldRilFeature("icccardstatus");

IccCardStatus status = new IccCardStatus();
status.setCardState(p.readInt());
status.setUniversalPinState(p.readInt());
status.setGsmUmtsSubscriptionAppIndex(p.readInt());
status.setCdmaSubscriptionAppIndex(p.readInt());

if (!oldRil)
status.setImsSubscriptionAppIndex(p.readInt());

int numApplications = p.readInt();

// limit to maximum allowed applications
if (numApplications > IccCardStatus.CARD_MAX_APPS) {
numApplications = IccCardStatus.CARD_MAX_APPS;
}
status.setNumApplications(numApplications);

for (int i = 0 ; i < numApplications ; i++) {
ca = new IccCardApplication();
ca.app_type = ca.AppTypeFromRILInt(p.readInt());
ca.app_state = ca.AppStateFromRILInt(p.readInt());
ca.perso_substate = ca.PersoSubstateFromRILInt(p.readInt());
if ((ca.app_state == IccCardApplication.AppState.APPSTATE_SUBSCRIPTION_PERSO) &&
((ca.perso_substate == IccCardApplication.PersoSubState.PERSOSUBSTATE_READY) ||
(ca.perso_substate == IccCardApplication.PersoSubState.PERSOSUBSTATE_UNKNOWN))) {
// ridiculous HTC hack
ca.app_state = IccCardApplication.AppState.APPSTATE_UNKNOWN;
Log.d(LOG_TAG, "ca.app_state == AppState.APPSTATE_SUBSCRIPTION_PERSO");
Log.d(LOG_TAG, "ca.perso_substate == PersoSubState.PERSOSUBSTATE_READY");
}
ca.aid = p.readString();
ca.app_label = p.readString();
ca.pin1_replaced = p.readInt();
ca.pin1 = ca.PinStateFromRILInt(p.readInt());
ca.pin2 = ca.PinStateFromRILInt(p.readInt());
status.addApplication(ca);
}

// use ril response to determine subscription source
if (subscriptionFromSource)
return status;

int appIndex = -1;
if (mPhoneType == RILConstants.CDMA_PHONE) {
appIndex = status.getCdmaSubscriptionAppIndex();
Log.d(LOG_TAG, "This is a CDMA PHONE " + appIndex);
} else {
appIndex = status.getGsmUmtsSubscriptionAppIndex();
Log.d(LOG_TAG, "This is a GSM PHONE " + appIndex);
}

mAid = status.getApplication(appIndex).aid;

return status;
}

@Override
protected Object
responseSignalStrength(Parcel p) {
int numInts = 14;
int response[];

/* HTC signal strength format:
* 0: GW_SignalStrength
* 1: GW_SignalStrength.bitErrorRate
* 2: CDMA_SignalStrength.dbm
* 3: CDMA_SignalStrength.ecio
* 4: EVDO_SignalStrength.dbm
* 5: EVDO_SignalStrength.ecio
* 6: EVDO_SignalStrength.signalNoiseRatio
* 7: ATT_SignalStrength.dbm
* 8: ATT_SignalStrength.ecno
* 9: LTE_SignalStrength.signalStrength
* 10: LTE_SignalStrength.rsrp
* 11: LTE_SignalStrength.rsrq
* 12: LTE_SignalStrength.rssnr
* 13: LTE_SignalStrength.cqi
*/

response = new int[numInts];
for (int i = 0; i < numInts; i++) {
if (i > 8) {
response[i-2] = p.readInt();
response[i] = -1;
} else {
response[i] = p.readInt();
}
}

return response;
}

@Override
protected void
processUnsolicited (Parcel p) {
Object ret;
int dataPosition = p.dataPosition(); // save off position within the Parcel
int response = p.readInt();

switch(response) {
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: ret = responseVoid(p); break;
case 21004: ret = responseVoid(p); break; // RIL_UNSOL_VOICE_RADIO_TECH_CHANGED
case 21005: ret = responseVoid(p); break; // RIL_UNSOL_IMS_NETWORK_STATE_CHANGED
case 21007: ret = responseVoid(p); break; // RIL_UNSOL_DATA_NETWORK_STATE_CHANGED

default:
// Rewind the Parcel
p.setDataPosition(dataPosition);

// Forward responses that we are not overriding to the super class
super.processUnsolicited(p);
return;
}

switch(response) {
case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
int state = p.readInt();
setRadioStateFromRILInt(state);
break;
case 21004:
case 21005:
case 21007:
if (RILJ_LOGD) unsljLogRet(response, ret);

if (mExitEmergencyCallbackModeRegistrants != null) {
mExitEmergencyCallbackModeRegistrants.notifyRegistrants(
new AsyncResult (null, null, null));
}
break;
}
}

private void setRadioStateFromRILInt(int stateCode) {
CommandsInterface.RadioState radioState;
HandlerThread handlerThread;
Looper looper;
IccHandler iccHandler;

switch (stateCode) {
case RIL_INT_RADIO_OFF:
radioState = CommandsInterface.RadioState.RADIO_OFF;
if (mIccHandler != null) {
mIccThread = null;
mIccHandler = null;
}
break;
case RIL_INT_RADIO_UNAVAILABLE:
radioState = CommandsInterface.RadioState.RADIO_UNAVAILABLE;
break;
case RIL_INT_RADIO_ON:
if (mIccHandler == null) {
handlerThread = new HandlerThread("IccHandler");
mIccThread = handlerThread;

mIccThread.start();

looper = mIccThread.getLooper();
mIccHandler = new IccHandler(this,looper);
mIccHandler.run();
}
radioState = CommandsInterface.RadioState.RADIO_ON;
break;
default:
throw new RuntimeException("Unrecognized RIL_RadioState: " + stateCode);
}

setRadioState(radioState);
}
}
Loading

0 comments on commit e6a4f7c

Please sign in to comment.