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.Manifest;
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.app.AppGlobals;
|
|
||||||
import android.app.KeyguardManager;
|
import android.app.KeyguardManager;
|
||||||
import android.app.admin.DevicePolicyManagerInternal;
|
import android.app.admin.DevicePolicyManagerInternal;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -342,9 +341,9 @@ class ActivityStartInterceptor {
|
|||||||
private boolean interceptHarmfulAppIfNeeded() {
|
private boolean interceptHarmfulAppIfNeeded() {
|
||||||
CharSequence harmfulAppWarning;
|
CharSequence harmfulAppWarning;
|
||||||
try {
|
try {
|
||||||
harmfulAppWarning = AppGlobals.getPackageManager().getHarmfulAppWarning(
|
harmfulAppWarning = mService.getPackageManager()
|
||||||
mAInfo.packageName, mUserId);
|
.getHarmfulAppWarning(mAInfo.packageName, mUserId);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import android.testing.DexmakerShareClassLoaderRule;
|
|||||||
|
|
||||||
import com.android.internal.app.UnlaunchableAppActivity;
|
import com.android.internal.app.UnlaunchableAppActivity;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
|
import com.android.server.pm.PackageManagerService;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -90,6 +91,8 @@ public class ActivityStartInterceptorTest {
|
|||||||
private UserController mUserController;
|
private UserController mUserController;
|
||||||
@Mock
|
@Mock
|
||||||
private KeyguardManager mKeyguardManager;
|
private KeyguardManager mKeyguardManager;
|
||||||
|
@Mock
|
||||||
|
private PackageManagerService mPackageManager;
|
||||||
|
|
||||||
private ActivityStartInterceptor mInterceptor;
|
private ActivityStartInterceptor mInterceptor;
|
||||||
private ActivityInfo mAInfo = new ActivityInfo();
|
private ActivityInfo mAInfo = new ActivityInfo();
|
||||||
@@ -121,6 +124,11 @@ public class ActivityStartInterceptorTest {
|
|||||||
nullable(CharSequence.class), nullable(CharSequence.class), eq(TEST_USER_ID))).
|
nullable(CharSequence.class), nullable(CharSequence.class), eq(TEST_USER_ID))).
|
||||||
thenReturn(CONFIRM_CREDENTIALS_INTENT);
|
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
|
// Initialise activity info
|
||||||
mAInfo.applicationInfo = new ApplicationInfo();
|
mAInfo.applicationInfo = new ApplicationInfo();
|
||||||
mAInfo.packageName = mAInfo.applicationInfo.packageName = TEST_PACKAGE_NAME;
|
mAInfo.packageName = mAInfo.applicationInfo.packageName = TEST_PACKAGE_NAME;
|
||||||
|
|||||||
Reference in New Issue
Block a user