Merge "Fixes broadcast filtering for multi-user sys apps" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
55d0fb08e9
@@ -15788,9 +15788,10 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
}
|
}
|
||||||
if (receivers != null && broadcastWhitelist != null) {
|
if (receivers != null && broadcastWhitelist != null) {
|
||||||
for (int i = receivers.size() - 1; i >= 0; i--) {
|
for (int i = receivers.size() - 1; i >= 0; i--) {
|
||||||
final int uid = receivers.get(i).activityInfo.applicationInfo.uid;
|
final int receiverAppId = UserHandle.getAppId(
|
||||||
if (uid >= Process.FIRST_APPLICATION_UID
|
receivers.get(i).activityInfo.applicationInfo.uid);
|
||||||
&& Arrays.binarySearch(broadcastWhitelist, UserHandle.getAppId(uid)) < 0) {
|
if (receiverAppId >= Process.FIRST_APPLICATION_UID
|
||||||
|
&& Arrays.binarySearch(broadcastWhitelist, receiverAppId) < 0) {
|
||||||
receivers.remove(i);
|
receivers.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16436,9 +16437,9 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
// if a uid whitelist was provided, remove anything in the application space that wasn't
|
// if a uid whitelist was provided, remove anything in the application space that wasn't
|
||||||
// in it.
|
// in it.
|
||||||
for (int i = registeredReceivers.size() - 1; i >= 0; i--) {
|
for (int i = registeredReceivers.size() - 1; i >= 0; i--) {
|
||||||
final int uid = registeredReceivers.get(i).owningUid;
|
final int owningAppId = UserHandle.getAppId(registeredReceivers.get(i).owningUid);
|
||||||
if (uid >= Process.FIRST_APPLICATION_UID
|
if (owningAppId >= Process.FIRST_APPLICATION_UID
|
||||||
&& Arrays.binarySearch(broadcastWhitelist, UserHandle.getAppId(uid)) < 0) {
|
&& Arrays.binarySearch(broadcastWhitelist, owningAppId) < 0) {
|
||||||
registeredReceivers.remove(i);
|
registeredReceivers.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -859,8 +859,9 @@ public class AppsFilter {
|
|||||||
PackageSetting targetPkgSetting, int userId) {
|
PackageSetting targetPkgSetting, int userId) {
|
||||||
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplication");
|
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "shouldFilterApplication");
|
||||||
try {
|
try {
|
||||||
if (callingUid < Process.FIRST_APPLICATION_UID
|
int callingAppId = UserHandle.getAppId(callingUid);
|
||||||
|| UserHandle.getAppId(callingUid) == targetPkgSetting.appId) {
|
if (callingAppId < Process.FIRST_APPLICATION_UID
|
||||||
|
|| callingAppId == targetPkgSetting.appId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mShouldFilterCache != null) { // use cache
|
if (mShouldFilterCache != null) { // use cache
|
||||||
@@ -885,7 +886,7 @@ public class AppsFilter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DEBUG_LOGGING || mFeatureConfig.isLoggingEnabled(UserHandle.getAppId(callingUid))) {
|
if (DEBUG_LOGGING || mFeatureConfig.isLoggingEnabled(callingAppId)) {
|
||||||
log(callingSetting, targetPkgSetting, "BLOCKED");
|
log(callingSetting, targetPkgSetting, "BLOCKED");
|
||||||
}
|
}
|
||||||
return !DEBUG_ALLOW_ALL;
|
return !DEBUG_ALLOW_ALL;
|
||||||
|
|||||||
@@ -512,6 +512,22 @@ public class AppsFilterTest {
|
|||||||
null, target, SYSTEM_USER));
|
null, target, SYSTEM_USER));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSystemUidSecondaryUser_DoesntFilter() throws Exception {
|
||||||
|
final AppsFilter appsFilter =
|
||||||
|
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||||
|
simulateAddBasicAndroid(appsFilter);
|
||||||
|
appsFilter.onSystemReady();
|
||||||
|
|
||||||
|
PackageSetting target = simulateAddPackage(appsFilter,
|
||||||
|
pkg("com.some.package"), DUMMY_TARGET_APPID);
|
||||||
|
|
||||||
|
assertFalse(appsFilter.shouldFilterApplication(0, null, target, SECONDARY_USER));
|
||||||
|
assertFalse(appsFilter.shouldFilterApplication(
|
||||||
|
UserHandle.getUid(SECONDARY_USER, Process.FIRST_APPLICATION_UID - 1),
|
||||||
|
null, target, SECONDARY_USER));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonSystemUid_NoCallingSetting_Filters() throws Exception {
|
public void testNonSystemUid_NoCallingSetting_Filters() throws Exception {
|
||||||
final AppsFilter appsFilter =
|
final AppsFilter appsFilter =
|
||||||
|
|||||||
Reference in New Issue
Block a user