Files
app_Settings/src/com/android/settings/search/SearchFeatureProviderImpl.java
Fan Zhang 7431c91de6 Remove search indexing pipeline from Settings
Index is already handled by SettingsIntelligenec. No longer needed in
Settings.

Change-Id: Id43fb3100dc2759185744441cff8cb9cd2d2da20
Fixes: 69808376
Test: robotests
2018-06-21 09:38:36 -07:00

66 lines
2.4 KiB
Java

/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.android.settings.search;
import android.content.ComponentName;
import android.content.Context;
import android.text.TextUtils;
import com.android.settingslib.search.SearchIndexableResources;
import com.android.settingslib.search.SearchIndexableResourcesMobile;
/**
* FeatureProvider for the refactored search code.
*/
public class SearchFeatureProviderImpl implements SearchFeatureProvider {
private static final String TAG = "SearchFeatureProvider";
private SearchIndexableResources mSearchIndexableResources;
@Override
public void verifyLaunchSearchResultPageCaller(Context context, ComponentName caller) {
if (caller == null) {
throw new IllegalArgumentException("ExternalSettingsTrampoline intents "
+ "must be called with startActivityForResult");
}
final String packageName = caller.getPackageName();
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
public SearchIndexableResources getSearchIndexableResources() {
if (mSearchIndexableResources == null) {
mSearchIndexableResources = new SearchIndexableResourcesMobile();
}
return mSearchIndexableResources;
}
protected boolean isSignatureWhitelisted(Context context, String callerPackage) {
return false;
}
}