BG-FGS-Launch uses the same grace period mechanism as BG-Activity-Launch.
WindowProcessController.areBackgroundActivityStartsAllowed() has the 10 seconds grace period, starts from last activity's launch time or finish time. Expose this method as an ATMS interface for AMS to call, to determine if BG-FGS-Launch is allowed. Bug: 171305836 Test: atest cts/tests/app/src/android/app/cts/ActivityManagerFgsBgStartTest.java Change-Id: I30706dc1950bf5d49926a8e26c0493d9e168eb1b
This commit is contained in:
@@ -169,6 +169,7 @@ public final class ActiveServices {
|
||||
public static final int FGS_FEATURE_ALLOWED_BY_DEVICE_DEMO_MODE = 18;
|
||||
public static final int FGS_FEATURE_ALLOWED_BY_PROCESS_RECORD = 19;
|
||||
public static final int FGS_FEATURE_ALLOWED_BY_EXEMPTED_PACKAGES = 20;
|
||||
public static final int FGS_FEATURE_ALLOWED_BY_ACTIVITY_STARTER = 21;
|
||||
|
||||
@IntDef(flag = true, prefix = { "FGS_FEATURE_" }, value = {
|
||||
FGS_FEATURE_DENIED,
|
||||
@@ -191,6 +192,7 @@ public final class ActiveServices {
|
||||
FGS_FEATURE_ALLOWED_BY_DEVICE_DEMO_MODE,
|
||||
FGS_FEATURE_ALLOWED_BY_PROCESS_RECORD,
|
||||
FGS_FEATURE_ALLOWED_BY_EXEMPTED_PACKAGES,
|
||||
FGS_FEATURE_ALLOWED_BY_ACTIVITY_STARTER
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FgsFeatureRetCode {}
|
||||
@@ -5202,8 +5204,8 @@ public final class ActiveServices {
|
||||
for (int i = mAm.mProcessList.mLruProcesses.size() - 1; i >= 0; i--) {
|
||||
final ProcessRecord pr = mAm.mProcessList.mLruProcesses.get(i);
|
||||
if (pr.uid == callingUid) {
|
||||
if (pr.areBackgroundActivityStartsAllowedByToken()) {
|
||||
ret = FGS_FEATURE_ALLOWED_BY_ACTIVITY_TOKEN;
|
||||
if (pr.getWindowProcessController().areBackgroundActivityStartsAllowed()) {
|
||||
ret = FGS_FEATURE_ALLOWED_BY_ACTIVITY_STARTER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5406,6 +5408,8 @@ public final class ActiveServices {
|
||||
return "ALLOWED_BY_PROCESS_RECORD";
|
||||
case FGS_FEATURE_ALLOWED_BY_EXEMPTED_PACKAGES:
|
||||
return "FGS_FEATURE_ALLOWED_BY_EXEMPTED_PACKAGES";
|
||||
case FGS_FEATURE_ALLOWED_BY_ACTIVITY_STARTER:
|
||||
return "ALLOWED_BY_ACTIVITY_STARTER";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1381,10 +1381,6 @@ class ProcessRecord implements WindowProcessListener {
|
||||
mWindowProcessController.removeAllowBackgroundActivityStartsToken(entity);
|
||||
}
|
||||
|
||||
boolean areBackgroundActivityStartsAllowedByToken() {
|
||||
return mWindowProcessController.areBackgroundActivityStartsAllowedByToken();
|
||||
}
|
||||
|
||||
void addBoundClientUid(int clientUid) {
|
||||
mBoundClientUids.add(clientUid);
|
||||
mWindowProcessController.setBoundClientUids(mBoundClientUids);
|
||||
|
||||
@@ -510,13 +510,9 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if background activity starts are allowed by any token added via {@link
|
||||
* #addOrUpdateAllowBackgroundActivityStartsToken(Binder, IBinder)}.
|
||||
*/
|
||||
public boolean areBackgroundActivityStartsAllowedByToken() {
|
||||
public boolean areBackgroundActivityStartsAllowed() {
|
||||
synchronized (mAtm.mGlobalLock) {
|
||||
return !mBackgroundActivityStartTokens.isEmpty();
|
||||
return areBackgroundActivityStartsAllowed(mAtm.getBalAppSwitchesAllowed());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user