Merge "[RCS] Implement get/setRcsProvisioningStatusForCapability"
diff --git a/Android.bp b/Android.bp
index 76e910f..a06d5ef 100644
--- a/Android.bp
+++ b/Android.bp
@@ -22,7 +22,6 @@
"telephony-common",
"voip-common",
"ims-common",
- "org.apache.http.legacy",
"libprotobuf-java-lite",
"unsupportedappusage",
],
@@ -32,10 +31,10 @@
"androidx.preference_preference",
"androidx.recyclerview_recyclerview",
"androidx.legacy_legacy-preference-v14",
- "guava",
- "volley",
"android-support-annotations",
"com.android.phone.common-lib",
+ "guava",
+ "PlatformProperties",
],
srcs: [
@@ -79,4 +78,4 @@
proto: {
type: "lite",
},
-}
\ No newline at end of file
+}
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6d11cf6..3f24251 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -32,10 +32,8 @@
<protected-broadcast android:name="android.intent.action.EMERGENCY_CALL_STATE_CHANGED" />
<protected-broadcast android:name="android.intent.action.SIG_STR" />
<protected-broadcast android:name="android.intent.action.ANY_DATA_STATE" />
- <protected-broadcast android:name="android.intent.action.DATA_CONNECTION_FAILED" />
<protected-broadcast android:name="android.intent.action.DATA_STALL_DETECTED" />
<protected-broadcast android:name="android.intent.action.SIM_STATE_CHANGED" />
- <protected-broadcast android:name="android.telephony.action.NETWORK_SET_TIME" />
<protected-broadcast android:name="com.android.internal.intent.action.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS" />
<protected-broadcast android:name="android.intent.action.ACTION_MDN_STATE_CHANGED" />
<protected-broadcast android:name="android.provider.Telephony.SPN_STRINGS_UPDATED" />
@@ -130,8 +128,8 @@
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.SEND_RESPOND_VIA_MESSAGE" />
- <uses-permission android:name="android.permission.SET_TIME" />
<uses-permission android:name="android.permission.SET_TIME_ZONE" />
+ <uses-permission android:name="android.permission.SUGGEST_PHONE_TIME_AND_ZONE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 22845e0..3aa8121 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -50,3 +50,6 @@
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.services.telephony.common_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/telephony-common.jar)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/ims-common.jar)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/apex/com.android.telephony/javalib/telephony-common.jar)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/apex/com.android.telephony/javalib/ims-common.jar)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/apex/com.android.telephony.apex)
\ No newline at end of file
diff --git a/OWNERS b/OWNERS
index 5be6fe5..849347f 100644
--- a/OWNERS
+++ b/OWNERS
@@ -11,4 +11,5 @@
shuoq@google.com
paulye@google.com
nazaninb@google.com
-sarahchin@google.com
\ No newline at end of file
+sarahchin@google.com
+dbright@google.com
diff --git a/apex/Android.bp b/apex/Android.bp
index f9e4b67..16bcb72 100644
--- a/apex/Android.bp
+++ b/apex/Android.bp
@@ -4,7 +4,7 @@
// optional. if unspecified, a default one is auto-generated
androidManifest: "AndroidManifest.xml",
- java_libs: ["telephony-common", "ims-common"],
+ //java_libs: ["telephony-common", "ims-common", "voip-common"],
//apps: ["TeleService", "StkLib", "ONSLib"],
key: "com.android.telephony.key",
@@ -30,4 +30,4 @@
// This will use com.android.telephony.x509.pem (the cert) and
// com.android.telephony.pk8 (the private key)
certificate: "com.android.telephony",
-}
+}
\ No newline at end of file
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index dab04f0..0af1b23 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -558,7 +558,8 @@
public void updatePhoneStateListeners(boolean isRefresh, int updateType, int subIdToUpdate) {
List<SubscriptionInfo> subInfos = SubscriptionController.getInstance()
- .getActiveSubscriptionInfoList(mApplication.getOpPackageName());
+ .getActiveSubscriptionInfoList(mApplication.getOpPackageName(),
+ null);
// Sort sub id list based on slot id, so that CFI/MWI notifications will be updated for
// slot 0 first then slot 1. This is needed to ensure that when CFI or MWI is enabled for
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 49f690a..3812b2f 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -57,13 +57,8 @@
import com.android.internal.telephony.SubscriptionInfoUpdater;
import com.android.internal.telephony.TelephonyPermissions;
import com.android.internal.telephony.util.ArrayUtils;
-import com.android.internal.util.FastXmlSerializer;
import com.android.internal.util.IndentingPrintWriter;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlPullParserFactory;
-
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
@@ -80,7 +75,6 @@
/**
* CarrierConfigLoader binds to privileged carrier apps to fetch carrier config overlays.
*/
-
public class CarrierConfigLoader extends ICarrierConfigLoader.Stub {
private static final String LOG_TAG = "CarrierConfigLoader";
@@ -149,10 +143,8 @@
private static final int BIND_TIMEOUT_MILLIS = 30000;
- // Tags used for saving and restoring XML documents.
- private static final String TAG_DOCUMENT = "carrier_config";
- private static final String TAG_VERSION = "package_version";
- private static final String TAG_BUNDLE = "bundle_data";
+ // Keys used for saving and restoring config bundle from file.
+ private static final String KEY_VERSION = "__carrier_config_package_version__";
private static final String OVERRIDE_PACKAGE_ADDITION = "-override";
@@ -793,27 +785,14 @@
outFile = new FileOutputStream(
new File(mContext.getFilesDir(),
getFilenameForConfig(packageName, extraString, iccid, cid)));
- FastXmlSerializer out = new FastXmlSerializer();
- out.setOutput(outFile, "utf-8");
- out.startDocument("utf-8", true);
- out.startTag(null, TAG_DOCUMENT);
- out.startTag(null, TAG_VERSION);
- out.text(version);
- out.endTag(null, TAG_VERSION);
- out.startTag(null, TAG_BUNDLE);
- config.saveToXml(out);
- out.endTag(null, TAG_BUNDLE);
- out.endTag(null, TAG_DOCUMENT);
- out.endDocument();
- out.flush();
+ config.putString(KEY_VERSION, version);
+ config.writeToStream(outFile);
+ outFile.flush();
outFile.close();
}
catch (IOException e) {
loge(e.toString());
}
- catch (XmlPullParserException e) {
- loge(e.toString());
- }
}
/**
@@ -858,24 +837,16 @@
file = new File(mContext.getFilesDir(),
getFilenameForConfig(packageName, extraString, iccid, cid));
inFile = new FileInputStream(file);
- XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
- parser.setInput(inFile, "utf-8");
- int event;
- while (((event = parser.next()) != XmlPullParser.END_DOCUMENT)) {
+ restoredBundle = PersistableBundle.readFromStream(inFile);
+ String savedVersion = restoredBundle.getString(KEY_VERSION);
+ restoredBundle.remove(KEY_VERSION);
- if (event == XmlPullParser.START_TAG && TAG_VERSION.equals(parser.getName())) {
- String savedVersion = parser.nextText();
- if (!version.equals(savedVersion)) {
- loge("Saved version mismatch: " + version + " vs " + savedVersion);
- break;
- }
- }
-
- if (event == XmlPullParser.START_TAG && TAG_BUNDLE.equals(parser.getName())) {
- restoredBundle = PersistableBundle.restoreFromXml(parser);
- }
+ if (!version.equals(savedVersion)) {
+ loge("Saved version mismatch: " + version + " vs " + savedVersion);
+ restoredBundle = null;
}
+
inFile.close();
}
catch (FileNotFoundException e) {
@@ -883,9 +854,6 @@
// an override file during boot and should not be treated as an error.
if (file != null) log("File not found: " + file.getPath());
}
- catch (XmlPullParserException e) {
- loge(e.toString());
- }
catch (IOException e) {
loge(e.toString());
}
@@ -967,8 +935,14 @@
@Override
public @NonNull PersistableBundle getConfigForSubId(int subId, String callingPackage) {
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mContext, subId, callingPackage, "getCarrierConfig")) {
+ return getConfigForSubIdWithFeature(subId, callingPackage, null);
+ }
+
+ @Override
+ public @NonNull PersistableBundle getConfigForSubIdWithFeature(int subId, String callingPackage,
+ String callingFeatureId) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mContext, subId, callingPackage,
+ callingFeatureId, "getCarrierConfig")) {
return new PersistableBundle();
}
@@ -1080,6 +1054,7 @@
case IccCardConstants.INTENT_VALUE_ICC_CARD_IO_ERROR:
case IccCardConstants.INTENT_VALUE_ICC_CARD_RESTRICTED:
case IccCardConstants.INTENT_VALUE_ICC_UNKNOWN:
+ case IccCardConstants.INTENT_VALUE_ICC_NOT_READY:
mHandler.sendMessage(mHandler.obtainMessage(EVENT_CLEAR_CONFIG, phoneId, -1));
break;
case IccCardConstants.INTENT_VALUE_ICC_LOADED:
diff --git a/src/com/android/phone/IccPanel.java b/src/com/android/phone/IccPanel.java
index be182233..73dd8bc 100644
--- a/src/com/android/phone/IccPanel.java
+++ b/src/com/android/phone/IccPanel.java
@@ -74,13 +74,13 @@
@Override
protected void onStart() {
super.onStart();
- mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND);
+ mStatusBarManager.setDisabledForSimNetworkLock(true);
}
@Override
public void onStop() {
super.onStop();
- mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
+ mStatusBarManager.setDisabledForSimNetworkLock(false);
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index 06d2367..1a28afd 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -23,14 +23,18 @@
import android.os.ServiceManager;
import android.os.ServiceSpecificException;
import android.telephony.ims.ImsException;
+import android.telephony.ims.RegistrationManager;
import android.telephony.ims.aidl.IImsCapabilityCallback;
import android.telephony.ims.aidl.IImsRcsController;
+import android.telephony.ims.aidl.IImsRegistrationCallback;
import android.telephony.ims.aidl.IRcsUceControllerCallback;
import android.telephony.ims.feature.RcsFeature;
import android.telephony.ims.stub.ImsRegistrationImplBase;
import android.util.Log;
+import com.android.ims.ImsManager;
import com.android.ims.RcsFeatureManager;
+import com.android.internal.telephony.IIntegerConsumer;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.imsphone.ImsPhone;
@@ -70,6 +74,86 @@
}
/**
+ * Register a IImsRegistrationCallback to receive IMS network registration state.
+ */
+ @Override
+ public void registerImsRegistrationCallback(int subId, IImsRegistrationCallback callback)
+ throws RemoteException {
+ enforceReadPrivilegedPermission("registerImsRegistrationCallback");
+ final long token = Binder.clearCallingIdentity();
+ try {
+ getRcsFeatureManager(subId).registerImsRegistrationCallback(callback);
+ } catch (com.android.ims.ImsException e) {
+ Log.e(TAG, "registerImsRegistrationCallback: sudId=" + subId + ", " + e.getMessage());
+ throw new ServiceSpecificException(e.getCode());
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ /**
+ * Removes an existing {@link RegistrationCallback}.
+ */
+ @Override
+ public void unregisterImsRegistrationCallback(int subId, IImsRegistrationCallback callback) {
+ enforceReadPrivilegedPermission("unregisterImsRegistrationCallback");
+ final long token = Binder.clearCallingIdentity();
+ try {
+ getRcsFeatureManager(subId).unregisterImsRegistrationCallback(callback);
+ } catch (ServiceSpecificException e) {
+ Log.e(TAG, "unregisterImsRegistrationCallback: error=" + e.errorCode);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ /**
+ * Get the IMS service registration state for the RcsFeature associated with this sub id.
+ */
+ @Override
+ public void getImsRcsRegistrationState(int subId, IIntegerConsumer consumer) {
+ enforceReadPrivilegedPermission("getImsRcsRegistrationState");
+ final long token = Binder.clearCallingIdentity();
+ try {
+ getImsPhone(subId).getImsRcsRegistrationState(regState -> {
+ try {
+ consumer.accept((regState == null)
+ ? RegistrationManager.REGISTRATION_STATE_NOT_REGISTERED : regState);
+ } catch (RemoteException e) {
+ Log.w(TAG, "getImsRcsRegistrationState: callback is not available.");
+ }
+ });
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ /**
+ * Gets the Transport Type associated with the current IMS RCS registration.
+ */
+ @Override
+ public void getImsRcsRegistrationTransportType(int subId, IIntegerConsumer consumer) {
+ enforceReadPrivilegedPermission("getImsRcsRegistrationTransportType");
+ final long token = Binder.clearCallingIdentity();
+ try {
+ getImsPhone(subId).getImsRcsRegistrationTech(regTech -> {
+ // Convert registration tech from ImsRegistrationImplBase -> RegistrationManager
+ int regTechConverted = (regTech == null)
+ ? ImsRegistrationImplBase.REGISTRATION_TECH_NONE : regTech;
+ regTechConverted = RegistrationManager.IMS_REG_TO_ACCESS_TYPE_MAP.get(
+ regTechConverted);
+ try {
+ consumer.accept(regTechConverted);
+ } catch (RemoteException e) {
+ Log.w(TAG, "getImsRcsRegistrationTransportType: callback is not available.");
+ }
+ });
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ /**
* Register a capability callback which will provide RCS availability updates for the
* subscription specified.
*
@@ -202,13 +286,17 @@
}
/**
- * Retrieve RcsFeatureManager instance.
+ * Retrieve ImsPhone instance.
*
* @param subId the subscription ID
- * @return The RcsFeatureManager instance
- * @throws SecurityException if getting Phone or RcsFeatureManager instance failed.
+ * @return The ImsPhone instance
+ * @throws ServiceSpecificException if getting ImsPhone instance failed.
*/
- private RcsFeatureManager getRcsFeatureManager(int subId) {
+ private ImsPhone getImsPhone(int subId) {
+ if (!ImsManager.isImsSupportedOnDevice(mApp)) {
+ throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
+ "IMS is not available on device.");
+ }
Phone phone = PhoneGlobals.getPhone(subId);
if (phone == null) {
throw new ServiceSpecificException(ImsException.CODE_ERROR_INVALID_SUBSCRIPTION,
@@ -216,7 +304,32 @@
}
ImsPhone imsPhone = (ImsPhone) phone.getImsPhone();
if (imsPhone == null) {
+ throw new ServiceSpecificException(ImsException.CODE_ERROR_SERVICE_UNAVAILABLE,
+ "Cannot find ImsPhone instance: " + subId);
+ }
+ return imsPhone;
+ }
+
+ /**
+ * Retrieve RcsFeatureManager instance.
+ *
+ * @param subId the subscription ID
+ * @return The RcsFeatureManager instance
+ * @throws ServiceSpecificException if getting RcsFeatureManager instance failed.
+ */
+ private RcsFeatureManager getRcsFeatureManager(int subId) {
+ if (!ImsManager.isImsSupportedOnDevice(mApp)) {
throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
+ "IMS is not available on device.");
+ }
+ Phone phone = PhoneGlobals.getPhone(subId);
+ if (phone == null) {
+ throw new ServiceSpecificException(ImsException.CODE_ERROR_INVALID_SUBSCRIPTION,
+ "Invalid subscription Id: " + subId);
+ }
+ ImsPhone imsPhone = (ImsPhone) phone.getImsPhone();
+ if (imsPhone == null) {
+ throw new ServiceSpecificException(ImsException.CODE_ERROR_SERVICE_UNAVAILABLE,
"Cannot find ImsPhone instance: " + subId);
}
RcsFeatureManager rcsFeatureManager = imsPhone.getRcsManager();
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 1371674..9ecb2c5 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -467,7 +467,7 @@
}
public PersistableBundle getCarrierConfigForSubId(int subId) {
- return configLoader.getConfigForSubId(subId, getOpPackageName());
+ return configLoader.getConfigForSubIdWithFeature(subId, getOpPackageName(), null);
}
private void registerSettingsObserver() {
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e9cd638..a505e55 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -22,6 +22,7 @@
import static com.android.internal.telephony.PhoneConstants.SUBSCRIPTION_KEY;
import android.Manifest.permission;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.PendingIntent;
@@ -67,10 +68,11 @@
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierRestrictionRules;
import android.telephony.CellIdentity;
+import android.telephony.CellIdentityCdma;
+import android.telephony.CellIdentityGsm;
import android.telephony.CellInfo;
import android.telephony.CellInfoGsm;
import android.telephony.CellInfoWcdma;
-import android.telephony.CellLocation;
import android.telephony.ClientRequestStats;
import android.telephony.ICellInfoCallback;
import android.telephony.IccOpenLogicalChannelResponse;
@@ -94,10 +96,8 @@
import android.telephony.UiccSlotInfo;
import android.telephony.UssdResponse;
import android.telephony.VisualVoicemailSmsFilterSettings;
-import android.telephony.cdma.CdmaCellLocation;
import android.telephony.data.ApnSetting;
import android.telephony.emergency.EmergencyNumber;
-import android.telephony.gsm.GsmCellLocation;
import android.telephony.ims.ImsException;
import android.telephony.ims.ProvisioningManager;
import android.telephony.ims.RegistrationManager;
@@ -158,6 +158,7 @@
import com.android.internal.telephony.metrics.TelephonyMetrics;
import com.android.internal.telephony.uicc.IccCardApplicationStatus.AppType;
import com.android.internal.telephony.uicc.IccIoResult;
+import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.uicc.SIMRecords;
import com.android.internal.telephony.uicc.UiccCard;
@@ -1103,7 +1104,7 @@
request = (MainThreadRequest) msg.obj;
WorkSource ws = (WorkSource) request.argument;
Phone phone = getPhoneFromRequest(request);
- phone.getCellLocation(ws, obtainMessage(EVENT_GET_CELL_LOCATION_DONE, request));
+ phone.getCellIdentity(ws, obtainMessage(EVENT_GET_CELL_LOCATION_DONE, request));
break;
case EVENT_GET_CELL_LOCATION_DONE:
ar = (AsyncResult) msg.obj;
@@ -1113,7 +1114,7 @@
} else {
phone = getPhoneFromRequest(request);
request.result = (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA)
- ? new CdmaCellLocation() : new GsmCellLocation();
+ ? new CellIdentityCdma() : new CellIdentityGsm();
}
synchronized (request) {
@@ -1529,29 +1530,16 @@
}
}
- public boolean supplyPin(String pin) {
- return supplyPinForSubscriber(getDefaultSubscription(), pin);
- }
-
public boolean supplyPinForSubscriber(int subId, String pin) {
int [] resultArray = supplyPinReportResultForSubscriber(subId, pin);
return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false;
}
- public boolean supplyPuk(String puk, String pin) {
- return supplyPukForSubscriber(getDefaultSubscription(), puk, pin);
- }
-
public boolean supplyPukForSubscriber(int subId, String puk, String pin) {
int [] resultArray = supplyPukReportResultForSubscriber(subId, puk, pin);
return (resultArray[0] == PhoneConstants.PIN_RESULT_SUCCESS) ? true : false;
}
- /** {@hide} */
- public int[] supplyPinReportResult(String pin) {
- return supplyPinReportResultForSubscriber(getDefaultSubscription(), pin);
- }
-
public int[] supplyPinReportResultForSubscriber(int subId, String pin) {
enforceModifyPermission();
@@ -1565,11 +1553,6 @@
}
}
- /** {@hide} */
- public int[] supplyPukReportResult(String puk, String pin) {
- return supplyPukReportResultForSubscriber(getDefaultSubscription(), puk, pin);
- }
-
public int[] supplyPukReportResultForSubscriber(int subId, String puk, String pin) {
enforceModifyPermission();
@@ -1702,15 +1685,29 @@
}
}
+ @Deprecated
@Override
public boolean isRadioOn(String callingPackage) {
- return isRadioOnForSubscriber(getDefaultSubscription(), callingPackage);
+ return isRadioOnWithFeature(callingPackage, null);
}
@Override
+ public boolean isRadioOnWithFeature(String callingPackage, String callingFeatureId) {
+ return isRadioOnForSubscriberWithFeature(getDefaultSubscription(), callingPackage,
+ callingFeatureId);
+ }
+
+ @Deprecated
+ @Override
public boolean isRadioOnForSubscriber(int subId, String callingPackage) {
+ return isRadioOnForSubscriberWithFeature(subId, callingPackage, null);
+ }
+
+ @Override
+ public boolean isRadioOnForSubscriberWithFeature(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "isRadioOnForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId, "isRadioOnForSubscriber")) {
return false;
}
@@ -1997,7 +1994,7 @@
}
@Override
- public Bundle getCellLocation(String callingPackage) {
+ public CellIdentity getCellLocation(String callingPackage, String callingFeatureId) {
mApp.getSystemService(AppOpsManager.class)
.checkPackage(Binder.getCallingUid(), callingPackage);
@@ -2005,6 +2002,7 @@
LocationAccessPolicy.checkLocationPermission(mApp,
new LocationAccessPolicy.LocationPermissionQuery.Builder()
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
.setMethod("getCellLocation")
@@ -2014,29 +2012,28 @@
case DENIED_HARD:
throw new SecurityException("Not allowed to access cell location");
case DENIED_SOFT:
- return new Bundle();
+ return (getDefaultPhone().getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA)
+ ? new CellIdentityCdma() : new CellIdentityGsm();
}
WorkSource workSource = getWorkSource(Binder.getCallingUid());
final long identity = Binder.clearCallingIdentity();
try {
if (DBG_LOC) log("getCellLocation: is active user");
- Bundle data = new Bundle();
int subId = mSubscriptionController.getDefaultDataSubId();
- CellLocation cl = (CellLocation) sendRequest(CMD_GET_CELL_LOCATION, workSource, subId);
- cl.fillInNotifierBundle(data);
- return data;
+ return (CellIdentity) sendRequest(CMD_GET_CELL_LOCATION, workSource, subId);
} finally {
Binder.restoreCallingIdentity(identity);
}
}
@Override
- public String getNetworkCountryIsoForPhone(int phoneId, String callingPackage) {
+ public String getNetworkCountryIsoForPhone(int phoneId, String callingPackage,
+ String callingFeatureId) {
if (!TextUtils.isEmpty(callingPackage)) {
final int subId = mSubscriptionController.getSubIdUsingPhoneId(phoneId);
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getNetworkCountryIsoForPhone")) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage,
+ callingFeatureId, "getNetworkCountryIsoForPhone")) {
return "";
}
}
@@ -2053,7 +2050,8 @@
// Todo: fix this when we can get the actual cellular network info when the device
// is on IWLAN.
if (TelephonyManager.NETWORK_TYPE_IWLAN
- == getVoiceNetworkTypeForSubscriber(subId, mApp.getPackageName())) {
+ == getVoiceNetworkTypeForSubscriber(subId, mApp.getPackageName(),
+ null)) {
return "";
}
Phone phone = PhoneFactory.getPhone(phoneId);
@@ -2140,7 +2138,8 @@
@Override
@SuppressWarnings("unchecked")
- public List<NeighboringCellInfo> getNeighboringCellInfo(String callingPackage) {
+ public List<NeighboringCellInfo> getNeighboringCellInfo(String callingPackage,
+ String callingFeatureId) {
final int targetSdk = getTargetSdk(callingPackage);
if (targetSdk >= android.os.Build.VERSION_CODES.Q) {
throw new SecurityException(
@@ -2154,7 +2153,7 @@
if (DBG_LOC) log("getNeighboringCellInfo: is active user");
- List<CellInfo> info = getAllCellInfo(callingPackage);
+ List<CellInfo> info = getAllCellInfo(callingPackage, callingFeatureId);
if (info == null) return null;
List<NeighboringCellInfo> neighbors = new ArrayList<NeighboringCellInfo>();
@@ -2178,7 +2177,7 @@
}
@Override
- public List<CellInfo> getAllCellInfo(String callingPackage) {
+ public List<CellInfo> getAllCellInfo(String callingPackage, String callingFeatureId) {
mApp.getSystemService(AppOpsManager.class)
.checkPackage(Binder.getCallingUid(), callingPackage);
@@ -2186,6 +2185,7 @@
LocationAccessPolicy.checkLocationPermission(mApp,
new LocationAccessPolicy.LocationPermissionQuery.Builder()
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
.setMethod("getAllCellInfo")
@@ -2221,20 +2221,21 @@
}
@Override
- public void requestCellInfoUpdate(int subId, ICellInfoCallback cb, String callingPackage) {
- requestCellInfoUpdateInternal(
- subId, cb, callingPackage, getWorkSource(Binder.getCallingUid()));
+ public void requestCellInfoUpdate(int subId, ICellInfoCallback cb, String callingPackage,
+ String callingFeatureId) {
+ requestCellInfoUpdateInternal(subId, cb, callingPackage, callingFeatureId,
+ getWorkSource(Binder.getCallingUid()));
}
@Override
- public void requestCellInfoUpdateWithWorkSource(
- int subId, ICellInfoCallback cb, String callingPackage, WorkSource workSource) {
+ public void requestCellInfoUpdateWithWorkSource(int subId, ICellInfoCallback cb,
+ String callingPackage, String callingFeatureId, WorkSource workSource) {
enforceModifyPermission();
- requestCellInfoUpdateInternal(subId, cb, callingPackage, workSource);
+ requestCellInfoUpdateInternal(subId, cb, callingPackage, callingFeatureId, workSource);
}
- private void requestCellInfoUpdateInternal(
- int subId, ICellInfoCallback cb, String callingPackage, WorkSource workSource) {
+ private void requestCellInfoUpdateInternal(int subId, ICellInfoCallback cb,
+ String callingPackage, String callingFeatureId, WorkSource workSource) {
mApp.getSystemService(AppOpsManager.class)
.checkPackage(Binder.getCallingUid(), callingPackage);
@@ -2242,6 +2243,7 @@
LocationAccessPolicy.checkLocationPermission(mApp,
new LocationAccessPolicy.LocationPermissionQuery.Builder()
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
.setMethod("requestCellInfoUpdate")
@@ -2280,14 +2282,14 @@
}
@Override
- public String getImeiForSlot(int slotIndex, String callingPackage) {
+ public String getImeiForSlot(int slotIndex, String callingPackage, String callingFeatureId) {
Phone phone = PhoneFactory.getPhone(slotIndex);
if (phone == null) {
return null;
}
int subId = phone.getSubId();
if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mApp, subId,
- callingPackage, "getImeiForSlot")) {
+ callingPackage, callingFeatureId, "getImeiForSlot")) {
return null;
}
@@ -2311,7 +2313,7 @@
}
@Override
- public String getMeidForSlot(int slotIndex, String callingPackage) {
+ public String getMeidForSlot(int slotIndex, String callingPackage, String callingFeatureId) {
Phone phone = PhoneFactory.getPhone(slotIndex);
if (phone == null) {
return null;
@@ -2319,7 +2321,7 @@
int subId = phone.getSubId();
if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mApp, subId,
- callingPackage, "getMeidForSlot")) {
+ callingPackage, callingFeatureId, "getMeidForSlot")) {
return null;
}
@@ -2343,14 +2345,16 @@
}
@Override
- public String getDeviceSoftwareVersionForSlot(int slotIndex, String callingPackage) {
+ public String getDeviceSoftwareVersionForSlot(int slotIndex, String callingPackage,
+ String callingFeatureId) {
Phone phone = PhoneFactory.getPhone(slotIndex);
if (phone == null) {
return null;
}
int subId = phone.getSubId();
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getDeviceSoftwareVersionForSlot")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getDeviceSoftwareVersionForSlot")) {
return null;
}
@@ -2499,14 +2503,17 @@
* Returns the CDMA ERI icon index to display
*/
@Override
- public int getCdmaEriIconIndex(String callingPackage) {
- return getCdmaEriIconIndexForSubscriber(getDefaultSubscription(), callingPackage);
+ public int getCdmaEriIconIndex(String callingPackage, String callingFeatureId) {
+ return getCdmaEriIconIndexForSubscriber(getDefaultSubscription(), callingPackage,
+ callingFeatureId);
}
@Override
- public int getCdmaEriIconIndexForSubscriber(int subId, String callingPackage) {
+ public int getCdmaEriIconIndexForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getCdmaEriIconIndexForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getCdmaEriIconIndexForSubscriber")) {
return -1;
}
@@ -2529,14 +2536,17 @@
* 1 - FLASHING
*/
@Override
- public int getCdmaEriIconMode(String callingPackage) {
- return getCdmaEriIconModeForSubscriber(getDefaultSubscription(), callingPackage);
+ public int getCdmaEriIconMode(String callingPackage, String callingFeatureId) {
+ return getCdmaEriIconModeForSubscriber(getDefaultSubscription(), callingPackage,
+ callingFeatureId);
}
@Override
- public int getCdmaEriIconModeForSubscriber(int subId, String callingPackage) {
+ public int getCdmaEriIconModeForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getCdmaEriIconModeForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getCdmaEriIconModeForSubscriber")) {
return -1;
}
@@ -2557,14 +2567,17 @@
* Returns the CDMA ERI text,
*/
@Override
- public String getCdmaEriText(String callingPackage) {
- return getCdmaEriTextForSubscriber(getDefaultSubscription(), callingPackage);
+ public String getCdmaEriText(String callingPackage, String callingFeatureId) {
+ return getCdmaEriTextForSubscriber(getDefaultSubscription(), callingPackage,
+ callingFeatureId);
}
@Override
- public String getCdmaEriTextForSubscriber(int subId, String callingPackage) {
+ public String getCdmaEriTextForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getCdmaEriIconTextForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getCdmaEriIconTextForSubscriber")) {
return null;
}
@@ -2699,10 +2712,12 @@
}
@Override
- public String getVisualVoicemailPackageName(String callingPackage, int subId) {
+ public String getVisualVoicemailPackageName(String callingPackage, String callingFeatureId,
+ int subId) {
mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getVisualVoicemailPackageName")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getVisualVoicemailPackageName")) {
return null;
}
@@ -2865,9 +2880,11 @@
* Returns the unread count of voicemails for a subId
*/
@Override
- public int getVoiceMessageCountForSubscriber(int subId, String callingPackage) {
+ public int getVoiceMessageCountForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getVoiceMessageCountForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getVoiceMessageCountForSubscriber")) {
return 0;
}
final long identity = Binder.clearCallingIdentity();
@@ -3871,13 +3888,15 @@
* Returns the data network type for a subId; does not throw SecurityException.
*/
@Override
- public int getNetworkTypeForSubscriber(int subId, String callingPackage) {
+ public int getNetworkTypeForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
final int targetSdk = getTargetSdk(callingPackage);
if (targetSdk > android.os.Build.VERSION_CODES.Q) {
- return getDataNetworkTypeForSubscriber(subId, callingPackage);
+ return getDataNetworkTypeForSubscriber(subId, callingPackage, callingFeatureId);
} else if (targetSdk == android.os.Build.VERSION_CODES.Q
&& !TelephonyPermissions.checkCallingOrSelfReadPhoneStateNoThrow(
- mApp, subId, callingPackage, "getNetworkTypeForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getNetworkTypeForSubscriber")) {
return TelephonyManager.NETWORK_TYPE_UNKNOWN;
}
@@ -3898,17 +3917,20 @@
* Returns the data network type
*/
@Override
- public int getDataNetworkType(String callingPackage) {
- return getDataNetworkTypeForSubscriber(getDefaultSubscription(), callingPackage);
+ public int getDataNetworkType(String callingPackage, String callingFeatureId) {
+ return getDataNetworkTypeForSubscriber(getDefaultSubscription(), callingPackage,
+ callingFeatureId);
}
/**
* Returns the data network type for a subId
*/
@Override
- public int getDataNetworkTypeForSubscriber(int subId, String callingPackage) {
+ public int getDataNetworkTypeForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getDataNetworkTypeForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getDataNetworkTypeForSubscriber")) {
return TelephonyManager.NETWORK_TYPE_UNKNOWN;
}
@@ -3929,9 +3951,11 @@
* Returns the Voice network type for a subId
*/
@Override
- public int getVoiceNetworkTypeForSubscriber(int subId, String callingPackage) {
+ public int getVoiceNetworkTypeForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getDataNetworkTypeForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getDataNetworkTypeForSubscriber")) {
return TelephonyManager.NETWORK_TYPE_UNKNOWN;
}
@@ -3985,14 +4009,17 @@
* or {@link Phone#LTE_ON_CDMA_TRUE}
*/
@Override
- public int getLteOnCdmaMode(String callingPackage) {
- return getLteOnCdmaModeForSubscriber(getDefaultSubscription(), callingPackage);
+ public int getLteOnCdmaMode(String callingPackage, String callingFeatureId) {
+ return getLteOnCdmaModeForSubscriber(getDefaultSubscription(), callingPackage,
+ callingFeatureId);
}
@Override
- public int getLteOnCdmaModeForSubscriber(int subId, String callingPackage) {
+ public int getLteOnCdmaModeForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getLteOnCdmaModeForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getLteOnCdmaModeForSubscriber")) {
return PhoneConstants.LTE_ON_CDMA_UNKNOWN;
}
@@ -4316,9 +4343,10 @@
* Get the forbidden PLMN List from the given app type (ex APPTYPE_USIM)
* on a particular subscription
*/
- public String[] getForbiddenPlmns(int subId, int appType, String callingPackage) {
+ public String[] getForbiddenPlmns(int subId, int appType, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getForbiddenPlmns")) {
+ mApp, subId, callingPackage, callingFeatureId, "getForbiddenPlmns")) {
return null;
}
@@ -4350,12 +4378,13 @@
* @param appType the uicc app type, must be USIM or SIM.
* @param fplmns the Forbiden plmns list that needed to be written to the SIM.
* @param callingPackage the op Package name.
+ * @param callingFeatureId the feature in the package.
* @return number of fplmns that is successfully written to the SIM.
*/
- public int setForbiddenPlmns(
- int subId, int appType, List<String> fplmns, String callingPackage) {
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "setForbiddenPlmns")) {
+ public int setForbiddenPlmns(int subId, int appType, List<String> fplmns, String callingPackage,
+ String callingFeatureId) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, subId, callingPackage,
+ callingFeatureId, "setForbiddenPlmns")) {
if (DBG) logv("no permissions for setForbiddenplmns");
throw new IllegalStateException("No Permissions for setForbiddenPlmns");
}
@@ -4531,10 +4560,11 @@
return false;
}
- public String[] getPcscfAddress(String apnType, String callingPackage) {
+ public String[] getPcscfAddress(String apnType, String callingPackage,
+ String callingFeatureId) {
final Phone defaultPhone = getDefaultPhone();
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, defaultPhone.getSubId(), callingPackage, "getPcscfAddress")) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, defaultPhone.getSubId(),
+ callingPackage, callingFeatureId, "getPcscfAddress")) {
return new String[0];
}
@@ -4837,13 +4867,15 @@
* Scans for available networks.
*/
@Override
- public CellNetworkScanResult getCellNetworkScanResults(int subId, String callingPackage) {
+ public CellNetworkScanResult getCellNetworkScanResults(int subId, String callingPackage,
+ String callingFeatureId) {
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, subId, "getCellNetworkScanResults");
LocationAccessPolicy.LocationPermissionResult locationResult =
LocationAccessPolicy.checkLocationPermission(mApp,
new LocationAccessPolicy.LocationPermissionQuery.Builder()
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
.setMethod("getCellNetworkScanResults")
@@ -4877,13 +4909,14 @@
*/
@Override
public int requestNetworkScan(int subId, NetworkScanRequest request, Messenger messenger,
- IBinder binder, String callingPackage) {
+ IBinder binder, String callingPackage, String callingFeatureId) {
TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
mApp, subId, "requestNetworkScan");
LocationAccessPolicy.LocationPermissionResult locationResult =
LocationAccessPolicy.checkLocationPermission(mApp,
new LocationAccessPolicy.LocationPermissionQuery.Builder()
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
.setMethod("requestNetworkScan")
@@ -4964,10 +4997,10 @@
* @return the preferred network type, defined in RILConstants.java.
*/
@Override
- public int getCalculatedPreferredNetworkType(String callingPackage) {
+ public int getCalculatedPreferredNetworkType(String callingPackage, String callingFeatureId) {
final Phone defaultPhone = getDefaultPhone();
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, defaultPhone.getSubId(),
- callingPackage, "getCalculatedPreferredNetworkType")) {
+ callingPackage, callingFeatureId, "getCalculatedPreferredNetworkType")) {
return RILConstants.PREFERRED_NETWORK_MODE;
}
@@ -5424,10 +5457,11 @@
}
@Override
- public String getLine1NumberForDisplay(int subId, String callingPackage) {
+ public String getLine1NumberForDisplay(int subId, String callingPackage,
+ String callingFeatureId) {
// This is open to apps with WRITE_SMS.
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneNumber(
- mApp, subId, callingPackage, "getLine1NumberForDisplay")) {
+ mApp, subId, callingPackage, callingFeatureId, "getLine1NumberForDisplay")) {
if (DBG_MERGE) log("getLine1NumberForDisplay returning null due to permission");
return null;
}
@@ -5451,9 +5485,10 @@
}
@Override
- public String getLine1AlphaTagForDisplay(int subId, String callingPackage) {
+ public String getLine1AlphaTagForDisplay(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getLine1AlphaTagForDisplay")) {
+ mApp, subId, callingPackage, callingFeatureId, "getLine1AlphaTagForDisplay")) {
return null;
}
@@ -5471,12 +5506,13 @@
}
@Override
- public String[] getMergedSubscriberIds(int subId, String callingPackage) {
+ public String[] getMergedSubscriberIds(int subId, String callingPackage,
+ String callingFeatureId) {
// This API isn't public, so no need to provide a valid subscription ID - we're not worried
// about carrier-privileged callers not having access.
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
mApp, SubscriptionManager.INVALID_SUBSCRIPTION_ID, callingPackage,
- "getMergedSubscriberIds")) {
+ callingFeatureId, "getMergedSubscriberIds")) {
return null;
}
@@ -5581,7 +5617,8 @@
// Get all subscriberIds from the group.
final List<String> mergedSubscriberIds = new ArrayList<>();
final List<SubscriptionInfo> groupInfos = SubscriptionController.getInstance()
- .getSubscriptionsInGroup(groupUuid, mApp.getOpPackageName());
+ .getSubscriptionsInGroup(groupUuid, mApp.getOpPackageName(),
+ null);
for (SubscriptionInfo subInfo : groupInfos) {
subscriberId = telephonyManager.getSubscriberId(subInfo.getSubscriptionId());
if (subscriberId != null) {
@@ -5705,10 +5742,10 @@
}
@Override
- public boolean isVideoCallingEnabled(String callingPackage) {
+ public boolean isVideoCallingEnabled(String callingPackage, String callingFeatureId) {
final Phone defaultPhone = getDefaultPhone();
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, defaultPhone.getSubId(), callingPackage, "isVideoCallingEnabled")) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, defaultPhone.getSubId(),
+ callingPackage, callingFeatureId, "isVideoCallingEnabled")) {
return false;
}
@@ -5729,9 +5766,11 @@
}
@Override
- public boolean canChangeDtmfToneLength(int subId, String callingPackage) {
+ public boolean canChangeDtmfToneLength(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "isVideoCallingEnabled")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "isVideoCallingEnabled")) {
return false;
}
@@ -5747,9 +5786,9 @@
}
@Override
- public boolean isWorldPhone(int subId, String callingPackage) {
+ public boolean isWorldPhone(int subId, String callingPackage, String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "isVideoCallingEnabled")) {
+ mApp, subId, callingPackage, callingFeatureId, "isVideoCallingEnabled")) {
return false;
}
@@ -5819,6 +5858,12 @@
}
}
+ @Deprecated
+ @Override
+ public String getDeviceId(String callingPackage) {
+ return getDeviceIdWithFeature(callingPackage, null);
+ }
+
/**
* Returns the unique device ID of phone, for example, the IMEI for
* GSM and the MEID for CDMA phones. Return null if device ID is not available.
@@ -5827,14 +5872,14 @@
* {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*/
@Override
- public String getDeviceId(String callingPackage) {
+ public String getDeviceIdWithFeature(String callingPackage, String callingFeatureId) {
final Phone phone = PhoneFactory.getPhone(0);
if (phone == null) {
return null;
}
int subId = phone.getSubId();
if (!TelephonyPermissions.checkCallingOrSelfReadDeviceIdentifiers(mApp, subId,
- callingPackage, "getDeviceId")) {
+ callingPackage, callingFeatureId, "getDeviceId")) {
return null;
}
@@ -5873,9 +5918,9 @@
@Override
public int getSubIdForPhoneAccountHandle(
- PhoneAccountHandle phoneAccountHandle, String callingPackage) {
+ PhoneAccountHandle phoneAccountHandle, String callingPackage, String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, getDefaultSubscription(),
- callingPackage, "getSubIdForPhoneAccountHandle")) {
+ callingPackage, callingFeatureId, "getSubIdForPhoneAccountHandle")) {
throw new SecurityException("Requires READ_PHONE_STATE permission.");
}
final long identity = Binder.clearCallingIdentity();
@@ -6009,7 +6054,7 @@
final long identity = Binder.clearCallingIdentity();
try {
final SubscriptionInfo info = mSubscriptionController.getActiveSubscriptionInfo(subId,
- phone.getContext().getOpPackageName());
+ phone.getContext().getOpPackageName(), null);
if (info == null) {
log("getSimLocaleForSubscriber, inactive subId: " + subId);
return null;
@@ -6047,14 +6092,16 @@
}
private List<SubscriptionInfo> getAllSubscriptionInfoList() {
- return mSubscriptionController.getAllSubInfoList(mApp.getOpPackageName());
+ return mSubscriptionController.getAllSubInfoList(mApp.getOpPackageName(),
+ null);
}
/**
* 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(mApp.getOpPackageName(),
+ null);
}
private final ModemActivityInfo mLastModemActivityInfo =
@@ -6137,9 +6184,10 @@
* Returns the service state information on specified subscription.
*/
@Override
- public ServiceState getServiceStateForSubscriber(int subId, String callingPackage) {
+ public ServiceState getServiceStateForSubscriber(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getServiceStateForSubscriber")) {
+ mApp, subId, callingPackage, callingFeatureId, "getServiceStateForSubscriber")) {
return null;
}
@@ -6147,6 +6195,7 @@
LocationAccessPolicy.checkLocationPermission(mApp,
new LocationAccessPolicy.LocationPermissionQuery.Builder()
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
.setMethod("getServiceStateForSubscriber")
@@ -6158,6 +6207,7 @@
LocationAccessPolicy.checkLocationPermission(mApp,
new LocationAccessPolicy.LocationPermissionQuery.Builder()
.setCallingPackage(callingPackage)
+ .setCallingFeatureId(callingFeatureId)
.setCallingPid(Binder.getCallingPid())
.setCallingUid(Binder.getCallingUid())
.setMethod("getServiceStateForSubscriber")
@@ -6182,8 +6232,8 @@
// Scrub out the location info in ServiceState depending on what level of access
// the caller has.
if (hasFinePermission) return ss;
- if (hasCoarsePermission) return ss.sanitizeLocationInfo(false);
- return ss.sanitizeLocationInfo(true);
+ if (hasCoarsePermission) return ss.createLocationInfoSanitizedCopy(false);
+ return ss.createLocationInfoSanitizedCopy(true);
} finally {
Binder.restoreCallingIdentity(identity);
}
@@ -6687,9 +6737,10 @@
* @hide
*/
@Override
- public List<ClientRequestStats> getClientRequestStats(String callingPackage, int subId) {
+ public List<ClientRequestStats> getClientRequestStats(String callingPackage,
+ String callingFeatureId, int subId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getClientRequestStats")) {
+ mApp, subId, callingPackage, callingFeatureId, "getClientRequestStats")) {
return null;
}
Phone phone = getPhone(subId);
@@ -6800,14 +6851,15 @@
* Get the current modem radio state for the given slot.
* @param slotIndex slot index.
* @param callingPackage the name of the package making the call.
+ * @param callingFeatureId The feature in the package.
* @return the current radio power state from the modem
*/
@Override
- public int getRadioPowerState(int slotIndex, String callingPackage) {
+ public int getRadioPowerState(int slotIndex, String callingPackage, String callingFeatureId) {
Phone phone = PhoneFactory.getPhone(slotIndex);
if (phone != null) {
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, phone.getSubId(), callingPackage, "getRadioPowerState")) {
+ if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp, phone.getSubId(),
+ callingPackage, callingFeatureId, "getRadioPowerState")) {
return TelephonyManager.RADIO_POWER_UNAVAILABLE;
}
@@ -6881,7 +6933,8 @@
@Override
public boolean isManualNetworkSelectionAllowed(int subId) {
- TelephonyPermissions.enforeceCallingOrSelfReadPhoneStatePermissionOrCarrierPrivilege(
+ TelephonyPermissions
+ .enforeceCallingOrSelfReadPrivilegedPhoneStatePermissionOrCarrierPrivilege(
mApp, subId, "isManualNetworkSelectionAllowed");
boolean isAllowed = true;
@@ -7156,9 +7209,11 @@
}
@Override
- public int getNumberOfModemsWithSimultaneousDataConnections(int subId, String callingPackage) {
+ public int getNumberOfModemsWithSimultaneousDataConnections(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getNumberOfModemsWithSimultaneousDataConnections")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "getNumberOfModemsWithSimultaneousDataConnections")) {
return -1;
}
@@ -7211,9 +7266,10 @@
@Override
public Map<Integer, List<EmergencyNumber>> getEmergencyNumberList(
- String callingPackage) {
+ String callingPackage, String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, getDefaultSubscription(), callingPackage, "getEmergencyNumberList")) {
+ mApp, getDefaultSubscription(), callingPackage, callingFeatureId,
+ "getEmergencyNumberList")) {
throw new SecurityException("Requires READ_PHONE_STATE permission.");
}
final long identity = Binder.clearCallingIdentity();
@@ -7399,12 +7455,14 @@
* Whether a modem stack is enabled or not.
*/
@Override
- public boolean isModemEnabledForSlot(int slotIndex, String callingPackage) {
+ public boolean isModemEnabledForSlot(int slotIndex, String callingPackage,
+ String callingFeatureId) {
Phone phone = PhoneFactory.getPhone(slotIndex);
if (phone == null) return false;
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, phone.getSubId(), callingPackage, "isModemEnabledForSlot")) {
+ mApp, phone.getSubId(), callingPackage, callingFeatureId,
+ "isModemEnabledForSlot")) {
throw new SecurityException("Requires READ_PHONE_STATE permission.");
}
@@ -7436,9 +7494,10 @@
@Override
@TelephonyManager.IsMultiSimSupportedResult
- public int isMultiSimSupported(String callingPackage) {
+ public int isMultiSimSupported(String callingPackage, String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(mApp,
- getDefaultPhone().getSubId(), callingPackage, "isMultiSimSupported")) {
+ getDefaultPhone().getSubId(), callingPackage, callingFeatureId,
+ "isMultiSimSupported")) {
return TelephonyManager.MULTISIM_NOT_SUPPORTED_BY_HARDWARE;
}
@@ -7539,9 +7598,11 @@
* Return value defaults to true.
*/
@Override
- public boolean doesSwitchMultiSimConfigTriggerReboot(int subId, String callingPackage) {
+ public boolean doesSwitchMultiSimConfigTriggerReboot(int subId, String callingPackage,
+ String callingFeatureId) {
if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "doesSwitchMultiSimConfigTriggerReboot")) {
+ mApp, subId, callingPackage, callingFeatureId,
+ "doesSwitchMultiSimConfigTriggerReboot")) {
return false;
}
final long identity = Binder.clearCallingIdentity();
@@ -7640,6 +7701,17 @@
}
@Override
+ public boolean isMvnoMatched(int subId, int mvnoType, @NonNull String mvnoMatchData) {
+ IccRecords iccRecords = UiccController.getInstance().getIccRecords(
+ SubscriptionManager.getPhoneId(subId), UiccController.APP_FAM_3GPP);
+ if (iccRecords == null) {
+ Log.d(LOG_TAG, "isMvnoMatched# IccRecords is null");
+ return false;
+ }
+ return ApnSettingUtils.mvnoMatches(iccRecords, mvnoType, mvnoMatchData);
+ }
+
+ @Override
public void enqueueSmsPickResult(String callingPackage, IIntegerConsumer pendingSubIdResult) {
SmsPermissions permissions = new SmsPermissions(getDefaultPhone(), mApp,
(AppOpsManager) mApp.getSystemService(Context.APP_OPS_SERVICE));
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 9835ba1..c865f14 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -701,7 +701,7 @@
* {@code false} otherwise.
*/
public static boolean isPhoneAccountActive(SubscriptionManager sm, PhoneAccountHandle handle) {
- return sm.getActiveSubscriptionInfoForIccIndex(handle.getId()) != null;
+ return sm.getActiveSubscriptionInfoForIcc(handle.getId()) != null;
}
private static ComponentName getPstnConnectionServiceName() {
diff --git a/src/com/android/services/telephony/RadioOnHelper.java b/src/com/android/services/telephony/RadioOnHelper.java
index 981dc96..116c61d 100644
--- a/src/com/android/services/telephony/RadioOnHelper.java
+++ b/src/com/android/services/telephony/RadioOnHelper.java
@@ -110,6 +110,11 @@
Settings.Global.putInt(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, 0);
+ for (Phone phone : PhoneFactory.getPhones()) {
+ Log.d(this, "powerOnRadio, enabling Radio");
+ phone.setRadioPower(true);
+ }
+
// Post the broadcast intend for change in airplane mode
// TODO: We really should not be in charge of sending this broadcast.
// If changing the setting is sufficient to trigger all of the rest of the logic,
diff --git a/src/com/android/services/telephony/RadioOnStateListener.java b/src/com/android/services/telephony/RadioOnStateListener.java
index 52bd9cf..43269b4 100644
--- a/src/com/android/services/telephony/RadioOnStateListener.java
+++ b/src/com/android/services/telephony/RadioOnStateListener.java
@@ -56,6 +56,9 @@
@VisibleForTesting
public static final int MSG_SERVICE_STATE_CHANGED = 2;
private static final int MSG_RETRY_TIMEOUT = 3;
+ @VisibleForTesting
+ public static final int MSG_RADIO_ON = 4;
+ public static final int MSG_RADIO_OFF_OR_NOT_AVAILABLE = 5;
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
@@ -75,6 +78,12 @@
case MSG_SERVICE_STATE_CHANGED:
onServiceStateChanged((ServiceState) ((AsyncResult) msg.obj).result);
break;
+ case MSG_RADIO_ON:
+ onRadioOn();
+ break;
+ case MSG_RADIO_OFF_OR_NOT_AVAILABLE:
+ registerForRadioOn();
+ break;
case MSG_RETRY_TIMEOUT:
onRetryTimeout();
break;
@@ -135,6 +144,9 @@
mCallback = callback;
registerForServiceStateChanged();
+ // Register for RADIO_OFF to handle cases where emergency call is dialed before
+ // we receive UNSOL_RESPONSE_RADIO_STATE_CHANGED with RADIO_OFF.
+ registerForRadioOff();
// Next step: when the SERVICE_STATE_CHANGED event comes in, we'll retry the call; see
// onServiceStateChanged(). But also, just in case, start a timer to make sure we'll retry
// the call even if the SERVICE_STATE_CHANGED event never comes in for some reason.
@@ -169,6 +181,17 @@
}
}
+ private void onRadioOn() {
+ ServiceState state = mPhone.getServiceState();
+ Log.d(this, "onRadioOn, state = %s, Phone = %s", state,
+ mPhone.getPhoneId());
+ if (isOkToCall(state.getState())) {
+ onComplete(true);
+ cleanup();
+ } else {
+ Log.d(this, "onRadioOn: not ready to call yet, keep waiting.");
+ }
+ }
/**
* Callback to see if it is okay to call yet, given the current conditions.
*/
@@ -239,6 +262,8 @@
onComplete(false);
unregisterForServiceStateChanged();
+ unregisterForRadioOff();
+ unregisterForRadioOn();
cancelRetryTimer();
// Used for unregisterForServiceStateChanged() so we null it out here instead.
@@ -271,6 +296,31 @@
mHandler.removeMessages(MSG_SERVICE_STATE_CHANGED); // Clean up any pending messages too
}
+ private void registerForRadioOff() {
+ mPhone.mCi.registerForOffOrNotAvailable(mHandler, MSG_RADIO_OFF_OR_NOT_AVAILABLE, null);
+ }
+
+ private void unregisterForRadioOff() {
+ // This method is safe to call even if we haven't set mPhone yet.
+ if (mPhone != null) {
+ mPhone.mCi.unregisterForOffOrNotAvailable(mHandler); // Safe even if unnecessary
+ }
+ mHandler.removeMessages(MSG_RADIO_OFF_OR_NOT_AVAILABLE); // Clean up any pending messages
+ }
+
+ private void registerForRadioOn() {
+ unregisterForRadioOff();
+ mPhone.mCi.registerForOn(mHandler, MSG_RADIO_ON, null);
+ }
+
+ private void unregisterForRadioOn() {
+ // This method is safe to call even if we haven't set mPhone yet.
+ if (mPhone != null) {
+ mPhone.mCi.unregisterForOn(mHandler); // Safe even if unnecessary
+ }
+ mHandler.removeMessages(MSG_RADIO_ON); // Clean up any pending messages too
+ }
+
private void onComplete(boolean isRadioReady) {
if (mCallback != null) {
Callback tempCallback = mCallback;
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 40b941e..2aba682 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -662,7 +662,7 @@
// been powered on and isn't in the UNAVAILABLE state, even if it is
// reporting the OUT_OF_SERVICE state.
return (phone.getState() == PhoneConstants.State.OFFHOOK)
- || phone.getServiceState().getState() != ServiceState.STATE_POWER_OFF;
+ || phone.getServiceStateTracker().isRadioOn();
} else {
// Wait until we are in service and ready to make calls. This can happen
// when we power down the radio on bluetooth to save power on watches or if
@@ -816,7 +816,8 @@
// TODO: Switch out the underlying connection instead of creating a new
// one and causing UI Jank.
boolean noActiveSimCard = SubscriptionController.getInstance()
- .getActiveSubInfoCount(phone.getContext().getOpPackageName()) == 0;
+ .getActiveSubInfoCount(phone.getContext().getOpPackageName(),
+ null) == 0;
// If there's no active sim card and the device is in emergency mode, use E account.
addExistingConnection(mPhoneUtilsProxy.makePstnPhoneAccountHandleWithPrefix(
phone, "", isEmergencyNumber && noActiveSimCard), repConnection);
diff --git a/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java b/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
index 8b46bf0..afdfab5 100644
--- a/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
+++ b/tests/src/com/android/services/telephony/RadioOnStateListenerTest.java
@@ -34,6 +34,7 @@
import androidx.test.runner.AndroidJUnit4;
import com.android.TelephonyTestBase;
+import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
@@ -55,6 +56,7 @@
@Mock Phone mMockPhone;
@Mock RadioOnStateListener.Callback mCallback;
+ @Mock CommandsInterface mMockCi;
RadioOnStateListener mListener;
@Override
@@ -80,6 +82,7 @@
@Test
@SmallTest
public void testRegisterForCallback() {
+ mMockPhone.mCi = mMockCi;
mListener.waitForRadioOn(mMockPhone, mCallback);
waitForHandlerAction(mListener.getHandler(), TIMEOUT_MS);
@@ -87,6 +90,9 @@
verify(mMockPhone).unregisterForServiceStateChanged(any(Handler.class));
verify(mMockPhone).registerForServiceStateChanged(any(Handler.class),
eq(RadioOnStateListener.MSG_SERVICE_STATE_CHANGED), isNull());
+
+ verify(mMockCi).registerForOffOrNotAvailable(any(Handler.class),
+ eq(RadioOnStateListener.MSG_RADIO_OFF_OR_NOT_AVAILABLE), isNull());
}
/**
@@ -101,6 +107,7 @@
state.setState(ServiceState.STATE_IN_SERVICE);
when(mMockPhone.getState()).thenReturn(PhoneConstants.State.IDLE);
when(mCallback.isOkToCall(eq(mMockPhone), anyInt())).thenReturn(true);
+ mMockPhone.mCi = mMockCi;
mListener.waitForRadioOn(mMockPhone, mCallback);
waitForHandlerAction(mListener.getHandler(), TIMEOUT_MS);
@@ -124,6 +131,7 @@
when(mMockPhone.getState()).thenReturn(PhoneConstants.State.IDLE);
when(mCallback.isOkToCall(eq(mMockPhone), anyInt())).thenReturn(false);
when(mMockPhone.getServiceState()).thenReturn(state);
+ mMockPhone.mCi = mMockCi;
mListener.waitForRadioOn(mMockPhone, mCallback);
waitForHandlerAction(mListener.getHandler(), TIMEOUT_MS);
@@ -152,6 +160,7 @@
mListener.setMaxNumRetries(2);
// Wait for the timer to expire and check state manually in onRetryTimeout
+ mMockPhone.mCi = mMockCi;
mListener.waitForRadioOn(mMockPhone, mCallback);
waitForHandlerActionDelayed(mListener.getHandler(), TIMEOUT_MS, TIMEOUT_MS /*delay*/);