Merge "Allow BAL from explicit start methods." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1cae945226
@@ -1503,7 +1503,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
.setCallingPid(callingPid)
|
.setCallingPid(callingPid)
|
||||||
.setCallingPackage(intent.getPackage())
|
.setCallingPackage(intent.getPackage())
|
||||||
.setActivityInfo(a)
|
.setActivityInfo(a)
|
||||||
.setActivityOptions(options.toBundle())
|
.setActivityOptions(createSafeActivityOptionsWithBalAllowed(options))
|
||||||
// To start the dream from background, we need to start it from a persistent
|
// To start the dream from background, we need to start it from a persistent
|
||||||
// system process. Here we set the real calling uid to the system server uid
|
// system process. Here we set the real calling uid to the system server uid
|
||||||
.setRealCallingUid(Binder.getCallingUid())
|
.setRealCallingUid(Binder.getCallingUid())
|
||||||
@@ -1651,7 +1651,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
.setResultWho(resultWho)
|
.setResultWho(resultWho)
|
||||||
.setRequestCode(requestCode)
|
.setRequestCode(requestCode)
|
||||||
.setStartFlags(startFlags)
|
.setStartFlags(startFlags)
|
||||||
.setActivityOptions(bOptions)
|
.setActivityOptions(createSafeActivityOptionsWithBalAllowed(bOptions))
|
||||||
.setUserId(userId)
|
.setUserId(userId)
|
||||||
.setIgnoreTargetSecurity(ignoreTargetSecurity)
|
.setIgnoreTargetSecurity(ignoreTargetSecurity)
|
||||||
.setFilterCallingUid(isResolver ? 0 /* system */ : targetUid)
|
.setFilterCallingUid(isResolver ? 0 /* system */ : targetUid)
|
||||||
@@ -1701,7 +1701,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
.setVoiceInteractor(interactor)
|
.setVoiceInteractor(interactor)
|
||||||
.setStartFlags(startFlags)
|
.setStartFlags(startFlags)
|
||||||
.setProfilerInfo(profilerInfo)
|
.setProfilerInfo(profilerInfo)
|
||||||
.setActivityOptions(bOptions)
|
.setActivityOptions(createSafeActivityOptionsWithBalAllowed(bOptions))
|
||||||
.setUserId(userId)
|
.setUserId(userId)
|
||||||
.setBackgroundStartPrivileges(BackgroundStartPrivileges.ALLOW_BAL)
|
.setBackgroundStartPrivileges(BackgroundStartPrivileges.ALLOW_BAL)
|
||||||
.execute();
|
.execute();
|
||||||
@@ -1728,7 +1728,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
.setCallingPackage(callingPackage)
|
.setCallingPackage(callingPackage)
|
||||||
.setCallingFeatureId(callingFeatureId)
|
.setCallingFeatureId(callingFeatureId)
|
||||||
.setResolvedType(resolvedType)
|
.setResolvedType(resolvedType)
|
||||||
.setActivityOptions(bOptions)
|
.setActivityOptions(createSafeActivityOptionsWithBalAllowed(bOptions))
|
||||||
.setUserId(userId)
|
.setUserId(userId)
|
||||||
.setBackgroundStartPrivileges(BackgroundStartPrivileges.ALLOW_BAL)
|
.setBackgroundStartPrivileges(BackgroundStartPrivileges.ALLOW_BAL)
|
||||||
.execute();
|
.execute();
|
||||||
@@ -5507,6 +5507,31 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
return checkPermission(permission, -1, sourceUid) == PackageManager.PERMISSION_GRANTED;
|
return checkPermission(permission, -1, sourceUid) == PackageManager.PERMISSION_GRANTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap the {@link ActivityOptions} in {@link SafeActivityOptions} and attach caller options
|
||||||
|
* that allow using the callers permissions to start background activities.
|
||||||
|
*/
|
||||||
|
private SafeActivityOptions createSafeActivityOptionsWithBalAllowed(
|
||||||
|
@Nullable ActivityOptions options) {
|
||||||
|
if (options == null) {
|
||||||
|
options = ActivityOptions.makeBasic().setPendingIntentBackgroundActivityStartMode(
|
||||||
|
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
|
||||||
|
} else if (options.getPendingIntentBackgroundActivityStartMode()
|
||||||
|
== ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_SYSTEM_DEFINED) {
|
||||||
|
options.setPendingIntentBackgroundActivityStartMode(
|
||||||
|
ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED);
|
||||||
|
}
|
||||||
|
return new SafeActivityOptions(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap the options {@link Bundle} in {@link SafeActivityOptions} and attach caller options
|
||||||
|
* that allow using the callers permissions to start background activities.
|
||||||
|
*/
|
||||||
|
private SafeActivityOptions createSafeActivityOptionsWithBalAllowed(@Nullable Bundle bOptions) {
|
||||||
|
return createSafeActivityOptionsWithBalAllowed(ActivityOptions.fromBundle(bOptions));
|
||||||
|
}
|
||||||
|
|
||||||
final class H extends Handler {
|
final class H extends Handler {
|
||||||
static final int REPORT_TIME_TRACKER_MSG = 1;
|
static final int REPORT_TIME_TRACKER_MSG = 1;
|
||||||
static final int UPDATE_PROCESS_ANIMATING_STATE = 2;
|
static final int UPDATE_PROCESS_ANIMATING_STATE = 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user