Merge "Merge "Check device owner by callingUid in ActivityStarter" into qt-dev am: ab48af4b76" into qt-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
bafc04a7cb
@@ -1018,11 +1018,11 @@ class ActivityStarter {
|
|||||||
if (mSupervisor.mRecentTasks.isCallerRecents(callingUid)) {
|
if (mSupervisor.mRecentTasks.isCallerRecents(callingUid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// don't abort if the callingPackage is the device owner
|
// don't abort if the callingUid is the device owner
|
||||||
if (mService.isDeviceOwner(callingPackage)) {
|
if (mService.isDeviceOwner(callingUid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// don't abort if the callingPackage has companion device
|
// don't abort if the callingUid has companion device
|
||||||
final int callingUserId = UserHandle.getUserId(callingUid);
|
final int callingUserId = UserHandle.getUserId(callingUid);
|
||||||
if (mService.isAssociatedCompanionApp(callingUserId, callingUid)) {
|
if (mService.isAssociatedCompanionApp(callingUserId, callingUid)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -507,9 +507,9 @@ public abstract class ActivityTaskManagerInternal {
|
|||||||
public abstract boolean isUidForeground(int uid);
|
public abstract boolean isUidForeground(int uid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by DevicePolicyManagerService to set the package name of the device owner.
|
* Called by DevicePolicyManagerService to set the uid of the device owner.
|
||||||
*/
|
*/
|
||||||
public abstract void setDeviceOwnerPackageName(String deviceOwnerPkg);
|
public abstract void setDeviceOwnerUid(int uid);
|
||||||
|
|
||||||
/** Set all associated companion app that belongs to an userId. */
|
/** Set all associated companion app that belongs to an userId. */
|
||||||
public abstract void setCompanionAppPackages(int userId, Set<String> companionAppPackages);
|
public abstract void setCompanionAppPackages(int userId, Set<String> companionAppPackages);
|
||||||
|
|||||||
@@ -633,7 +633,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
|
|
||||||
private FontScaleSettingObserver mFontScaleSettingObserver;
|
private FontScaleSettingObserver mFontScaleSettingObserver;
|
||||||
|
|
||||||
private String mDeviceOwnerPackageName;
|
private int mDeviceOwnerUid = Process.INVALID_UID;
|
||||||
|
|
||||||
private final class FontScaleSettingObserver extends ContentObserver {
|
private final class FontScaleSettingObserver extends ContentObserver {
|
||||||
private final Uri mFontScaleUri = Settings.System.getUriFor(FONT_SCALE);
|
private final Uri mFontScaleUri = Settings.System.getUriFor(FONT_SCALE);
|
||||||
@@ -5876,15 +5876,12 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
|| mWindowManager.mRoot.isAnyNonToastWindowVisibleForUid(uid);
|
|| mWindowManager.mRoot.isAnyNonToastWindowVisibleForUid(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isDeviceOwner(String packageName) {
|
boolean isDeviceOwner(int uid) {
|
||||||
if (packageName == null) {
|
return uid >= 0 && mDeviceOwnerUid == uid;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return packageName.equals(mDeviceOwnerPackageName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDeviceOwnerPackageName(String deviceOwnerPkg) {
|
void setDeviceOwnerUid(int uid) {
|
||||||
mDeviceOwnerPackageName = deviceOwnerPkg;
|
mDeviceOwnerUid = uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7334,9 +7331,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDeviceOwnerPackageName(String deviceOwnerPkg) {
|
public void setDeviceOwnerUid(int uid) {
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
ActivityTaskManagerService.this.setDeviceOwnerPackageName(deviceOwnerPkg);
|
ActivityTaskManagerService.this.setDeviceOwnerUid(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.content.pm.PackageManagerInternal;
|
|||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.os.Process;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.os.UserManagerInternal;
|
import android.os.UserManagerInternal;
|
||||||
@@ -209,8 +210,11 @@ class Owners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void pushToActivityTaskManagerLocked() {
|
private void pushToActivityTaskManagerLocked() {
|
||||||
mActivityTaskManagerInternal.setDeviceOwnerPackageName(mDeviceOwner != null
|
final int uid = mDeviceOwner != null ? mPackageManagerInternal.getPackageUid(
|
||||||
? mDeviceOwner.packageName : null);
|
mDeviceOwner.packageName,
|
||||||
|
PackageManager.MATCH_ALL | PackageManager.MATCH_KNOWN_PACKAGES, mDeviceOwnerUserId)
|
||||||
|
: Process.INVALID_UID;
|
||||||
|
mActivityTaskManagerInternal.setDeviceOwnerUid(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
String getDeviceOwnerPackageName() {
|
String getDeviceOwnerPackageName() {
|
||||||
|
|||||||
@@ -659,7 +659,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
|
|||||||
boolean hasForegroundActivities, boolean callerIsRecents,
|
boolean hasForegroundActivities, boolean callerIsRecents,
|
||||||
boolean callerIsTempWhitelisted,
|
boolean callerIsTempWhitelisted,
|
||||||
boolean callerIsInstrumentingWithBackgroundActivityStartPrivileges,
|
boolean callerIsInstrumentingWithBackgroundActivityStartPrivileges,
|
||||||
boolean isCallingPackageNameDeviceOwner, boolean isCallingPackageTempWhitelisted) {
|
boolean isCallingUidDeviceOwner, boolean isCallingPackageTempWhitelisted) {
|
||||||
// window visibility
|
// window visibility
|
||||||
doReturn(callingUidHasVisibleWindow).when(mService.mWindowManager.mRoot)
|
doReturn(callingUidHasVisibleWindow).when(mService.mWindowManager.mRoot)
|
||||||
.isAnyNonToastWindowVisibleForUid(callingUid);
|
.isAnyNonToastWindowVisibleForUid(callingUid);
|
||||||
@@ -685,8 +685,8 @@ public class ActivityStarterTests extends ActivityTestsBase {
|
|||||||
// caller is instrumenting with background activity starts privileges
|
// caller is instrumenting with background activity starts privileges
|
||||||
callerApp.setInstrumenting(callerIsInstrumentingWithBackgroundActivityStartPrivileges,
|
callerApp.setInstrumenting(callerIsInstrumentingWithBackgroundActivityStartPrivileges,
|
||||||
callerIsInstrumentingWithBackgroundActivityStartPrivileges);
|
callerIsInstrumentingWithBackgroundActivityStartPrivileges);
|
||||||
// calling package name is the device owner
|
// callingUid is the device owner
|
||||||
doReturn(isCallingPackageNameDeviceOwner).when(mService).isDeviceOwner(any());
|
doReturn(isCallingUidDeviceOwner).when(mService).isDeviceOwner(callingUid);
|
||||||
// calling package name is temporarily whitelisted
|
// calling package name is temporarily whitelisted
|
||||||
doReturn(isCallingPackageTempWhitelisted).when(mService)
|
doReturn(isCallingPackageTempWhitelisted).when(mService)
|
||||||
.isPackageNameWhitelistedForBgActivityStarts("com.whatever.dude");
|
.isPackageNameWhitelistedForBgActivityStarts("com.whatever.dude");
|
||||||
|
|||||||
Reference in New Issue
Block a user