Merge changes from topic "presubmit-am-d2fb8e1cab9f469d997bbe6f898c6870" into tm-mainline-prod
* changes:
[automerge] Fix NPE in AppsFilter 2p: dd2636a4f8
Fix NPE in AppsFilter
This commit is contained in:
committed by
Android (Google) Code Review
commit
a439a9a9e9
@@ -76,6 +76,7 @@ import com.android.server.utils.Watcher;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
@@ -173,7 +174,6 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
private final FeatureConfig mFeatureConfig;
|
||||
private final OverlayReferenceMapper mOverlayReferenceMapper;
|
||||
private final StateProvider mStateProvider;
|
||||
private final PackageManagerInternal mPmInternal;
|
||||
private SigningDetails mSystemSigningDetails;
|
||||
|
||||
@Watched
|
||||
@@ -284,15 +284,13 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
String[] forceQueryableList,
|
||||
boolean systemAppsQueryable,
|
||||
@Nullable OverlayReferenceMapper.Provider overlayProvider,
|
||||
Executor backgroundExecutor,
|
||||
PackageManagerInternal pmInternal) {
|
||||
Executor backgroundExecutor) {
|
||||
mFeatureConfig = featureConfig;
|
||||
mForceQueryableByDevicePackageNames = forceQueryableList;
|
||||
mSystemAppsQueryable = systemAppsQueryable;
|
||||
mOverlayReferenceMapper = new OverlayReferenceMapper(true /*deferRebuild*/,
|
||||
overlayProvider);
|
||||
mStateProvider = stateProvider;
|
||||
mPmInternal = pmInternal;
|
||||
mBackgroundExecutor = backgroundExecutor;
|
||||
mShouldFilterCache = new WatchedSparseBooleanMatrix();
|
||||
mShouldFilterCacheSnapshot = new SnapshotCache.Auto<>(
|
||||
@@ -359,7 +357,6 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
}
|
||||
|
||||
mBackgroundExecutor = null;
|
||||
mPmInternal = null;
|
||||
mSnapshot = new SnapshotCache.Sealed<>();
|
||||
mSystemReady = true;
|
||||
}
|
||||
@@ -397,6 +394,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
|
||||
interface CurrentStateCallback {
|
||||
void currentState(ArrayMap<String, ? extends PackageStateInternal> settings,
|
||||
Collection<SharedUserSetting> sharedUserSettings,
|
||||
UserInfo[] users);
|
||||
}
|
||||
}
|
||||
@@ -588,12 +586,13 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
final StateProvider stateProvider = command -> {
|
||||
synchronized (injector.getLock()) {
|
||||
command.currentState(injector.getSettings().getPackagesLocked().untrackedStorage(),
|
||||
injector.getSettings().getAllSharedUsersLPw(),
|
||||
injector.getUserManagerInternal().getUserInfos());
|
||||
}
|
||||
};
|
||||
AppsFilterImpl appsFilter = new AppsFilterImpl(stateProvider, featureConfig,
|
||||
forcedQueryablePackageNames, forceSystemAppsQueryable, null,
|
||||
injector.getBackgroundExecutor(), pmInt);
|
||||
injector.getBackgroundExecutor());
|
||||
featureConfig.setAppsFilter(appsFilter);
|
||||
return appsFilter;
|
||||
}
|
||||
@@ -788,7 +787,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
// let's first remove any prior rules for this package
|
||||
removePackage(newPkgSetting, true /*isReplace*/);
|
||||
}
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
mStateProvider.runWithState((settings, sharedUserSettings, users) -> {
|
||||
ArraySet<String> additionalChangedPackages =
|
||||
addPackageInternal(newPkgSetting, settings);
|
||||
if (mSystemReady) {
|
||||
@@ -806,9 +805,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
continue;
|
||||
}
|
||||
|
||||
updateShouldFilterCacheForPackage(null,
|
||||
changedPkgSetting, settings, users, USER_ALL,
|
||||
settings.size());
|
||||
updateShouldFilterCacheForPackage(null, changedPkgSetting,
|
||||
settings, users, USER_ALL, settings.size());
|
||||
}
|
||||
}
|
||||
} // else, rebuild entire cache when system is ready
|
||||
@@ -954,7 +952,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
}
|
||||
|
||||
private void updateEntireShouldFilterCache(int subjectUserId) {
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
mStateProvider.runWithState((settings, sharedUserSettings, users) -> {
|
||||
int userId = USER_NULL;
|
||||
for (int u = 0; u < users.length; u++) {
|
||||
if (subjectUserId == users[u].id) {
|
||||
@@ -972,7 +970,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
}
|
||||
|
||||
private void updateEntireShouldFilterCacheInner(
|
||||
ArrayMap<String, ? extends PackageStateInternal> settings, UserInfo[] users,
|
||||
ArrayMap<String, ? extends PackageStateInternal> settings,
|
||||
UserInfo[] users,
|
||||
int subjectUserId) {
|
||||
synchronized (mCacheLock) {
|
||||
if (subjectUserId == USER_ALL) {
|
||||
@@ -982,16 +981,19 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
}
|
||||
for (int i = settings.size() - 1; i >= 0; i--) {
|
||||
updateShouldFilterCacheForPackage(
|
||||
null /*skipPackage*/, settings.valueAt(i), settings, users, subjectUserId, i);
|
||||
null /*skipPackage*/, settings.valueAt(i), settings, users,
|
||||
subjectUserId, i);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEntireShouldFilterCacheAsync() {
|
||||
mBackgroundExecutor.execute(() -> {
|
||||
final ArrayMap<String, PackageStateInternal> settingsCopy = new ArrayMap<>();
|
||||
final Collection<SharedUserSetting> sharedUserSettingsCopy =
|
||||
new ArraySet<SharedUserSetting>();
|
||||
final ArrayMap<String, AndroidPackage> packagesCache = new ArrayMap<>();
|
||||
final UserInfo[][] usersRef = new UserInfo[1][];
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
mStateProvider.runWithState((settings, sharedUserSettings, users) -> {
|
||||
packagesCache.ensureCapacity(settings.size());
|
||||
settingsCopy.putAll(settings);
|
||||
usersRef[0] = users;
|
||||
@@ -1001,11 +1003,12 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
final AndroidPackage pkg = settings.valueAt(i).getPkg();
|
||||
packagesCache.put(settings.keyAt(i), pkg);
|
||||
}
|
||||
sharedUserSettingsCopy.addAll(sharedUserSettings);
|
||||
});
|
||||
|
||||
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) -> {
|
||||
mStateProvider.runWithState((settings, sharedUserSettings, users) -> {
|
||||
if (settings.size() != settingsCopy.size()) {
|
||||
changed[0] = true;
|
||||
return;
|
||||
@@ -1025,7 +1028,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
Slog.i(TAG, "Rebuilding cache with lock due to package change.");
|
||||
}
|
||||
} else {
|
||||
updateEntireShouldFilterCacheInner(settingsCopy, usersRef[0], USER_ALL);
|
||||
updateEntireShouldFilterCacheInner(settingsCopy,
|
||||
usersRef[0], USER_ALL);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1047,7 +1051,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
}
|
||||
|
||||
private void updateShouldFilterCacheForPackage(String packageName) {
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
mStateProvider.runWithState((settings, sharedUserSettings, users) -> {
|
||||
if (!mSystemReady) {
|
||||
return;
|
||||
}
|
||||
@@ -1249,7 +1253,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
* @param isReplace if the package is being replaced.
|
||||
*/
|
||||
public void removePackage(PackageStateInternal setting, boolean isReplace) {
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
mStateProvider.runWithState((settings, sharedUserSettings, users) -> {
|
||||
final ArraySet<String> additionalChangedPackages;
|
||||
final int userCount = users.length;
|
||||
for (int u = 0; u < userCount; u++) {
|
||||
@@ -1314,8 +1318,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
// update the
|
||||
// cache
|
||||
if (setting.hasSharedUser()) {
|
||||
final ArraySet<PackageStateInternal> sharedUserPackages =
|
||||
mPmInternal.getSharedUserPackages(setting.getSharedUserAppId());
|
||||
final ArraySet<? extends PackageStateInternal> sharedUserPackages =
|
||||
getSharedUserPackages(setting.getSharedUserAppId(), sharedUserSettings);
|
||||
for (int i = sharedUserPackages.size() - 1; i >= 0; i--) {
|
||||
if (sharedUserPackages.valueAt(i) == setting) {
|
||||
continue;
|
||||
@@ -1327,8 +1331,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
|
||||
removeAppIdFromVisibilityCache(setting.getAppId());
|
||||
if (mSystemReady && setting.hasSharedUser()) {
|
||||
final ArraySet<PackageStateInternal> sharedUserPackages =
|
||||
mPmInternal.getSharedUserPackages(setting.getSharedUserAppId());
|
||||
final ArraySet<? extends PackageStateInternal> sharedUserPackages =
|
||||
getSharedUserPackages(setting.getSharedUserAppId(), sharedUserSettings);
|
||||
for (int i = sharedUserPackages.size() - 1; i >= 0; i--) {
|
||||
PackageStateInternal siblingSetting =
|
||||
sharedUserPackages.valueAt(i);
|
||||
@@ -1336,8 +1340,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
continue;
|
||||
}
|
||||
updateShouldFilterCacheForPackage(
|
||||
setting.getPackageName(), siblingSetting, settings, users,
|
||||
USER_ALL, settings.size());
|
||||
setting.getPackageName(), siblingSetting, settings,
|
||||
users, USER_ALL, settings.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1353,8 +1357,8 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
continue;
|
||||
}
|
||||
|
||||
updateShouldFilterCacheForPackage(null,
|
||||
changedPkgSetting, settings, users, USER_ALL, settings.size());
|
||||
updateShouldFilterCacheForPackage(null, changedPkgSetting,
|
||||
settings, users, USER_ALL, settings.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1363,6 +1367,17 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
});
|
||||
}
|
||||
|
||||
private ArraySet<? extends PackageStateInternal> getSharedUserPackages(int sharedUserAppId,
|
||||
Collection<SharedUserSetting> sharedUserSettings) {
|
||||
for (SharedUserSetting setting : sharedUserSettings) {
|
||||
if (setting.mAppId != sharedUserAppId) {
|
||||
continue;
|
||||
}
|
||||
return setting.getPackageStates();
|
||||
}
|
||||
return new ArraySet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* See
|
||||
* {@link AppsFilterSnapshot#shouldFilterApplication(int, Object, PackageStateInternal,
|
||||
@@ -1441,23 +1456,25 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
return true;
|
||||
}
|
||||
final PackageStateInternal callingPkgSetting;
|
||||
final ArraySet<? extends PackageStateInternal> callingSharedPkgSettings;
|
||||
if (DEBUG_TRACING) {
|
||||
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "callingSetting instanceof");
|
||||
}
|
||||
final ArraySet<PackageStateInternal> callingSharedPkgSettings = new ArraySet<>();
|
||||
|
||||
if (callingSetting instanceof PackageStateInternal) {
|
||||
final PackageStateInternal packageState = (PackageStateInternal) callingSetting;
|
||||
if (packageState.hasSharedUser()) {
|
||||
callingPkgSetting = null;
|
||||
callingSharedPkgSettings = mPmInternal.getSharedUserPackages(
|
||||
packageState.getSharedUserAppId());
|
||||
mStateProvider.runWithState((settings, sharedUserSettings, users) ->
|
||||
callingSharedPkgSettings.addAll(getSharedUserPackages(
|
||||
packageState.getSharedUserAppId(), sharedUserSettings)));
|
||||
} else {
|
||||
callingPkgSetting = packageState;
|
||||
callingSharedPkgSettings = null;
|
||||
}
|
||||
} else {
|
||||
callingPkgSetting = null;
|
||||
callingSharedPkgSettings = ((SharedUserSetting) callingSetting).getPackageStates();
|
||||
callingSharedPkgSettings.addAll(
|
||||
((SharedUserSetting) callingSetting).getPackageStates());
|
||||
}
|
||||
if (DEBUG_TRACING) {
|
||||
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
|
||||
@@ -1576,7 +1593,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mQueriesViaComponent");
|
||||
}
|
||||
if (mQueriesViaComponentRequireRecompute) {
|
||||
mStateProvider.runWithState((settings, users) -> {
|
||||
mStateProvider.runWithState((settings, sharedUserSettings, users) -> {
|
||||
recomputeComponentVisibility(settings);
|
||||
});
|
||||
}
|
||||
@@ -1632,7 +1649,7 @@ public class AppsFilterImpl implements AppsFilterSnapshot, Watchable, Snappable
|
||||
Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "mOverlayReferenceMapper");
|
||||
}
|
||||
final String targetName = targetPkg.getPackageName();
|
||||
if (callingSharedPkgSettings != null) {
|
||||
if (!callingSharedPkgSettings.isEmpty()) {
|
||||
int size = callingSharedPkgSettings.size();
|
||||
for (int index = 0; index < size; index++) {
|
||||
PackageStateInternal pkgSetting = callingSharedPkgSettings.valueAt(index);
|
||||
|
||||
@@ -30,7 +30,6 @@ import android.annotation.Nullable;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManagerInternal;
|
||||
import android.content.pm.Signature;
|
||||
import android.content.pm.SigningDetails;
|
||||
import android.content.pm.UserInfo;
|
||||
@@ -48,7 +47,6 @@ import com.android.server.om.OverlayReferenceMapper;
|
||||
import com.android.server.pm.parsing.pkg.AndroidPackage;
|
||||
import com.android.server.pm.parsing.pkg.PackageImpl;
|
||||
import com.android.server.pm.parsing.pkg.ParsedPackage;
|
||||
import com.android.server.pm.pkg.PackageStateInternal;
|
||||
import com.android.server.pm.pkg.component.ParsedActivity;
|
||||
import com.android.server.pm.pkg.component.ParsedActivityImpl;
|
||||
import com.android.server.pm.pkg.component.ParsedInstrumentationImpl;
|
||||
@@ -69,6 +67,7 @@ import org.mockito.stubbing.Answer;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -103,10 +102,9 @@ public class AppsFilterImplTest {
|
||||
AppsFilterImpl.StateProvider mStateProvider;
|
||||
@Mock
|
||||
Executor mMockExecutor;
|
||||
@Mock
|
||||
PackageManagerInternal mMockPmInternal;
|
||||
|
||||
private ArrayMap<String, PackageSetting> mExisting = new ArrayMap<>();
|
||||
private Collection<SharedUserSetting> mSharedUserSettings = new ArraySet<>();
|
||||
|
||||
private static ParsingPackage pkg(String packageName) {
|
||||
return PackageImpl.forTesting(packageName)
|
||||
@@ -205,7 +203,7 @@ public class AppsFilterImplTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
doAnswer(invocation -> {
|
||||
((AppsFilterImpl.StateProvider.CurrentStateCallback) invocation.getArgument(0))
|
||||
.currentState(mExisting, USER_INFO_LIST);
|
||||
.currentState(mExisting, mSharedUserSettings, USER_INFO_LIST);
|
||||
return new Object();
|
||||
}).when(mStateProvider)
|
||||
.runWithState(any(AppsFilterImpl.StateProvider.CurrentStateCallback.class));
|
||||
@@ -226,7 +224,7 @@ public class AppsFilterImplTest {
|
||||
public void testSystemReadyPropogates() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
appsFilter.onSystemReady();
|
||||
@@ -238,7 +236,7 @@ public class AppsFilterImplTest {
|
||||
public void testQueriesAction_FilterMatches() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
@@ -261,7 +259,7 @@ public class AppsFilterImplTest {
|
||||
public void testQueriesProtectedAction_FilterDoesNotMatch() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
final Signature frameworkSignature = Mockito.mock(Signature.class);
|
||||
@@ -310,7 +308,7 @@ public class AppsFilterImplTest {
|
||||
public void testQueriesProvider_FilterMatches() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
@@ -335,7 +333,7 @@ public class AppsFilterImplTest {
|
||||
public void testOnUserUpdated_FilterMatches() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
|
||||
appsFilter.onSystemReady();
|
||||
@@ -357,7 +355,7 @@ public class AppsFilterImplTest {
|
||||
// adds new user
|
||||
doAnswer(invocation -> {
|
||||
((AppsFilterImpl.StateProvider.CurrentStateCallback) invocation.getArgument(0))
|
||||
.currentState(mExisting, USER_INFO_LIST_WITH_ADDED);
|
||||
.currentState(mExisting, mSharedUserSettings, USER_INFO_LIST_WITH_ADDED);
|
||||
return new Object();
|
||||
}).when(mStateProvider)
|
||||
.runWithState(any(AppsFilterImpl.StateProvider.CurrentStateCallback.class));
|
||||
@@ -374,7 +372,7 @@ public class AppsFilterImplTest {
|
||||
// delete user
|
||||
doAnswer(invocation -> {
|
||||
((AppsFilterImpl.StateProvider.CurrentStateCallback) invocation.getArgument(0))
|
||||
.currentState(mExisting, USER_INFO_LIST);
|
||||
.currentState(mExisting, mSharedUserSettings, USER_INFO_LIST);
|
||||
return new Object();
|
||||
}).when(mStateProvider)
|
||||
.runWithState(any(AppsFilterImpl.StateProvider.CurrentStateCallback.class));
|
||||
@@ -393,7 +391,7 @@ public class AppsFilterImplTest {
|
||||
public void testQueriesDifferentProvider_Filters() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
@@ -418,7 +416,7 @@ public class AppsFilterImplTest {
|
||||
public void testQueriesProviderWithSemiColon_FilterMatches() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -437,7 +435,7 @@ public class AppsFilterImplTest {
|
||||
public void testQueriesAction_NoMatchingAction_Filters() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -454,7 +452,7 @@ public class AppsFilterImplTest {
|
||||
public void testQueriesAction_NoMatchingActionFilterLowSdk_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -475,7 +473,7 @@ public class AppsFilterImplTest {
|
||||
public void testNoQueries_Filters() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -492,7 +490,7 @@ public class AppsFilterImplTest {
|
||||
public void testNoUsesLibrary_Filters() throws Exception {
|
||||
final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock,
|
||||
new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
@@ -518,7 +516,7 @@ public class AppsFilterImplTest {
|
||||
public void testUsesLibrary_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock,
|
||||
new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
@@ -545,7 +543,7 @@ public class AppsFilterImplTest {
|
||||
public void testUsesOptionalLibrary_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock,
|
||||
new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
@@ -572,7 +570,7 @@ public class AppsFilterImplTest {
|
||||
public void testUsesLibrary_ShareUid_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter = new AppsFilterImpl(mStateProvider, mFeatureConfigMock,
|
||||
new String[]{}, /* systemAppsQueryable */ false, /* overlayProvider */ null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
@@ -604,7 +602,7 @@ public class AppsFilterImplTest {
|
||||
public void testForceQueryable_SystemDoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -623,7 +621,7 @@ public class AppsFilterImplTest {
|
||||
public void testForceQueryable_NonSystemFilters() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -641,7 +639,7 @@ public class AppsFilterImplTest {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock,
|
||||
new String[]{"com.some.package"}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -660,7 +658,7 @@ public class AppsFilterImplTest {
|
||||
public void testSystemSignedTarget_DoesntFilter() throws CertificateException {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
final Signature frameworkSignature = Mockito.mock(Signature.class);
|
||||
@@ -690,7 +688,7 @@ public class AppsFilterImplTest {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock,
|
||||
new String[]{"com.some.package"}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -708,8 +706,7 @@ public class AppsFilterImplTest {
|
||||
public void testSystemQueryable_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{},
|
||||
true /* system force queryable */, null, mMockExecutor,
|
||||
mMockPmInternal);
|
||||
true /* system force queryable */, null, mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -727,7 +724,7 @@ public class AppsFilterImplTest {
|
||||
public void testQueriesPackage_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -746,7 +743,7 @@ public class AppsFilterImplTest {
|
||||
.thenReturn(false);
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -763,7 +760,7 @@ public class AppsFilterImplTest {
|
||||
public void testSystemUid_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -779,7 +776,7 @@ public class AppsFilterImplTest {
|
||||
public void testSystemUidSecondaryUser_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -796,7 +793,7 @@ public class AppsFilterImplTest {
|
||||
public void testNonSystemUid_NoCallingSetting_Filters() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -811,7 +808,7 @@ public class AppsFilterImplTest {
|
||||
public void testNoTargetPackage_filters() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -869,7 +866,7 @@ public class AppsFilterImplTest {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
},
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -925,16 +922,11 @@ public class AppsFilterImplTest {
|
||||
.setOverlayTargetOverlayableName("overlayableName");
|
||||
ParsingPackage actorOne = pkg("com.some.package.actor.one");
|
||||
ParsingPackage actorTwo = pkg("com.some.package.actor.two");
|
||||
ArraySet<PackageStateInternal> actorSharedSettingPackages = new ArraySet<>();
|
||||
PackageSetting ps1 = getPackageSettingFromParsingPackage(actorOne, DUMMY_ACTOR_APPID,
|
||||
null /*settingBuilder*/);
|
||||
PackageSetting ps2 = getPackageSettingFromParsingPackage(actorTwo, DUMMY_ACTOR_APPID,
|
||||
null /*settingBuilder*/);
|
||||
actorSharedSettingPackages.add(ps1);
|
||||
actorSharedSettingPackages.add(ps2);
|
||||
when(mMockPmInternal.getSharedUserPackages(any(Integer.class))).thenReturn(
|
||||
actorSharedSettingPackages
|
||||
);
|
||||
|
||||
final AppsFilterImpl appsFilter = new AppsFilterImpl(
|
||||
mStateProvider,
|
||||
mFeatureConfigMock,
|
||||
@@ -965,7 +957,7 @@ public class AppsFilterImplTest {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
},
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -989,7 +981,7 @@ public class AppsFilterImplTest {
|
||||
public void testInitiatingApp_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -1007,7 +999,7 @@ public class AppsFilterImplTest {
|
||||
public void testUninstalledInitiatingApp_Filters() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -1025,7 +1017,7 @@ public class AppsFilterImplTest {
|
||||
public void testOriginatingApp_Filters() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
@@ -1050,7 +1042,7 @@ public class AppsFilterImplTest {
|
||||
public void testInstallingApp_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
@@ -1075,7 +1067,7 @@ public class AppsFilterImplTest {
|
||||
public void testInstrumentation_DoesntFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
@@ -1104,7 +1096,7 @@ public class AppsFilterImplTest {
|
||||
public void testWhoCanSee() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
@@ -1177,7 +1169,7 @@ public class AppsFilterImplTest {
|
||||
public void testOnChangeReport() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange");
|
||||
watcher.register();
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
@@ -1250,7 +1242,7 @@ public class AppsFilterImplTest {
|
||||
public void testOnChangeReportedFilter() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
final WatchableTester watcher = new WatchableTester(appsFilter, "onChange filter");
|
||||
@@ -1276,7 +1268,7 @@ public class AppsFilterImplTest {
|
||||
public void testAppsFilterRead() throws Exception {
|
||||
final AppsFilterImpl appsFilter =
|
||||
new AppsFilterImpl(mStateProvider, mFeatureConfigMock, new String[]{}, false, null,
|
||||
mMockExecutor, mMockPmInternal);
|
||||
mMockExecutor);
|
||||
simulateAddBasicAndroid(appsFilter);
|
||||
appsFilter.onSystemReady();
|
||||
|
||||
@@ -1379,6 +1371,7 @@ public class AppsFilterImplTest {
|
||||
if (sharedUserSetting != null) {
|
||||
sharedUserSetting.addPackage(setting);
|
||||
setting.setSharedUserAppId(sharedUserSetting.mAppId);
|
||||
mSharedUserSettings.add(sharedUserSetting);
|
||||
}
|
||||
filter.addPackage(setting);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user