diff options
Diffstat (limited to 'telephony')
9 files changed, 1413 insertions, 361 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index db78e2e..9e3a3fd 100755 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -470,6 +470,17 @@ public class TelephonyManager { } } + /** + * {@hide} + */ + public void toggleLTE(boolean on) { + try { + getITelephony().toggleLTE(on); + } catch (RemoteException e) { + //Silently fail + } + } + /** Unknown network class. {@hide} */ public static final int NETWORK_CLASS_UNKNOWN = 0; /** Class of broadly defined "2G" networks. {@hide} */ diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 19441cd..cd92e93 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -44,6 +44,12 @@ interface ITelephony { void call(String number); /** + * Toggle between 3G and LTE (NT_MODE_CDMA, NT_MODE_GLOBAL) + * @param boolean to turn on and off LTE + */ + void toggleLTE(boolean on); + + /** * If there is currently a call in progress, show the call screen. * The DTMF dialpad may or may not be visible initially, depending on * whether it was up when the user last exited the InCallScreen. diff --git a/telephony/java/com/android/internal/telephony/LGEStarRIL.java b/telephony/java/com/android/internal/telephony/LGEStarRIL.java index 0606225..9fd00cf 100644 --- a/telephony/java/com/android/internal/telephony/LGEStarRIL.java +++ b/telephony/java/com/android/internal/telephony/LGEStarRIL.java @@ -1018,14 +1018,12 @@ public class LGEStarRIL extends RIL implements CommandsInterface { /* Infineon modems need some additional hax... */ if (isIfx) { - /* Store DST before cropping */ - parcelextra = parceldata.substring(parceldata.lastIndexOf(",")+1); - if (parcelextra != null) dst = Integer.parseInt(parcelextra); - parceldata = parceldata.substring(0,(parceldata.lastIndexOf(","))); + String [] parcelarray = parceldata.split(","); + parceldata = parcelarray[0] + "," + parcelarray[1]; // assuming there is always one comma at least + parcelextra = (parcelarray.length > 2 ? parcelarray[2] : "0"); + dst = Integer.parseInt(parcelextra); } - int offset = num*15*60*1000; // DST corrected - /* WTH... Date may come with 4 digits in the year, reduce to 2 */ try { dateFormatter = new SimpleDateFormat("yy/MM/dd,HH:mm:ss"); @@ -1034,6 +1032,7 @@ public class LGEStarRIL extends RIL implements CommandsInterface { /* Ifx delivers localtime, convert to UTC */ if (isIfx) { /* Directly calculate UTC time using DST Offset */ + int offset = num*15*60*1000; // DST corrected long when = dateParser.parse(parceldata).getTime() - offset; Date d = new Date(when); response = dateFormatter.format(d); diff --git a/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java index 042075d..8de4798 100644 --- a/telephony/java/com/android/internal/telephony/RIL.java +++ b/telephony/java/com/android/internal/telephony/RIL.java @@ -3601,7 +3601,7 @@ public class RIL extends BaseCommands implements CommandsInterface { case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: return "UNSOL_CDMA_OTA_PROVISION_STATUS"; case RIL_UNSOL_CDMA_INFO_REC: return "UNSOL_CDMA_INFO_REC"; case RIL_UNSOL_OEM_HOOK_RAW: return "UNSOL_OEM_HOOK_RAW"; - case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONG"; + case RIL_UNSOL_RINGBACK_TONE: return "UNSOL_RINGBACK_TONE"; case RIL_UNSOL_RESEND_INCALL_MUTE: return "UNSOL_RESEND_INCALL_MUTE"; case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: return "CDMA_SUBSCRIPTION_SOURCE_CHANGED"; case RIL_UNSOl_CDMA_PRL_CHANGED: return "UNSOL_CDMA_PRL_CHANGED"; diff --git a/telephony/java/com/android/internal/telephony/SamsungRIL.java b/telephony/java/com/android/internal/telephony/SamsungRIL.java index 11ffa13..38ae600 100644 --- a/telephony/java/com/android/internal/telephony/SamsungRIL.java +++ b/telephony/java/com/android/internal/telephony/SamsungRIL.java @@ -31,6 +31,8 @@ import com.android.internal.telephony.RILConstants; import com.android.internal.telephony.SmsResponse; import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; import com.android.internal.telephony.cdma.CdmaInformationRecords; +import com.android.internal.telephony.cdma.CdmaInformationRecords.CdmaSignalInfoRec; +import com.android.internal.telephony.cdma.SignalToneUtil; import android.util.Log; @@ -47,6 +49,7 @@ public class SamsungRIL extends RIL implements CommandsInterface { static final int RIL_UNSOL_STK_SEND_SMS_RESULT = 11002; static final int RIL_UNSOL_O2_HOME_ZONE_INFO = 11007; static final int RIL_UNSOL_DEVICE_READY_NOTI = 11008; + static final int RIL_UNSOL_GPS_NOTI = 11009; static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3 = 11010; static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2 = 11011; static final int RIL_UNSOL_HSDPA_STATE_CHANGED = 11016; @@ -121,7 +124,7 @@ public class SamsungRIL extends RIL implements CommandsInterface { case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break; case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break; case RIL_REQUEST_UDUB: ret = responseVoid(p); break; - case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break; + case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseLastCallFailCause(p); break; case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break; case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseVoiceRegistrationState(p); break; case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseStrings(p); break; @@ -144,7 +147,7 @@ public class SamsungRIL extends RIL implements CommandsInterface { case RIL_REQUEST_GET_IMEI: ret = responseString(p); break; case RIL_REQUEST_GET_IMEISV: ret = responseString(p); break; case RIL_REQUEST_ANSWER: ret = responseVoid(p); break; - case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseDeactivateDataCall(p); break; + case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseVoid(p); break; case RIL_REQUEST_QUERY_FACILITY_LOCK: ret = responseInts(p); break; case RIL_REQUEST_SET_FACILITY_LOCK: ret = responseInts(p); break; case RIL_REQUEST_CHANGE_BARRING_PASSWORD: ret = responseVoid(p); break; @@ -343,6 +346,7 @@ public class SamsungRIL extends RIL implements CommandsInterface { case RIL_UNSOL_O2_HOME_ZONE_INFO: ret = responseVoid(p); break; case RIL_UNSOL_STK_SEND_SMS_RESULT: ret = responseVoid(p); break; case RIL_UNSOL_DEVICE_READY_NOTI: ret = responseVoid(p); break; + case RIL_UNSOL_GPS_NOTI: ret = responseVoid(p); break; // Ignored in TW RIL. case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST: ret = responseVoid(p); break; case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2: ret = responseVoid(p); break; case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3: ret = responseVoid(p); break; @@ -776,6 +780,22 @@ public class SamsungRIL extends RIL implements CommandsInterface { return response; } + + protected Object + responseLastCallFailCause(Parcel p) { + int response[] = (int[])responseInts(p); + + if (mIsSamsungCdma && response.length > 0 && + response[0] == com.android.internal.telephony.cdma.CallFailCause.ERROR_UNSPECIFIED) { + + // Far-end hangup returns ERROR_UNSPECIFIED, which shows "Call Lost" dialog. + Log.d(LOG_TAG, "Overriding ERROR_UNSPECIFIED fail cause with NORMAL_CLEARING."); + response[0] = com.android.internal.telephony.cdma.CallFailCause.NORMAL_CLEARING; + } + + return response; + } + @Override protected Object responseSignalStrength(Parcel p) { @@ -877,6 +897,14 @@ public class SamsungRIL extends RIL implements CommandsInterface { } } } else { + if (mIsSamsungCdma) { + // On rare occasion the pppd_cdma service is left active from a stale + // session, causing the data call setup to fail. Make sure that pppd_cdma + // is stopped now, so that the next setup attempt may succeed. + Log.d(LOG_TAG, "Set ril.cdma.data_state=0 to make sure pppd_cdma is stopped."); + SystemProperties.set("ril.cdma.data_state", "0"); + } + dataCall.status = FailCause.ERROR_UNSPECIFIED.getErrorCode(); // Who knows? } @@ -918,15 +946,16 @@ public class SamsungRIL extends RIL implements CommandsInterface { return false; } - protected Object - responseDeactivateDataCall(Parcel p) { + @Override + public void + deactivateDataCall(int cid, int reason, Message result) { if (mIsSamsungCdma) { // Disconnect: Set ril.cdma.data_state=0 to stop pppd_cdma service. Log.d(LOG_TAG, "Set ril.cdma.data_state=0."); SystemProperties.set("ril.cdma.data_state", "0"); } - return null; + super.deactivateDataCall(cid, reason, result); } protected Object @@ -943,6 +972,62 @@ public class SamsungRIL extends RIL implements CommandsInterface { return response; } + // Workaround for Samsung CDMA "ring of death" bug: + // + // Symptom: As soon as the phone receives notice of an incoming call, an + // audible "old fashioned ring" is emitted through the earpiece and + // persists through the duration of the call, or until reboot if the call + // isn't answered. + // + // Background: The CDMA telephony stack implements a number of "signal info + // tones" that are locally generated by ToneGenerator and mixed into the + // voice call path in response to radio RIL_UNSOL_CDMA_INFO_REC requests. + // One of these tones, IS95_CONST_IR_SIG_IS54B_L, is requested by the + // radio just prior to notice of an incoming call when the voice call + // path is muted. CallNotifier is responsible for stopping all signal + // tones (by "playing" the TONE_CDMA_SIGNAL_OFF tone) upon receipt of a + // "new ringing connection", prior to unmuting the voice call path. + // + // Problem: CallNotifier's incoming call path is designed to minimize + // latency to notify users of incoming calls ASAP. Thus, + // SignalInfoTonePlayer requests are handled asynchronously by spawning a + // one-shot thread for each. Unfortunately the ToneGenerator API does + // not provide a mechanism to specify an ordering on requests, and thus, + // unexpected thread interleaving may result in ToneGenerator processing + // them in the opposite order that CallNotifier intended. In this case, + // playing the "signal off" tone first, followed by playing the "old + // fashioned ring" indefinitely. + // + // Solution: An API change to ToneGenerator is required to enable + // SignalInfoTonePlayer to impose an ordering on requests (i.e., drop any + // request that's older than the most recent observed). Such a change, + // or another appropriate fix should be implemented in AOSP first. + // + // Workaround: Intercept RIL_UNSOL_CDMA_INFO_REC requests from the radio, + // check for a signal info record matching IS95_CONST_IR_SIG_IS54B_L, and + // drop it so it's never seen by CallNotifier. If other signal tones are + // observed to cause this problem, they should be dropped here as well. + @Override + protected void + notifyRegistrantsCdmaInfoRec(CdmaInformationRecords infoRec) { + final int response = RIL_UNSOL_CDMA_INFO_REC; + + if (/* mIsSamsungCdma && */ infoRec.record instanceof CdmaSignalInfoRec) { + CdmaSignalInfoRec sir = (CdmaSignalInfoRec)infoRec.record; + if (sir != null && sir.isPresent && + sir.signalType == SignalToneUtil.IS95_CONST_IR_SIGNAL_IS54B && + sir.alertPitch == SignalToneUtil.IS95_CONST_IR_ALERT_MED && + sir.signal == SignalToneUtil.IS95_CONST_IR_SIG_IS54B_L) { + + Log.d(LOG_TAG, "Dropping \"" + responseToString(response) + " " + + retToString(response, sir) + "\" to prevent \"ring of death\" bug."); + return; + } + } + + super.notifyRegistrantsCdmaInfoRec(infoRec); + } + protected class SamsungDriverCall extends DriverCall { @Override public String diff --git a/telephony/java/com/android/internal/telephony/SemcRIL.java b/telephony/java/com/android/internal/telephony/SemcRIL.java index 9288aa1..837f148 100644 --- a/telephony/java/com/android/internal/telephony/SemcRIL.java +++ b/telephony/java/com/android/internal/telephony/SemcRIL.java @@ -1,8 +1,6 @@ /* * Copyright (C) 2011 The CyanogenMod Project * - * Diogo Ferreira, Andreas Makris, Alin Jerpelea - * * 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 @@ -20,247 +18,208 @@ package com.android.internal.telephony; import static com.android.internal.telephony.RILConstants.*; -import android.content.Context; -import android.content.res.Resources; -import android.os.Message; -import android.os.Parcel; -import android.os.SystemProperties; +import android.content.*; +import android.net.*; +import android.os.*; +import android.telephony.*; import android.text.TextUtils; import android.util.Log; -import android.net.ConnectivityManager; -import android.net.LocalSocket; -import android.net.LocalSocketAddress; - -import com.android.internal.telephony.DataCallState; -import com.android.internal.telephony.DataConnection.FailCause; -import com.android.internal.telephony.OperatorInfo; -import com.android.internal.telephony.IccCardApplication; -import com.android.internal.telephony.IccCardStatus; - -import java.util.ArrayList; - +import com.android.internal.telephony.cdma.CdmaCallWaitingNotification; +import com.android.internal.telephony.cdma.CdmaInformationRecords; +import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo; +import com.android.internal.telephony.gsm.SuppServiceNotification; +import java.io.*; +import java.util.*; /** * Custom SEMC ril * * {@hide} */ -public class SemcRIL extends QualcommNoSimReadyRIL implements CommandsInterface { - protected String mAid; - - boolean RILJ_LOGV = true; - boolean RILJ_LOGD = true; +public class SemcRIL extends RIL { + String mAid = ""; + IccHandler mIccHandler; + HandlerThread mIccThread; public SemcRIL(Context context, int networkMode, int cdmaSubscription) { super(context, networkMode, cdmaSubscription); + mIccHandler = null; } @Override - public void - supplyIccPin(String pin, Message result) { - // but this request is also valid for SIM and RUIM - RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN, result); - - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - rr.mp.writeInt(0); - rr.mp.writeString(mAid); - rr.mp.writeString(pin); - - send(rr); + protected RadioState getRadioStateFromInt(int stateInt) { + RadioState state; + + /* RIL_RadioState ril.h */ + switch(stateInt) { + case 0: state = RadioState.RADIO_OFF; break; + case 1: state = RadioState.RADIO_UNAVAILABLE; break; + case 2: { + if (mIccHandler == null) + { + mIccThread = new HandlerThread("IccHandler"); + mIccThread.start(); + mIccHandler = new IccHandler(this, mIccThread.getLooper()); + } + mIccHandler.run(); + state = mPhoneType == RILConstants.CDMA_PHONE ? RadioState.RUIM_NOT_READY : RadioState.SIM_NOT_READY; + break; + } + case 3: state = RadioState.SIM_LOCKED_OR_ABSENT; break; + case 4: state = RadioState.SIM_READY; break; + case 5: state = RadioState.RUIM_NOT_READY; break; + case 6: state = RadioState.RUIM_READY; break; + case 7: state = RadioState.RUIM_LOCKED_OR_ABSENT; break; + case 8: state = RadioState.NV_NOT_READY; break; + case 9: state = RadioState.NV_READY; break; + + default: + throw new RuntimeException( + "Unrecognized RIL_RadioState: " + stateInt); + } + return state; } @Override - public void - supplyIccPuk(String puk, String newPin, Message result) { - //Note: This RIL request has not been renamed to ICC, - // but this request is also valid for SIM and RUIM - RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PUK, result); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - rr.mp.writeInt(0); - rr.mp.writeString(mAid); - rr.mp.writeString(puk); - rr.mp.writeString(newPin); + protected Object + responseIccCardStatus(Parcel p) { + IccCardApplication ca; - send(rr); - } + IccCardStatus status = new IccCardStatus(); + status.setCardState(p.readInt()); + status.setUniversalPinState(p.readInt()); + status.setGsmUmtsSubscriptionAppIndex(p.readInt()); + status.setCdmaSubscriptionAppIndex(p.readInt()); + status.setImsSubscriptionAppIndex(p.readInt()); - @Override - public void - supplyIccPin2(String pin, Message result) { - //Note: This RIL request has not been renamed to ICC, - // but this request is also valid for SIM and RUIM - RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PIN2, result); + int numApplications = p.readInt(); - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); + // limit to maximum allowed applications + if (numApplications > IccCardStatus.CARD_MAX_APPS) { + numApplications = IccCardStatus.CARD_MAX_APPS; + } + status.setNumApplications(numApplications); - rr.mp.writeInt(0); - rr.mp.writeString(mAid); - rr.mp.writeString(pin); + 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()); + 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); + } - send(rr); + updateIccType(status); + return status; } - @Override - public void - supplyIccPuk2(String puk, String newPin2, Message result) { - //Note: This RIL request has not been renamed to ICC, - // but this request is also valid for SIM and RUIM - RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_SIM_PUK2, result); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - rr.mp.writeInt(0); - rr.mp.writeString(mAid); - rr.mp.writeString(puk); - rr.mp.writeString(newPin2); + private void updateIccType (IccCardStatus status) { + if (status.getNumApplications() > 0) + { + int appType; + if (mPhoneType == RILConstants.CDMA_PHONE) + { + appType = status.getCdmaSubscriptionAppIndex(); + } else { + appType = status.getGsmUmtsSubscriptionAppIndex(); + } - send(rr); + IccCardApplication application = status.getApplication(appType); + mAid = application.aid; + Log.d(LOG_TAG, "Picked default AID: " + mAid); + SystemProperties.set("ril.icctype", Integer.toString(application.app_type.ordinal())); + } } @Override - public void - changeIccPin(String oldPin, String newPin, Message result) { - //Note: This RIL request has not been renamed to ICC, - // but this request is also valid for SIM and RUIM - RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_SIM_PIN, result); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - rr.mp.writeInt(0); - rr.mp.writeString(mAid); - rr.mp.writeString(oldPin); - rr.mp.writeString(newPin); + protected DataCallState getDataCallState(Parcel p, int version) { + DataCallState dataCall = new DataCallState(); - send(rr); + dataCall.version = version; + if (version < 5) { + dataCall.cid = p.readInt(); + dataCall.active = p.readInt(); + dataCall.type = p.readString(); + String addresses = p.readString(); + if (!TextUtils.isEmpty(addresses)) { + dataCall.addresses = addresses.split(" "); + } + // DataCallState needs an ifname. Since we don't have one use the name from the ThrottleService resource (default=rmnet0). + dataCall.ifname = "rmnet0"; + } else { + dataCall.status = p.readInt(); + dataCall.suggestedRetryTime = p.readInt(); + dataCall.cid = p.readInt(); + dataCall.active = p.readInt(); + dataCall.type = p.readString(); + dataCall.ifname = p.readString(); + if ((dataCall.status == DataConnection.FailCause.NONE.getErrorCode()) && + TextUtils.isEmpty(dataCall.ifname)) { + throw new RuntimeException("getDataCallState, no ifname"); + } + String addresses = p.readString(); + if (!TextUtils.isEmpty(addresses)) { + dataCall.addresses = addresses.split(" "); + } + String dnses = p.readString(); + if (!TextUtils.isEmpty(dnses)) { + dataCall.dnses = dnses.split(" "); + } + String gateways = p.readString(); + if (!TextUtils.isEmpty(gateways)) { + dataCall.gateways = gateways.split(" "); + } + } + return dataCall; } - @Override - public void - changeIccPin2(String oldPin2, String newPin2, Message result) { - //Note: This RIL request has not been renamed to ICC, - // but this request is also valid for SIM and RUIM - RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_SIM_PIN2, result); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - rr.mp.writeInt(0); - rr.mp.writeString(mAid); - rr.mp.writeString(oldPin2); - rr.mp.writeString(newPin2); - send(rr); + @Override public void + supplyIccPin(String pin, Message result) { + supplyIccPinForApp(pin, mAid, result); } - @Override - public void - supplyNetworkDepersonalization(String netpin, Message result) { - RILRequest rr = RILRequest.obtain(RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION, result); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - rr.mp.writeInt(3); - rr.mp.writeString(netpin); - - send(rr); + @Override public void + changeIccPin(String oldPin, String newPin, Message result) { + changeIccPinForApp(oldPin, newPin, mAid, result); } - @Override - public void - changeBarringPassword(String facility, String oldPwd, String newPwd, Message result) { - RILRequest rr = RILRequest.obtain(RIL_REQUEST_CHANGE_BARRING_PASSWORD, result); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - rr.mp.writeInt(3); - rr.mp.writeString(facility); - rr.mp.writeString(oldPwd); - rr.mp.writeString(newPwd); - - send(rr); + @Override public void + supplyIccPin2(String pin, Message result) { + supplyIccPin2ForApp(pin, mAid, result); } - - @Override - public void - dial(String address, int clirMode, UUSInfo uusInfo, Message result) { - RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result); - - rr.mp.writeString(address); - rr.mp.writeInt(clirMode); - - if (uusInfo == null) { - rr.mp.writeInt(0); // UUS information is absent - } else { - rr.mp.writeInt(1); // UUS information is present - rr.mp.writeInt(uusInfo.getType()); - rr.mp.writeInt(uusInfo.getDcs()); - rr.mp.writeByteArray(uusInfo.getUserData()); - } - rr.mp.writeInt(0xff); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - send(rr); + @Override public void + changeIccPin2(String oldPin2, String newPin2, Message result) { + changeIccPin2ForApp(oldPin2, newPin2, mAid, result); } - @Override - public void - getIMSI(Message result) { - RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMSI, result); - rr.mp.writeInt(0); - rr.mp.writeString(mAid); - if (RILJ_LOGD) riljLog(rr.serialString() + - "> getIMSI:RIL_REQUEST_GET_IMSI " + - RIL_REQUEST_GET_IMSI + - " " + requestToString(rr.mRequest)); + @Override public void + supplyIccPuk(String puk, String newPin, Message result) { + supplyIccPukForApp(puk, newPin, mAid, result); + } - send(rr); + @Override public void + supplyIccPuk2(String puk2, String newPin2, Message result) { + supplyIccPuk2ForApp(puk2, newPin2, mAid, result); } @Override public void - setupDataCall(String radioTechnology, String profile, String apn, - String user, String password, String authType, String ipVersion, - Message result) { - RILRequest rr - = RILRequest.obtain(RIL_REQUEST_SETUP_DATA_CALL, result); - - rr.mp.writeInt(7); - - rr.mp.writeString(radioTechnology); - rr.mp.writeString(profile); - rr.mp.writeString(apn); - rr.mp.writeString(user); - rr.mp.writeString(password); - rr.mp.writeString(authType); - rr.mp.writeString(ipVersion); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " - + requestToString(rr.mRequest) + " " + radioTechnology + " " - + profile + " " + apn + " " + user + " " - + password + " " + authType + " " + ipVersion); - - send(rr); + queryFacilityLock(String facility, String password, int serviceClass, + Message response) { + queryFacilityLockForApp(facility, password, serviceClass, mAid, response); } @Override public void - deactivateDataCall(int cid, int reason, Message result) { - RILRequest rr - = RILRequest.obtain(RIL_REQUEST_DEACTIVATE_DATA_CALL, result); - - rr.mp.writeInt(2); - rr.mp.writeString(Integer.toString(cid)); - rr.mp.writeString(Integer.toString(reason)); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + - requestToString(rr.mRequest) + " " + cid + " " + reason); - - send(rr); + setFacilityLock (String facility, boolean lockState, String password, + int serviceClass, Message response) { + setFacilityLockForApp(facility, lockState, password, serviceClass, mAid, response); } @Override @@ -272,8 +231,6 @@ public class SemcRIL extends QualcommNoSimReadyRIL implements CommandsInterface RILRequest rr = RILRequest.obtain(RIL_REQUEST_SIM_IO, result); - rr.mp.writeInt(0); - rr.mp.writeString(mAid); rr.mp.writeInt(command); rr.mp.writeInt(fileid); rr.mp.writeString(path); @@ -282,6 +239,7 @@ public class SemcRIL extends QualcommNoSimReadyRIL implements CommandsInterface rr.mp.writeInt(p3); rr.mp.writeString(data); rr.mp.writeString(pin2); + rr.mp.writeString(mAid); if (RILJ_LOGD) riljLog(rr.serialString() + "> iccIO: " + requestToString(rr.mRequest) + " 0x" + Integer.toHexString(command) @@ -294,6 +252,17 @@ public class SemcRIL extends QualcommNoSimReadyRIL implements CommandsInterface @Override public void + getIMSI(Message result) { + RILRequest rr = RILRequest.obtain(RIL_REQUEST_GET_IMSI, result); + rr.mp.writeString(mAid); + + if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); + + send(rr); + } + + @Override + public void setNetworkSelectionModeAutomatic(Message response) { RILRequest rr = RILRequest.obtain(RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, @@ -303,6 +272,7 @@ public class SemcRIL extends QualcommNoSimReadyRIL implements CommandsInterface rr.mp.writeString(null); rr.mp.writeInt(-1); + send(rr); } @@ -323,179 +293,162 @@ public class SemcRIL extends QualcommNoSimReadyRIL implements CommandsInterface } @Override - public void - queryFacilityLock (String facility, String password, int serviceClass, - Message response) { - RILRequest rr = RILRequest.obtain(RIL_REQUEST_QUERY_FACILITY_LOCK, response); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - // count strings - rr.mp.writeInt(5); - rr.mp.writeString("0"); - rr.mp.writeString(mAid); - rr.mp.writeString(facility); - rr.mp.writeString(password); - - rr.mp.writeString(Integer.toString(serviceClass)); - - send(rr); - } - - @Override - public void - setFacilityLock (String facility, boolean lockState, String password, - int serviceClass, Message response) { - String lockString; - RILRequest rr - = RILRequest.obtain(RIL_REQUEST_SET_FACILITY_LOCK, response); - - if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - - // count strings - rr.mp.writeInt(6); - - rr.mp.writeString("0"); - rr.mp.writeString(mAid); - rr.mp.writeString(facility); - lockString = (lockState)?"1":"0"; - rr.mp.writeString(lockString); - rr.mp.writeString(password); - rr.mp.writeString(Integer.toString(serviceClass)); - - send(rr); - - } - - @Override protected Object - responseIccCardStatus(Parcel p) { - IccCardApplication ca; - - IccCardStatus status = new IccCardStatus(); - p.readInt(); // unknown first parameter - status.setCardState(p.readInt()); - status.setUniversalPinState(p.readInt()); - int gsmUmtsSubscriptionAppCount = p.readInt(); - - for (int i = 0; i < gsmUmtsSubscriptionAppCount; i++) { - if (i == 0) - status.setGsmUmtsSubscriptionAppIndex(p.readInt()); - else - p.readInt(); - } + responseOperatorInfos(Parcel p) { + String strings[] = (String [])responseStrings(p); + ArrayList<OperatorInfo> ret; - int cdmaSubscriptionAppCount = p.readInt(); - for (int i = 0; i < cdmaSubscriptionAppCount; i++) { - if (i == 0) - status.setCdmaSubscriptionAppIndex(p.readInt()); - else - p.readInt(); + if (strings.length % 5 != 0) { + throw new RuntimeException( + "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got " + + strings.length + " strings, expected multible of 5"); } - int numApplications = p.readInt(); + ret = new ArrayList<OperatorInfo>(strings.length / 4); - // limit to maximum allowed applications - if (numApplications > IccCardStatus.CARD_MAX_APPS) { - numApplications = IccCardStatus.CARD_MAX_APPS; + for (int i = 0 ; i < strings.length ; i += 5) { + ret.add ( + new OperatorInfo( + strings[i+0], + strings[i+1], + strings[i+2], + strings[i+3])); } - status.setNumApplications(numApplications); + return ret; + } - 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()); - 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); - p.readInt(); - p.readInt(); - p.readInt(); - p.readInt(); - } + @Override + public void + dial(String address, int clirMode, UUSInfo uusInfo, Message result) { + RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result); + rr.mp.writeString(address); + rr.mp.writeInt(clirMode); + rr.mp.writeInt(0); // UUS information is absent - int appIndex = -1; - if (mPhoneType == RILConstants.CDMA_PHONE) { - appIndex = status.getCdmaSubscriptionAppIndex(); - Log.d(LOG_TAG, "This is a CDMA PHONE " + appIndex); + if (uusInfo == null) { + rr.mp.writeInt(0); // UUS information is absent } else { - appIndex = status.getGsmUmtsSubscriptionAppIndex(); - Log.d(LOG_TAG, "This is a GSM PHONE " + appIndex); + rr.mp.writeInt(1); // UUS information is present + rr.mp.writeInt(uusInfo.getType()); + rr.mp.writeInt(uusInfo.getDcs()); + rr.mp.writeByteArray(uusInfo.getUserData()); } + rr.mp.writeInt(255); - IccCardApplication application = status.getApplication(appIndex); - mAid = application.aid; - - return status; - } + if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)); - @Override - protected DataCallState getDataCallState(Parcel p, int version) { - DataCallState datacallstate = new DataCallState(); - datacallstate.version = 3; - datacallstate.cid = p.readInt(); - datacallstate.active = p.readInt(); - datacallstate.type = p.readString(); - String s1 = p.readString(); - if(!TextUtils.isEmpty(s1)) { - datacallstate.addresses = s1.split(" "); } - datacallstate.ifname = "rmnet0"; - p.readInt(); - p.readInt(); - return datacallstate; + send(rr); } - @Override - protected Object - responseSetupDataCall(Parcel p) { + class IccHandler extends Handler implements Runnable { + private static final int EVENT_RADIO_ON = 1; + private static final int EVENT_ICC_STATUS_CHANGED = 2; + private static final int EVENT_GET_ICC_STATUS_DONE = 3; + private static final int EVENT_RADIO_OFF_OR_UNAVAILABLE = 4; - DataCallState dataCall; + private RIL mRil; + private boolean mRadioOn = false; - dataCall = new DataCallState(); - dataCall.version = 3; - dataCall.cid = 0; - p.readInt(); - dataCall.ifname = p.readString(); - if (TextUtils.isEmpty(dataCall.ifname)) { - throw new RuntimeException( - "RIL_REQUEST_SETUP_DATA_CALL response, no ifname"); - } + public IccHandler (RIL ril, Looper looper) { + super (looper); + mRil = ril; + } - String addresses = p.readString(); - if (!TextUtils.isEmpty(addresses)) { - dataCall.addresses = addresses.split(" "); + public void handleMessage (Message paramMessage) { + switch (paramMessage.what) { + case EVENT_RADIO_ON: + mRadioOn = true; + Log.d(LOG_TAG, "Radio on -> Forcing sim status update"); + sendMessage(obtainMessage(EVENT_ICC_STATUS_CHANGED)); + break; + case EVENT_GET_ICC_STATUS_DONE: + AsyncResult asyncResult = (AsyncResult) paramMessage.obj; + if (asyncResult.exception != null) { + Log.e (LOG_TAG, "IccCardStatusDone shouldn't return exceptions!", asyncResult.exception); + break; + } + IccCardStatus status = (IccCardStatus) asyncResult.result; + if (status.getNumApplications() == 0) { + if (!mRil.getRadioState().isOn()) { + break; + } + + if (mPhoneType == RILConstants.CDMA_PHONE) { + mRil.setRadioState(CommandsInterface.RadioState.RUIM_LOCKED_OR_ABSENT); + } else { + mRil.setRadioState(CommandsInterface.RadioState.SIM_LOCKED_OR_ABSENT); + } + } else { + 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); + } + + IccCardApplication application = status.getApplication(appIndex); + IccCardApplication.AppState app_state = application.app_state; + IccCardApplication.AppType app_type = application.app_type; + + switch (app_state) { + case APPSTATE_PIN: + case APPSTATE_PUK: + switch (app_type) { + case APPTYPE_SIM: + case APPTYPE_USIM: + mRil.setRadioState(CommandsInterface.RadioState.SIM_LOCKED_OR_ABSENT); + break; + case APPTYPE_RUIM: + mRil.setRadioState(CommandsInterface.RadioState.RUIM_LOCKED_OR_ABSENT); + break; + default: + Log.e(LOG_TAG, "Currently we don't handle SIMs of type: " + app_type); + return; + } + break; + case APPSTATE_READY: + switch (app_type) { + case APPTYPE_SIM: + case APPTYPE_USIM: + mRil.setRadioState(CommandsInterface.RadioState.SIM_READY); + break; + case APPTYPE_RUIM: + mRil.setRadioState(CommandsInterface.RadioState.RUIM_READY); + break; + default: + Log.e(LOG_TAG, "Currently we don't handle SIMs of type: " + app_type); + return; + } + break; + default: + return; + } + } + break; + case EVENT_ICC_STATUS_CHANGED: + if (mRadioOn) { + Log.d(LOG_TAG, "Received EVENT_ICC_STATUS_CHANGED, calling getIccCardStatus"); + mRil.getIccCardStatus(obtainMessage(EVENT_GET_ICC_STATUS_DONE, paramMessage.obj)); + } else { + Log.d(LOG_TAG, "Received EVENT_ICC_STATUS_CHANGED while radio is not ON. Ignoring"); + } + break; + case EVENT_RADIO_OFF_OR_UNAVAILABLE: + mRadioOn = false; + // disposeCards(); // to be verified; + default: + Log.e(LOG_TAG, " Unknown Event " + paramMessage.what); + break; } - return dataCall; - } - - @Override - protected Object - responseOperatorInfos(Parcel p) { - String strings[] = (String [])responseStrings(p); - ArrayList<OperatorInfo> ret; - - if (strings.length % 5 != 0) { - throw new RuntimeException( - "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got " - + strings.length + " strings, expected multible of 5"); } - ret = new ArrayList<OperatorInfo>(strings.length / 5); - - for (int i = 0 ; i < strings.length ; i += 5) { - ret.add ( - new OperatorInfo( - strings[i+0], - strings[i+1], - strings[i+2], - strings[i+3])); + public void run () { + mRil.registerForIccStatusChanged(this, EVENT_ICC_STATUS_CHANGED, null); + Message msg = obtainMessage(EVENT_RADIO_ON); + mRil.getIccCardStatus(msg); } - - return ret; } } diff --git a/telephony/java/com/android/internal/telephony/Smdk4210RIL.java b/telephony/java/com/android/internal/telephony/Smdk4210RIL.java new file mode 100644 index 0000000..49d1602 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/Smdk4210RIL.java @@ -0,0 +1,965 @@ +/*
+ * Copyright (C) 2011 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 static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSDPA;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSUPA;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSPA;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Resources;
+import android.net.ConnectivityManager;
+import android.net.LocalSocket;
+import android.net.LocalSocketAddress;
+import android.os.AsyncResult;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.Looper;
+import android.os.Message;
+import android.os.Parcel;
+import android.os.PowerManager;
+import android.os.SystemProperties;
+import android.os.PowerManager.WakeLock;
+import android.telephony.NeighboringCellInfo;
+import android.telephony.PhoneNumberUtils;
+import android.telephony.SmsManager;
+import android.telephony.SmsMessage;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
+import com.android.internal.telephony.gsm.SuppServiceNotification;
+import com.android.internal.telephony.cdma.CdmaCallWaitingNotification;
+import com.android.internal.telephony.cdma.CdmaInformationRecords;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+
+public class Smdk4210RIL extends RIL implements CommandsInterface {
+
+ //SAMSUNG SMDK4210 STATES
+ static final int RIL_REQUEST_DIAL_EMERGENCY = 10016;
+ static final int RIL_UNSOL_STK_SEND_SMS_RESULT = 11002;
+ static final int RIL_UNSOL_O2_HOME_ZONE_INFO = 11007;
+ static final int RIL_UNSOL_DEVICE_READY_NOTI = 11008;
+ static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_1 = 11010;
+ static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2 = 11011;
+ static final int RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3 = 11012;
+ static final int RIL_UNSOL_HSDPA_STATE_CHANGED = 11016;
+
+ public Smdk4210RIL(Context context, int networkMode, int cdmaSubscription) {
+ super(context, networkMode, cdmaSubscription);
+ }
+
+ @Override
+ public void setCurrentPreferredNetworkType() {
+ if (RILJ_LOGD) riljLog("setCurrentPreferredNetworkType IGNORED");
+ /* Google added this as a fix for crespo loosing network type after
+ * taking an OTA. This messes up the data connection state for us
+ * due to the way we handle network type change (disable data
+ * then change then re-enable).
+ */
+ }
+
+ @Override
+ public void setPreferredNetworkType(int networkType , Message response) {
+ /* Samsung modem implementation does bad things when a datacall is running
+ * while switching the preferred networktype.
+ */
+ ConnectivityManager cm =
+ (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+
+ if(cm.getMobileDataEnabled())
+ {
+ ConnectivityHandler handler = new ConnectivityHandler(mContext);
+ handler.setPreferedNetworkType(networkType, response);
+ } else {
+ sendPreferedNetworktype(networkType, response);
+ }
+ }
+
+ //Sends the real RIL request to the modem.
+ private void sendPreferedNetworktype(int networkType, Message response) {
+ RILRequest rr = RILRequest.obtain(
+ RILConstants.RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, response);
+
+ rr.mp.writeInt(1);
+ rr.mp.writeInt(networkType);
+
+ if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest)
+ + " : " + networkType);
+
+ send(rr);
+ }
+
+ /* private class that does the handling for the dataconnection
+ * dataconnection is done async, so we send the request for disabling it,
+ * wait for the response, set the prefered networktype and notify the
+ * real sender with its result.
+ */
+ private class ConnectivityHandler extends Handler{
+
+ private static final int MESSAGE_SET_PREFERRED_NETWORK_TYPE = 30;
+ private Context mContext;
+ private int mDesiredNetworkType;
+ //the original message, we need it for calling back the original caller when done
+ private Message mNetworktypeResponse;
+ private ConnectivityBroadcastReceiver mConnectivityReceiver = new ConnectivityBroadcastReceiver();
+
+ public ConnectivityHandler(Context context)
+ {
+ mContext = context;
+ }
+
+ private void startListening() {
+ IntentFilter filter = new IntentFilter();
+ filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
+ mContext.registerReceiver(mConnectivityReceiver, filter);
+ }
+
+ private synchronized void stopListening() {
+ mContext.unregisterReceiver(mConnectivityReceiver);
+ }
+
+ public void setPreferedNetworkType(int networkType, Message response)
+ {
+ Log.d(LOG_TAG, "Mobile Dataconnection is online setting it down");
+ mDesiredNetworkType = networkType;
+ mNetworktypeResponse = response;
+ ConnectivityManager cm =
+ (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+ //start listening for the connectivity change broadcast
+ startListening();
+ cm.setMobileDataEnabled(false);
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ switch(msg.what) {
+ //networktype was set, now we can enable the dataconnection again
+ case MESSAGE_SET_PREFERRED_NETWORK_TYPE:
+ ConnectivityManager cm =
+ (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
+
+ Log.d(LOG_TAG, "preferred NetworkType set upping Mobile Dataconnection");
+
+ cm.setMobileDataEnabled(true);
+ //everything done now call back that we have set the networktype
+ AsyncResult.forMessage(mNetworktypeResponse, null, null);
+ mNetworktypeResponse.sendToTarget();
+ mNetworktypeResponse = null;
+ break;
+ default:
+ throw new RuntimeException("unexpected event not handled");
+ }
+ }
+
+ private class ConnectivityBroadcastReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
+ Log.w(LOG_TAG, "onReceived() called with " + intent);
+ return;
+ }
+ boolean noConnectivity =
+ intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
+
+ if (noConnectivity) {
+ //Ok dataconnection is down, now set the networktype
+ Log.w(LOG_TAG, "Mobile Dataconnection is now down setting preferred NetworkType");
+ stopListening();
+ sendPreferedNetworktype(mDesiredNetworkType, obtainMessage(MESSAGE_SET_PREFERRED_NETWORK_TYPE));
+ mDesiredNetworkType = -1;
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void processSolicited (Parcel p) {
+ int serial, error;
+ boolean found = false;
+
+ serial = p.readInt();
+ error = p.readInt();
+
+ RILRequest rr;
+
+ rr = findAndRemoveRequestFromList(serial);
+
+ if (rr == null) {
+ Log.w(LOG_TAG, "Unexpected solicited response! sn: "
+ + serial + " error: " + error);
+ return;
+ }
+
+ Object ret = null;
+
+ if (error == 0 || p.dataAvail() > 0) {
+ // either command succeeds or command fails but with data payload
+ try {switch (rr.mRequest) {
+
+ case RIL_REQUEST_GET_SIM_STATUS: ret = responseIccCardStatus(p); break;
+ case RIL_REQUEST_ENTER_SIM_PIN: ret = responseInts(p); break;
+ case RIL_REQUEST_ENTER_SIM_PUK: ret = responseInts(p); break;
+ case RIL_REQUEST_ENTER_SIM_PIN2: ret = responseInts(p); break;
+ case RIL_REQUEST_ENTER_SIM_PUK2: ret = responseInts(p); break;
+ case RIL_REQUEST_CHANGE_SIM_PIN: ret = responseInts(p); break;
+ case RIL_REQUEST_CHANGE_SIM_PIN2: ret = responseInts(p); break;
+ case RIL_REQUEST_ENTER_NETWORK_DEPERSONALIZATION: ret = responseInts(p); break;
+ case RIL_REQUEST_GET_CURRENT_CALLS: ret = responseCallList(p); break;
+ case RIL_REQUEST_DIAL: ret = responseVoid(p); break;
+ case RIL_REQUEST_GET_IMSI: ret = responseString(p); break;
+ case RIL_REQUEST_HANGUP: ret = responseVoid(p); break;
+ case RIL_REQUEST_HANGUP_WAITING_OR_BACKGROUND: ret = responseVoid(p); break;
+ case RIL_REQUEST_HANGUP_FOREGROUND_RESUME_BACKGROUND: ret = responseVoid(p); break;
+ case RIL_REQUEST_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE: ret = responseVoid(p); break;
+ case RIL_REQUEST_CONFERENCE: ret = responseVoid(p); break;
+ case RIL_REQUEST_UDUB: ret = responseVoid(p); break;
+ case RIL_REQUEST_LAST_CALL_FAIL_CAUSE: ret = responseInts(p); break;
+ case RIL_REQUEST_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break;
+ case RIL_REQUEST_VOICE_REGISTRATION_STATE: ret = responseStrings(p); break;
+ case RIL_REQUEST_DATA_REGISTRATION_STATE: ret = responseStrings(p); break;
+ case RIL_REQUEST_OPERATOR: ret = responseStrings(p); break;
+ case RIL_REQUEST_RADIO_POWER: ret = responseVoid(p); break;
+ case RIL_REQUEST_DTMF: ret = responseVoid(p); break;
+ case RIL_REQUEST_SEND_SMS: ret = responseSMS(p); break;
+ case RIL_REQUEST_SEND_SMS_EXPECT_MORE: ret = responseSMS(p); break;
+ case RIL_REQUEST_SETUP_DATA_CALL: ret = responseSetupDataCall(p); break;
+ case RIL_REQUEST_SIM_IO: ret = responseICC_IO(p); break;
+ case RIL_REQUEST_SEND_USSD: ret = responseVoid(p); break;
+ case RIL_REQUEST_CANCEL_USSD: ret = responseVoid(p); break;
+ case RIL_REQUEST_GET_CLIR: ret = responseInts(p); break;
+ case RIL_REQUEST_SET_CLIR: ret = responseVoid(p); break;
+ case RIL_REQUEST_QUERY_CALL_FORWARD_STATUS: ret = responseCallForward(p); break;
+ case RIL_REQUEST_SET_CALL_FORWARD: ret = responseVoid(p); break;
+ case RIL_REQUEST_QUERY_CALL_WAITING: ret = responseInts(p); break;
+ case RIL_REQUEST_SET_CALL_WAITING: ret = responseVoid(p); break;
+ case RIL_REQUEST_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
+ case RIL_REQUEST_GET_IMEI: ret = responseString(p); break;
+ case RIL_REQUEST_GET_IMEISV: ret = responseString(p); break;
+ case RIL_REQUEST_ANSWER: ret = responseVoid(p); break;
+ case RIL_REQUEST_DEACTIVATE_DATA_CALL: ret = responseVoid(p); break;
+ case RIL_REQUEST_QUERY_FACILITY_LOCK: ret = responseInts(p); break;
+ case RIL_REQUEST_SET_FACILITY_LOCK: ret = responseInts(p); break;
+ case RIL_REQUEST_CHANGE_BARRING_PASSWORD: ret = responseVoid(p); break;
+ case RIL_REQUEST_QUERY_NETWORK_SELECTION_MODE: ret = responseInts(p); break;
+ case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC: ret = responseVoid(p); break;
+ case RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL: ret = responseVoid(p); break;
+ case RIL_REQUEST_QUERY_AVAILABLE_NETWORKS : ret = responseOperatorInfos(p); break;
+ case RIL_REQUEST_DTMF_START: ret = responseVoid(p); break;
+ case RIL_REQUEST_DTMF_STOP: ret = responseVoid(p); break;
+ case RIL_REQUEST_BASEBAND_VERSION: ret = responseString(p); break;
+ case RIL_REQUEST_SEPARATE_CONNECTION: ret = responseVoid(p); break;
+ case RIL_REQUEST_SET_MUTE: ret = responseVoid(p); break;
+ case RIL_REQUEST_GET_MUTE: ret = responseInts(p); break;
+ case RIL_REQUEST_QUERY_CLIP: ret = responseInts(p); break;
+ case RIL_REQUEST_LAST_DATA_CALL_FAIL_CAUSE: ret = responseInts(p); break;
+ case RIL_REQUEST_DATA_CALL_LIST: ret = responseDataCallList(p); break;
+ case RIL_REQUEST_RESET_RADIO: ret = responseVoid(p); break;
+ case RIL_REQUEST_OEM_HOOK_RAW: ret = responseRaw(p); break;
+ case RIL_REQUEST_OEM_HOOK_STRINGS: ret = responseStrings(p); break;
+ case RIL_REQUEST_SCREEN_STATE: ret = responseVoid(p); break;
+ case RIL_REQUEST_SET_SUPP_SVC_NOTIFICATION: ret = responseVoid(p); break;
+ case RIL_REQUEST_WRITE_SMS_TO_SIM: ret = responseInts(p); break;
+ case RIL_REQUEST_DELETE_SMS_ON_SIM: ret = responseVoid(p); break;
+ case RIL_REQUEST_SET_BAND_MODE: ret = responseVoid(p); break;
+ case RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE: ret = responseInts(p); break;
+ case RIL_REQUEST_STK_GET_PROFILE: ret = responseString(p); break;
+ case RIL_REQUEST_STK_SET_PROFILE: ret = responseVoid(p); break;
+ case RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND: ret = responseString(p); break;
+ case RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE: ret = responseVoid(p); break;
+ case RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM: ret = responseInts(p); break;
+ case RIL_REQUEST_EXPLICIT_CALL_TRANSFER: ret = responseVoid(p); break;
+ case RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE: ret = responseVoid(p); break;
+ case RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE: ret = responseGetPreferredNetworkType(p); break;
+ case RIL_REQUEST_GET_NEIGHBORING_CELL_IDS: ret = responseVoid(p); break;
+ case RIL_REQUEST_SET_LOCATION_UPDATES: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_SET_ROAMING_PREFERENCE: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_QUERY_ROAMING_PREFERENCE: ret = responseInts(p); break;
+ case RIL_REQUEST_SET_TTY_MODE: ret = responseVoid(p); break;
+ case RIL_REQUEST_QUERY_TTY_MODE: ret = responseInts(p); break;
+ case RIL_REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE: ret = responseInts(p); break;
+ case RIL_REQUEST_CDMA_FLASH: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_BURST_DTMF: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_SEND_SMS: ret = responseSMS(p); break;
+ case RIL_REQUEST_CDMA_SMS_ACKNOWLEDGE: ret = responseVoid(p); break;
+ case RIL_REQUEST_GSM_GET_BROADCAST_CONFIG: ret = responseGmsBroadcastConfig(p); break;
+ case RIL_REQUEST_GSM_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
+ case RIL_REQUEST_GSM_BROADCAST_ACTIVATION: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_GET_BROADCAST_CONFIG: ret = responseCdmaBroadcastConfig(p); break;
+ case RIL_REQUEST_CDMA_SET_BROADCAST_CONFIG: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_BROADCAST_ACTIVATION: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_VALIDATE_AND_WRITE_AKEY: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_SUBSCRIPTION: ret = responseStrings(p); break;
+ case RIL_REQUEST_CDMA_WRITE_SMS_TO_RUIM: ret = responseInts(p); break;
+ case RIL_REQUEST_CDMA_DELETE_SMS_ON_RUIM: ret = responseVoid(p); break;
+ case RIL_REQUEST_DEVICE_IDENTITY: ret = responseStrings(p); break;
+ case RIL_REQUEST_GET_SMSC_ADDRESS: ret = responseString(p); break;
+ case RIL_REQUEST_SET_SMSC_ADDRESS: ret = responseVoid(p); break;
+ case RIL_REQUEST_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
+ case RIL_REQUEST_REPORT_SMS_MEMORY_STATUS: ret = responseVoid(p); break;
+ case RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING: ret = responseVoid(p); break;
+ case RIL_REQUEST_CDMA_GET_SUBSCRIPTION_SOURCE: ret = responseInts(p); break;
+ case RIL_REQUEST_ISIM_AUTHENTICATION: ret = responseString(p); break;
+ default:
+ throw new RuntimeException("Unrecognized solicited response: " + rr.mRequest);
+ //break;
+ }} catch (Throwable tr) {
+ // Exceptions here usually mean invalid RIL responses
+
+ Log.w(LOG_TAG, rr.serialString() + "< "
+ + requestToString(rr.mRequest)
+ + " exception, possible invalid RIL response", tr);
+
+ if (rr.mResult != null) {
+ AsyncResult.forMessage(rr.mResult, null, tr);
+ rr.mResult.sendToTarget();
+ }
+ rr.release();
+ return;
+ }
+ }
+
+ if (error != 0) {
+ //ugly fix for Samsung messing up SMS_SEND request fail in binary RIL
+ if(!(error == -1 && rr.mRequest == RIL_REQUEST_SEND_SMS))
+ {
+ rr.onError(error, ret);
+ rr.release();
+ return;
+ } else {
+ try
+ {
+ ret = responseSMS(p);
+ } catch (Throwable tr) {
+ Log.w(LOG_TAG, rr.serialString() + "< "
+ + requestToString(rr.mRequest)
+ + " exception, Processing Samsung SMS fix ", tr);
+ rr.onError(error, ret);
+ rr.release();
+ return;
+ }
+ }
+ }
+
+ if (RILJ_LOGD) riljLog(rr.serialString() + "< " + requestToString(rr.mRequest)
+ + " " + retToString(rr.mRequest, ret));
+
+ if (rr.mResult != null) {
+ AsyncResult.forMessage(rr.mResult, ret, null);
+ rr.mResult.sendToTarget();
+ }
+
+ rr.release();
+ }
+
+ @Override
+ protected void
+ processUnsolicited (Parcel p) {
+ int response;
+ Object ret;
+
+ response = p.readInt();
+
+ try {switch(response) {
+
+ case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED: ret = responseVoid(p); break;
+ case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED: ret = responseVoid(p); break;
+ case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: ret = responseVoid(p); break;
+ case RIL_UNSOL_RESPONSE_NEW_SMS: ret = responseString(p); break;
+ case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT: ret = responseString(p); break;
+ case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM: ret = responseInts(p); break;
+ case RIL_UNSOL_ON_USSD: ret = responseStrings(p); break;
+ case RIL_UNSOL_NITZ_TIME_RECEIVED: ret = responseString(p); break;
+ case RIL_UNSOL_SIGNAL_STRENGTH: ret = responseSignalStrength(p); break;
+ case RIL_UNSOL_DATA_CALL_LIST_CHANGED: ret = responseDataCallList(p);break;
+ case RIL_UNSOL_SUPP_SVC_NOTIFICATION: ret = responseSuppServiceNotification(p); break;
+ case RIL_UNSOL_STK_SESSION_END: ret = responseVoid(p); break;
+ case RIL_UNSOL_STK_PROACTIVE_COMMAND: ret = responseString(p); break;
+ case RIL_UNSOL_STK_EVENT_NOTIFY: ret = responseString(p); break;
+ case RIL_UNSOL_STK_CALL_SETUP: ret = responseInts(p); break;
+ case RIL_UNSOL_SIM_SMS_STORAGE_FULL: ret = responseVoid(p); break;
+ case RIL_UNSOL_SIM_REFRESH: ret = responseInts(p); break;
+ case RIL_UNSOL_CALL_RING: ret = responseCallRing(p); break;
+ case RIL_UNSOL_RESTRICTED_STATE_CHANGED: ret = responseInts(p); break;
+ case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED: ret = responseVoid(p); break;
+ case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS: ret = responseCdmaSms(p); break;
+ case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS: ret = responseString(p); break;
+ case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL: ret = responseVoid(p); break;
+ case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
+ case RIL_UNSOL_CDMA_CALL_WAITING: ret = responseCdmaCallWaiting(p); break;
+ case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS: ret = responseInts(p); break;
+ case RIL_UNSOL_CDMA_INFO_REC: ret = responseCdmaInformationRecord(p); break;
+ case RIL_UNSOL_OEM_HOOK_RAW: ret = responseRaw(p); break;
+ case RIL_UNSOL_RINGBACK_TONE: ret = responseInts(p); break;
+ case RIL_UNSOL_RESEND_INCALL_MUTE: ret = responseVoid(p); break;
+ case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED: ret = responseInts(p); break;
+ case RIL_UNSOl_CDMA_PRL_CHANGED: ret = responseInts(p); break;
+ case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE: ret = responseVoid(p); break;
+ case RIL_UNSOL_RIL_CONNECTED: ret = responseInts(p); break;
+
+ // SAMSUNG STATES
+ case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_1: ret = responseVoid(p); break;
+ case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_2: ret = responseVoid(p); break;
+ case RIL_UNSOL_SAMSUNG_UNKNOWN_MAGIC_REQUEST_3: ret = responseVoid(p); break;
+
+ default:
+ throw new RuntimeException("Unrecognized unsol response: " + response);
+ //break; (implied)
+ }} catch (Throwable tr) {
+ Log.e(LOG_TAG, "Exception processing unsol response: " + response +
+ "Exception:" + tr.toString());
+ return;
+ }
+
+ switch(response) {
+ case RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED:
+ /* has bonus radio state int */
+ RadioState newState = getRadioStateFromInt(p.readInt());
+ if (RILJ_LOGD) unsljLogMore(response, newState.toString());
+
+ switchToRadioState(newState);
+ break;
+ case RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED:
+ if (RILJ_LOGD) unsljLog(response);
+
+ mCallStateRegistrants
+ .notifyRegistrants(new AsyncResult(null, null, null));
+ break;
+ case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED:
+ if (RILJ_LOGD) unsljLog(response);
+
+ mVoiceNetworkStateRegistrants
+ .notifyRegistrants(new AsyncResult(null, null, null));
+ break;
+ case RIL_UNSOL_RESPONSE_NEW_SMS: {
+ if (RILJ_LOGD) unsljLog(response);
+
+ // FIXME this should move up a layer
+ String a[] = new String[2];
+
+ a[1] = (String)ret;
+
+ SmsMessage sms;
+
+ sms = SmsMessage.newFromCMT(a);
+ if (mGsmSmsRegistrant != null) {
+ mGsmSmsRegistrant
+ .notifyRegistrant(new AsyncResult(null, sms, null));
+ }
+ break;
+ }
+ case RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mSmsStatusRegistrant != null) {
+ mSmsStatusRegistrant.notifyRegistrant(
+ new AsyncResult(null, ret, null));
+ }
+ break;
+ case RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ int[] smsIndex = (int[])ret;
+
+ if(smsIndex.length == 1) {
+ if (mSmsOnSimRegistrant != null) {
+ mSmsOnSimRegistrant.
+ notifyRegistrant(new AsyncResult(null, smsIndex, null));
+ }
+ } else {
+ if (RILJ_LOGD) riljLog(" NEW_SMS_ON_SIM ERROR with wrong length "
+ + smsIndex.length);
+ }
+ break;
+ case RIL_UNSOL_ON_USSD:
+ String[] resp = (String[])ret;
+
+ if (resp.length < 2) {
+ resp = new String[2];
+ resp[0] = ((String[])ret)[0];
+ resp[1] = null;
+ }
+ if (RILJ_LOGD) unsljLogMore(response, resp[0]);
+ if (mUSSDRegistrant != null) {
+ mUSSDRegistrant.notifyRegistrant(
+ new AsyncResult (null, resp, null));
+ }
+ break;
+ case RIL_UNSOL_NITZ_TIME_RECEIVED:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ // has bonus long containing milliseconds since boot that the NITZ
+ // time was received
+ long nitzReceiveTime = p.readLong();
+
+ Object[] result = new Object[2];
+
+ result[0] = ret;
+ result[1] = Long.valueOf(nitzReceiveTime);
+
+ if (mNITZTimeRegistrant != null) {
+
+ mNITZTimeRegistrant
+ .notifyRegistrant(new AsyncResult (null, result, null));
+ } else {
+ // in case NITZ time registrant isnt registered yet
+ mLastNITZTimeInfo = result;
+ }
+ break;
+
+ case RIL_UNSOL_SIGNAL_STRENGTH:
+ // Note this is set to "verbose" because it happens
+ // frequently
+ if (RILJ_LOGV) unsljLogvRet(response, ret);
+
+ if (mSignalStrengthRegistrant != null) {
+ mSignalStrengthRegistrant.notifyRegistrant(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+ case RIL_UNSOL_DATA_CALL_LIST_CHANGED:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ mDataNetworkStateRegistrants.notifyRegistrants(new AsyncResult(null, ret, null));
+ break;
+
+ case RIL_UNSOL_SUPP_SVC_NOTIFICATION:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mSsnRegistrant != null) {
+ mSsnRegistrant.notifyRegistrant(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_STK_SESSION_END:
+ if (RILJ_LOGD) unsljLog(response);
+
+ if (mCatSessionEndRegistrant != null) {
+ mCatSessionEndRegistrant.notifyRegistrant(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_STK_PROACTIVE_COMMAND:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mCatProCmdRegistrant != null) {
+ mCatProCmdRegistrant.notifyRegistrant(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_STK_EVENT_NOTIFY:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mCatEventRegistrant != null) {
+ mCatEventRegistrant.notifyRegistrant(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_STK_CALL_SETUP:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mCatCallSetUpRegistrant != null) {
+ mCatCallSetUpRegistrant.notifyRegistrant(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_SIM_SMS_STORAGE_FULL:
+ if (RILJ_LOGD) unsljLog(response);
+
+ if (mIccSmsFullRegistrant != null) {
+ mIccSmsFullRegistrant.notifyRegistrant();
+ }
+ break;
+
+ case RIL_UNSOL_SIM_REFRESH:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mIccRefreshRegistrants != null) {
+ mIccRefreshRegistrants.notifyRegistrants(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_CALL_RING:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mRingRegistrant != null) {
+ mRingRegistrant.notifyRegistrant(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_RESTRICTED_STATE_CHANGED:
+ if (RILJ_LOGD) unsljLogvRet(response, ret);
+ if (mRestrictedStateRegistrant != null) {
+ mRestrictedStateRegistrant.notifyRegistrant(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED:
+ if (RILJ_LOGD) unsljLog(response);
+
+ if (mIccStatusChangedRegistrants != null) {
+ mIccStatusChangedRegistrants.notifyRegistrants();
+ }
+ break;
+
+ case RIL_UNSOL_RESPONSE_CDMA_NEW_SMS:
+ if (RILJ_LOGD) unsljLog(response);
+
+ SmsMessage sms = (SmsMessage) ret;
+
+ if (mCdmaSmsRegistrant != null) {
+ mCdmaSmsRegistrant
+ .notifyRegistrant(new AsyncResult(null, sms, null));
+ }
+ break;
+
+ case RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS:
+ if (RILJ_LOGD) unsljLog(response);
+
+ if (mGsmBroadcastSmsRegistrant != null) {
+ mGsmBroadcastSmsRegistrant
+ .notifyRegistrant(new AsyncResult(null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_CDMA_RUIM_SMS_STORAGE_FULL:
+ if (RILJ_LOGD) unsljLog(response);
+
+ if (mIccSmsFullRegistrant != null) {
+ mIccSmsFullRegistrant.notifyRegistrant();
+ }
+ break;
+
+ case RIL_UNSOL_ENTER_EMERGENCY_CALLBACK_MODE:
+ if (RILJ_LOGD) unsljLog(response);
+
+ if (mEmergencyCallbackModeRegistrant != null) {
+ mEmergencyCallbackModeRegistrant.notifyRegistrant();
+ }
+ break;
+
+ case RIL_UNSOL_CDMA_CALL_WAITING:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mCallWaitingInfoRegistrants != null) {
+ mCallWaitingInfoRegistrants.notifyRegistrants(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_CDMA_OTA_PROVISION_STATUS:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mOtaProvisionRegistrants != null) {
+ mOtaProvisionRegistrants.notifyRegistrants(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_CDMA_INFO_REC:
+ ArrayList<CdmaInformationRecords> listInfoRecs;
+
+ try {
+ listInfoRecs = (ArrayList<CdmaInformationRecords>)ret;
+ } catch (ClassCastException e) {
+ Log.e(LOG_TAG, "Unexpected exception casting to listInfoRecs", e);
+ break;
+ }
+
+ for (CdmaInformationRecords rec : listInfoRecs) {
+ if (RILJ_LOGD) unsljLogRet(response, rec);
+ notifyRegistrantsCdmaInfoRec(rec);
+ }
+ break;
+
+ case RIL_UNSOL_OEM_HOOK_RAW:
+ if (RILJ_LOGD) unsljLogvRet(response, IccUtils.bytesToHexString((byte[])ret));
+ if (mUnsolOemHookRawRegistrant != null) {
+ mUnsolOemHookRawRegistrant.notifyRegistrant(new AsyncResult(null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_RINGBACK_TONE:
+ if (RILJ_LOGD) unsljLogvRet(response, ret);
+ if (mRingbackToneRegistrants != null) {
+ boolean playtone = (((int[])ret)[0] == 1);
+ mRingbackToneRegistrants.notifyRegistrants(
+ new AsyncResult (null, playtone, null));
+ }
+ break;
+
+ case RIL_UNSOL_RESEND_INCALL_MUTE:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mResendIncallMuteRegistrants != null) {
+ mResendIncallMuteRegistrants.notifyRegistrants(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_CDMA_SUBSCRIPTION_SOURCE_CHANGED:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mCdmaSubscriptionChangedRegistrants != null) {
+ mCdmaSubscriptionChangedRegistrants.notifyRegistrants(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOl_CDMA_PRL_CHANGED:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mCdmaPrlChangedRegistrants != null) {
+ mCdmaPrlChangedRegistrants.notifyRegistrants(
+ new AsyncResult (null, ret, null));
+ }
+ break;
+
+ case RIL_UNSOL_EXIT_EMERGENCY_CALLBACK_MODE:
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ if (mExitEmergencyCallbackModeRegistrants != null) {
+ mExitEmergencyCallbackModeRegistrants.notifyRegistrants(
+ new AsyncResult (null, null, null));
+ }
+ break;
+
+ case RIL_UNSOL_RIL_CONNECTED: {
+ if (RILJ_LOGD) unsljLogRet(response, ret);
+
+ // Initial conditions
+ setRadioPower(false, null);
+ sendPreferedNetworktype(mPreferredNetworkType, null);
+ setCdmaSubscriptionSource(mCdmaSubscription, null);
+ notifyRegistrantsRilConnectionChanged(((int[])ret)[0]);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Notifiy all registrants that the ril has connected or disconnected.
+ *
+ * @param rilVer is the version of the ril or -1 if disconnected.
+ */
+ private void notifyRegistrantsRilConnectionChanged(int rilVer) {
+ mRilVersion = rilVer;
+ if (mRilConnectedRegistrants != null) {
+ mRilConnectedRegistrants.notifyRegistrants(
+ new AsyncResult (null, new Integer(rilVer), null));
+ }
+ }
+
+ @Override
+ protected Object
+ responseCallList(Parcel p) {
+ int num;
+ int voiceSettings;
+ ArrayList<DriverCall> response;
+ DriverCall dc;
+ int dataAvail = p.dataAvail();
+ int pos = p.dataPosition();
+ int size = p.dataSize();
+
+ Log.d(LOG_TAG, "Parcel size = " + size);
+ Log.d(LOG_TAG, "Parcel pos = " + pos);
+ Log.d(LOG_TAG, "Parcel dataAvail = " + dataAvail);
+
+ //Samsung changes
+ num = p.readInt();
+
+ Log.d(LOG_TAG, "num = " + num);
+ response = new ArrayList<DriverCall>(num);
+
+ for (int i = 0 ; i < num ; i++) {
+
+ dc = new DriverCall();
+
+ dc.state = DriverCall.stateFromCLCC(p.readInt());
+ Log.d(LOG_TAG, "state = " + dc.state);
+ dc.index = p.readInt();
+ Log.d(LOG_TAG, "index = " + dc.index);
+ dc.TOA = p.readInt();
+ Log.d(LOG_TAG, "state = " + dc.TOA);
+ dc.isMpty = (0 != p.readInt());
+ Log.d(LOG_TAG, "isMpty = " + dc.isMpty);
+ dc.isMT = (0 != p.readInt());
+ Log.d(LOG_TAG, "isMT = " + dc.isMT);
+ dc.als = p.readInt();
+ Log.d(LOG_TAG, "als = " + dc.als);
+ voiceSettings = p.readInt();
+ dc.isVoice = (0 == voiceSettings) ? false : true;
+ Log.d(LOG_TAG, "isVoice = " + dc.isVoice);
+ dc.isVoicePrivacy = (0 != p.readInt());
+ //Some Samsung magic data for Videocalls
+ voiceSettings = p.readInt();
+ //printing it to cosole for later investigation
+ Log.d(LOG_TAG, "Samsung magic = " + voiceSettings);
+ dc.number = p.readString();
+ Log.d(LOG_TAG, "number = " + dc.number);
+ int np = p.readInt();
+ Log.d(LOG_TAG, "np = " + np);
+ dc.numberPresentation = DriverCall.presentationFromCLIP(np);
+ dc.name = p.readString();
+ Log.d(LOG_TAG, "name = " + dc.name);
+ dc.namePresentation = p.readInt();
+ Log.d(LOG_TAG, "namePresentation = " + dc.namePresentation);
+ int uusInfoPresent = p.readInt();
+ Log.d(LOG_TAG, "uusInfoPresent = " + uusInfoPresent);
+
+ if (uusInfoPresent == 1) {
+ dc.uusInfo = new UUSInfo();
+ dc.uusInfo.setType(p.readInt());
+ dc.uusInfo.setDcs(p.readInt());
+ byte[] userData = p.createByteArray();
+ dc.uusInfo.setUserData(userData);
+ Log
+ .v(LOG_TAG, String.format("Incoming UUS : type=%d, dcs=%d, length=%d",
+ dc.uusInfo.getType(), dc.uusInfo.getDcs(),
+ dc.uusInfo.getUserData().length));
+ Log.v(LOG_TAG, "Incoming UUS : data (string)="
+ + new String(dc.uusInfo.getUserData()));
+ Log.v(LOG_TAG, "Incoming UUS : data (hex): "
+ + IccUtils.bytesToHexString(dc.uusInfo.getUserData()));
+ } else {
+ Log.v(LOG_TAG, "Incoming UUS : NOT present!");
+ }
+
+ // Make sure there's a leading + on addresses with a TOA of 145
+ dc.number = PhoneNumberUtils.stringFromStringAndTOA(dc.number, dc.TOA);
+
+ response.add(dc);
+
+ if (dc.isVoicePrivacy) {
+ mVoicePrivacyOnRegistrants.notifyRegistrants();
+ Log.d(LOG_TAG, "InCall VoicePrivacy is enabled");
+ } else {
+ mVoicePrivacyOffRegistrants.notifyRegistrants();
+ Log.d(LOG_TAG, "InCall VoicePrivacy is disabled");
+ }
+ }
+
+ Collections.sort(response);
+
+ return response;
+ }
+
+ @Override
+ protected Object responseGetPreferredNetworkType(Parcel p) {
+ int [] response = (int[]) responseInts(p);
+
+ if (response.length >= 1) {
+ // Since this is the response for getPreferredNetworkType
+ // we'll assume that it should be the value we want the
+ // vendor ril to take if we reestablish a connection to it.
+ mPreferredNetworkType = response[0];
+ }
+
+ // When the modem responds Phone.NT_MODE_GLOBAL, it means Phone.NT_MODE_WCDMA_PREF
+ if (response[0] == Phone.NT_MODE_GLOBAL) {
+ Log.d(LOG_TAG, "Overriding network type response from GLOBAL to WCDMA preferred");
+ response[0] = Phone.NT_MODE_WCDMA_PREF;
+ }
+
+ return response;
+ }
+
+ @Override
+ protected Object
+ responseOperatorInfos(Parcel p) {
+ String strings[] = (String [])responseStrings(p);
+ ArrayList<OperatorInfo> ret;
+
+ if (strings.length % 5 != 0) {
+ throw new RuntimeException(
+ "RIL_REQUEST_QUERY_AVAILABLE_NETWORKS: invalid response. Got "
+ + strings.length + " strings, expected multible of 5");
+ }
+
+ ret = new ArrayList<OperatorInfo>(strings.length / 5);
+
+ for (int i = 0 ; i < strings.length ; i += 5) {
+ ret.add (
+ new OperatorInfo(
+ strings[i+0],
+ strings[i+1],
+ strings[i+2],
+ strings[i+3]));
+ }
+
+ return ret;
+ }
+
+ @Override
+ protected Object
+ responseSignalStrength(Parcel p) {
+ int numInts = 12;
+ int response[];
+
+ /* TODO: Add SignalStrength class to match RIL_SignalStrength */
+ response = new int[numInts];
+ for (int i = 0 ; i < numInts ; i++) {
+ response[i] = p.readInt();
+ }
+
+ // SamsungRIL is a v3 RIL, fill the rest with -1
+ for (int i = 7; i < numInts; i++) {
+ response[i] = -1;
+ }
+
+ /* Matching Samsung signal strength to asu.
+ Method taken from Samsungs cdma/gsmSignalStateTracker */
+ response[0] = ((response[0] & 0xFF00) >> 8) * 3; //gsmDbm
+ response[1] = -1; //gsmEcio
+ response[2] = (response[2] < 0)?-120:-response[2]; //cdmaDbm
+ response[3] = (response[3] < 0)?-160:-response[3]; //cdmaEcio
+ response[4] = (response[4] < 0)?-120:-response[4]; //evdoRssi
+ response[5] = (response[5] < 0)?-1:-response[5]; //evdoEcio
+ if (response[6] < 0 || response[6] > 8) {
+ response[6] = -1;
+ }
+
+ return response;
+ }
+
+}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java b/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java index c1ad7b3..1941362 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmConnection.java @@ -26,6 +26,7 @@ import android.os.SystemClock; import android.util.Log; import android.telephony.PhoneNumberUtils; import android.telephony.ServiceState; +import android.text.TextUtils; import com.android.internal.telephony.*; @@ -46,6 +47,7 @@ public class GsmConnection extends Connection { boolean isIncoming; boolean disconnected; + String cnapName; int index; // index in GsmCallTracker.connections[], -1 if unassigned // The GSM index is 1 + this @@ -72,6 +74,7 @@ public class GsmConnection extends Connection { DisconnectCause cause = DisconnectCause.NOT_DISCONNECTED; PostDialState postDialState = PostDialState.NOT_STARTED; int numberPresentation = Connection.PRESENTATION_ALLOWED; + int cnapNamePresentation = Connection.PRESENTATION_ALLOWED; UUSInfo uusInfo; Handler h; @@ -125,6 +128,8 @@ public class GsmConnection extends Connection { isIncoming = dc.isMT; createTime = System.currentTimeMillis(); + cnapName = dc.name; + cnapNamePresentation = dc.namePresentation; numberPresentation = dc.numberPresentation; uusInfo = dc.uusInfo; @@ -151,6 +156,9 @@ public class GsmConnection extends Connection { index = -1; isIncoming = false; + cnapName = null; + cnapNamePresentation = Connection.PRESENTATION_ALLOWED; + numberPresentation = Connection.PRESENTATION_ALLOWED; createTime = System.currentTimeMillis(); this.parent = parent; @@ -189,6 +197,14 @@ public class GsmConnection extends Connection { return parent; } + public String getCnapName() { + return cnapName; + } + + public int getCnapNamePresentation() { + return cnapNamePresentation; + } + public long getCreateTime() { return createTime; } @@ -437,6 +453,21 @@ public class GsmConnection extends Connection { changed = true; } + // A null cnapName should be the same as "" + if (TextUtils.isEmpty(dc.name)) { + if (!TextUtils.isEmpty(cnapName)) { + changed = true; + cnapName = ""; + } + } else if (!dc.name.equals(cnapName)) { + changed = true; + cnapName = dc.name; + } + + if (Phone.DEBUG_PHONE) log("--dssds----"+cnapName); + cnapNamePresentation = dc.namePresentation; + numberPresentation = dc.numberPresentation; + if (newParent != parent) { if (parent != null) { parent.detach(this); diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java index 84127cf..9e8a830 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java @@ -1220,7 +1220,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker { } catch (Exception e){ } - return gsmRoaming && !(equalsMcc && (equalsOnsl || equalsOnss)); + boolean mvnoRoaming = Settings.System.getInt(phone.getContext().getContentResolver(), + Settings.System.MVNO_ROAMING, 0) == 1; + return gsmRoaming && !(equalsMcc && (equalsOnsl || equalsOnss || mvnoRoaming)); } private static int twoDigitsAt(String s, int offset) { |