Loading core/java/android/content/Context.java +9 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,7 @@ public abstract class Context { BIND_IMPORTANT, BIND_ADJUST_WITH_ACTIVITY, BIND_NOT_PERCEPTIBLE, BIND_DENY_ACTIVITY_STARTS, BIND_INCLUDE_CAPABILITIES }) @Retention(RetentionPolicy.SOURCE) Loading Loading @@ -355,6 +356,14 @@ public abstract class Context { /*********** Public flags above this line ***********/ /*********** Hidden flags below this line ***********/ /** * Flag for {@link #bindService}: If binding from an app that is visible, the bound service is * allowed to start an activity from background. Add a flag so that this behavior can be opted * out. * @hide */ public static final int BIND_DENY_ACTIVITY_STARTS = 0X000004000; /** * Flag for {@link #bindService}: This flag is intended to be used only by the system to adjust * the scheduling policy for IMEs (and any other out-of-process user-visible components that Loading core/proto/android/server/activitymanagerservice.proto +1 −0 Original line number Diff line number Diff line Loading @@ -524,6 +524,7 @@ message ConnectionRecordProto { DEAD = 15; NOT_PERCEPTIBLE = 16; INCLUDE_CAPABILITIES = 17; DENY_ACTIVITY_STARTS = 18; } repeated Flag flags = 3; optional string service_name = 4; Loading services/core/java/com/android/server/am/ConnectionRecord.java +5 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ final class ConnectionRecord { Context.BIND_NOT_VISIBLE, Context.BIND_NOT_PERCEPTIBLE, Context.BIND_INCLUDE_CAPABILITIES, Context.BIND_DENY_ACTIVITY_STARTS, }; private static final int[] BIND_PROTO_ENUMS = new int[] { ConnectionRecordProto.AUTO_CREATE, Loading @@ -86,6 +87,7 @@ final class ConnectionRecord { ConnectionRecordProto.NOT_VISIBLE, ConnectionRecordProto.NOT_PERCEPTIBLE, ConnectionRecordProto.INCLUDE_CAPABILITIES, ConnectionRecordProto.DENY_ACTIVITY_STARTS, }; void dump(PrintWriter pw, String prefix) { Loading Loading @@ -219,6 +221,9 @@ final class ConnectionRecord { if ((flags & Context.BIND_NOT_PERCEPTIBLE) != 0) { sb.append("!PRCP "); } if ((flags & Context.BIND_DENY_ACTIVITY_STARTS) != 0) { sb.append("BALFD "); } if ((flags & Context.BIND_INCLUDE_CAPABILITIES) != 0) { sb.append("CAPS "); } Loading services/core/java/com/android/server/am/ProcessRecord.java +12 −8 Original line number Diff line number Diff line Loading @@ -1341,14 +1341,14 @@ class ProcessRecord implements WindowProcessListener { !mAllowBackgroundActivityStartsTokens.isEmpty()); } void addBoundClientUid(int clientUid) { void addBoundClientUid(int clientUid, String clientPackageName, int bindFlags) { mBoundClientUids.add(clientUid); mWindowProcessController.setBoundClientUids(mBoundClientUids); mWindowProcessController.addBoundClientUid(clientUid, clientPackageName, bindFlags); } void updateBoundClientUids() { if (mServices.isEmpty()) { clearBoundClientUids(); if (mServices.isEmpty()) { return; } // grab a set of clientUids of all connections of all services Loading @@ -1361,12 +1361,14 @@ class ProcessRecord implements WindowProcessListener { for (int conni = 0; conni < N; conni++) { ArrayList<ConnectionRecord> c = conns.valueAt(conni); for (int i = 0; i < c.size(); i++) { boundClientUids.add(c.get(i).clientUid); ConnectionRecord cr = c.get(i); boundClientUids.add(cr.clientUid); mWindowProcessController .addBoundClientUid(cr.clientUid, cr.clientPackageName, cr.flags); } } } mBoundClientUids = boundClientUids; mWindowProcessController.setBoundClientUids(mBoundClientUids); } void addBoundClientUidsOfNewService(ServiceRecord sr) { Loading @@ -1377,15 +1379,17 @@ class ProcessRecord implements WindowProcessListener { for (int conni = conns.size() - 1; conni >= 0; conni--) { ArrayList<ConnectionRecord> c = conns.valueAt(conni); for (int i = 0; i < c.size(); i++) { mBoundClientUids.add(c.get(i).clientUid); ConnectionRecord cr = c.get(i); mBoundClientUids.add(cr.clientUid); mWindowProcessController .addBoundClientUid(cr.clientUid, cr.clientPackageName, cr.flags); } } mWindowProcessController.setBoundClientUids(mBoundClientUids); } void clearBoundClientUids() { mBoundClientUids.clear(); mWindowProcessController.setBoundClientUids(mBoundClientUids); mWindowProcessController.clearBoundClientUids(); } void setActiveInstrumentation(ActiveInstrumentation instr) { Loading services/core/java/com/android/server/am/ServiceRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -627,7 +627,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN // if we have a process attached, add bound client uid of this connection to it if (app != null) { app.addBoundClientUid(c.clientUid); app.addBoundClientUid(c.clientUid, c.clientPackageName, c.flags); } } Loading Loading
core/java/android/content/Context.java +9 −0 Original line number Diff line number Diff line Loading @@ -242,6 +242,7 @@ public abstract class Context { BIND_IMPORTANT, BIND_ADJUST_WITH_ACTIVITY, BIND_NOT_PERCEPTIBLE, BIND_DENY_ACTIVITY_STARTS, BIND_INCLUDE_CAPABILITIES }) @Retention(RetentionPolicy.SOURCE) Loading Loading @@ -355,6 +356,14 @@ public abstract class Context { /*********** Public flags above this line ***********/ /*********** Hidden flags below this line ***********/ /** * Flag for {@link #bindService}: If binding from an app that is visible, the bound service is * allowed to start an activity from background. Add a flag so that this behavior can be opted * out. * @hide */ public static final int BIND_DENY_ACTIVITY_STARTS = 0X000004000; /** * Flag for {@link #bindService}: This flag is intended to be used only by the system to adjust * the scheduling policy for IMEs (and any other out-of-process user-visible components that Loading
core/proto/android/server/activitymanagerservice.proto +1 −0 Original line number Diff line number Diff line Loading @@ -524,6 +524,7 @@ message ConnectionRecordProto { DEAD = 15; NOT_PERCEPTIBLE = 16; INCLUDE_CAPABILITIES = 17; DENY_ACTIVITY_STARTS = 18; } repeated Flag flags = 3; optional string service_name = 4; Loading
services/core/java/com/android/server/am/ConnectionRecord.java +5 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ final class ConnectionRecord { Context.BIND_NOT_VISIBLE, Context.BIND_NOT_PERCEPTIBLE, Context.BIND_INCLUDE_CAPABILITIES, Context.BIND_DENY_ACTIVITY_STARTS, }; private static final int[] BIND_PROTO_ENUMS = new int[] { ConnectionRecordProto.AUTO_CREATE, Loading @@ -86,6 +87,7 @@ final class ConnectionRecord { ConnectionRecordProto.NOT_VISIBLE, ConnectionRecordProto.NOT_PERCEPTIBLE, ConnectionRecordProto.INCLUDE_CAPABILITIES, ConnectionRecordProto.DENY_ACTIVITY_STARTS, }; void dump(PrintWriter pw, String prefix) { Loading Loading @@ -219,6 +221,9 @@ final class ConnectionRecord { if ((flags & Context.BIND_NOT_PERCEPTIBLE) != 0) { sb.append("!PRCP "); } if ((flags & Context.BIND_DENY_ACTIVITY_STARTS) != 0) { sb.append("BALFD "); } if ((flags & Context.BIND_INCLUDE_CAPABILITIES) != 0) { sb.append("CAPS "); } Loading
services/core/java/com/android/server/am/ProcessRecord.java +12 −8 Original line number Diff line number Diff line Loading @@ -1341,14 +1341,14 @@ class ProcessRecord implements WindowProcessListener { !mAllowBackgroundActivityStartsTokens.isEmpty()); } void addBoundClientUid(int clientUid) { void addBoundClientUid(int clientUid, String clientPackageName, int bindFlags) { mBoundClientUids.add(clientUid); mWindowProcessController.setBoundClientUids(mBoundClientUids); mWindowProcessController.addBoundClientUid(clientUid, clientPackageName, bindFlags); } void updateBoundClientUids() { if (mServices.isEmpty()) { clearBoundClientUids(); if (mServices.isEmpty()) { return; } // grab a set of clientUids of all connections of all services Loading @@ -1361,12 +1361,14 @@ class ProcessRecord implements WindowProcessListener { for (int conni = 0; conni < N; conni++) { ArrayList<ConnectionRecord> c = conns.valueAt(conni); for (int i = 0; i < c.size(); i++) { boundClientUids.add(c.get(i).clientUid); ConnectionRecord cr = c.get(i); boundClientUids.add(cr.clientUid); mWindowProcessController .addBoundClientUid(cr.clientUid, cr.clientPackageName, cr.flags); } } } mBoundClientUids = boundClientUids; mWindowProcessController.setBoundClientUids(mBoundClientUids); } void addBoundClientUidsOfNewService(ServiceRecord sr) { Loading @@ -1377,15 +1379,17 @@ class ProcessRecord implements WindowProcessListener { for (int conni = conns.size() - 1; conni >= 0; conni--) { ArrayList<ConnectionRecord> c = conns.valueAt(conni); for (int i = 0; i < c.size(); i++) { mBoundClientUids.add(c.get(i).clientUid); ConnectionRecord cr = c.get(i); mBoundClientUids.add(cr.clientUid); mWindowProcessController .addBoundClientUid(cr.clientUid, cr.clientPackageName, cr.flags); } } mWindowProcessController.setBoundClientUids(mBoundClientUids); } void clearBoundClientUids() { mBoundClientUids.clear(); mWindowProcessController.setBoundClientUids(mBoundClientUids); mWindowProcessController.clearBoundClientUids(); } void setActiveInstrumentation(ActiveInstrumentation instr) { Loading
services/core/java/com/android/server/am/ServiceRecord.java +1 −1 Original line number Diff line number Diff line Loading @@ -627,7 +627,7 @@ final class ServiceRecord extends Binder implements ComponentName.WithComponentN // if we have a process attached, add bound client uid of this connection to it if (app != null) { app.addBoundClientUid(c.clientUid); app.addBoundClientUid(c.clientUid, c.clientPackageName, c.flags); } } Loading