Revert "have PhoneInterfaceManager use phone obj with default subid instead of"
This reverts commit a5509e910c1983c217da0f0d18d79a250bb9867c.
Reason for revert: Broke build, see original CL for details.
Change-Id: I6d039698aa5a216b6123fdbea328a4a684f43e09
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e3bd8a6..973ddf0 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -242,6 +242,7 @@
private static PhoneInterfaceManager sInstance;
private PhoneGlobals mApp;
+ private Phone mPhone;
private CallManager mCM;
private UserManager mUserManager;
private AppOpsManager mAppOps;
@@ -366,7 +367,6 @@
AsyncResult ar;
UiccCard uiccCard;
IccAPDUArgument iccArgument;
- final Phone defaultPhone = getDefaultPhone();
switch (msg.what) {
case CMD_HANDLE_USSD_REQUEST: {
@@ -621,8 +621,7 @@
case CMD_NV_READ_ITEM:
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_NV_READ_ITEM_DONE, request);
- defaultPhone.nvReadItem((Integer) request.argument, onCompleted,
- request.workSource);
+ mPhone.nvReadItem((Integer) request.argument, onCompleted, request.workSource);
break;
case EVENT_NV_READ_ITEM_DONE:
@@ -648,7 +647,7 @@
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_NV_WRITE_ITEM_DONE, request);
Pair<Integer, String> idValue = (Pair<Integer, String>) request.argument;
- defaultPhone.nvWriteItem(idValue.first, idValue.second, onCompleted,
+ mPhone.nvWriteItem(idValue.first, idValue.second, onCompleted,
request.workSource);
break;
@@ -659,7 +658,7 @@
case CMD_NV_WRITE_CDMA_PRL:
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_NV_WRITE_CDMA_PRL_DONE, request);
- defaultPhone.nvWriteCdmaPrl((byte[]) request.argument, onCompleted);
+ mPhone.nvWriteCdmaPrl((byte[]) request.argument, onCompleted);
break;
case EVENT_NV_WRITE_CDMA_PRL_DONE:
@@ -669,7 +668,7 @@
case CMD_RESET_MODEM_CONFIG:
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_RESET_MODEM_CONFIG_DONE, request);
- defaultPhone.resetModemConfig(onCompleted);
+ mPhone.resetModemConfig(onCompleted);
break;
case EVENT_RESET_MODEM_CONFIG_DONE:
@@ -715,7 +714,7 @@
case CMD_INVOKE_OEM_RIL_REQUEST_RAW:
request = (MainThreadRequest)msg.obj;
onCompleted = obtainMessage(EVENT_INVOKE_OEM_RIL_REQUEST_RAW_DONE, request);
- defaultPhone.invokeOemRilRequestRaw((byte[]) request.argument, onCompleted);
+ mPhone.invokeOemRilRequestRaw((byte[]) request.argument, onCompleted);
break;
case EVENT_INVOKE_OEM_RIL_REQUEST_RAW_DONE:
@@ -811,7 +810,7 @@
case CMD_GET_MODEM_ACTIVITY_INFO:
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_GET_MODEM_ACTIVITY_INFO_DONE, request);
- defaultPhone.getModemActivityInfo(onCompleted, request.workSource);
+ mPhone.getModemActivityInfo(onCompleted, request.workSource);
break;
case EVENT_GET_MODEM_ACTIVITY_INFO_DONE:
@@ -839,7 +838,7 @@
case CMD_SET_ALLOWED_CARRIERS:
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_SET_ALLOWED_CARRIERS_DONE, request);
- defaultPhone.setAllowedCarriers(
+ mPhone.setAllowedCarriers(
(List<CarrierIdentifier>) request.argument,
onCompleted, request.workSource);
break;
@@ -869,7 +868,7 @@
case CMD_GET_ALLOWED_CARRIERS:
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_GET_ALLOWED_CARRIERS_DONE, request);
- defaultPhone.getAllowedCarriers(onCompleted, request.workSource);
+ mPhone.getAllowedCarriers(onCompleted, request.workSource);
break;
case EVENT_GET_ALLOWED_CARRIERS_DONE:
@@ -1076,7 +1075,7 @@
case CMD_MODEM_REBOOT:
request = (MainThreadRequest) msg.obj;
onCompleted = obtainMessage(EVENT_RESET_MODEM_CONFIG_DONE, request);
- defaultPhone.rebootModem(onCompleted);
+ mPhone.rebootModem(onCompleted);
break;
case EVENT_CMD_MODEM_REBOOT_DONE:
handleNullReturnEvent(msg, "rebootModem");
@@ -1227,10 +1226,10 @@
* Initialize the singleton PhoneInterfaceManager instance.
* This is only done once, at startup, from PhoneApp.onCreate().
*/
- /* package */ static PhoneInterfaceManager init(PhoneGlobals app) {
+ /* package */ static PhoneInterfaceManager init(PhoneGlobals app, Phone phone) {
synchronized (PhoneInterfaceManager.class) {
if (sInstance == null) {
- sInstance = new PhoneInterfaceManager(app);
+ sInstance = new PhoneInterfaceManager(app, phone);
} else {
Log.wtf(LOG_TAG, "init() called multiple times! sInstance = " + sInstance);
}
@@ -1239,26 +1238,22 @@
}
/** Private constructor; @see init() */
- private PhoneInterfaceManager(PhoneGlobals app) {
+ private PhoneInterfaceManager(PhoneGlobals app, Phone phone) {
mApp = app;
+ mPhone = phone;
mCM = PhoneGlobals.getInstance().mCM;
mUserManager = (UserManager) app.getSystemService(Context.USER_SERVICE);
mAppOps = (AppOpsManager)app.getSystemService(Context.APP_OPS_SERVICE);
mMainThreadHandler = new MainThreadHandler();
- mSubscriptionController = SubscriptionController.getInstance();
mTelephonySharedPreferences =
- PreferenceManager.getDefaultSharedPreferences(mApp);
+ PreferenceManager.getDefaultSharedPreferences(mPhone.getContext());
+ mSubscriptionController = SubscriptionController.getInstance();
mNetworkScanRequestTracker = new NetworkScanRequestTracker();
mPhoneConfigurationManager = PhoneConfigurationManager.getInstance();
publish();
}
- private Phone getDefaultPhone() {
- Phone thePhone = getPhone(getDefaultSubscription());
- return (thePhone != null) ? thePhone : PhoneFactory.getDefaultPhone();
- }
-
private void publish() {
if (DBG) log("publish: " + this);
@@ -1267,7 +1262,7 @@
private Phone getPhoneFromRequest(MainThreadRequest request) {
return (request.subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID)
- ? getDefaultPhone() : getPhone(request.subId);
+ ? mPhone : getPhone(request.subId);
}
private UiccCard getUiccCardFromRequest(MainThreadRequest request) {
@@ -1815,10 +1810,10 @@
@Override
public Bundle getCellLocation(String callingPackage) {
- mApp.getSystemService(AppOpsManager.class)
+ mPhone.getContext().getSystemService(AppOpsManager.class)
.checkPackage(Binder.getCallingUid(), callingPackage);
- if (!LocationAccessPolicy.canAccessCellLocation(mApp, callingPackage,
- Binder.getCallingUid(), Binder.getCallingPid(), true)) {
+ if (!LocationAccessPolicy.canAccessCellLocation(mPhone.getContext(),
+ callingPackage, Binder.getCallingUid(), Binder.getCallingPid(), true)) {
return null;
}
@@ -1918,8 +1913,8 @@
*/
private int getTargetSdk(String packageName) {
try {
- final ApplicationInfo ai = mApp.getPackageManager().getApplicationInfo(
- packageName, 0);
+ final ApplicationInfo ai =
+ mPhone.getContext().getPackageManager().getApplicationInfo(packageName, 0);
if (ai != null) return ai.targetSdkVersion;
} catch (PackageManager.NameNotFoundException unexpected) {
}
@@ -1967,9 +1962,9 @@
@Override
public List<CellInfo> getAllCellInfo(String callingPackage) {
- mApp.getSystemService(AppOpsManager.class)
+ mPhone.getContext().getSystemService(AppOpsManager.class)
.checkPackage(Binder.getCallingUid(), callingPackage);
- if (!LocationAccessPolicy.canAccessCellLocation(mApp,
+ if (!LocationAccessPolicy.canAccessCellLocation(mPhone.getContext(),
callingPackage, Binder.getCallingUid(), Binder.getCallingPid(), true)) {
return null;
}
@@ -2010,10 +2005,10 @@
private void requestCellInfoUpdateInternal(
int subId, ICellInfoCallback cb, String callingPackage, WorkSource workSource) {
- mApp.getSystemService(AppOpsManager.class)
+ mPhone.getContext().getSystemService(AppOpsManager.class)
.checkPackage(Binder.getCallingUid(), callingPackage);
- if (!LocationAccessPolicy.canAccessCellLocation(mApp, callingPackage,
- Binder.getCallingUid(), Binder.getCallingPid(), true)) {
+ if (!LocationAccessPolicy.canAccessCellLocation(mPhone.getContext(),
+ callingPackage, Binder.getCallingUid(), Binder.getCallingPid(), true)) {
return;
}
@@ -2030,7 +2025,7 @@
final long identity = Binder.clearCallingIdentity();
try {
- getDefaultPhone().setCellInfoListRate(rateInMillis, workSource);
+ mPhone.setCellInfoListRate(rateInMillis, workSource);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2073,7 +2068,6 @@
if (phone == null) {
return null;
}
-
int subId = phone.getSubId();
if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mApp, subId,
callingPackage, "getMeidForSlot")) {
@@ -2212,7 +2206,8 @@
}
private void enforceConnectivityInternalPermission() {
- mApp.enforceCallingOrSelfPermission(android.Manifest.permission.CONNECTIVITY_INTERNAL,
+ mApp.enforceCallingOrSelfPermission(
+ android.Manifest.permission.CONNECTIVITY_INTERNAL,
"ConnectivityService");
}
@@ -2353,10 +2348,9 @@
final long identity = Binder.clearCallingIdentity();
try {
final Phone phone = getPhone(subId);
- if (phone != null && phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
+ if (mPhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA && phone != null) {
return phone.getLine1Number();
} else {
- loge("getCdmaMdn: no phone found. Invalid subId: " + subId);
return null;
}
} finally {
@@ -2415,7 +2409,7 @@
public boolean needsOtaServiceProvisioning() {
final long identity = Binder.clearCallingIdentity();
try {
- return getDefaultPhone().needsOtaServiceProvisioning();
+ return mPhone.needsOtaServiceProvisioning();
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2441,7 +2435,7 @@
@Override
public Bundle getVisualVoicemailSettings(String callingPackage, int subId) {
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
- String systemDialer = TelecomManager.from(mApp).getSystemDialerPackage();
+ String systemDialer = TelecomManager.from(mPhone.getContext()).getSystemDialerPackage();
if (!TextUtils.equals(callingPackage, systemDialer)) {
throw new SecurityException("caller must be system dialer");
}
@@ -2452,7 +2446,7 @@
if (phoneAccountHandle == null) {
return null;
}
- return VisualVoicemailSettingsUtil.dump(mApp, phoneAccountHandle);
+ return VisualVoicemailSettingsUtil.dump(mPhone.getContext(), phoneAccountHandle);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2468,7 +2462,8 @@
final long identity = Binder.clearCallingIdentity();
try {
- return RemoteVvmTaskManager.getRemotePackage(mApp, subId).getPackageName();
+ return RemoteVvmTaskManager
+ .getRemotePackage(mPhone.getContext(), subId).getPackageName();
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2482,7 +2477,7 @@
final long identity = Binder.clearCallingIdentity();
try {
VisualVoicemailSmsFilterConfig.enableVisualVoicemailSmsFilter(
- mApp, callingPackage, subId, settings);
+ mPhone.getContext(), callingPackage, subId, settings);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2495,7 +2490,7 @@
final long identity = Binder.clearCallingIdentity();
try {
VisualVoicemailSmsFilterConfig.disableVisualVoicemailSmsFilter(
- mApp, callingPackage, subId);
+ mPhone.getContext(), callingPackage, subId);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2509,7 +2504,7 @@
final long identity = Binder.clearCallingIdentity();
try {
return VisualVoicemailSmsFilterConfig.getVisualVoicemailSmsFilterSettings(
- mApp, callingPackage, subId);
+ mPhone.getContext(), callingPackage, subId);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2522,7 +2517,7 @@
final long identity = Binder.clearCallingIdentity();
try {
return VisualVoicemailSmsFilterConfig.getActiveVisualVoicemailSmsFilterSettings(
- mApp, subId);
+ mPhone.getContext(), subId);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2676,10 +2671,8 @@
*/
@Override
public void sendDialerSpecialCode(String callingPackage, String inputCode) {
- final Phone defaultPhone = getDefaultPhone();
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
- String defaultDialer = TelecomManager.from(defaultPhone.getContext())
- .getDefaultDialerPackage();
+ String defaultDialer = TelecomManager.from(mPhone.getContext()).getDefaultDialerPackage();
if (!TextUtils.equals(callingPackage, defaultDialer)) {
TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(
getDefaultSubscription(), "sendDialerSpecialCode");
@@ -2687,7 +2680,7 @@
final long identity = Binder.clearCallingIdentity();
try {
- defaultPhone.sendDialerSpecialCode(inputCode);
+ mPhone.sendDialerSpecialCode(inputCode);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2730,7 +2723,7 @@
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
final long token = Binder.clearCallingIdentity();
try {
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
.addRegistrationCallbackForSubscription(c, subId);
} finally {
Binder.restoreCallingIdentity(token);
@@ -2742,7 +2735,7 @@
enforceReadPrivilegedPermission("unregisterImsRegistrationCallback");
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
Binder.withCleanCallingIdentity(() ->
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
.removeRegistrationCallbackForSubscription(c, subId));
}
@@ -2753,7 +2746,7 @@
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
final long token = Binder.clearCallingIdentity();
try {
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
.addCapabilitiesCallbackForSubscription(c, subId);
} finally {
Binder.restoreCallingIdentity(token);
@@ -2765,7 +2758,7 @@
enforceReadPrivilegedPermission("unregisterMmTelCapabilityCallback");
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
Binder.withCleanCallingIdentity(() ->
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
.removeCapabilitiesCallbackForSubscription(c, subId));
}
@@ -2775,7 +2768,7 @@
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
final long token = Binder.clearCallingIdentity();
try {
- return ImsManager.getInstance(mApp,
+ return ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).queryMmTelCapability(capability, regTech);
} catch (ImsException e) {
Log.w(LOG_TAG, "IMS isCapable - service unavailable: " + e.getMessage());
@@ -2804,7 +2797,7 @@
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
final long token = Binder.clearCallingIdentity();
try {
- return ImsManager.getInstance(mApp,
+ return ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).isEnhanced4gLteModeSettingEnabledByUser();
} finally {
Binder.restoreCallingIdentity(token);
@@ -2818,7 +2811,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp,
+ ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).setEnhanced4gLteModeSetting(isEnabled);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2831,7 +2824,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
+ return ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).isVtEnabledByUser();
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2845,7 +2838,8 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId)).setVtSetting(isEnabled);
+ ImsManager.getInstance(mPhone.getContext(),
+ getSlotIndexOrException(subId)).setVtSetting(isEnabled);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2857,7 +2851,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
+ return ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).isWfcEnabledByUser();
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2871,7 +2865,8 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId)).setWfcSetting(isEnabled);
+ ImsManager.getInstance(mPhone.getContext(),
+ getSlotIndexOrException(subId)).setWfcSetting(isEnabled);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -2883,7 +2878,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
+ return ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).isWfcRoamingEnabledByUser();
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2897,7 +2892,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp,
+ ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).setWfcRoamingSetting(isEnabled);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2911,7 +2906,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp,
+ ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).setWfcNonPersistent(isCapable, mode);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2924,7 +2919,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
+ return ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).getWfcMode(false /*isRoaming*/);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2938,7 +2933,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp,
+ ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).setWfcMode(mode, false /*isRoaming*/);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2951,7 +2946,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
+ return ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).getWfcMode(true /*isRoaming*/);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2965,7 +2960,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp,
+ ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).setWfcMode(mode, true /*isRoaming*/);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2979,7 +2974,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp,
+ ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).setRttEnabled(isEnabled);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -2992,7 +2987,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
+ return ImsManager.getInstance(mPhone.getContext(),
getSlotIndexOrException(subId)).isTtyOnVoLteCapable();
} finally {
Binder.restoreCallingIdentity(identity);
@@ -3005,7 +3000,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
.getConfigInterface().addConfigCallback(callback);
} catch (ImsException e) {
throw new IllegalArgumentException(e.getMessage());
@@ -3020,7 +3015,7 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- ImsManager.getInstance(mApp, getSlotIndexOrException(subId))
+ ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
.getConfigInterface().removeConfigCallback(callback);
} catch (ImsException e) {
throw new IllegalArgumentException(e.getMessage());
@@ -3035,8 +3030,8 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
- getSlotIndexOrException(subId)).getConfigInterface().getConfigInt(key);
+ return ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
+ .getConfigInterface().getConfigInt(key);
} catch (ImsException e) {
throw new IllegalArgumentException(e.getMessage());
} finally {
@@ -3050,8 +3045,8 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
- getSlotIndexOrException(subId)).getConfigInterface().getConfigString(key);
+ return ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
+ .getConfigInterface().getConfigString(key);
} catch (ImsException e) {
throw new IllegalArgumentException(e.getMessage());
} finally {
@@ -3066,8 +3061,8 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
- getSlotIndexOrException(subId)).getConfigInterface().setConfig(key, value);
+ return ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
+ .getConfigInterface().setConfig(key, value);
} catch (ImsException e) {
throw new IllegalArgumentException(e.getMessage());
} finally {
@@ -3082,8 +3077,8 @@
final long identity = Binder.clearCallingIdentity();
try {
// TODO: Refactor to remove ImsManager dependence and query through ImsPhone directly.
- return ImsManager.getInstance(mApp,
- getSlotIndexOrException(subId)).getConfigInterface().setConfig(key, value);
+ return ImsManager.getInstance(mPhone.getContext(), getSlotIndexOrException(subId))
+ .getConfigInterface().setConfig(key, value);
} catch (ImsException e) {
throw new IllegalArgumentException(e.getMessage());
} finally {
@@ -3237,6 +3232,10 @@
}
}
+ public void setPhone(Phone phone) {
+ mPhone = phone;
+ }
+
/**
* {@hide}
* Returns Default subId, 0 in the case of single standby.
@@ -3263,7 +3262,7 @@
public int getWhenToMakeWifiCalls() {
final long identity = Binder.clearCallingIdentity();
try {
- return Settings.System.getInt(mApp.getContentResolver(),
+ return Settings.System.getInt(mPhone.getContext().getContentResolver(),
Settings.System.WHEN_TO_MAKE_WIFI_CALLS,
getWhenToMakeWifiCallsDefaultPreference());
} finally {
@@ -3278,7 +3277,7 @@
final long identity = Binder.clearCallingIdentity();
try {
if (DBG) log("setWhenToMakeWifiCallsStr, storing setting = " + preference);
- Settings.System.putInt(mApp.getContentResolver(),
+ Settings.System.putInt(mPhone.getContext().getContentResolver(),
Settings.System.WHEN_TO_MAKE_WIFI_CALLS, preference);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -3301,8 +3300,8 @@
try {
if (TextUtils.equals(ISDR_AID, aid)) {
// Only allows LPA to open logical channel to ISD-R.
- ComponentInfo bestComponent = EuiccConnector.findBestComponent(getDefaultPhone()
- .getContext().getPackageManager());
+ ComponentInfo bestComponent =
+ EuiccConnector.findBestComponent(mPhone.getContext().getPackageManager());
if (bestComponent == null
|| !TextUtils.equals(callingPackage, bestComponent.packageName)) {
loge("The calling package is not allowed to access ISD-R.");
@@ -3388,8 +3387,8 @@
if (command == SELECT_COMMAND && p1 == SELECT_P1 && p2 == SELECT_P2 && p3 == SELECT_P3
&& TextUtils.equals(ISDR_AID, data)) {
// Only allows LPA to select ISD-R.
- ComponentInfo bestComponent = EuiccConnector.findBestComponent(getDefaultPhone()
- .getContext().getPackageManager());
+ ComponentInfo bestComponent =
+ EuiccConnector.findBestComponent(mPhone.getContext().getPackageManager());
if (bestComponent == null
|| !TextUtils.equals(callingPackage, bestComponent.packageName)) {
loge("The calling package is not allowed to select ISD-R.");
@@ -3638,15 +3637,14 @@
}
public String[] getPcscfAddress(String apnType, String callingPackage) {
- final Phone defaultPhone = getDefaultPhone();
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, defaultPhone.getSubId(), callingPackage, "getPcscfAddress")) {
+ mApp, mPhone.getSubId(), callingPackage, "getPcscfAddress")) {
return new String[0];
}
final long identity = Binder.clearCallingIdentity();
try {
- return defaultPhone.getPcscfAddress(apnType);
+ return mPhone.getPcscfAddress(apnType);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -3800,7 +3798,7 @@
final long identity = Binder.clearCallingIdentity();
try {
- getDefaultPhone().setImsRegistrationState(registered);
+ mPhone.setImsRegistrationState(registered);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -3932,16 +3930,15 @@
*/
@Override
public int getCalculatedPreferredNetworkType(String callingPackage) {
- final Phone defaultPhone = getDefaultPhone();
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, defaultPhone.getSubId(),
- callingPackage, "getCalculatedPreferredNetworkType")) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
+ mApp, mPhone.getSubId(), callingPackage, "getCalculatedPreferredNetworkType")) {
return RILConstants.PREFERRED_NETWORK_MODE;
}
final long identity = Binder.clearCallingIdentity();
try {
// FIXME: need to get SubId from somewhere.
- return PhoneFactory.calculatePreferredNetworkType(defaultPhone.getContext(), 0);
+ return PhoneFactory.calculatePreferredNetworkType(mPhone.getContext(), 0);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -3989,7 +3986,7 @@
CMD_SET_PREFERRED_NETWORK_TYPE, networkType, subId);
if (DBG) log("setPreferredNetworkType: " + (success ? "ok" : "fail"));
if (success) {
- Settings.Global.putInt(mApp.getContentResolver(),
+ Settings.Global.putInt(mPhone.getContext().getContentResolver(),
Settings.Global.PREFERRED_NETWORK_MODE + subId, networkType);
}
return success;
@@ -4011,12 +4008,11 @@
enforceModifyPermission();
final long identity = Binder.clearCallingIdentity();
- final Phone defaultPhone = getDefaultPhone();
try {
- int dunRequired = Settings.Global.getInt(defaultPhone.getContext().getContentResolver(),
+ int dunRequired = Settings.Global.getInt(mPhone.getContext().getContentResolver(),
Settings.Global.TETHER_DUN_REQUIRED, 2);
// If not set, check net.tethering.noprovisioning, TETHER_DUN_APN setting
- if (dunRequired == 2 && defaultPhone.hasMatchedTetherApnSetting()) {
+ if (dunRequired == 2 && mPhone.hasMatchedTetherApnSetting()) {
dunRequired = 1;
}
return dunRequired;
@@ -4045,7 +4041,7 @@
if (DBG) log("setUserDataEnabled: subId=" + subId + " enable=" + enable);
phone.setUserDataEnabled(enable);
} else {
- loge("setUserDataEnabled: no phone found. Invalid subId=" + subId);
+ loge("setUserDataEnabled: no phone for subId=" + subId);
}
} finally {
Binder.restoreCallingIdentity(identity);
@@ -4177,16 +4173,14 @@
@Override
public int checkCarrierPrivilegesForPackage(String pkgName) {
- final Phone defaultPhone = getDefaultPhone();
if (TextUtils.isEmpty(pkgName))
return TelephonyManager.CARRIER_PRIVILEGE_STATUS_NO_ACCESS;
- UiccCard card = UiccController.getInstance().getUiccCard(defaultPhone.getPhoneId());
+ UiccCard card = UiccController.getInstance().getUiccCard(mPhone.getPhoneId());
if (card == null) {
loge("checkCarrierPrivilegesForPackage: No UICC");
return TelephonyManager.CARRIER_PRIVILEGE_STATUS_RULES_NOT_LOADED;
}
- return card.getCarrierPrivilegeStatus(defaultPhone.getContext().getPackageManager(),
- pkgName);
+ return card.getCarrierPrivilegeStatus(mPhone.getContext().getPackageManager(), pkgName);
}
@Override
@@ -4201,7 +4195,8 @@
continue;
}
- result = card.getCarrierPrivilegeStatus(mApp.getPackageManager(), pkgName);
+ result = card.getCarrierPrivilegeStatus(
+ mPhone.getContext().getPackageManager(), pkgName);
if (result == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
break;
}
@@ -4221,12 +4216,13 @@
loge("getCarrierPackageNamesForIntent: No UICC");
return null ;
}
- return card.getCarrierPackageNamesForIntent(mApp.getPackageManager(), intent);
+ return card.getCarrierPackageNamesForIntent(
+ mPhone.getContext().getPackageManager(), intent);
}
@Override
public List<String> getPackagesWithCarrierPrivileges() {
- PackageManager pm = mApp.getPackageManager();
+ PackageManager pm = mPhone.getContext().getPackageManager();
List<String> privilegedPackages = new ArrayList<>();
List<PackageInfo> packages = null;
for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
@@ -4382,7 +4378,7 @@
final long identity = Binder.clearCallingIdentity();
try {
- final Context context = mApp;
+ final Context context = mPhone.getContext();
final TelephonyManager tele = TelephonyManager.from(context);
final SubscriptionManager sub = SubscriptionManager.from(context);
@@ -4548,13 +4544,11 @@
@Override
public void enableVideoCalling(boolean enable) {
- final Phone defaultPhone = getDefaultPhone();
enforceModifyPermission();
final long identity = Binder.clearCallingIdentity();
try {
- ImsManager.getInstance(defaultPhone.getContext(),
- defaultPhone.getPhoneId()).setVtSetting(enable);
+ ImsManager.getInstance(mPhone.getContext(), mPhone.getPhoneId()).setVtSetting(enable);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4562,9 +4556,8 @@
@Override
public boolean isVideoCallingEnabled(String callingPackage) {
- final Phone defaultPhone = getDefaultPhone();
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, defaultPhone.getSubId(), callingPackage, "isVideoCallingEnabled")) {
+ mApp, mPhone.getSubId(), callingPackage, "isVideoCallingEnabled")) {
return false;
}
@@ -4575,7 +4568,7 @@
// In the long run, we may instead need to check if there exists a connection service
// which can support video calling.
ImsManager imsManager =
- ImsManager.getInstance(defaultPhone.getContext(), defaultPhone.getPhoneId());
+ ImsManager.getInstance(mPhone.getContext(), mPhone.getPhoneId());
return imsManager.isVtEnabledByPlatform()
&& imsManager.isEnhanced4gLteModeSettingEnabledByUser()
&& imsManager.isVtEnabledByUser();
@@ -4595,7 +4588,7 @@
try {
CarrierConfigManager configManager =
(CarrierConfigManager) mApp.getSystemService(Context.CARRIER_CONFIG_SERVICE);
- return configManager.getConfigForSubId(subId)
+ return configManager.getConfigForSubId(mPhone.getSubId())
.getBoolean(CarrierConfigManager.KEY_DTMF_TYPE_ENABLED_BOOL);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -4613,7 +4606,7 @@
try {
CarrierConfigManager configManager =
(CarrierConfigManager) mApp.getSystemService(Context.CARRIER_CONFIG_SERVICE);
- return configManager.getConfigForSubId(subId)
+ return configManager.getConfigForSubId(mPhone.getSubId())
.getBoolean(CarrierConfigManager.KEY_WORLD_PHONE_BOOL);
} finally {
Binder.restoreCallingIdentity(identity);
@@ -4622,7 +4615,7 @@
@Override
public boolean isTtyModeSupported() {
- TelecomManager telecomManager = TelecomManager.from(mApp);
+ TelecomManager telecomManager = TelecomManager.from(mPhone.getContext());
return telecomManager.isTtySupported();
}
@@ -4630,7 +4623,7 @@
public boolean isHearingAidCompatibilitySupported() {
final long identity = Binder.clearCallingIdentity();
try {
- return mApp.getResources().getBoolean(R.bool.hac_enabled);
+ return mPhone.getContext().getResources().getBoolean(R.bool.hac_enabled);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4645,16 +4638,12 @@
@Override
public boolean isRttSupported(int subscriptionId) {
final long identity = Binder.clearCallingIdentity();
- final Phone phone = getPhone(subscriptionId);
- if (phone == null) {
- loge("isRttSupported: no Phone found. Invalid subId:" + subscriptionId);
- return false;
- }
try {
- boolean isCarrierSupported = mApp.getCarrierConfigForSubId(subscriptionId).getBoolean(
+ boolean isCarrierSupported = mApp.getCarrierConfigForSubId(
+ mPhone.getSubId()).getBoolean(
CarrierConfigManager.KEY_RTT_SUPPORTED_BOOL);
boolean isDeviceSupported =
- phone.getContext().getResources().getBoolean(R.bool.config_support_rtt);
+ mPhone.getContext().getResources().getBoolean(R.bool.config_support_rtt);
return isCarrierSupported && isDeviceSupported;
} finally {
Binder.restoreCallingIdentity(identity);
@@ -4669,7 +4658,8 @@
final long identity = Binder.clearCallingIdentity();
try {
return isRttSupported(subscriptionId) && Settings.Secure.getInt(
- mApp.getContentResolver(), Settings.Secure.RTT_CALLING_MODE, 0) != 0;
+ mPhone.getContext().getContentResolver(),
+ Settings.Secure.RTT_CALLING_MODE, 0) != 0;
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -4787,15 +4777,14 @@
}
final long identity = Binder.clearCallingIdentity();
-
try {
if (SubscriptionManager.isUsableSubIdValue(subId) && !mUserManager.hasUserRestriction(
UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
setUserDataEnabled(subId, getDefaultDataEnabled());
setNetworkSelectionModeAutomatic(subId);
setPreferredNetworkType(subId, getDefaultNetworkType(subId));
- setDataRoamingEnabled(subId, getDefaultDataRoamingEnabled(subId));
- CarrierInfoManager.deleteAllCarrierKeysForImsiEncryption(mApp);
+ mPhone.setDataRoamingEnabled(getDefaultDataRoamingEnabled(subId));
+ CarrierInfoManager.deleteAllCarrierKeysForImsiEncryption(mPhone.getContext());
}
} finally {
Binder.restoreCallingIdentity(identity);
@@ -4855,7 +4844,8 @@
// exact locale (e.g. fr_FR = French/France). So, if the locale returned from
// the SIM and carrier preferences does not include a country we add the country
// determined from the SIM MCC to provide an exact locale.
- final Locale mccLocale = MccTable.getLocaleFromMcc(mApp, mcc, simLanguage);
+ final Locale mccLocale = MccTable.getLocaleFromMcc(mPhone.getContext(), mcc,
+ simLanguage);
if (mccLocale != null) {
if (DBG) log("No locale from default SIM, using mcc locale:" + mccLocale);
return mccLocale.toLanguageTag();
@@ -4869,14 +4859,16 @@
}
private List<SubscriptionInfo> getAllSubscriptionInfoList() {
- return mSubscriptionController.getAllSubInfoList(mApp.getOpPackageName());
+ return mSubscriptionController.getAllSubInfoList(
+ mPhone.getContext().getOpPackageName());
}
/**
* NOTE: this method assumes permission checks are done and caller identity has been cleared.
*/
private List<SubscriptionInfo> getActiveSubscriptionInfoListPrivileged() {
- return mSubscriptionController.getActiveSubscriptionInfoList(mApp.getOpPackageName());
+ return mSubscriptionController.getActiveSubscriptionInfoList(
+ mPhone.getContext().getOpPackageName());
}
private final ModemActivityInfo mLastModemActivityInfo =
@@ -4905,12 +4897,14 @@
if (isModemActivityInfoValid(info)) {
int[] mergedTxTimeMs = new int[ModemActivityInfo.TX_POWER_LEVELS];
for (int i = 0; i < mergedTxTimeMs.length; i++) {
- mergedTxTimeMs[i] = info.getTxTimeMillis()[i]
- + mLastModemActivityInfo.getTxTimeMillis()[i];
+ mergedTxTimeMs[i] =
+ info.getTxTimeMillis()[i]
+ + mLastModemActivityInfo.getTxTimeMillis()[i];
}
mLastModemActivityInfo.setTimestamp(info.getTimestamp());
- mLastModemActivityInfo.setSleepTimeMillis(info.getSleepTimeMillis()
- + mLastModemActivityInfo.getSleepTimeMillis());
+ mLastModemActivityInfo.setSleepTimeMillis(
+ info.getSleepTimeMillis()
+ + mLastModemActivityInfo.getSleepTimeMillis());
mLastModemActivityInfo.setIdleTimeMillis(
info.getIdleTimeMillis() + mLastModemActivityInfo.getIdleTimeMillis());
mLastModemActivityInfo.setTxTimeMillis(mergedTxTimeMs);
@@ -4991,7 +4985,7 @@
try {
Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(accountHandle);
if (phone == null) {
- phone = getDefaultPhone();
+ phone = mPhone;
}
return VoicemailNotificationSettingsUtil.getRingtoneUri(phone.getContext());
@@ -5014,10 +5008,9 @@
@Override
public void setVoicemailRingtoneUri(String callingPackage,
PhoneAccountHandle phoneAccountHandle, Uri uri) {
- final Phone defaultPhone = getDefaultPhone();
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
if (!TextUtils.equals(callingPackage,
- TelecomManager.from(defaultPhone.getContext()).getDefaultDialerPackage())) {
+ TelecomManager.from(mPhone.getContext()).getDefaultDialerPackage())) {
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, PhoneUtils.getSubIdForPhoneAccountHandle(phoneAccountHandle),
"setVoicemailRingtoneUri");
@@ -5027,7 +5020,7 @@
try {
Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(phoneAccountHandle);
if (phone == null) {
- phone = defaultPhone;
+ phone = mPhone;
}
VoicemailNotificationSettingsUtil.setRingtoneUri(phone.getContext(), uri);
} finally {
@@ -5048,7 +5041,7 @@
try {
Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(accountHandle);
if (phone == null) {
- phone = getDefaultPhone();
+ phone = mPhone;
}
return VoicemailNotificationSettingsUtil.isVibrationEnabled(phone.getContext());
@@ -5071,10 +5064,9 @@
@Override
public void setVoicemailVibrationEnabled(String callingPackage,
PhoneAccountHandle phoneAccountHandle, boolean enabled) {
- final Phone defaultPhone = getDefaultPhone();
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
if (!TextUtils.equals(callingPackage,
- TelecomManager.from(defaultPhone.getContext()).getDefaultDialerPackage())) {
+ TelecomManager.from(mPhone.getContext()).getDefaultDialerPackage())) {
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, PhoneUtils.getSubIdForPhoneAccountHandle(phoneAccountHandle),
"setVoicemailVibrationEnabled");
@@ -5084,7 +5076,7 @@
try {
Phone phone = PhoneUtils.getPhoneForPhoneAccountHandle(phoneAccountHandle);
if (phone == null) {
- phone = defaultPhone;
+ phone = mPhone;
}
VoicemailNotificationSettingsUtil.setVibrationEnabled(phone.getContext(), enabled);
} finally {
@@ -5121,7 +5113,7 @@
final long identity = Binder.clearCallingIdentity();
try {
ComponentName componentName =
- RemoteVvmTaskManager.getRemotePackage(mApp, subId);
+ RemoteVvmTaskManager.getRemotePackage(mPhone.getContext(), subId);
if (componentName == null) {
throw new SecurityException(
"Caller not current active visual voicemail package[null]");
@@ -5374,8 +5366,8 @@
*/
@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
- if (mApp.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
- != PackageManager.PERMISSION_GRANTED) {
+ if (mPhone.getContext().checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
+ != PERMISSION_GRANTED) {
writer.println("Permission Denial: can't dump Phone from pid="
+ Binder.getCallingPid()
+ ", uid=" + Binder.getCallingUid()
@@ -5383,7 +5375,7 @@
+ android.Manifest.permission.DUMP);
return;
}
- DumpsysHandler.dump(mApp, fd, writer, args);
+ DumpsysHandler.dump(mPhone.getContext(), fd, writer, args);
}
@Override
@@ -5467,7 +5459,7 @@
}
private WorkSource getWorkSource(int uid) {
- String packageName = mApp.getPackageManager().getNameForUid(uid);
+ String packageName = mPhone.getContext().getPackageManager().getNameForUid(uid);
return new WorkSource(uid, packageName);
}
@@ -5500,7 +5492,8 @@
private boolean isUssdApiAllowed(int subId) {
CarrierConfigManager configManager =
- (CarrierConfigManager) mApp.getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ (CarrierConfigManager) mPhone.getContext().getSystemService(
+ Context.CARRIER_CONFIG_SERVICE);
if (configManager == null) {
return false;
}
@@ -5790,7 +5783,7 @@
*/
private boolean getDefaultDataRoamingEnabled(int subId) {
final CarrierConfigManager configMgr = (CarrierConfigManager)
- mApp.getSystemService(Context.CARRIER_CONFIG_SERVICE);
+ mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
boolean isDataRoamingEnabled = "true".equalsIgnoreCase(
SystemProperties.get(DEFAULT_DATA_ROAMING_PROPERTY_NAME, "false"));
isDataRoamingEnabled |= configMgr.getConfigForSubId(subId).getBoolean(