Replace getCallingActivity() with getLaunchedFromPackage()
getLaunchedFromPackage() reports who launched this Activity or built
PendingIntent used to launch it, whereas getCallingActivity() reports
who will get result of Activity.
Bug: 316891059
Test: robotest, manual
Change-Id: If97018c2741caef622f0596bbfeaa42ef1788b78
Merged-In: If97018c2741caef622f0596bbfeaa42ef1788b78
(cherry picked from commit ddc11bc03a
)
This commit is contained in:
@@ -20,7 +20,6 @@ package com.android.settings.search;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
@@ -127,20 +126,22 @@ public class SearchFeatureProviderImplTest {
|
||||
|
||||
@Test(expected = SecurityException.class)
|
||||
public void verifyLaunchSearchResultPageCaller_badCaller_shouldCrash() {
|
||||
final ComponentName cn = new ComponentName("pkg", "class");
|
||||
mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
|
||||
final String packageName = "pkg";
|
||||
|
||||
mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyLaunchSearchResultPageCaller_settingsCaller_shouldNotCrash() {
|
||||
final ComponentName cn = new ComponentName(mActivity.getPackageName(), "class");
|
||||
mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
|
||||
final String packageName = mActivity.getPackageName();
|
||||
|
||||
mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyLaunchSearchResultPageCaller_settingsIntelligenceCaller_shouldNotCrash() {
|
||||
final String packageName = mProvider.getSettingsIntelligencePkgName(mActivity);
|
||||
final ComponentName cn = new ComponentName(packageName, "class");
|
||||
mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
|
||||
|
||||
mProvider.verifyLaunchSearchResultPageCaller(mActivity, packageName);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user