Merge "Build AppsFilter cache in background" into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4336e7ca72
@@ -35,6 +35,9 @@ import android.content.pm.parsing.component.ParsedInstrumentation;
|
||||
import android.content.pm.parsing.component.ParsedIntentInfo;
|
||||
import android.content.pm.parsing.component.ParsedMainComponent;
|
||||
import android.content.pm.parsing.component.ParsedProvider;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerExecutor;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Process;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
@@ -48,6 +51,7 @@ import android.util.SparseBooleanArray;
|
||||
import android.util.SparseSetArray;
|
||||
|
||||
import com.android.internal.R;
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.server.FgThread;
|
||||
@@ -61,6 +65,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/**
|
||||
* The entity responsible for filtering visibility between apps based on declarations in their
|
||||
@@ -95,6 +100,12 @@ public class AppsFilter {
|
||||
*/
|
||||
private final SparseSetArray<Integer> mQueriesViaComponent = new SparseSetArray<>();
|
||||
|
||||
/**
|
||||
* Executor for running reasonably short background tasks such as building the initial
|
||||
* visibility cache.
|
||||
*/
|
||||
private final Executor mBackgroundExecutor;
|
||||
|
||||
/**
|
||||
* Pending full recompute of mQueriesViaComponent. Occurs when a package adds a new set of
|
||||
* protected broadcast. This in turn invalidates all prior additions and require a very
|
||||
@@ -125,6 +136,8 @@ public class AppsFilter {
|
||||
private PackageParser.SigningDetails mSystemSigningDetails;
|
||||
private Set<String> mProtectedBroadcasts = new ArraySet<>();
|
||||
|
||||
private final Object mCacheLock = new Object();
|
||||
|
||||
/**
|
||||
* This structure maps uid -> uid and indicates whether access from the first should be
|
||||
* filtered to the second. It's essentially a cache of the
|
||||
@@ -132,6 +145,7 @@ public class AppsFilter {
|
||||
* NOTE: It can only be relied upon after the system is ready to avoid unnecessary update on
|
||||
* initial scam and is null until {@link #onSystemReady()} is called.
|
||||
*/
|
||||
@GuardedBy("mCacheLock")
|
||||
private volatile SparseArray<SparseBooleanArray> mShouldFilterCache;
|
||||
|
||||
@VisibleForTesting(visibility = PRIVATE)
|
||||
@@ -139,13 +153,15 @@ public class AppsFilter {
|
||||
FeatureConfig featureConfig,
|
||||
String[] forceQueryableWhitelist,
|
||||
boolean systemAppsQueryable,
|
||||
@Nullable OverlayReferenceMapper.Provider overlayProvider) {
|
||||
@Nullable OverlayReferenceMapper.Provider overlayProvider,
|
||||
Executor backgroundExecutor) {
|
||||
mFeatureConfig = featureConfig;
|
||||
mForceQueryableByDevicePackageNames = forceQueryableWhitelist;
|
||||
mSystemAppsQueryable = systemAppsQueryable;
|
||||
mOverlayReferenceMapper = new OverlayReferenceMapper(true /*deferRebuild*/,
|
||||
overlayProvider);
|
||||
mStateProvider = stateProvider;
|
||||
mBackgroundExecutor = backgroundExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,8 +353,13 @@ public class AppsFilter {
|
||||
injector.getUserManagerInternal().getUserInfos());
|
||||
}
|
||||
};
|
||||
HandlerThread appsFilterThread = new HandlerThread("appsFilter");
|
||||
appsFilterThread.start();
|
||||
Handler appsFilterHandler = new Handler(appsFilterThread.getLooper());
|
||||
Executor executor = new HandlerExecutor(appsFilterHandler);
|
||||
|
||||
AppsFilter appsFilter = new AppsFilter(stateProvider, featureConfig,
|
||||
forcedQueryablePackageNames, forceSystemAppsQueryable, null);
|
||||
forcedQueryablePackageNames, forceSystemAppsQueryable, null, executor);
|
||||
featureConfig.setAppsFilter(appsFilter);
|
||||
return appsFilter;
|
||||
}
|
||||
@@ -470,29 +491,26 @@ public class AppsFilter {
|
||||
if (mImplicitlyQueryable.add(recipientUid, visibleUid) && DEBUG_LOGGING) {
|
||||
Slog.i(TAG, "implicit access granted: " + recipientUid + " -> " + visibleUid);
|
||||
}
|
||||
if (mShouldFilterCache != null) {
|
||||
// update the cache in a one-off manner since we've got all the information we need.
|
||||
SparseBooleanArray visibleUids = mShouldFilterCache.get(recipientUid);
|
||||
if (visibleUids == null) {
|
||||
visibleUids = new SparseBooleanArray();
|
||||
mShouldFilterCache.put(recipientUid, visibleUids);
|
||||
synchronized (mCacheLock) {
|
||||
if (mShouldFilterCache != null) {
|
||||
// update the cache in a one-off manner since we've got all the information we
|
||||
// need.
|
||||
SparseBooleanArray visibleUids = mShouldFilterCache.get(recipientUid);
|
||||
if (visibleUids == null) {
|
||||
visibleUids = new SparseBooleanArray();
|
||||
mShouldFilterCache.put(recipientUid, visibleUids);
|
||||
}
|
||||
visibleUids.put(visibleUid, false);
|
||||
}
|
||||
visibleUids.put(visibleUid, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onSystemReady() {
|
||||
mStateProvider.runWithState(new StateProvider.CurrentStateCallback() {
|
||||
@Override
|
||||
public void currentState(ArrayMap<String, PackageSetting> settings,
|
||||
UserInfo[] users) {
|
||||
mShouldFilterCache = new SparseArray<>(users.length * settings.size());
|
||||
}
|
||||
});
|
||||
mFeatureConfig.onSystemReady();
|
||||
mOverlayReferenceMapper.rebuildIfDeferred();
|
||||
updateEntireShouldFilterCache();
|
||||
mFeatureConfig.onSystemReady();
|
||||
|
||||
updateEntireShouldFilterCacheAsync();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -510,10 +528,12 @@ public class AppsFilter {
|
||||
}
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
addPackageInternal(newPkgSetting, settings);
|
||||
if (mShouldFilterCache != null) {
|
||||
updateShouldFilterCacheForPackage(
|
||||
null, newPkgSetting, settings, users, settings.size());
|
||||
} // else, rebuild entire cache when system is ready
|
||||
synchronized (mCacheLock) {
|
||||
if (mShouldFilterCache != null) {
|
||||
updateShouldFilterCacheForPackage(mShouldFilterCache, null, newPkgSetting,
|
||||
settings, users, settings.size());
|
||||
} // else, rebuild entire cache when system is ready
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
@@ -607,6 +627,7 @@ public class AppsFilter {
|
||||
mFeatureConfig.updatePackageState(newPkgSetting, false /*removed*/);
|
||||
}
|
||||
|
||||
@GuardedBy("mCacheLock")
|
||||
private void removeAppIdFromVisibilityCache(int appId) {
|
||||
if (mShouldFilterCache == null) {
|
||||
return;
|
||||
@@ -627,31 +648,95 @@ public class AppsFilter {
|
||||
|
||||
private void updateEntireShouldFilterCache() {
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
mShouldFilterCache.clear();
|
||||
for (int i = settings.size() - 1; i >= 0; i--) {
|
||||
updateShouldFilterCacheForPackage(
|
||||
null /*skipPackage*/, settings.valueAt(i), settings, users, i);
|
||||
SparseArray<SparseBooleanArray> cache =
|
||||
updateEntireShouldFilterCacheInner(settings, users);
|
||||
synchronized (mCacheLock) {
|
||||
mShouldFilterCache = cache;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private SparseArray<SparseBooleanArray> updateEntireShouldFilterCacheInner(
|
||||
ArrayMap<String, PackageSetting> settings, UserInfo[] users) {
|
||||
SparseArray<SparseBooleanArray> cache =
|
||||
new SparseArray<>(users.length * settings.size());
|
||||
for (int i = settings.size() - 1; i >= 0; i--) {
|
||||
updateShouldFilterCacheForPackage(cache,
|
||||
null /*skipPackage*/, settings.valueAt(i), settings, users, i);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
private void updateEntireShouldFilterCacheAsync() {
|
||||
mBackgroundExecutor.execute(() -> {
|
||||
final ArrayMap<String, PackageSetting> settingsCopy = new ArrayMap<>();
|
||||
final ArrayMap<String, AndroidPackage> packagesCache = new ArrayMap<>();
|
||||
final UserInfo[][] usersRef = new UserInfo[1][];
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
packagesCache.ensureCapacity(settings.size());
|
||||
settingsCopy.putAll(settings);
|
||||
usersRef[0] = users;
|
||||
// store away the references to the immutable packages, since settings are retained
|
||||
// during updates.
|
||||
for (int i = 0, max = settings.size(); i < max; i++) {
|
||||
final AndroidPackage pkg = settings.valueAt(i).pkg;
|
||||
packagesCache.put(settings.keyAt(i), pkg);
|
||||
}
|
||||
});
|
||||
SparseArray<SparseBooleanArray> cache =
|
||||
updateEntireShouldFilterCacheInner(settingsCopy, usersRef[0]);
|
||||
boolean[] changed = new boolean[1];
|
||||
// We have a cache, let's make sure the world hasn't changed out from under us.
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
if (settings.size() != settingsCopy.size()) {
|
||||
changed[0] = true;
|
||||
return;
|
||||
}
|
||||
for (int i = 0, max = settings.size(); i < max; i++) {
|
||||
final AndroidPackage pkg = settings.valueAt(i).pkg;
|
||||
if (!Objects.equals(pkg, packagesCache.get(settings.keyAt(i)))) {
|
||||
changed[0] = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
if (changed[0]) {
|
||||
// Something has changed, just update the cache inline with the lock held
|
||||
updateEntireShouldFilterCache();
|
||||
if (DEBUG_LOGGING) {
|
||||
Slog.i(TAG, "Rebuilding cache with lock due to package change.");
|
||||
}
|
||||
} else {
|
||||
synchronized (mCacheLock) {
|
||||
mShouldFilterCache = cache;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onUsersChanged() {
|
||||
if (mShouldFilterCache != null) {
|
||||
updateEntireShouldFilterCache();
|
||||
synchronized (mCacheLock) {
|
||||
if (mShouldFilterCache != null) {
|
||||
updateEntireShouldFilterCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateShouldFilterCacheForPackage(String packageName) {
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
updateShouldFilterCacheForPackage(null /* skipPackage */, settings.get(packageName),
|
||||
settings, users, settings.size() /*maxIndex*/);
|
||||
});
|
||||
|
||||
synchronized (mCacheLock) {
|
||||
if (mShouldFilterCache != null) {
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
updateShouldFilterCacheForPackage(mShouldFilterCache, null /* skipPackage */,
|
||||
settings.get(packageName), settings, users,
|
||||
settings.size() /*maxIndex*/);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateShouldFilterCacheForPackage(@Nullable String skipPackageName,
|
||||
PackageSetting subjectSetting, ArrayMap<String, PackageSetting> allSettings,
|
||||
UserInfo[] allUsers, int maxIndex) {
|
||||
private void updateShouldFilterCacheForPackage(SparseArray<SparseBooleanArray> cache,
|
||||
@Nullable String skipPackageName, PackageSetting subjectSetting, ArrayMap<String,
|
||||
PackageSetting> allSettings, UserInfo[] allUsers, int maxIndex) {
|
||||
for (int i = Math.min(maxIndex, allSettings.size() - 1); i >= 0; i--) {
|
||||
PackageSetting otherSetting = allSettings.valueAt(i);
|
||||
if (subjectSetting.appId == otherSetting.appId) {
|
||||
@@ -668,17 +753,17 @@ public class AppsFilter {
|
||||
for (int ou = 0; ou < userCount; ou++) {
|
||||
int otherUser = allUsers[ou].id;
|
||||
int subjectUid = UserHandle.getUid(subjectUser, subjectSetting.appId);
|
||||
if (!mShouldFilterCache.contains(subjectUid)) {
|
||||
mShouldFilterCache.put(subjectUid, new SparseBooleanArray(appxUidCount));
|
||||
if (!cache.contains(subjectUid)) {
|
||||
cache.put(subjectUid, new SparseBooleanArray(appxUidCount));
|
||||
}
|
||||
int otherUid = UserHandle.getUid(otherUser, otherSetting.appId);
|
||||
if (!mShouldFilterCache.contains(otherUid)) {
|
||||
mShouldFilterCache.put(otherUid, new SparseBooleanArray(appxUidCount));
|
||||
if (!cache.contains(otherUid)) {
|
||||
cache.put(otherUid, new SparseBooleanArray(appxUidCount));
|
||||
}
|
||||
mShouldFilterCache.get(subjectUid).put(otherUid,
|
||||
cache.get(subjectUid).put(otherUid,
|
||||
shouldFilterApplicationInternal(
|
||||
subjectUid, subjectSetting, otherSetting, otherUser));
|
||||
mShouldFilterCache.get(otherUid).put(subjectUid,
|
||||
cache.get(otherUid).put(subjectUid,
|
||||
shouldFilterApplicationInternal(
|
||||
otherUid, otherSetting, subjectSetting, subjectUser));
|
||||
}
|
||||
@@ -712,7 +797,8 @@ public class AppsFilter {
|
||||
* This method recomputes all component / intent-based visibility and is intended to match the
|
||||
* relevant logic of {@link #addPackageInternal(PackageSetting, ArrayMap)}
|
||||
*/
|
||||
private void recomputeComponentVisibility(ArrayMap<String, PackageSetting> existingSettings) {
|
||||
private void recomputeComponentVisibility(
|
||||
ArrayMap<String, PackageSetting> existingSettings) {
|
||||
mQueriesViaComponent.clear();
|
||||
for (int i = existingSettings.size() - 1; i >= 0; i--) {
|
||||
PackageSetting setting = existingSettings.valueAt(i);
|
||||
@@ -854,15 +940,17 @@ public class AppsFilter {
|
||||
}
|
||||
}
|
||||
|
||||
removeAppIdFromVisibilityCache(setting.appId);
|
||||
if (mShouldFilterCache != null && setting.sharedUser != null) {
|
||||
for (int i = setting.sharedUser.packages.size() - 1; i >= 0; i--) {
|
||||
PackageSetting siblingSetting = setting.sharedUser.packages.valueAt(i);
|
||||
if (siblingSetting == setting) {
|
||||
continue;
|
||||
synchronized (mCacheLock) {
|
||||
removeAppIdFromVisibilityCache(setting.appId);
|
||||
if (mShouldFilterCache != null && setting.sharedUser != null) {
|
||||
for (int i = setting.sharedUser.packages.size() - 1; i >= 0; i--) {
|
||||
PackageSetting siblingSetting = setting.sharedUser.packages.valueAt(i);
|
||||
if (siblingSetting == setting) {
|
||||
continue;
|
||||
}
|
||||
updateShouldFilterCacheForPackage(mShouldFilterCache, setting.name,
|
||||
siblingSetting, settings, users, settings.size());
|
||||
}
|
||||
updateShouldFilterCacheForPackage(
|
||||
setting.name, siblingSetting, settings, users, settings.size());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -888,26 +976,29 @@ public class AppsFilter {
|
||||
|| callingAppId == targetPkgSetting.appId) {
|
||||
return false;
|
||||
}
|
||||
if (mShouldFilterCache != null) { // use cache
|
||||
SparseBooleanArray shouldFilterTargets = mShouldFilterCache.get(callingUid);
|
||||
final int targetUid = UserHandle.getUid(userId, targetPkgSetting.appId);
|
||||
if (shouldFilterTargets == null) {
|
||||
Slog.wtf(TAG, "Encountered calling uid with no cached rules: " + callingUid);
|
||||
return true;
|
||||
}
|
||||
int indexOfTargetUid = shouldFilterTargets.indexOfKey(targetUid);
|
||||
if (indexOfTargetUid < 0) {
|
||||
Slog.w(TAG, "Encountered calling -> target with no cached rules: "
|
||||
+ callingUid + " -> " + targetUid);
|
||||
return true;
|
||||
}
|
||||
if (!shouldFilterTargets.valueAt(indexOfTargetUid)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!shouldFilterApplicationInternal(
|
||||
callingUid, callingSetting, targetPkgSetting, userId)) {
|
||||
return false;
|
||||
synchronized (mCacheLock) {
|
||||
if (mShouldFilterCache != null) { // use cache
|
||||
SparseBooleanArray shouldFilterTargets = mShouldFilterCache.get(callingUid);
|
||||
final int targetUid = UserHandle.getUid(userId, targetPkgSetting.appId);
|
||||
if (shouldFilterTargets == null) {
|
||||
Slog.wtf(TAG, "Encountered calling uid with no cached rules: "
|
||||
+ callingUid);
|
||||
return true;
|
||||
}
|
||||
int indexOfTargetUid = shouldFilterTargets.indexOfKey(targetUid);
|
||||
if (indexOfTargetUid < 0) {
|
||||
Slog.w(TAG, "Encountered calling -> target with no cached rules: "
|
||||
+ callingUid + " -> " + targetUid);
|
||||
return true;
|
||||
}
|
||||
if (!shouldFilterTargets.valueAt(indexOfTargetUid)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!shouldFilterApplicationInternal(
|
||||
callingUid, callingSetting, targetPkgSetting, userId)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DEBUG_LOGGING || mFeatureConfig.isLoggingEnabled(callingAppId)) {
|
||||
|
||||
@@ -72,6 +72,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Presubmit
|
||||
@RunWith(JUnit4.class)
|
||||
@@ -91,6 +92,8 @@ public class AppsFilterTest {
|
||||
AppsFilter.FeatureConfig mFeatureConfigMock;
|
||||
@Mock
|
||||
AppsFilter.StateProvider mStateProvider;
|
||||
@Mock
|
||||
Executor mMockExecutor;
|
||||
|
||||
private ArrayMap<String, PackageSetting> mExisting = new ArrayMap<>();
|
||||
|
||||
@@ -187,10 +190,15 @@ public class AppsFilterTest {
|
||||
doAnswer(invocation -> {
|
||||
((AppsFilter.StateProvider.CurrentStateCallback) invocation.getArgument(0))
|
||||
.currentState(mExisting, USER_INFO_LIST);
|
||||
return null;
|
||||
return new Object();
|
||||
}).when(mStateProvider)
|
||||
.runWithState(any(AppsFilter.StateProvider.CurrentStateCallback.class));
|
||||
|
||||
doAnswer(invocation -> {
|
||||
((Runnable) invocation.getArgument(0)).run();
|
||||
return new Object();
|
||||
}).when(mMockExecutor).execute(any(Runnable.class));
|
||||
|
||||
when(mFeatureConfigMock.isGloballyEnabled()).thenReturn(true);
|
||||
when(mFeatureConfigMock.packageIsEnabled(any(AndroidPackage.class))).thenAnswer(
|
||||
(Answer<Boolean>) invocation ->
|
||||
@@ -201,7 +209,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testSystemReadyPropogates() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
appsFilter.onSystemReady();
|
||||
verify(mFeatureConfigMock).onSystemReady();
|
||||
}
|
||||
@@ -209,7 +218,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testQueriesAction_FilterMatches() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -225,7 +235,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testQueriesProtectedAction_FilterDoesNotMatch() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
final Signature frameworkSignature = Mockito.mock(Signature.class);
|
||||
final PackageParser.SigningDetails frameworkSigningDetails =
|
||||
new PackageParser.SigningDetails(new Signature[]{frameworkSignature}, 1);
|
||||
@@ -263,7 +274,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testQueriesProvider_FilterMatches() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -280,7 +292,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testQueriesDifferentProvider_Filters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -297,7 +310,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testQueriesProviderWithSemiColon_FilterMatches() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -315,7 +329,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testQueriesAction_NoMatchingAction_Filters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -331,7 +346,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testQueriesAction_NoMatchingActionFilterLowSdk_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -351,7 +367,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testNoQueries_Filters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -367,7 +384,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testForceQueryable_SystemDoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -385,7 +403,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testForceQueryable_NonSystemFilters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -402,7 +421,7 @@ public class AppsFilterTest {
|
||||
public void testForceQueryableByDevice_SystemCaller_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{"com.some.package"},
|
||||
false, null);
|
||||
false, null, mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -420,7 +439,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testSystemSignedTarget_DoesntFilter() throws CertificateException {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
final Signature frameworkSignature = Mockito.mock(Signature.class);
|
||||
@@ -449,7 +469,7 @@ public class AppsFilterTest {
|
||||
public void testForceQueryableByDevice_NonSystemCaller_Filters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{"com.some.package"},
|
||||
false, null);
|
||||
false, null, mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -467,7 +487,7 @@ public class AppsFilterTest {
|
||||
public void testSystemQueryable_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{},
|
||||
true /* system force queryable */, null);
|
||||
true /* system force queryable */, null, mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -484,7 +504,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testQueriesPackage_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -502,7 +523,8 @@ public class AppsFilterTest {
|
||||
when(mFeatureConfigMock.packageIsEnabled(any(AndroidPackage.class)))
|
||||
.thenReturn(false);
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -518,7 +540,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testSystemUid_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -533,7 +556,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testSystemUidSecondaryUser_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -549,7 +573,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testNonSystemUid_NoCallingSetting_Filters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -563,7 +588,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testNoTargetPackage_filters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -621,7 +647,8 @@ public class AppsFilterTest {
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
});
|
||||
},
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -693,7 +720,8 @@ public class AppsFilterTest {
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
});
|
||||
},
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -718,7 +746,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testInitiatingApp_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -734,7 +763,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testUninstalledInitiatingApp_Filters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -750,7 +780,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testOriginatingApp_Filters() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -766,7 +797,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testInstallingApp_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -782,7 +814,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testInstrumentation_DoesntFilter() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -804,7 +837,8 @@ public class AppsFilterTest {
|
||||
@Test
|
||||
public void testWhoCanSee() throws Exception {
|
||||
final AppsFilter appsFilter =
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null);
|
||||
new AppsFilter(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user