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

Commit f5c29834 authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Add work profile support for registering phone accounts with Telecom

When registering a phone account for a user not associated with the
phone process, we want to grab the user associated with the
phone subscription. Currently, we enable MULTI_USER_CAPABILITY for all
phone accounts; we should disable this when registering another user.
We will also need the INTERACT_ACROSS_USERS permission to perform
actions across users (other than the primary).

Bug: 255342474
Test: PhoneUtilsTest.java
Change-Id: I51f8068ebc3842c2264eade52131a99ffc81f5d0
parent 539b191b
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -2467,7 +2467,9 @@ public class TelecomServiceImpl {

    private void enforceUserHandleMatchesCaller(PhoneAccountHandle accountHandle) {
        if (!Binder.getCallingUserHandle().equals(accountHandle.getUserHandle())) {
            throw new SecurityException("Calling UserHandle does not match PhoneAccountHandle's");
            // Enforce INTERACT_ACROSS_USERS if the calling user handle does not match
            // phoen account's user handle
            enforceInAppCrossUserPermission();
        }
    }

@@ -2486,6 +2488,12 @@ public class TelecomServiceImpl {
        }
    }

    private void enforceInAppCrossUserPermission() {
        mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.INTERACT_ACROSS_USERS, "Must be system or have"
                        + " INTERACT_ACROSS_USERS permission");
    }

    // to be used for TestApi methods that can only be called with SHELL UID.
    private void enforceShellOnly(int callingUid, String message) {
        if (callingUid == Process.SHELL_UID || callingUid == Process.ROOT_UID) {