Merge "Update IMS MMTEL API impls to include NR tech types"
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index 31059e7..bcc312c 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -407,6 +407,20 @@
return pidfXml == null ? "none" : pidfXml;
}
+ /**
+ * Remove UCE requests cannot be sent to the network status.
+ * @return true if this command is successful.
+ */
+ // Used for SHELL command only right now.
+ public boolean removeUceRequestDisallowedStatus(int subId) throws ImsException {
+ UceControllerManager uceCtrlManager = getRcsFeatureController(subId).getFeature(
+ UceControllerManager.class);
+ if (uceCtrlManager == null) {
+ return false;
+ }
+ return uceCtrlManager.removeUceRequestDisallowedStatus();
+ }
+
@Override
public void registerUcePublishStateCallback(int subId, IRcsUcePublishStateCallback c) {
enforceReadPrivilegedPermission("registerUcePublishStateCallback");
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 2f22d63..801c480 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -5783,6 +5783,8 @@
.setCallingUid(Binder.getCallingUid())
.setMethod("getCellNetworkScanResults")
.setMinSdkVersionForFine(Build.VERSION_CODES.Q)
+ .setMinSdkVersionForCoarse(Build.VERSION_CODES.Q)
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.Q)
.build());
switch (locationResult) {
case DENIED_HARD:
@@ -7462,6 +7464,8 @@
.setMethod("getServiceStateForSubscriber")
.setLogAsInfo(true)
.setMinSdkVersionForFine(Build.VERSION_CODES.Q)
+ .setMinSdkVersionForCoarse(Build.VERSION_CODES.Q)
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.Q)
.build());
LocationAccessPolicy.LocationPermissionResult coarseLocationResult =
@@ -7474,6 +7478,8 @@
.setMethod("getServiceStateForSubscriber")
.setLogAsInfo(true)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.Q)
+ .setMinSdkVersionForFine(Integer.MAX_VALUE)
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.Q)
.build());
// We don't care about hard or soft here -- all we need to know is how much info to scrub.
boolean hasFinePermission =
@@ -10135,6 +10141,23 @@
}
}
+ /**
+ * Remove UCE requests cannot be sent to the network status.
+ */
+ // Used for SHELL command only right now.
+ @Override
+ public boolean removeUceRequestDisallowedStatus(int subId) {
+ TelephonyPermissions.enforceShellOnly(Binder.getCallingUid(), "uceRemoveDisallowedStatus");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return mApp.imsRcsController.removeUceRequestDisallowedStatus(subId);
+ } catch (ImsException e) {
+ throw new ServiceSpecificException(e.getCode(), e.getMessage());
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
@Override
public void setSignalStrengthUpdateRequest(int subId, SignalStrengthUpdateRequest request,
diff --git a/src/com/android/phone/TelephonyShellCommand.java b/src/com/android/phone/TelephonyShellCommand.java
index 36d539a..7b11c89 100644
--- a/src/com/android/phone/TelephonyShellCommand.java
+++ b/src/com/android/phone/TelephonyShellCommand.java
@@ -126,6 +126,8 @@
private static final String UCE_SET_DEVICE_ENABLED = "set-device-enabled";
private static final String UCE_OVERRIDE_PUBLISH_CAPS = "override-published-caps";
private static final String UCE_GET_LAST_PIDF_XML = "get-last-publish-pidf";
+ private static final String UCE_REMOVE_REQUEST_DISALLOWED_STATUS =
+ "remove-request-disallowed-status";
// Check if a package has carrier privileges on any SIM, regardless of subId/phoneId.
private static final String HAS_CARRIER_PRIVILEGES_COMMAND = "has-carrier-privileges";
@@ -405,6 +407,8 @@
pw.println(" uce get-last-publish-pidf [-s SLOT_ID]");
pw.println(" Get the PIDF XML included in the last SIP PUBLISH, or \"none\" if no ");
pw.println(" PUBLISH is active");
+ pw.println(" uce remove-request-disallowed-status [-s SLOT_ID]");
+ pw.println(" Remove the UCE is disallowed to execute UCE requests status");
}
private void onHelpNumberVerification() {
@@ -1809,6 +1813,8 @@
return handleUceOverridePublishCaps();
case UCE_GET_LAST_PIDF_XML:
return handleUceGetPidfXml();
+ case UCE_REMOVE_REQUEST_DISALLOWED_STATUS:
+ return handleUceRemoveRequestDisallowedStatus();
}
return -1;
}
@@ -1895,6 +1901,26 @@
return 0;
}
+ private int handleUceRemoveRequestDisallowedStatus() {
+ int subId = getSubId("uce remove-request-disallowed-status");
+ if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ Log.w(LOG_TAG, "uce remove-request-disallowed-status, Invalid subscription ID");
+ return -1;
+ }
+ boolean result;
+ try {
+ result = mInterface.removeUceRequestDisallowedStatus(subId);
+ } catch (RemoteException e) {
+ Log.w(LOG_TAG, "uce remove-request-disallowed-status, error " + e.getMessage());
+ return -1;
+ }
+ if (VDBG) {
+ Log.v(LOG_TAG, "uce remove-request-disallowed-status, returned: " + result);
+ }
+ getOutPrintWriter().println(result);
+ return 0;
+ }
+
private int handleSrcSetTestEnabledCommand() {
String enabledStr = getNextArg();
if (enabledStr == null) {
diff --git a/src/com/android/services/telephony/rcs/UceControllerManager.java b/src/com/android/services/telephony/rcs/UceControllerManager.java
index 3051253..cca8330 100644
--- a/src/com/android/services/telephony/rcs/UceControllerManager.java
+++ b/src/com/android/services/telephony/rcs/UceControllerManager.java
@@ -70,12 +70,13 @@
* Constructor to inject dependencies for testing.
*/
@VisibleForTesting
- public UceControllerManager(Context context, int slotId, int subId, ExecutorService executor) {
+ public UceControllerManager(Context context, int slotId, int subId, ExecutorService executor,
+ UceController uceController) {
mSlotId = slotId;
mSubId = subId;
mContext = context;
mExecutorService = executor;
- mUceController = new UceController(mContext, subId);
+ mUceController = uceController;
}
@Override
@@ -140,11 +141,6 @@
});
}
- @VisibleForTesting
- public void setUceController(UceController uceController) {
- mUceController = uceController;
- }
-
/**
* Request the capabilities for contacts.
*
@@ -328,6 +324,32 @@
}
/**
+ * Remove UCE requests cannot be sent to the network status.
+ * @return true if this command is successful.
+ */
+ public boolean removeUceRequestDisallowedStatus() throws ImsException {
+ Future<Boolean> future = mExecutorService.submit(() -> {
+ if (mUceController == null) {
+ throw new ImsException("UCE controller is null",
+ ImsException.CODE_ERROR_SERVICE_UNAVAILABLE);
+ }
+ mUceController.removeRequestDisallowedStatus();
+ return true;
+ });
+
+ try {
+ return future.get();
+ } catch (ExecutionException | InterruptedException e) {
+ Log.w(LOG_TAG, "removeUceRequestDisallowedStatus exception: " + e);
+ Throwable cause = e.getCause();
+ if (cause instanceof ImsException) {
+ throw (ImsException) cause;
+ }
+ return false;
+ }
+ }
+
+ /**
* Register the Publish state changed callback.
*
* @throws ImsException if the ImsService connected to this controller is currently down.
diff --git a/tests/src/com/android/phone/LocationAccessPolicyBuilderTest.java b/tests/src/com/android/phone/LocationAccessPolicyBuilderTest.java
new file mode 100644
index 0000000..4fe2da9
--- /dev/null
+++ b/tests/src/com/android/phone/LocationAccessPolicyBuilderTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.phone;
+
+import static org.junit.Assert.fail;
+
+import android.os.Build;
+import android.telephony.LocationAccessPolicy;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class LocationAccessPolicyBuilderTest {
+ @Test
+ public void testBuilderMissingMinCoarse() {
+ try {
+ new LocationAccessPolicy.LocationPermissionQuery.Builder()
+ .setMethod("test")
+ .setCallingPackage("com.android.test")
+ .setCallingFeatureId(null)
+ .setCallingPid(0)
+ .setCallingUid(0)
+ .setMinSdkVersionForFine(Build.VERSION_CODES.N)
+ .build();
+ fail("Should have failed without specifying min version for coarse");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testBuilderMissingMinFine() {
+ try {
+ new LocationAccessPolicy.LocationPermissionQuery.Builder()
+ .setMethod("test")
+ .setCallingPackage("com.android.test")
+ .setCallingFeatureId(null)
+ .setCallingPid(0)
+ .setCallingUid(0)
+ .setMinSdkVersionForCoarse(Build.VERSION_CODES.N)
+ .build();
+ fail("Should have failed without specifying min version for fine");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+
+ @Test
+ public void testBuilderMissingMinEnforcement() {
+ try {
+ new LocationAccessPolicy.LocationPermissionQuery.Builder()
+ .setMethod("test")
+ .setCallingPackage("com.android.test")
+ .setCallingFeatureId(null)
+ .setCallingPid(0)
+ .setCallingUid(0)
+ .setMinSdkVersionForFine(Build.VERSION_CODES.N)
+ .setMinSdkVersionForCoarse(Build.VERSION_CODES.N)
+ .build();
+ fail("Should have failed without specifying min version for any enforcement");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ }
+}
diff --git a/tests/src/com/android/phone/LocationAccessPolicyTest.java b/tests/src/com/android/phone/LocationAccessPolicyTest.java
index b2489e7..84bf619 100644
--- a/tests/src/com/android/phone/LocationAccessPolicyTest.java
+++ b/tests/src/com/android/phone/LocationAccessPolicyTest.java
@@ -242,6 +242,7 @@
.setAppSdkLevel(Build.VERSION_CODES.P)
.setIsDynamicLocationEnabled(false)
.setQuery(getDefaultQueryBuilder()
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.N)
.setMinSdkVersionForFine(Build.VERSION_CODES.N)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.N).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.DENIED_SOFT)
@@ -254,6 +255,7 @@
.setAppSdkLevel(Build.VERSION_CODES.P)
.setIsDynamicLocationEnabled(true)
.setQuery(getDefaultQueryBuilder()
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.N)
.setMinSdkVersionForFine(Build.VERSION_CODES.N)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.N).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.ALLOWED)
@@ -266,6 +268,7 @@
.setAppSdkLevel(Build.VERSION_CODES.JELLY_BEAN)
.setIsDynamicLocationEnabled(true)
.setQuery(getDefaultQueryBuilder()
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.JELLY_BEAN)
.setMinSdkVersionForFine(Build.VERSION_CODES.M)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.JELLY_BEAN).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.ALLOWED)
@@ -278,6 +281,7 @@
.setAppSdkLevel(Build.VERSION_CODES.P)
.setIsDynamicLocationEnabled(true)
.setQuery(getDefaultQueryBuilder()
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.N)
.setMinSdkVersionForFine(Build.VERSION_CODES.N)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.N).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.DENIED_HARD)
@@ -292,6 +296,7 @@
.setQuery(getDefaultQueryBuilder()
.setMinSdkVersionForFine(
LocationAccessPolicy.MAX_SDK_FOR_ANY_ENFORCEMENT + 1)
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.N)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.N).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.ALLOWED)
.build());
@@ -303,6 +308,7 @@
.setAppSdkLevel(Build.VERSION_CODES.P)
.setIsDynamicLocationEnabled(true)
.setQuery(getDefaultQueryBuilder()
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.N)
.setMinSdkVersionForFine(Build.VERSION_CODES.P)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.N).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.DENIED_HARD)
@@ -316,6 +322,7 @@
.setAppSdkLevel(Build.VERSION_CODES.P)
.setIsDynamicLocationEnabled(true)
.setQuery(getDefaultQueryBuilder()
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.O)
.setMinSdkVersionForFine(Build.VERSION_CODES.P)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.O).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.DENIED_HARD)
@@ -326,6 +333,7 @@
.setAppSdkLevel(Build.VERSION_CODES.N)
.setIsDynamicLocationEnabled(true)
.setQuery(getDefaultQueryBuilder()
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.O)
.setMinSdkVersionForFine(Build.VERSION_CODES.Q)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.O).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.ALLOWED)
@@ -338,6 +346,9 @@
.setAppSdkLevel(Build.VERSION_CODES.P)
.setIsDynamicLocationEnabled(true)
.setQuery(getDefaultQueryBuilder()
+ .setMinSdkVersionForEnforcement(Build.VERSION_CODES.P)
+ .setMinSdkVersionForFine(
+ LocationAccessPolicy.MAX_SDK_FOR_ANY_ENFORCEMENT + 1)
.setMinSdkVersionForCoarse(Build.VERSION_CODES.P).build())
.setExpectedResult(LocationAccessPolicy.LocationPermissionResult.ALLOWED)
.build());
diff --git a/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java b/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
index 82687f8..75ddb96 100644
--- a/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
+++ b/tests/src/com/android/services/telephony/rcs/UceControllerManagerTest.java
@@ -243,8 +243,7 @@
private UceControllerManager getUceControllerManager() {
UceControllerManager manager = new UceControllerManager(mContext, mSlotId, mSubId,
- mExecutorService);
- manager.setUceController(mUceController);
+ mExecutorService, mUceController);
return manager;
}
}