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

This commit is contained in:
Mehdi Alizadeh
2020-02-19 19:54:34 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 3 deletions

View File

@@ -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,

View File

@@ -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 {