Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 59b7d0a3 authored by Nathan Harold's avatar Nathan Harold
Browse files

TelephonyRegistry - Allow Hard Permissions Checks

When a soft permission failure occurs, don't early-exit
which might accidentally skip hard permissions checks that
should cause a SecurityException.

Bug: 159082270
Test: atest TelephonyRegistryTest
Change-Id: I7552364ed92d7a65ba9b7a26cee5d379505f1fab
parent 36c319a3
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -2642,6 +2642,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
            shouldCheckLocationPermissions = true;
        }

        boolean isPermissionCheckSuccessful = true;

        if (shouldCheckLocationPermissions) {
            LocationAccessPolicy.LocationPermissionResult result =
                    LocationAccessPolicy.checkLocationPermission(
@@ -2651,14 +2653,14 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    throw new SecurityException("Unable to listen for events " + events + " due to "
                            + "insufficient location permissions.");
                case DENIED_SOFT:
                    return false;
                    isPermissionCheckSuccessful = false;
            }
        }

        if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) {
            if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
                    mContext, subId, callingPackage, callingFeatureId, message)) {
                return false;
                isPermissionCheckSuccessful = false;
            }
        }

@@ -2688,7 +2690,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
                    android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
        }

        return true;
        return isPermissionCheckSuccessful;
    }

    private void handleRemoveListLocked() {