Allow SettingsIntelligence to access SearchResultTrampoline
Bug: 64938328 Test: robotests Change-Id: I89b0b8adf1e034f0fc57a3991fb56452a7210219
This commit is contained in:
@@ -37,11 +37,6 @@ import java.util.concurrent.FutureTask;
|
||||
*/
|
||||
public interface SearchFeatureProvider {
|
||||
|
||||
/**
|
||||
* @return true to use the new version of search
|
||||
*/
|
||||
boolean isEnabled(Context context);
|
||||
|
||||
/**
|
||||
* Ensures the caller has necessary privilege to launch search result page.
|
||||
*
|
||||
|
@@ -40,16 +40,10 @@ public class SearchFeatureProviderImpl implements SearchFeatureProvider {
|
||||
private static final String TAG = "SearchFeatureProvider";
|
||||
|
||||
private static final String METRICS_ACTION_SETTINGS_INDEX = "search_synchronous_indexing";
|
||||
|
||||
private DatabaseIndexingManager mDatabaseIndexingManager;
|
||||
private SiteMapManager mSiteMapManager;
|
||||
private ExecutorService mExecutorService;
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Context context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verifyLaunchSearchResultPageCaller(Context context, ComponentName caller) {
|
||||
if (caller == null) {
|
||||
@@ -57,9 +51,15 @@ public class SearchFeatureProviderImpl implements SearchFeatureProvider {
|
||||
+ "must be called with startActivityForResult");
|
||||
}
|
||||
final String packageName = caller.getPackageName();
|
||||
if (!TextUtils.equals(packageName, context.getPackageName())) {
|
||||
throw new SecurityException("Only Settings app can launch search result page");
|
||||
final boolean isSettingsPackage = TextUtils.equals(packageName, context.getPackageName())
|
||||
|| TextUtils.equals(getSettingsIntelligencePkgName(), packageName);
|
||||
final boolean isWhitelistedPackage =
|
||||
isSignatureWhitelisted(context, caller.getPackageName());
|
||||
if (isSettingsPackage || isWhitelistedPackage) {
|
||||
return;
|
||||
}
|
||||
throw new SecurityException("Search result intents must be called with from a "
|
||||
+ "whitelisted package.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,6 +141,14 @@ public class SearchFeatureProviderImpl implements SearchFeatureProvider {
|
||||
return mExecutorService;
|
||||
}
|
||||
|
||||
protected boolean isSignatureWhitelisted(Context context, String callerPackage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String getSettingsIntelligencePkgName() {
|
||||
return "com.android.settings.intelligence";
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic method to make the query suitable for searching the database.
|
||||
*
|
||||
|
@@ -140,11 +140,18 @@ public class SearchFeatureProviderImplTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyLaunchSearchResultPageCaller_goodCaller_shouldNotCrash() {
|
||||
public void verifyLaunchSearchResultPageCaller_settingsCaller_shouldNotCrash() {
|
||||
final ComponentName cn = new ComponentName(mActivity.getPackageName(), "class");
|
||||
mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyLaunchSearchResultPageCaller_settingsIntelligenceCaller_shouldNotCrash() {
|
||||
final ComponentName cn =
|
||||
new ComponentName(mProvider.getSettingsIntelligencePkgName(), "class");
|
||||
mProvider.verifyLaunchSearchResultPageCaller(mActivity, cn);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cleanQuery_trimsWhitespace() {
|
||||
final String query = " space ";
|
||||
|
Reference in New Issue
Block a user