diff options
Diffstat (limited to 'telephony/java/android')
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 414 |
1 files changed, 318 insertions, 96 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 89978b7..b44fa6c 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -603,7 +603,10 @@ public class TelephonyManager { return null; } try { - return getSubscriberInfo().getDeviceSvnUsingSubId(subId[0]); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getDeviceSvnUsingSubId(subId[0]); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -620,7 +623,10 @@ public class TelephonyManager { */ public String getDeviceId() { try { - return getITelephony().getDeviceId(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getDeviceId(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -641,7 +647,10 @@ public class TelephonyManager { public String getDeviceId(int slotId) { // FIXME this assumes phoneId == slotId try { - return getSubscriberInfo().getDeviceIdForPhone(slotId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getDeviceIdForPhone(slotId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -672,7 +681,10 @@ public class TelephonyManager { public String getImei(int slotId) { int[] subId = SubscriptionManager.getSubId(slotId); try { - return getSubscriberInfo().getImeiForSubscriber(subId[0]); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getImeiForSubscriber(subId[0]); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -698,7 +710,10 @@ public class TelephonyManager { public String getNai(int slotId) { int[] subId = SubscriptionManager.getSubId(slotId); try { - String nai = getSubscriberInfo().getNaiForSubscriber(subId[0]); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + String nai = info.getNaiForSubscriber(subId[0]); if (Log.isLoggable(TAG, Log.VERBOSE)) { Rlog.v(TAG, "Nai = " + nai); } @@ -727,7 +742,10 @@ public class TelephonyManager { */ public CellLocation getCellLocation() { try { - Bundle bundle = getITelephony().getCellLocation(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + Bundle bundle = telephony.getCellLocation(); if (bundle.isEmpty()) return null; CellLocation cl = CellLocation.newFromBundle(bundle); if (cl.isEmpty()) @@ -766,7 +784,9 @@ public class TelephonyManager { /** @hide */ public void enableLocationUpdates(int subId) { try { - getITelephony().enableLocationUpdatesForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.enableLocationUpdatesForSubscriber(subId); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -788,7 +808,9 @@ public class TelephonyManager { /** @hide */ public void disableLocationUpdates(int subId) { try { - getITelephony().disableLocationUpdatesForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.disableLocationUpdatesForSubscriber(subId); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -807,7 +829,10 @@ public class TelephonyManager { */ public List<NeighboringCellInfo> getNeighboringCellInfo() { try { - return getITelephony().getNeighboringCellInfo(mContext.getOpPackageName()); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getNeighboringCellInfo(mContext.getOpPackageName()); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1513,7 +1538,10 @@ public class TelephonyManager { public boolean hasIccCard(int slotId) { try { - return getITelephony().hasIccCardUsingSlotId(slotId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return false; + return telephony.hasIccCardUsingSlotId(slotId); } catch (RemoteException ex) { // Assume no ICC card if remote exception which shouldn't happen return false; @@ -1745,7 +1773,10 @@ public class TelephonyManager { /** {@hide} */ public String getSimSerialNumber(int subId) { try { - return getSubscriberInfo().getIccSerialNumberForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIccSerialNumberForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1781,7 +1812,10 @@ public class TelephonyManager { /** {@hide} */ public int getLteOnCdmaMode(int subId) { try { - return getITelephony().getLteOnCdmaModeForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return PhoneConstants.LTE_ON_CDMA_UNKNOWN; + return telephony.getLteOnCdmaModeForSubscriber(subId); } catch (RemoteException ex) { // Assume no ICC card if remote exception which shouldn't happen return PhoneConstants.LTE_ON_CDMA_UNKNOWN; @@ -1821,7 +1855,10 @@ public class TelephonyManager { /** {@hide} */ public String getSubscriberId(int subId) { try { - return getSubscriberInfo().getSubscriberIdForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getSubscriberIdForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1839,7 +1876,10 @@ public class TelephonyManager { */ public String getGroupIdLevel1() { try { - return getSubscriberInfo().getGroupIdLevel1(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getGroupIdLevel1(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1860,7 +1900,10 @@ public class TelephonyManager { /** {@hide} */ public String getGroupIdLevel1(int subId) { try { - return getSubscriberInfo().getGroupIdLevel1ForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getGroupIdLevel1ForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1893,7 +1936,9 @@ public class TelephonyManager { public String getLine1NumberForSubscriber(int subId) { String number = null; try { - number = getITelephony().getLine1NumberForDisplay(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + number = telephony.getLine1NumberForDisplay(subId); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -1901,7 +1946,10 @@ public class TelephonyManager { return number; } try { - return getSubscriberInfo().getLine1NumberForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getLine1NumberForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -1944,7 +1992,9 @@ public class TelephonyManager { */ public boolean setLine1NumberForDisplayForSubscriber(int subId, String alphaTag, String number) { try { - return getITelephony().setLine1NumberForDisplayForSubscriber(subId, alphaTag, number); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setLine1NumberForDisplayForSubscriber(subId, alphaTag, number); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -1978,7 +2028,9 @@ public class TelephonyManager { public String getLine1AlphaTagForSubscriber(int subId) { String alphaTag = null; try { - alphaTag = getITelephony().getLine1AlphaTagForDisplay(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + alphaTag = telephony.getLine1AlphaTagForDisplay(subId); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -1986,7 +2038,10 @@ public class TelephonyManager { return alphaTag; } try { - return getSubscriberInfo().getLine1AlphaTagForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getLine1AlphaTagForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2005,7 +2060,9 @@ public class TelephonyManager { */ public @Nullable String[] getMergedSubscriberIds() { try { - return getITelephony().getMergedSubscriberIds(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getMergedSubscriberIds(); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2037,7 +2094,10 @@ public class TelephonyManager { /** {@hide} */ public String getMsisdn(int subId) { try { - return getSubscriberInfo().getMsisdnForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getMsisdnForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2067,7 +2127,10 @@ public class TelephonyManager { /** {@hide} */ public String getVoiceMailNumber(int subId) { try { - return getSubscriberInfo().getVoiceMailNumberForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getVoiceMailNumberForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2099,7 +2162,10 @@ public class TelephonyManager { /** {@hide} */ public String getCompleteVoiceMailNumber(int subId) { try { - return getSubscriberInfo().getCompleteVoiceMailNumberForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getCompleteVoiceMailNumberForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2134,7 +2200,9 @@ public class TelephonyManager { /** {@hide} */ public boolean setVoiceMailNumber(int subId, String alphaTag, String number) { try { - return getITelephony().setVoiceMailNumber(subId, alphaTag, number); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setVoiceMailNumber(subId, alphaTag, number); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2162,7 +2230,10 @@ public class TelephonyManager { /** {@hide} */ public int getVoiceMessageCount(int subId) { try { - return getITelephony().getVoiceMessageCountForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return 0; + return telephony.getVoiceMessageCountForSubscriber(subId); } catch (RemoteException ex) { return 0; } catch (NullPointerException ex) { @@ -2194,7 +2265,10 @@ public class TelephonyManager { /** {@hide} */ public String getVoiceMailAlphaTag(int subId) { try { - return getSubscriberInfo().getVoiceMailAlphaTagForSubscriber(subId); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getVoiceMailAlphaTagForSubscriber(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2210,7 +2284,10 @@ public class TelephonyManager { */ public String getIsimImpi() { try { - return getSubscriberInfo().getIsimImpi(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimImpi(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2226,7 +2303,10 @@ public class TelephonyManager { */ public String getIsimDomain() { try { - return getSubscriberInfo().getIsimDomain(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimDomain(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2243,7 +2323,10 @@ public class TelephonyManager { */ public String[] getIsimImpu() { try { - return getSubscriberInfo().getIsimImpu(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimImpu(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2287,7 +2370,10 @@ public class TelephonyManager { /** {@hide} */ public int getCallState(int subId) { try { - return getITelephony().getCallStateForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return CALL_STATE_IDLE; + return telephony.getCallStateForSubscriber(subId); } catch (RemoteException ex) { // the phone process is restarting. return CALL_STATE_IDLE; @@ -2323,7 +2409,10 @@ public class TelephonyManager { */ public int getDataActivity() { try { - return getITelephony().getDataActivity(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return DATA_ACTIVITY_NONE; + return telephony.getDataActivity(); } catch (RemoteException ex) { // the phone process is restarting. return DATA_ACTIVITY_NONE; @@ -2359,7 +2448,10 @@ public class TelephonyManager { */ public int getDataState() { try { - return getITelephony().getDataState(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return DATA_DISCONNECTED; + return telephony.getDataState(); } catch (RemoteException ex) { // the phone process is restarting. return DATA_DISCONNECTED; @@ -2438,7 +2530,10 @@ public class TelephonyManager { /** {@hide} */ public int getCdmaEriIconIndex(int subId) { try { - return getITelephony().getCdmaEriIconIndexForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return -1; + return telephony.getCdmaEriIconIndexForSubscriber(subId); } catch (RemoteException ex) { // the phone process is restarting. return -1; @@ -2466,7 +2561,10 @@ public class TelephonyManager { /** {@hide} */ public int getCdmaEriIconMode(int subId) { try { - return getITelephony().getCdmaEriIconModeForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return -1; + return telephony.getCdmaEriIconModeForSubscriber(subId); } catch (RemoteException ex) { // the phone process is restarting. return -1; @@ -2491,7 +2589,10 @@ public class TelephonyManager { /** {@hide} */ public String getCdmaEriText(int subId) { try { - return getITelephony().getCdmaEriTextForSubscriber(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getCdmaEriTextForSubscriber(subId); } catch (RemoteException ex) { // the phone process is restarting. return null; @@ -2558,7 +2659,10 @@ public class TelephonyManager { */ public List<CellInfo> getAllCellInfo() { try { - return getITelephony().getAllCellInfo(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getAllCellInfo(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -2580,7 +2684,9 @@ public class TelephonyManager { */ public void setCellInfoListRate(int rateInMillis) { try { - getITelephony().setCellInfoListRate(rateInMillis); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.setCellInfoListRate(rateInMillis); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2618,7 +2724,9 @@ public class TelephonyManager { */ public IccOpenLogicalChannelResponse iccOpenLogicalChannel(String AID) { try { - return getITelephony().iccOpenLogicalChannel(AID); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccOpenLogicalChannel(AID); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2640,7 +2748,9 @@ public class TelephonyManager { */ public boolean iccCloseLogicalChannel(int channel) { try { - return getITelephony().iccCloseLogicalChannel(channel); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccCloseLogicalChannel(channel); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2671,7 +2781,9 @@ public class TelephonyManager { public String iccTransmitApduLogicalChannel(int channel, int cla, int instruction, int p1, int p2, int p3, String data) { try { - return getITelephony().iccTransmitApduLogicalChannel(channel, cla, + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccTransmitApduLogicalChannel(channel, cla, instruction, p1, p2, p3, data); } catch (RemoteException ex) { } catch (NullPointerException ex) { @@ -2701,7 +2813,9 @@ public class TelephonyManager { public String iccTransmitApduBasicChannel(int cla, int instruction, int p1, int p2, int p3, String data) { try { - return getITelephony().iccTransmitApduBasicChannel(cla, + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccTransmitApduBasicChannel(cla, instruction, p1, p2, p3, data); } catch (RemoteException ex) { } catch (NullPointerException ex) { @@ -2727,8 +2841,9 @@ public class TelephonyManager { public byte[] iccExchangeSimIO(int fileID, int command, int p1, int p2, int p3, String filePath) { try { - return getITelephony().iccExchangeSimIO(fileID, command, p1, p2, - p3, filePath); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.iccExchangeSimIO(fileID, command, p1, p2, p3, filePath); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2751,7 +2866,9 @@ public class TelephonyManager { */ public String sendEnvelopeWithStatus(String content) { try { - return getITelephony().sendEnvelopeWithStatus(content); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.sendEnvelopeWithStatus(content); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -2773,7 +2890,9 @@ public class TelephonyManager { */ public String nvReadItem(int itemID) { try { - return getITelephony().nvReadItem(itemID); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.nvReadItem(itemID); } catch (RemoteException ex) { Rlog.e(TAG, "nvReadItem RemoteException", ex); } catch (NullPointerException ex) { @@ -2798,7 +2917,9 @@ public class TelephonyManager { */ public boolean nvWriteItem(int itemID, String itemValue) { try { - return getITelephony().nvWriteItem(itemID, itemValue); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.nvWriteItem(itemID, itemValue); } catch (RemoteException ex) { Rlog.e(TAG, "nvWriteItem RemoteException", ex); } catch (NullPointerException ex) { @@ -2822,7 +2943,9 @@ public class TelephonyManager { */ public boolean nvWriteCdmaPrl(byte[] preferredRoamingList) { try { - return getITelephony().nvWriteCdmaPrl(preferredRoamingList); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.nvWriteCdmaPrl(preferredRoamingList); } catch (RemoteException ex) { Rlog.e(TAG, "nvWriteCdmaPrl RemoteException", ex); } catch (NullPointerException ex) { @@ -2847,7 +2970,9 @@ public class TelephonyManager { */ public boolean nvResetConfig(int resetType) { try { - return getITelephony().nvResetConfig(resetType); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.nvResetConfig(resetType); } catch (RemoteException ex) { Rlog.e(TAG, "nvResetConfig RemoteException", ex); } catch (NullPointerException ex) { @@ -3051,7 +3176,10 @@ public class TelephonyManager { */ public String getIsimIst() { try { - return getSubscriberInfo().getIsimIst(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimIst(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3068,7 +3196,10 @@ public class TelephonyManager { */ public String[] getIsimPcscf() { try { - return getSubscriberInfo().getIsimPcscf(); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimPcscf(); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3087,7 +3218,10 @@ public class TelephonyManager { */ public String getIsimChallengeResponse(String nonce){ try { - return getSubscriberInfo().getIsimChallengeResponse(nonce); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIsimChallengeResponse(nonce); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3107,7 +3241,10 @@ public class TelephonyManager { */ public String getIccSimChallengeResponse(int subId, int appType, String data) { try { - return getSubscriberInfo().getIccSimChallengeResponse(subId, appType, data); + IPhoneSubInfo info = getSubscriberInfo(); + if (info == null) + return null; + return info.getIccSimChallengeResponse(subId, appType, data); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3136,7 +3273,10 @@ public class TelephonyManager { */ public String[] getPcscfAddress(String apnType) { try { - return getITelephony().getPcscfAddress(apnType); + ITelephony telephony = getITelephony(); + if (telephony == null) + return new String[0]; + return telephony.getPcscfAddress(apnType); } catch (RemoteException e) { return new String[0]; } @@ -3150,7 +3290,9 @@ public class TelephonyManager { */ public void setImsRegistrationState(boolean registered) { try { - getITelephony().setImsRegistrationState(registered); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.setImsRegistrationState(registered); } catch (RemoteException e) { } } @@ -3168,7 +3310,9 @@ public class TelephonyManager { */ public int getPreferredNetworkType() { try { - return getITelephony().getPreferredNetworkType(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getPreferredNetworkType(); } catch (RemoteException ex) { Rlog.e(TAG, "getPreferredNetworkType RemoteException", ex); } catch (NullPointerException ex) { @@ -3191,7 +3335,9 @@ public class TelephonyManager { */ public boolean setPreferredNetworkType(int networkType) { try { - return getITelephony().setPreferredNetworkType(networkType); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setPreferredNetworkType(networkType); } catch (RemoteException ex) { Rlog.e(TAG, "setPreferredNetworkType RemoteException", ex); } catch (NullPointerException ex) { @@ -3223,7 +3369,9 @@ public class TelephonyManager { */ public int getTetherApnRequired() { try { - return getITelephony().getTetherApnRequired(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getTetherApnRequired(); } catch (RemoteException ex) { Rlog.e(TAG, "hasMatchedTetherApnSetting RemoteException", ex); } catch (NullPointerException ex) { @@ -3256,8 +3404,9 @@ public class TelephonyManager { */ public boolean hasCarrierPrivileges() { try { - return getITelephony().getCarrierPrivilegeStatus() == - CARRIER_PRIVILEGE_STATUS_HAS_ACCESS; + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getCarrierPrivilegeStatus() == CARRIER_PRIVILEGE_STATUS_HAS_ACCESS; } catch (RemoteException ex) { Rlog.e(TAG, "hasCarrierPrivileges RemoteException", ex); } catch (NullPointerException ex) { @@ -3282,7 +3431,9 @@ public class TelephonyManager { */ public boolean setOperatorBrandOverride(String brand) { try { - return getITelephony().setOperatorBrandOverride(brand); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setOperatorBrandOverride(brand); } catch (RemoteException ex) { Rlog.e(TAG, "setOperatorBrandOverride RemoteException", ex); } catch (NullPointerException ex) { @@ -3314,8 +3465,10 @@ public class TelephonyManager { List<String> gsmNonRoamingList, List<String> cdmaRoamingList, List<String> cdmaNonRoamingList) { try { - return getITelephony().setRoamingOverride(gsmRoamingList, gsmNonRoamingList, - cdmaRoamingList, cdmaNonRoamingList); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setRoamingOverride(gsmRoamingList, gsmNonRoamingList, + cdmaRoamingList, cdmaNonRoamingList); } catch (RemoteException ex) { Rlog.e(TAG, "setRoamingOverride RemoteException", ex); } catch (NullPointerException ex) { @@ -3338,7 +3491,10 @@ public class TelephonyManager { @SystemApi public String getCdmaMdn(int subId) { try { - return getITelephony().getCdmaMdn(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getCdmaMdn(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3356,7 +3512,10 @@ public class TelephonyManager { @SystemApi public String getCdmaMin(int subId) { try { - return getITelephony().getCdmaMin(subId); + ITelephony telephony = getITelephony(); + if (telephony == null) + return null; + return telephony.getCdmaMin(subId); } catch (RemoteException ex) { return null; } catch (NullPointerException ex) { @@ -3368,7 +3527,9 @@ public class TelephonyManager { @SystemApi public int checkCarrierPrivilegesForPackage(String pkgname) { try { - return getITelephony().checkCarrierPrivilegesForPackage(pkgname); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.checkCarrierPrivilegesForPackage(pkgname); } catch (RemoteException ex) { Rlog.e(TAG, "checkCarrierPrivilegesForPackage RemoteException", ex); } catch (NullPointerException ex) { @@ -3381,7 +3542,9 @@ public class TelephonyManager { @SystemApi public List<String> getCarrierPackageNamesForIntent(Intent intent) { try { - return getITelephony().getCarrierPackageNamesForIntent(intent); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.getCarrierPackageNamesForIntent(intent); } catch (RemoteException ex) { Rlog.e(TAG, "getCarrierPackageNamesForIntent RemoteException", ex); } catch (NullPointerException ex) { @@ -3394,7 +3557,9 @@ public class TelephonyManager { @SystemApi public void dial(String number) { try { - getITelephony().dial(number); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.dial(number); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#dial", e); } @@ -3404,7 +3569,9 @@ public class TelephonyManager { @SystemApi public void call(String callingPackage, String number) { try { - getITelephony().call(callingPackage, number); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.call(callingPackage, number); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#call", e); } @@ -3414,7 +3581,9 @@ public class TelephonyManager { @SystemApi public boolean endCall() { try { - return getITelephony().endCall(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.endCall(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#endCall", e); } @@ -3425,7 +3594,9 @@ public class TelephonyManager { @SystemApi public void answerRingingCall() { try { - getITelephony().answerRingingCall(); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.answerRingingCall(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#answerRingingCall", e); } @@ -3445,7 +3616,9 @@ public class TelephonyManager { @SystemApi public boolean isOffhook() { try { - return getITelephony().isOffhook(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isOffhook(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isOffhook", e); } @@ -3456,7 +3629,9 @@ public class TelephonyManager { @SystemApi public boolean isRinging() { try { - return getITelephony().isRinging(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isRinging(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isRinging", e); } @@ -3467,7 +3642,9 @@ public class TelephonyManager { @SystemApi public boolean isIdle() { try { - return getITelephony().isIdle(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isIdle(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isIdle", e); } @@ -3478,7 +3655,9 @@ public class TelephonyManager { @SystemApi public boolean isRadioOn() { try { - return getITelephony().isRadioOn(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isRadioOn(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isRadioOn", e); } @@ -3489,7 +3668,9 @@ public class TelephonyManager { @SystemApi public boolean isSimPinEnabled() { try { - return getITelephony().isSimPinEnabled(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isSimPinEnabled(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isSimPinEnabled", e); } @@ -3500,7 +3681,9 @@ public class TelephonyManager { @SystemApi public boolean supplyPin(String pin) { try { - return getITelephony().supplyPin(pin); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.supplyPin(pin); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#supplyPin", e); } @@ -3511,7 +3694,9 @@ public class TelephonyManager { @SystemApi public boolean supplyPuk(String puk, String pin) { try { - return getITelephony().supplyPuk(puk, pin); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.supplyPuk(puk, pin); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#supplyPuk", e); } @@ -3522,7 +3707,9 @@ public class TelephonyManager { @SystemApi public int[] supplyPinReportResult(String pin) { try { - return getITelephony().supplyPinReportResult(pin); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.supplyPinReportResult(pin); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#supplyPinReportResult", e); } @@ -3533,7 +3720,9 @@ public class TelephonyManager { @SystemApi public int[] supplyPukReportResult(String puk, String pin) { try { - return getITelephony().supplyPukReportResult(puk, pin); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.supplyPukReportResult(puk, pin); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#]", e); } @@ -3544,7 +3733,9 @@ public class TelephonyManager { @SystemApi public boolean handlePinMmi(String dialString) { try { - return getITelephony().handlePinMmi(dialString); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.handlePinMmi(dialString); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#handlePinMmi", e); } @@ -3555,7 +3746,9 @@ public class TelephonyManager { @SystemApi public boolean handlePinMmiForSubscriber(int subId, String dialString) { try { - return getITelephony().handlePinMmiForSubscriber(subId, dialString); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.handlePinMmiForSubscriber(subId, dialString); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#handlePinMmi", e); } @@ -3566,7 +3759,9 @@ public class TelephonyManager { @SystemApi public void toggleRadioOnOff() { try { - getITelephony().toggleRadioOnOff(); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.toggleRadioOnOff(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#toggleRadioOnOff", e); } @@ -3576,7 +3771,9 @@ public class TelephonyManager { @SystemApi public boolean setRadio(boolean turnOn) { try { - return getITelephony().setRadio(turnOn); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setRadio(turnOn); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setRadio", e); } @@ -3587,7 +3784,9 @@ public class TelephonyManager { @SystemApi public boolean setRadioPower(boolean turnOn) { try { - return getITelephony().setRadioPower(turnOn); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.setRadioPower(turnOn); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setRadioPower", e); } @@ -3598,7 +3797,9 @@ public class TelephonyManager { @SystemApi public void updateServiceLocation() { try { - getITelephony().updateServiceLocation(); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.updateServiceLocation(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#updateServiceLocation", e); } @@ -3608,7 +3809,9 @@ public class TelephonyManager { @SystemApi public boolean enableDataConnectivity() { try { - return getITelephony().enableDataConnectivity(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.enableDataConnectivity(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#enableDataConnectivity", e); } @@ -3619,7 +3822,9 @@ public class TelephonyManager { @SystemApi public boolean disableDataConnectivity() { try { - return getITelephony().disableDataConnectivity(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.disableDataConnectivity(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#disableDataConnectivity", e); } @@ -3630,7 +3835,9 @@ public class TelephonyManager { @SystemApi public boolean isDataConnectivityPossible() { try { - return getITelephony().isDataConnectivityPossible(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isDataConnectivityPossible(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isDataConnectivityPossible", e); } @@ -3641,7 +3848,9 @@ public class TelephonyManager { @SystemApi public boolean needsOtaServiceProvisioning() { try { - return getITelephony().needsOtaServiceProvisioning(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.needsOtaServiceProvisioning(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning", e); } @@ -3659,7 +3868,9 @@ public class TelephonyManager { public void setDataEnabled(int subId, boolean enable) { try { Log.d(TAG, "setDataEnabled: enabled=" + enable); - getITelephony().setDataEnabled(subId, enable); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.setDataEnabled(subId, enable); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#setDataEnabled", e); } @@ -3676,7 +3887,9 @@ public class TelephonyManager { public boolean getDataEnabled(int subId) { boolean retVal = false; try { - retVal = getITelephony().getDataEnabled(subId); + ITelephony telephony = getITelephony(); + if (telephony != null) + retVal = telephony.getDataEnabled(subId); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#getDataEnabled", e); } catch (NullPointerException e) { @@ -3697,7 +3910,9 @@ public class TelephonyManager { */ public int invokeOemRilRequestRaw(byte[] oemReq, byte[] oemResp) { try { - return getITelephony().invokeOemRilRequestRaw(oemReq, oemResp); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.invokeOemRilRequestRaw(oemReq, oemResp); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -3708,7 +3923,9 @@ public class TelephonyManager { @SystemApi public void enableVideoCalling(boolean enable) { try { - getITelephony().enableVideoCalling(enable); + ITelephony telephony = getITelephony(); + if (telephony != null) + telephony.enableVideoCalling(enable); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#enableVideoCalling", e); } @@ -3718,7 +3935,9 @@ public class TelephonyManager { @SystemApi public boolean isVideoCallingEnabled() { try { - return getITelephony().isVideoCallingEnabled(); + ITelephony telephony = getITelephony(); + if (telephony != null) + return telephony.isVideoCallingEnabled(); } catch (RemoteException e) { Log.e(TAG, "Error calling ITelephony#isVideoCallingEnabled", e); } @@ -3826,7 +4045,10 @@ public class TelephonyManager { */ public boolean isImsRegistered() { try { - return getITelephony().isImsRegistered(); + ITelephony telephony = getITelephony(); + if (telephony == null) + return false; + return telephony.isImsRegistered(); } catch (RemoteException ex) { return false; } catch (NullPointerException ex) { |