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;
|
public static final int BIND_BYPASS_POWER_NETWORK_RESTRICTIONS = 0x00020000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag for {@link #bindService}: allow background foreground service starts from the bound
|
* Do not use. This flag is no longer needed nor used.
|
||||||
* service's process.
|
|
||||||
* This flag is only respected if the caller is holding
|
|
||||||
* {@link android.Manifest.permission#START_FOREGROUND_SERVICES_FROM_BACKGROUND}.
|
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
|
|||||||
@@ -2569,10 +2569,6 @@ public final class ActiveServices {
|
|||||||
s.setAllowedBgActivityStartsByBinding(true);
|
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) {
|
if ((flags & Context.BIND_NOT_APP_COMPONENT_USAGE) != 0) {
|
||||||
s.isNotAppComponentUsage = true;
|
s.isNotAppComponentUsage = true;
|
||||||
}
|
}
|
||||||
@@ -4129,9 +4125,6 @@ public final class ActiveServices {
|
|||||||
if ((c.flags & Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS) != 0) {
|
if ((c.flags & Context.BIND_ALLOW_BACKGROUND_ACTIVITY_STARTS) != 0) {
|
||||||
s.updateIsAllowedBgActivityStartsByBinding();
|
s.updateIsAllowedBgActivityStartsByBinding();
|
||||||
}
|
}
|
||||||
if ((c.flags & Context.BIND_ALLOW_FOREGROUND_SERVICE_STARTS_FROM_BACKGROUND) != 0) {
|
|
||||||
s.updateIsAllowedBgFgsStartsByBinding();
|
|
||||||
}
|
|
||||||
if (s.app != null) {
|
if (s.app != null) {
|
||||||
updateServiceClientActivitiesLocked(s.app.mServices, c, true);
|
updateServiceClientActivitiesLocked(s.app.mServices, c, true);
|
||||||
}
|
}
|
||||||
@@ -5856,8 +5849,6 @@ public final class ActiveServices {
|
|||||||
final ProcessStateRecord state = app.mState;
|
final ProcessStateRecord state = app.mState;
|
||||||
if (state.isAllowedStartFgsState()) {
|
if (state.isAllowedStartFgsState()) {
|
||||||
return getReasonCodeFromProcState(state.getAllowStartFgsState());
|
return getReasonCodeFromProcState(state.getAllowStartFgsState());
|
||||||
} else if (state.areBackgroundFgsStartsAllowedByToken()) {
|
|
||||||
return REASON_FGS_BINDING;
|
|
||||||
} else {
|
} else {
|
||||||
final ActiveInstrumentation instr = app.getActiveInstrumentation();
|
final ActiveInstrumentation instr = app.getActiveInstrumentation();
|
||||||
if (instr != null
|
if (instr != null
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import static com.android.server.am.ProcessRecord.TAG;
|
|||||||
import android.annotation.ElapsedRealtimeLong;
|
import android.annotation.ElapsedRealtimeLong;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.os.Binder;
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
@@ -302,9 +301,6 @@ final class ProcessStateRecord {
|
|||||||
@GuardedBy("mService")
|
@GuardedBy("mService")
|
||||||
private int mAllowStartFgsState = PROCESS_STATE_NONEXISTENT;
|
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.
|
* Whether or not this process has been in forced-app-standby state.
|
||||||
*/
|
*/
|
||||||
@@ -1100,21 +1096,6 @@ final class ProcessStateRecord {
|
|||||||
PROCESS_STATE_NONEXISTENT;
|
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")
|
@GuardedBy("mService")
|
||||||
void resetAllowStartFgsState() {
|
void resetAllowStartFgsState() {
|
||||||
mAllowStartFgsState = PROCESS_STATE_NONEXISTENT;
|
mAllowStartFgsState = PROCESS_STATE_NONEXISTENT;
|
||||||
|
|||||||
@@ -149,10 +149,6 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
|||||||
@GuardedBy("ams")
|
@GuardedBy("ams")
|
||||||
private List<IBinder> mBgActivityStartsByStartOriginatingTokens = new ArrayList<>();
|
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.
|
// allow while-in-use permissions in foreground service or not.
|
||||||
// while-in-use permissions in FGS started from background might be restricted.
|
// while-in-use permissions in FGS started from background might be restricted.
|
||||||
boolean mAllowWhileInUsePermissionInFgs;
|
boolean mAllowWhileInUsePermissionInFgs;
|
||||||
@@ -445,10 +441,6 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
|||||||
pw.print(prefix); pw.print("mIsAllowedBgActivityStartsByStart=");
|
pw.print(prefix); pw.print("mIsAllowedBgActivityStartsByStart=");
|
||||||
pw.println(mIsAllowedBgActivityStartsByStart);
|
pw.println(mIsAllowedBgActivityStartsByStart);
|
||||||
}
|
}
|
||||||
if (mIsAllowedBgFgsStartsByBinding) {
|
|
||||||
pw.print(prefix); pw.print("mIsAllowedBgFgsStartsByBinding=");
|
|
||||||
pw.println(mIsAllowedBgFgsStartsByBinding);
|
|
||||||
}
|
|
||||||
pw.print(prefix); pw.print("allowWhileInUsePermissionInFgs=");
|
pw.print(prefix); pw.print("allowWhileInUsePermissionInFgs=");
|
||||||
pw.println(mAllowWhileInUsePermissionInFgs);
|
pw.println(mAllowWhileInUsePermissionInFgs);
|
||||||
pw.print(prefix); pw.print("recentCallingPackage=");
|
pw.print(prefix); pw.print("recentCallingPackage=");
|
||||||
@@ -634,11 +626,6 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN
|
|||||||
} else {
|
} else {
|
||||||
proc.removeAllowBackgroundActivityStartsToken(this);
|
proc.removeAllowBackgroundActivityStartsToken(this);
|
||||||
}
|
}
|
||||||
if (mIsAllowedBgFgsStartsByBinding) {
|
|
||||||
proc.mState.addAllowBackgroundFgsStartsToken(this);
|
|
||||||
} else {
|
|
||||||
proc.mState.removeAllowBackgroundFgsStartsToken(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (app != null && app != proc) {
|
if (app != null && app != proc) {
|
||||||
// If the old app is allowed to start bg activities because of a service start, leave it
|
// 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);
|
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) {
|
void setAllowedBgActivityStartsByBinding(boolean newValue) {
|
||||||
mIsAllowedBgActivityStartsByBinding = newValue;
|
mIsAllowedBgActivityStartsByBinding = newValue;
|
||||||
updateParentProcessBgActivityStartsToken();
|
updateParentProcessBgActivityStartsToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAllowedBgFgsStartsByBinding(boolean newValue) {
|
|
||||||
mIsAllowedBgFgsStartsByBinding = newValue;
|
|
||||||
updateParentProcessBgFgsStartsToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the service is started with allowBackgroundActivityStarts set. We allow
|
* 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
|
* 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
|
* 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
|
* 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