Merge "Remove BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS" into sc-dev
This commit is contained in:
@@ -400,10 +400,7 @@ public abstract class Context {
|
||||
public static final int BIND_BYPASS_POWER_NETWORK_RESTRICTIONS = 0x00020000;
|
||||
|
||||
/**
|
||||
* Flag for {@link #bindService}: allow background foreground service starts from the bound
|
||||
* service's process.
|
||||
* This flag is only respected if the caller is holding
|
||||
* {@link android.Manifest.permission#START_FOREGROUND_SERVICES_FROM_BACKGROUND}.
|
||||
* Do not use. This flag is no longer needed nor used.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
|
||||
@@ -2569,10 +2569,6 @@ public final class ActiveServices {
|
||||
s.setAllowedBgActivityStartsByBinding(true);
|
||||
}
|
||||
|
||||
if ((flags & Context.BIND_ALLOW_FOREGROUND_SERVICE_STARTS_FROM_BACKGROUND) != 0) {
|
||||
s.setAllowedBgFgsStartsByBinding(true);
|
||||
}
|
||||
|
||||
if ((flags & Context.BIND_NOT_APP_COMPONENT_USAGE) != 0) {
|
||||
s.isNotAppComponentUsage = true;
|
||||
}
|
||||
@@ -4129,9 +4125,6 @@ public final class ActiveServices {
|
||||
if ((c.flags & Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS) != 0) {
|
||||
s.updateIsAllowedBgActivityStartsByBinding();
|
||||
}
|
||||
if ((c.flags & Context.BIND_ALLOW_FOREGROUND_SERVICE_STARTS_FROM_BACKGROUND) != 0) {
|
||||
s.updateIsAllowedBgFgsStartsByBinding();
|
||||
}
|
||||
if (s.app != null) {
|
||||
updateServiceClientActivitiesLocked(s.app.mServices, c, true);
|
||||
}
|
||||
@@ -5856,8 +5849,6 @@ public final class ActiveServices {
|
||||
final ProcessStateRecord state = app.mState;
|
||||
if (state.isAllowedStartFgsState()) {
|
||||
return getReasonCodeFromProcState(state.getAllowStartFgsState());
|
||||
} else if (state.areBackgroundFgsStartsAllowedByToken()) {
|
||||
return REASON_FGS_BINDING;
|
||||
} else {
|
||||
final ActiveInstrumentation instr = app.getActiveInstrumentation();
|
||||
if (instr != null
|
||||
|
||||
@@ -26,7 +26,6 @@ import static com.android.server.am.ProcessRecord.TAG;
|
||||
import android.annotation.ElapsedRealtimeLong;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.os.Binder;
|
||||
import android.os.SystemClock;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Slog;
|
||||
@@ -302,9 +301,6 @@ final class ProcessStateRecord {
|
||||
@GuardedBy("mService")
|
||||
private int mAllowStartFgsState = PROCESS_STATE_NONEXISTENT;
|
||||
|
||||
@GuardedBy("mService")
|
||||
private final ArraySet<Binder> mBackgroundFgsStartTokens = new ArraySet<>();
|
||||
|
||||
/**
|
||||
* Whether or not this process has been in forced-app-standby state.
|
||||
*/
|
||||
@@ -1100,21 +1096,6 @@ final class ProcessStateRecord {
|
||||
PROCESS_STATE_NONEXISTENT;
|
||||
}
|
||||
|
||||
@GuardedBy("mService")
|
||||
void addAllowBackgroundFgsStartsToken(Binder entity) {
|
||||
mBackgroundFgsStartTokens.add(entity);
|
||||
}
|
||||
|
||||
@GuardedBy("mService")
|
||||
void removeAllowBackgroundFgsStartsToken(Binder entity) {
|
||||
mBackgroundFgsStartTokens.remove(entity);
|
||||
}
|
||||
|
||||
@GuardedBy("mService")
|
||||
boolean areBackgroundFgsStartsAllowedByToken() {
|
||||
return !mBackgroundFgsStartTokens.isEmpty();
|
||||
}
|
||||
|
||||
@GuardedBy("mService")
|
||||
void resetAllowStartFgsState() {
|
||||
mAllowStartFgsState = PROCESS_STATE_NONEXISTENT;
|
||||
|
||||
@@ -149,10 +149,6 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
@GuardedBy("ams")
|
||||
private List<IBinder> mBgActivityStartsByStartOriginatingTokens = new ArrayList<>();
|
||||
|
||||
// any current binding to this service has BIND_ALLOW_FOREGROUND_SERVICE_STARTS_FROM_BACKGROUND
|
||||
// flag? if true, the process can start FGS from background.
|
||||
boolean mIsAllowedBgFgsStartsByBinding;
|
||||
|
||||
// allow while-in-use permissions in foreground service or not.
|
||||
// while-in-use permissions in FGS started from background might be restricted.
|
||||
boolean mAllowWhileInUsePermissionInFgs;
|
||||
@@ -445,10 +441,6 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
pw.print(prefix); pw.print("mIsAllowedBgActivityStartsByStart=");
|
||||
pw.println(mIsAllowedBgActivityStartsByStart);
|
||||
}
|
||||
if (mIsAllowedBgFgsStartsByBinding) {
|
||||
pw.print(prefix); pw.print("mIsAllowedBgFgsStartsByBinding=");
|
||||
pw.println(mIsAllowedBgFgsStartsByBinding);
|
||||
}
|
||||
pw.print(prefix); pw.print("allowWhileInUsePermissionInFgs=");
|
||||
pw.println(mAllowWhileInUsePermissionInFgs);
|
||||
pw.print(prefix); pw.print("recentCallingPackage=");
|
||||
@@ -634,11 +626,6 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
} else {
|
||||
proc.removeAllowBackgroundActivityStartsToken(this);
|
||||
}
|
||||
if (mIsAllowedBgFgsStartsByBinding) {
|
||||
proc.mState.addAllowBackgroundFgsStartsToken(this);
|
||||
} else {
|
||||
proc.mState.removeAllowBackgroundFgsStartsToken(this);
|
||||
}
|
||||
}
|
||||
if (app != null && app != proc) {
|
||||
// If the old app is allowed to start bg activities because of a service start, leave it
|
||||
@@ -726,34 +713,11 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
setAllowedBgActivityStartsByBinding(isAllowedByBinding);
|
||||
}
|
||||
|
||||
void updateIsAllowedBgFgsStartsByBinding() {
|
||||
boolean isAllowedByBinding = false;
|
||||
for (int conni = connections.size() - 1; conni >= 0; conni--) {
|
||||
ArrayList<ConnectionRecord> cr = connections.valueAt(conni);
|
||||
for (int i = 0; i < cr.size(); i++) {
|
||||
if ((cr.get(i).flags
|
||||
& Context.BIND_ALLOW_FOREGROUND_SERVICE_STARTS_FROM_BACKGROUND) != 0) {
|
||||
isAllowedByBinding = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isAllowedByBinding) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
setAllowedBgFgsStartsByBinding(isAllowedByBinding);
|
||||
}
|
||||
|
||||
void setAllowedBgActivityStartsByBinding(boolean newValue) {
|
||||
mIsAllowedBgActivityStartsByBinding = newValue;
|
||||
updateParentProcessBgActivityStartsToken();
|
||||
}
|
||||
|
||||
void setAllowedBgFgsStartsByBinding(boolean newValue) {
|
||||
mIsAllowedBgFgsStartsByBinding = newValue;
|
||||
updateParentProcessBgFgsStartsToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the service is started with allowBackgroundActivityStarts set. We allow
|
||||
* it for background activity starts, setting up a callback to remove this ability after a
|
||||
@@ -846,17 +810,6 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
||||
}
|
||||
}
|
||||
|
||||
private void updateParentProcessBgFgsStartsToken() {
|
||||
if (app == null) {
|
||||
return;
|
||||
}
|
||||
if (mIsAllowedBgFgsStartsByBinding) {
|
||||
app.mState.addAllowBackgroundFgsStartsToken(this);
|
||||
} else {
|
||||
app.mState.removeAllowBackgroundFgsStartsToken(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the originating token if that's the only reason background activity starts are
|
||||
* allowed. In order for that to happen the service has to be allowed only due to starts, since
|
||||
|
||||
Reference in New Issue
Block a user