Update sms test app and integrate PERFORM_IMS_SINGLE_REGISTRATION into permission checks
1) Make a system app
2) Add a button that checks for the PERFORM_IMS_SINGLE_REGISTRATION permission
3) Move to checking PERFORM_IMS_SINGLE_REGISTRATION API check instead of further overloading phone state permissions.
4) Add permissions to test app
Bug: 168923956
Bug: 173652571
Bug: 149426399
Test: atest CtsTelephonyTestCases; use RcsTestApp to check perms
Merged-In: I91c5e49450545b76c6ccbaa900388abcc756aeb8
Merged-In: I9ebc9416f177b030ae531300b3024f31ddb07ca2
Change-Id: I9ebc9416f177b030ae531300b3024f31ddb07ca2
diff --git a/src/com/android/phone/ImsRcsController.java b/src/com/android/phone/ImsRcsController.java
index 701a759..5e616b7 100644
--- a/src/com/android/phone/ImsRcsController.java
+++ b/src/com/android/phone/ImsRcsController.java
@@ -16,6 +16,7 @@
package com.android.phone;
+import android.Manifest;
import android.app.ActivityManager;
import android.content.pm.PackageManager;
import android.net.Uri;
@@ -402,7 +403,10 @@
@Override
public boolean isSipDelegateSupported(int subId) {
- enforceReadPrivilegedPermission("isSipDelegateSupported");
+ TelephonyPermissions.enforceAnyPermissionGranted(mApp, Binder.getCallingUid(),
+ "isSipDelegateSupported",
+ Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION,
+ Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
if (!isImsSingleRegistrationSupportedOnDevice()) {
return false;
}
@@ -430,7 +434,7 @@
public void createSipDelegate(int subId, DelegateRequest request, String packageName,
ISipDelegateConnectionStateCallback delegateState,
ISipDelegateMessageCallback delegateMessage) {
- enforceModifyPermission();
+ enforceImsSingleRegistrationPermission("createSipDelegate");
if (!isImsSingleRegistrationSupportedOnDevice()) {
throw new ServiceSpecificException(ImsException.CODE_ERROR_UNSUPPORTED_OPERATION,
"SipDelegate creation is only supported for devices supporting IMS single "
@@ -468,7 +472,7 @@
@Override
public void destroySipDelegate(int subId, ISipDelegate connection, int reason) {
- enforceModifyPermission();
+ enforceImsSingleRegistrationPermission("destroySipDelegate");
final long identity = Binder.clearCallingIdentity();
try {
@@ -486,7 +490,7 @@
@Override
public void triggerNetworkRegistration(int subId, ISipDelegate connection, int sipCode,
String sipReason) {
- enforceModifyPermission();
+ enforceImsSingleRegistrationPermission("triggerNetworkRegistration");
final long identity = Binder.clearCallingIdentity();
try {
@@ -548,6 +552,15 @@
}
/**
+ * @throws SecurityException if the caller does not have the required
+ * PERFORM_IMS_SINGLE_REGISTRATION permission.
+ */
+ private void enforceImsSingleRegistrationPermission(String message) {
+ mApp.enforceCallingOrSelfPermission(
+ Manifest.permission.PERFORM_IMS_SINGLE_REGISTRATION, message);
+ }
+
+ /**
* Make sure the caller has the MODIFY_PHONE_STATE permission.
*
* @throws SecurityException if the caller does not have the required permission