fix: 首次提交
This commit is contained in:
24
SettingsLib/SearchProvider/Android.bp
Normal file
24
SettingsLib/SearchProvider/Android.bp
Normal file
@@ -0,0 +1,24 @@
|
||||
package {
|
||||
// See: http://go/android-license-faq
|
||||
// A large-scale-change added 'default_applicable_licenses' to import
|
||||
// all of the 'license_kinds' from "frameworks_base_license"
|
||||
// to get the below license kinds:
|
||||
// SPDX-license-identifier-Apache-2.0
|
||||
default_applicable_licenses: ["frameworks_base_license"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "SettingsLibSearchProvider",
|
||||
use_resource_processor: true,
|
||||
defaults: [
|
||||
"SettingsLintDefaults",
|
||||
],
|
||||
|
||||
srcs: ["src/**/*.java"],
|
||||
|
||||
sdk_version: "system_current",
|
||||
min_sdk_version: "21",
|
||||
lint: {
|
||||
baseline_filename: "lint-baseline.xml",
|
||||
},
|
||||
}
|
||||
23
SettingsLib/SearchProvider/AndroidManifest.xml
Normal file
23
SettingsLib/SearchProvider/AndroidManifest.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2019 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
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.settingslib.search.provider">
|
||||
|
||||
<uses-sdk android:minSdkVersion="21" />
|
||||
|
||||
</manifest>
|
||||
136
SettingsLib/SearchProvider/lint-baseline.xml
Normal file
136
SettingsLib/SearchProvider/lint-baseline.xml
Normal file
@@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<issues format="6" by="lint 8.4.0-alpha01" type="baseline" client="" dependencies="true" name="" variant="all" version="8.4.0-alpha01">
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Class requires API level 23 (current min is 21): `android.provider.SearchIndexablesProvider`"
|
||||
errorLine1="public abstract class SettingsXmlIndexProvider extends SearchIndexablesProvider {"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="34"
|
||||
column="56"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexablesContract#INDEXABLES_XML_RES_COLUMNS`"
|
||||
errorLine1=" final MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="45"
|
||||
column="54"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexableData#rank`"
|
||||
errorLine1=" .add(XmlResource.COLUMN_RANK, indexableResource.rank)"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="50"
|
||||
column="51"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexableResource#xmlResId`"
|
||||
errorLine1=" .add(XmlResource.COLUMN_XML_RESID, indexableResource.xmlResId)"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="51"
|
||||
column="56"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexableData#className`"
|
||||
errorLine1=" .add(XmlResource.COLUMN_CLASS_NAME, indexableResource.className)"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="52"
|
||||
column="57"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexableData#intentAction`"
|
||||
errorLine1=" .add(XmlResource.COLUMN_INTENT_ACTION, indexableResource.intentAction)"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="53"
|
||||
column="60"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexableData#intentTargetClass`"
|
||||
errorLine1=" indexableResource.intentTargetClass);"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="56"
|
||||
column="29"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Class requires API level 23 (current min is 21): `android.provider.SearchIndexableResource`"
|
||||
errorLine1=" public static final class SearchIndexableIntentResource extends SearchIndexableResource {"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="97"
|
||||
column="69"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Call requires API level 23 (current min is 21): `new android.provider.SearchIndexableResource`"
|
||||
errorLine1=" super("
|
||||
errorLine2=" ~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="107"
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexableData#intentAction`"
|
||||
errorLine1=' this.intentAction = "android.intent.action.MAIN";'
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="113"
|
||||
column="17"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexableData#intentAction`"
|
||||
errorLine1=" this.intentAction = intentAction;"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="115"
|
||||
column="17"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="NewApi"
|
||||
message="Field requires API level 23 (current min is 21): `android.provider.SearchIndexableData#intentTargetClass`"
|
||||
errorLine1=" this.intentTargetClass = className;"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="frameworks/base/packages/SettingsLib/SearchProvider/src/com/android/settingslib/searchprovider/SettingsXmlIndexProvider.java"
|
||||
line="117"
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
</issues>
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.settingslib.searchprovider;
|
||||
|
||||
import static android.provider.SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.MatrixCursor;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.SearchIndexablesContract.XmlResource;
|
||||
import android.provider.SearchIndexablesProvider;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* An abstract SearchIndexProvider using {@link SearchIndexableIntentResource} for indexing
|
||||
*/
|
||||
public abstract class SettingsXmlIndexProvider extends SearchIndexablesProvider {
|
||||
private static final String TAG = "XmlIndexProvider";
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor queryXmlResources(String[] projection) {
|
||||
final Context context = getContext();
|
||||
final MatrixCursor cursor = new MatrixCursor(INDEXABLES_XML_RES_COLUMNS);
|
||||
final Collection<SearchIndexableIntentResource> resources = getIntentResources();
|
||||
|
||||
for (SearchIndexableIntentResource indexableResource : resources) {
|
||||
cursor.newRow()
|
||||
.add(XmlResource.COLUMN_RANK, indexableResource.rank)
|
||||
.add(XmlResource.COLUMN_XML_RESID, indexableResource.xmlResId)
|
||||
.add(XmlResource.COLUMN_CLASS_NAME, indexableResource.className)
|
||||
.add(XmlResource.COLUMN_INTENT_ACTION, indexableResource.intentAction)
|
||||
.add(XmlResource.COLUMN_INTENT_TARGET_PACKAGE, context.getPackageName())
|
||||
.add(XmlResource.COLUMN_INTENT_TARGET_CLASS,
|
||||
indexableResource.intentTargetClass);
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all {@link android.provider.SearchIndexablesContract.RawData}.
|
||||
*
|
||||
* Those are the raw indexable data.
|
||||
*
|
||||
* @param projection list of {@link android.provider.SearchIndexablesContract.RawData} columns
|
||||
* to put into the cursor. If {@code null} all supported columns should be
|
||||
* included.
|
||||
*/
|
||||
public Cursor queryRawData(String[] projection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all {@link android.provider.SearchIndexablesContract.NonIndexableKey}.
|
||||
*
|
||||
* Those are the non indexable data keys.
|
||||
*
|
||||
* @param projection list of {@link android.provider.SearchIndexablesContract.NonIndexableKey}
|
||||
* columns to put into the cursor. If {@code null} all supported columns
|
||||
* should be included.
|
||||
*/
|
||||
public Cursor queryNonIndexableKeys(String[] projection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Collection of {@link SearchIndexableIntentResource} that should be indexed for
|
||||
* search.
|
||||
*/
|
||||
protected abstract Collection<SearchIndexableIntentResource> getIntentResources();
|
||||
|
||||
/**
|
||||
* Wrapper class of {@link SearchIndexableResource}. It is for setting the search indexable
|
||||
* resource of corresponding XML and intent action with class.
|
||||
*/
|
||||
public static final class SearchIndexableIntentResource extends SearchIndexableResource {
|
||||
/**
|
||||
* Constructor of {@link SearchIndexableIntentResource}.
|
||||
*
|
||||
* @param xmlResId preference xml of target {@link prefereceFragment}
|
||||
* @param intentAction the intent to open target {@link Activity}
|
||||
* @param className the target {@link Activity} class name
|
||||
*/
|
||||
public SearchIndexableIntentResource(int xmlResId, String intentAction,
|
||||
String className) {
|
||||
super(
|
||||
0 /* rank */,
|
||||
xmlResId,
|
||||
className,
|
||||
0 /* icon resource id */);
|
||||
if (TextUtils.isEmpty(intentAction)) {
|
||||
this.intentAction = "android.intent.action.MAIN";
|
||||
} else {
|
||||
this.intentAction = intentAction;
|
||||
}
|
||||
this.intentTargetClass = className;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user