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

Commit 8ceb9480 authored by Himanshu Dagar's avatar Himanshu Dagar Committed by Android (Google) Code Review
Browse files

Merge "Review Changes for Media CP Redirection CL"

parents 4559c7a8 9c8f6412
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.content;

import static android.Manifest.permission.INTERACT_ACROSS_USERS;
import static android.Manifest.permission.INTERACT_ACROSS_USERS_FULL;
import static android.os.Process.myUserHandle;
import static android.os.Trace.TRACE_TAG_DATABASE;

import android.annotation.NonNull;
@@ -738,7 +739,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
    }

    boolean checkUser(int pid, int uid, Context context) {
        int callingUserId = UserHandle.getUserId(uid);
        final int callingUserId = UserHandle.getUserId(uid);

        if (callingUserId == context.getUserId() || mSingleUser) {
            return true;
@@ -765,8 +766,8 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
                if (um != null && um.isCloneProfile()) {
                    UserHandle parent = um.getProfileParent(callingUser);

                    if (parent != null && parent.equals(context.getUser())) {
                        mUsersRedirectedToOwner.put(callingUser.getIdentifier(), true);
                    if (parent != null && parent.equals(myUserHandle())) {
                        mUsersRedirectedToOwner.put(callingUserId, true);
                        return true;
                    }
                }
@@ -774,7 +775,7 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
                // ignore
            }

            mUsersRedirectedToOwner.put(UserHandle.getUserId(uid), false);
            mUsersRedirectedToOwner.put(callingUserId, false);
            return false;
        }

+10 −21
Original line number Diff line number Diff line
@@ -1046,6 +1046,16 @@ public class ContentProviderHelper {
            userId = UserHandle.getCallingUserId();
        }

        if (isAuthorityRedirectedForCloneProfile(authority)) {
            UserManagerInternal umInternal = LocalServices.getService(UserManagerInternal.class);
            UserInfo userInfo = umInternal.getUserInfo(userId);

            if (userInfo != null && userInfo.isCloneProfile()) {
                userId = umInternal.getProfileParentId(userId);
                checkUser = false;
            }
        }

        ProviderInfo cpi = null;
        try {
            cpi = AppGlobals.getPackageManager().resolveContentProvider(authority,
@@ -1055,17 +1065,6 @@ public class ContentProviderHelper {
                            | PackageManager.MATCH_DIRECT_BOOT_AWARE
                            | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                    userId);
            if (cpi == null && isAuthorityRedirectedForCloneProfile(authority)) {
                // This might be a provider that's running only in the system user that's
                // also serving clone profiles
                cpi = AppGlobals.getPackageManager().resolveContentProvider(authority,
                        ActivityManagerService.STOCK_PM_FLAGS
                                | PackageManager.GET_URI_PERMISSION_PATTERNS
                                | PackageManager.MATCH_DISABLED_COMPONENTS
                                | PackageManager.MATCH_DIRECT_BOOT_AWARE
                                | PackageManager.MATCH_DIRECT_BOOT_UNAWARE,
                        UserHandle.USER_SYSTEM);
            }
        } catch (RemoteException ignored) {
        }
        if (cpi == null) {
@@ -1073,16 +1072,6 @@ public class ContentProviderHelper {
                    + "; expected to find a valid ContentProvider for this authority";
        }

        if (isAuthorityRedirectedForCloneProfile(authority)) {
            UserManagerInternal umInternal = LocalServices.getService(UserManagerInternal.class);
            UserInfo userInfo = umInternal.getUserInfo(userId);

            if (userInfo != null && userInfo.isCloneProfile()) {
                userId = umInternal.getProfileParentId(userId);
                checkUser = false;
            }
        }

        final int callingPid = Binder.getCallingPid();
        ProcessRecord r;
        final String appName;