Merge "Fix ActivityStartInterceptor tests" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
01a7dfa37b
@@ -36,7 +36,6 @@ import static com.android.server.pm.PackageManagerService.PLATFORM_PACKAGE_NAME;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.admin.DevicePolicyManagerInternal;
|
||||
import android.content.Context;
|
||||
@@ -342,9 +341,9 @@ class ActivityStartInterceptor {
|
||||
private boolean interceptHarmfulAppIfNeeded() {
|
||||
CharSequence harmfulAppWarning;
|
||||
try {
|
||||
harmfulAppWarning = AppGlobals.getPackageManager().getHarmfulAppWarning(
|
||||
mAInfo.packageName, mUserId);
|
||||
} catch (RemoteException e) {
|
||||
harmfulAppWarning = mService.getPackageManager()
|
||||
.getHarmfulAppWarning(mAInfo.packageName, mUserId);
|
||||
} catch (RemoteException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import android.testing.DexmakerShareClassLoaderRule;
|
||||
|
||||
import com.android.internal.app.UnlaunchableAppActivity;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.pm.PackageManagerService;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -90,6 +91,8 @@ public class ActivityStartInterceptorTest {
|
||||
private UserController mUserController;
|
||||
@Mock
|
||||
private KeyguardManager mKeyguardManager;
|
||||
@Mock
|
||||
private PackageManagerService mPackageManager;
|
||||
|
||||
private ActivityStartInterceptor mInterceptor;
|
||||
private ActivityInfo mAInfo = new ActivityInfo();
|
||||
@@ -121,6 +124,11 @@ public class ActivityStartInterceptorTest {
|
||||
nullable(CharSequence.class), nullable(CharSequence.class), eq(TEST_USER_ID))).
|
||||
thenReturn(CONFIRM_CREDENTIALS_INTENT);
|
||||
|
||||
// Mock PackageManager
|
||||
when(mService.getPackageManager()).thenReturn(mPackageManager);
|
||||
when(mPackageManager.getHarmfulAppWarning(TEST_PACKAGE_NAME, TEST_USER_ID))
|
||||
.thenReturn(null);
|
||||
|
||||
// Initialise activity info
|
||||
mAInfo.applicationInfo = new ApplicationInfo();
|
||||
mAInfo.packageName = mAInfo.applicationInfo.packageName = TEST_PACKAGE_NAME;
|
||||
|
||||
Reference in New Issue
Block a user