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

Commit f436164e authored by Mehdi Alizadeh's avatar Mehdi Alizadeh Committed by Android (Google) Code Review
Browse files

Merge "Overrides permission check in tests to fix failing unit tests"

parents 6dfeeb71 10e88cc1
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.server.pm;

import android.Manifest.permission;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
@@ -307,8 +306,8 @@ public class LauncherAppsService extends SystemService {
            final int callingUserId = injectCallingUserId();

            if (targetUserId == callingUserId) return true;
            if (mContext.checkCallingOrSelfPermission(permission.INTERACT_ACROSS_USERS_FULL)
                    == PackageManager.PERMISSION_GRANTED) {
            if (injectHasInteractAcrossUsersFullPermission(injectBinderCallingPid(),
                    injectBinderCallingUid())) {
                return true;
            }

@@ -684,6 +683,15 @@ public class LauncherAppsService extends SystemService {
                    callingPid, callingUid) == PackageManager.PERMISSION_GRANTED;
        }

        /**
         * Returns true if the caller has the "INTERACT_ACROSS_USERS_FULL" permission.
         */
        @VisibleForTesting
        boolean injectHasInteractAcrossUsersFullPermission(int callingPid, int callingUid) {
            return mContext.checkPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
                    callingPid, callingUid) == PackageManager.PERMISSION_GRANTED;
        }

        @Override
        public ParceledListSlice getShortcuts(String callingPackage, long changedSince,
                String packageName, List shortcutIds, List<LocusId> locusIds,
+5 −0
Original line number Diff line number Diff line
@@ -562,6 +562,11 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {
        boolean injectHasAccessShortcutsPermission(int callingPid, int callingUid) {
            return true;
        }

        @Override
        boolean injectHasInteractAcrossUsersFullPermission(int callingPid, int callingUid) {
            return false;
        }
    }

    protected class LauncherAppsTestable extends LauncherApps {