Merge changes from topic "misc" into q
* changes:
SettingsIntelligence: Change icon color
SettingsIntelligence: Match Settings style
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..fc8062a
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,42 @@
+// 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.
+
+android_app {
+ name: "SettingsIntelligence",
+ optimize: {
+ proguard_flags_files: ["proguard.cfg"],
+ },
+ sdk_version: "system_current",
+ product_specific: true,
+ privileged: true,
+ required: ["privapp_whitelist_com.android.settings.intelligence"],
+
+ static_libs: [
+ "androidx.legacy_legacy-support-v4",
+ "androidx.legacy_legacy-support-v13",
+ "androidx.appcompat_appcompat",
+ "androidx.cardview_cardview",
+ "androidx.preference_preference",
+ "androidx.recyclerview_recyclerview",
+ "androidx.legacy_legacy-preference-v14",
+ ],
+ resource_dirs: ["res"],
+ srcs: [
+ "src/**/*.java",
+ "proto/**/*.proto",
+ ],
+ proto: {
+ type: "nano",
+ },
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index b565774..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,50 +0,0 @@
-# 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_PACKAGE_NAME := SettingsIntelligence
-LOCAL_MODULE_TAGS := optional
-LOCAL_PROGUARD_FLAG_FILES := proguard.cfg
-
-LOCAL_SDK_VERSION := system_current
-LOCAL_PRIVILEGED_MODULE := true
-
-LOCAL_STATIC_ANDROID_LIBRARIES := \
- android-support-v4 \
- android-support-v13 \
- android-support-v7-appcompat \
- android-support-v7-cardview \
- android-support-v7-preference \
- android-support-v7-recyclerview \
- android-support-v14-preference
-
-LOCAL_USE_AAPT2 := true
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_SRC_FILES := \
- $(call all-java-files-under, src) \
- $(call all-proto-files-under, proto)
-
-LOCAL_PROTOC_OPTIMIZE_TYPE := nano
-
-include $(BUILD_PACKAGE)
-
-# Use the following include to make our test apk.
-ifeq (,$(ONE_SHOT_MAKEFILE))
-include $(call all-makefiles-under,$(LOCAL_PATH))
-endif
\ No newline at end of file
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5d1a1b9..5b0bd6a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -40,6 +40,7 @@
android:theme="@style/Theme.Settings.NoActionBar">
<intent-filter priority="-1">
<action android:name="com.android.settings.action.SETTINGS_SEARCH" />
+ <action android:name="android.settings.APP_SEARCH_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
diff --git a/CleanSpec.mk b/CleanSpec.mk
new file mode 100644
index 0000000..455dd53
--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,50 @@
+# 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.
+#
+
+# If you don't need to do a full clean build but would like to touch
+# a file or delete some intermediate files, add a clean step to the end
+# of the list. These steps will only be run once, if they haven't been
+# run before.
+#
+# E.g.:
+# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
+# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
+#
+# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
+# files that are missing or have been moved.
+#
+# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
+# Use $(OUT_DIR) to refer to the "out" directory.
+#
+# If you need to re-do something that's already mentioned, just copy
+# the command and add it to the bottom of the list. E.g., if a change
+# that you made last week required touching a file and a change you
+# made today requires touching the same file, just copy the old
+# touch step and add it to the end of the list.
+#
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
+
+# For example:
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
+#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
+#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
+#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/SettingsIntelligence)
+
+# ************************************************
+# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
+# ************************************************
diff --git a/OWNERS b/OWNERS
index 7d9f541..1703318 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,8 +1,10 @@
-# People who can approve changes
-dhnishi@google.com
-juanlang@google.com
-mfritze@google.com
-zhfan@google.com
+## People who can approve changes
-# Emergency approvers in case the above are not available
-miket@google.com
\ No newline at end of file
+# Android auto
+rlagos@google.com
+
+# TV Settings
+leifhendrik@google.com
+
+# Mobile Settings
+zhfan@google.com
\ No newline at end of file
diff --git a/proguard.cfg b/proguard.cfg
index 511e2bc..4ff3790 100644
--- a/proguard.cfg
+++ b/proguard.cfg
@@ -26,7 +26,7 @@
}
# Keep annotated classes or class members.
--keep @android.support.annotation.Keep class *
+-keep @androidx.annotation.Keep class *
-keepclassmembers class * {
- @android.support.annotation.Keep *;
+ @androidx.annotation.Keep *;
}
diff --git a/res/layout/search_panel.xml b/res/layout/search_panel.xml
index ea5de7e..cd53318 100644
--- a/res/layout/search_panel.xml
+++ b/res/layout/search_panel.xml
@@ -27,7 +27,7 @@
android:layout_height="wrap_content"
android:background="?android:attr/colorPrimary"
android:elevation="4dp">
- <android.support.v7.widget.CardView
+ <androidx.cardview.widget.CardView
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -50,7 +50,7 @@
android:imeOptions="actionSearch|flagNoExtractUi"
android:searchIcon="@null"/>
</Toolbar>
- </android.support.v7.widget.CardView>
+ </androidx.cardview.widget.CardView>
</FrameLayout>
<FrameLayout
@@ -61,7 +61,7 @@
android:orientation="vertical">
<!-- Padding is included in the background -->
- <android.support.v7.widget.RecyclerView
+ <androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_results"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/src/com/android/settings/intelligence/SettingsIntelligenceDumpService.java b/src/com/android/settings/intelligence/SettingsIntelligenceDumpService.java
index 3ece045..af3221e 100644
--- a/src/com/android/settings/intelligence/SettingsIntelligenceDumpService.java
+++ b/src/com/android/settings/intelligence/SettingsIntelligenceDumpService.java
@@ -21,7 +21,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.IBinder;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import com.android.settings.intelligence.suggestions.model.SuggestionCategory;
import com.android.settings.intelligence.suggestions.model.SuggestionCategoryRegistry;
diff --git a/src/com/android/settings/intelligence/overlay/FeatureFactoryImpl.java b/src/com/android/settings/intelligence/overlay/FeatureFactoryImpl.java
index 99798e7..20c0249 100644
--- a/src/com/android/settings/intelligence/overlay/FeatureFactoryImpl.java
+++ b/src/com/android/settings/intelligence/overlay/FeatureFactoryImpl.java
@@ -17,7 +17,7 @@
package com.android.settings.intelligence.overlay;
import android.content.Context;
-import android.support.annotation.Keep;
+import androidx.annotation.Keep;
import com.android.settings.intelligence.experiment.ExperimentFeatureProvider;
import com.android.settings.intelligence.instrumentation.MetricsFeatureProvider;
diff --git a/src/com/android/settings/intelligence/search/IntentSearchViewHolder.java b/src/com/android/settings/intelligence/search/IntentSearchViewHolder.java
index ec02164..b643368 100644
--- a/src/com/android/settings/intelligence/search/IntentSearchViewHolder.java
+++ b/src/com/android/settings/intelligence/search/IntentSearchViewHolder.java
@@ -19,7 +19,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.util.Log;
import android.view.View;
diff --git a/src/com/android/settings/intelligence/search/ResultPayload.java b/src/com/android/settings/intelligence/search/ResultPayload.java
index da5ff60..f7fd859 100644
--- a/src/com/android/settings/intelligence/search/ResultPayload.java
+++ b/src/com/android/settings/intelligence/search/ResultPayload.java
@@ -17,7 +17,7 @@
package com.android.settings.intelligence.search;
-import android.support.annotation.IntDef;
+import androidx.annotation.IntDef;
import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
diff --git a/src/com/android/settings/intelligence/search/SearchFeatureProviderImpl.java b/src/com/android/settings/intelligence/search/SearchFeatureProviderImpl.java
index 0489117..024bc61 100644
--- a/src/com/android/settings/intelligence/search/SearchFeatureProviderImpl.java
+++ b/src/com/android/settings/intelligence/search/SearchFeatureProviderImpl.java
@@ -18,7 +18,7 @@
package com.android.settings.intelligence.search;
import android.content.Context;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
diff --git a/src/com/android/settings/intelligence/search/SearchFragment.java b/src/com/android/settings/intelligence/search/SearchFragment.java
index 1f6a6c8..003a457 100644
--- a/src/com/android/settings/intelligence/search/SearchFragment.java
+++ b/src/com/android/settings/intelligence/search/SearchFragment.java
@@ -25,9 +25,9 @@
import android.content.Context;
import android.content.Loader;
import android.os.Bundle;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
+import androidx.annotation.VisibleForTesting;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.util.EventLog;
import android.util.Log;
diff --git a/src/com/android/settings/intelligence/search/SearchResultAggregator.java b/src/com/android/settings/intelligence/search/SearchResultAggregator.java
index 20b156c..cc36143 100644
--- a/src/com/android/settings/intelligence/search/SearchResultAggregator.java
+++ b/src/com/android/settings/intelligence/search/SearchResultAggregator.java
@@ -1,7 +1,7 @@
package com.android.settings.intelligence.search;
import android.content.Context;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import android.util.ArrayMap;
import android.util.Log;
@@ -30,7 +30,7 @@
* Timeout for subsequent tasks to allow for fast returning tasks.
* TODO(70164062): Tweak the timeout values.
*/
- private static final long SHORT_CHECK_TASK_TIMEOUT_MS = 300;
+ private static final long SHORT_CHECK_TASK_TIMEOUT_MS = 600;
private static SearchResultAggregator sResultAggregator;
diff --git a/src/com/android/settings/intelligence/search/SearchResultDiffCallback.java b/src/com/android/settings/intelligence/search/SearchResultDiffCallback.java
index 1d2b946..cafda9b 100644
--- a/src/com/android/settings/intelligence/search/SearchResultDiffCallback.java
+++ b/src/com/android/settings/intelligence/search/SearchResultDiffCallback.java
@@ -17,7 +17,7 @@
package com.android.settings.intelligence.search;
-import android.support.v7.util.DiffUtil;
+import androidx.recyclerview.widget.DiffUtil;
import java.util.List;
diff --git a/src/com/android/settings/intelligence/search/SearchResultsAdapter.java b/src/com/android/settings/intelligence/search/SearchResultsAdapter.java
index decf730..41df769 100644
--- a/src/com/android/settings/intelligence/search/SearchResultsAdapter.java
+++ b/src/com/android/settings/intelligence/search/SearchResultsAdapter.java
@@ -18,8 +18,8 @@
package com.android.settings.intelligence.search;
import android.content.Context;
-import android.support.v7.util.DiffUtil;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.DiffUtil;
+import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
diff --git a/src/com/android/settings/intelligence/search/SearchViewHolder.java b/src/com/android/settings/intelligence/search/SearchViewHolder.java
index c74391e..d669e6d 100644
--- a/src/com/android/settings/intelligence/search/SearchViewHolder.java
+++ b/src/com/android/settings/intelligence/search/SearchViewHolder.java
@@ -18,7 +18,7 @@
import android.content.Context;
import android.content.pm.PackageManager;
-import android.support.v7.widget.RecyclerView;
+import androidx.recyclerview.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
diff --git a/src/com/android/settings/intelligence/search/indexing/DatabaseIndexingManager.java b/src/com/android/settings/intelligence/search/indexing/DatabaseIndexingManager.java
index 0928611..0053f14 100644
--- a/src/com/android/settings/intelligence/search/indexing/DatabaseIndexingManager.java
+++ b/src/com/android/settings/intelligence/search/indexing/DatabaseIndexingManager.java
@@ -17,6 +17,7 @@
package com.android.settings.intelligence.search.indexing;
import static com.android.settings.intelligence.search.query.DatabaseResultTask.SELECT_COLUMNS;
+import static com.android.settings.intelligence.search.indexing.IndexDatabaseHelper.IndexColumns.DATA_AUTHORITY;
import static com.android.settings.intelligence.search.indexing.IndexDatabaseHelper.IndexColumns.DATA_PACKAGE;
import static com.android.settings.intelligence.search.indexing.IndexDatabaseHelper.IndexColumns.CLASS_NAME;
import static com.android.settings.intelligence.search.indexing.IndexDatabaseHelper.IndexColumns.DATA_ENTRIES;
@@ -46,7 +47,7 @@
import android.database.sqlite.SQLiteException;
import android.os.AsyncTask;
import android.provider.SearchIndexablesContract;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
@@ -220,6 +221,7 @@
values.put(DATA_ENTRIES, dataRow.entries);
values.put(DATA_KEYWORDS, dataRow.spaceDelimitedKeywords);
values.put(DATA_PACKAGE, dataRow.packageName);
+ values.put(DATA_AUTHORITY, dataRow.authority);
values.put(CLASS_NAME, dataRow.className);
values.put(SCREEN_TITLE, dataRow.screenTitle);
values.put(INTENT_ACTION, dataRow.intentAction);
@@ -241,7 +243,7 @@
* All rows which are disabled but no longer a non-indexable key will become enabled.
*
* @param database The database to validate.
- * @param nonIndexableKeys A map between package name and the set of non-indexable keys for it.
+ * @param nonIndexableKeys A map between authority and the set of non-indexable keys for it.
*/
@VisibleForTesting
void updateDataInDatabase(SQLiteDatabase database,
@@ -255,17 +257,17 @@
final ContentValues enabledToDisabledValue = new ContentValues();
enabledToDisabledValue.put(ENABLED, 0);
- String packageName;
+ String authority;
// TODO Refactor: Move these two loops into one method.
while (enabledResults.moveToNext()) {
- packageName = enabledResults.getString(enabledResults.getColumnIndexOrThrow(
- IndexDatabaseHelper.IndexColumns.DATA_PACKAGE));
+ authority = enabledResults.getString(enabledResults.getColumnIndexOrThrow(
+ DATA_AUTHORITY));
final String key = enabledResults.getString(enabledResults.getColumnIndexOrThrow(
- IndexDatabaseHelper.IndexColumns.DATA_KEY_REF));
- final Set<String> packageKeys = nonIndexableKeys.get(packageName);
+ DATA_KEY_REF));
+ final Set<String> authorityKeys = nonIndexableKeys.get(authority);
// The indexed item is set to Enabled but is now non-indexable
- if (packageKeys != null && packageKeys.contains(key)) {
+ if (authorityKeys != null && authorityKeys.contains(key)) {
final String whereClause = getKeyWhereClause(key);
database.update(TABLE_PREFS_INDEX, enabledToDisabledValue, whereClause, null);
}
@@ -279,17 +281,17 @@
disabledToEnabledValue.put(ENABLED, 1);
while (disabledResults.moveToNext()) {
- packageName = disabledResults.getString(disabledResults.getColumnIndexOrThrow(
- IndexDatabaseHelper.IndexColumns.DATA_PACKAGE));
+ authority = disabledResults.getString(disabledResults.getColumnIndexOrThrow(
+ DATA_AUTHORITY));
final String key = disabledResults.getString(disabledResults.getColumnIndexOrThrow(
- IndexDatabaseHelper.IndexColumns.DATA_KEY_REF));
- final Set<String> packageKeys = nonIndexableKeys.get(packageName);
+ DATA_KEY_REF));
+ final Set<String> authorityKeys = nonIndexableKeys.get(authority);
// The indexed item is set to Disabled but is no longer non-indexable.
- // We do not enable keys when packageKeys is null because it means the keys came
- // from an unrecognized package and therefore should not be surfaced as results.
- if (packageKeys != null && !packageKeys.contains(key)) {
+ // We do not enable keys when authorityKeys is null because it means the keys came
+ // from an unrecognized authority and therefore should not be surfaced as results.
+ if (authorityKeys != null && !authorityKeys.contains(key)) {
final String whereClause = getKeyWhereClause(key);
database.update(TABLE_PREFS_INDEX, disabledToEnabledValue, whereClause, null);
}
diff --git a/src/com/android/settings/intelligence/search/indexing/IndexData.java b/src/com/android/settings/intelligence/search/indexing/IndexData.java
index d178344..904deaf 100644
--- a/src/com/android/settings/intelligence/search/indexing/IndexData.java
+++ b/src/com/android/settings/intelligence/search/indexing/IndexData.java
@@ -38,6 +38,7 @@
* @see SearchIndexableData#iconResId
*/
public final String packageName;
+ public final String authority;
public final String locale;
public final String updatedTitle;
public final String normalizedTitle;
@@ -87,6 +88,7 @@
spaceDelimitedKeywords = normalizeKeywords(builder.mKeywords);
intentAction = builder.mIntentAction;
packageName = builder.mPackageName;
+ authority = builder.mAuthority;
intentTargetPackage = builder.mIntentTargetPackage;
intentTargetClass = builder.mIntentTargetClass;
enabled = builder.mEnabled;
@@ -155,6 +157,7 @@
private String mChildClassName;
private String mScreenTitle;
private String mPackageName;
+ private String mAuthority;
private int mIconResId;
private String mKeywords;
private String mIntentAction;
@@ -213,6 +216,11 @@
return this;
}
+ public Builder setAuthority(String authority) {
+ mAuthority = authority;
+ return this;
+ }
+
public Builder setIconResId(int iconResId) {
mIconResId = iconResId;
return this;
diff --git a/src/com/android/settings/intelligence/search/indexing/IndexDataConverter.java b/src/com/android/settings/intelligence/search/indexing/IndexDataConverter.java
index 167019b..bd53596 100644
--- a/src/com/android/settings/intelligence/search/indexing/IndexDataConverter.java
+++ b/src/com/android/settings/intelligence/search/indexing/IndexDataConverter.java
@@ -20,11 +20,11 @@
import android.content.Context;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
-import android.os.AsyncTask;
import android.provider.SearchIndexableData;
import android.provider.SearchIndexableResource;
-import android.support.annotation.DrawableRes;
-import android.support.annotation.Nullable;
+import androidx.annotation.DrawableRes;
+import androidx.annotation.Nullable;
+import androidx.collection.ArraySet;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
@@ -42,7 +42,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -74,25 +73,32 @@
*/
public List<IndexData> convertPreIndexDataToIndexData(PreIndexData preIndexData) {
final long startConversion = System.currentTimeMillis();
- final List<SearchIndexableData> indexableData = preIndexData.getDataToUpdate();
+ final Map<String, List<SearchIndexableData>> indexableDataMap =
+ preIndexData.getDataToUpdate();
final Map<String, Set<String>> nonIndexableKeys = preIndexData.getNonIndexableKeys();
final List<IndexData> indexData = new ArrayList<>();
- for (SearchIndexableData data : indexableData) {
- if (data instanceof SearchIndexableRaw) {
- final SearchIndexableRaw rawData = (SearchIndexableRaw) data;
- final Set<String> rawNonIndexableKeys = nonIndexableKeys.get(
- rawData.intentTargetPackage);
- final IndexData convertedRaw = convertRaw(mContext, rawData, rawNonIndexableKeys);
- if (convertedRaw != null) {
- indexData.add(convertedRaw);
+ for (Map.Entry<String, List<SearchIndexableData>> entry : indexableDataMap.entrySet()) {
+ final String authority = entry.getKey();
+ final List<SearchIndexableData> indexableData = entry.getValue();
+
+ for (SearchIndexableData data : indexableData) {
+ if (data instanceof SearchIndexableRaw) {
+ final SearchIndexableRaw rawData = (SearchIndexableRaw) data;
+ final Set<String> rawNonIndexableKeys = nonIndexableKeys.get(authority);
+ final IndexData convertedRaw = convertRaw(mContext, authority, rawData,
+ rawNonIndexableKeys);
+ if (convertedRaw != null) {
+ indexData.add(convertedRaw);
+ }
+ } else if (data instanceof SearchIndexableResource) {
+ final SearchIndexableResource sir = (SearchIndexableResource) data;
+ final Set<String> resourceNonIndexableKeys =
+ getNonIndexableKeysForResource(nonIndexableKeys, authority);
+ final List<IndexData> resourceData = convertResource(sir, authority,
+ resourceNonIndexableKeys);
+ indexData.addAll(resourceData);
}
- } else if (data instanceof SearchIndexableResource) {
- final SearchIndexableResource sir = (SearchIndexableResource) data;
- final Set<String> resourceNonIndexableKeys =
- getNonIndexableKeysForResource(nonIndexableKeys, sir.packageName);
- final List<IndexData> resourceData = convertResource(sir, resourceNonIndexableKeys);
- indexData.addAll(resourceData);
}
}
@@ -150,10 +156,10 @@
* and there is some data sanitization in the conversion.
*/
@Nullable
- private IndexData convertRaw(Context context, SearchIndexableRaw raw,
+ private IndexData convertRaw(Context context, String authority, SearchIndexableRaw raw,
Set<String> nonIndexableKeys) {
if (TextUtils.isEmpty(raw.key)) {
- Log.w(TAG, "Skipping null key for raw indexable " + raw.packageName + "/" + raw.title);
+ Log.w(TAG, "Skipping null key for raw indexable " + authority + "/" + raw.title);
return null;
}
// A row is enabled if it does not show up as an nonIndexableKey
@@ -172,6 +178,7 @@
.setIntentTargetClass(raw.intentTargetClass)
.setEnabled(enabled)
.setPackageName(raw.packageName)
+ .setAuthority(authority)
.setKey(raw.key);
return builder.build(context);
@@ -184,7 +191,7 @@
*
* TODO (b/33577327) simplify this method.
*/
- private List<IndexData> convertResource(SearchIndexableResource sir,
+ private List<IndexData> convertResource(SearchIndexableResource sir, String authority,
Set<String> nonIndexableKeys) {
final Context context = sir.context;
XmlResourceParser parser = null;
@@ -244,6 +251,7 @@
.setKeywords(headerKeywords)
.setClassName(sir.className)
.setPackageName(sir.packageName)
+ .setAuthority(authority)
.setIntentAction(sir.intentAction)
.setIntentTargetPackage(sir.intentTargetPackage)
.setIntentTargetClass(sir.intentTargetClass)
@@ -285,6 +293,7 @@
.setScreenTitle(screenTitle)
.setIconResId(iconResId)
.setPackageName(sir.packageName)
+ .setAuthority(authority)
.setIntentAction(sir.intentAction)
.setIntentTargetPackage(sir.intentTargetPackage)
.setIntentTargetClass(sir.intentTargetClass)
@@ -352,9 +361,8 @@
}
private Set<String> getNonIndexableKeysForResource(Map<String, Set<String>> nonIndexableKeys,
- String packageName) {
- return nonIndexableKeys.containsKey(packageName)
- ? nonIndexableKeys.get(packageName)
- : new HashSet<String>();
+ String authority) {
+ final Set<String> result = nonIndexableKeys.get(authority);
+ return result != null ? result : new ArraySet<>();
}
}
diff --git a/src/com/android/settings/intelligence/search/indexing/IndexDatabaseHelper.java b/src/com/android/settings/intelligence/search/indexing/IndexDatabaseHelper.java
index 4bec50e..cc90d21 100644
--- a/src/com/android/settings/intelligence/search/indexing/IndexDatabaseHelper.java
+++ b/src/com/android/settings/intelligence/search/indexing/IndexDatabaseHelper.java
@@ -25,7 +25,7 @@
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Build;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
@@ -37,7 +37,7 @@
private static final String TAG = "IndexDatabaseHelper";
private static final String DATABASE_NAME = "search_index.db";
- private static final int DATABASE_VERSION = 119;
+ private static final int DATABASE_VERSION = 120;
@VisibleForTesting
static final String SHARED_PREFS_TAG = "indexing_manager";
@@ -61,6 +61,7 @@
String DATA_ENTRIES = "data_entries";
String DATA_KEYWORDS = "data_keywords";
String DATA_PACKAGE = "package";
+ String DATA_AUTHORITY = "authority";
String CLASS_NAME = "class_name";
String SCREEN_TITLE = "screen_title";
String INTENT_ACTION = "intent_action";
@@ -111,6 +112,8 @@
", " +
IndexColumns.DATA_PACKAGE +
", " +
+ IndexColumns.DATA_AUTHORITY +
+ ", " +
IndexColumns.SCREEN_TITLE +
", " +
IndexColumns.CLASS_NAME +
diff --git a/src/com/android/settings/intelligence/search/indexing/PreIndexData.java b/src/com/android/settings/intelligence/search/indexing/PreIndexData.java
index 8f8ce07..7ea03fd 100644
--- a/src/com/android/settings/intelligence/search/indexing/PreIndexData.java
+++ b/src/com/android/settings/intelligence/search/indexing/PreIndexData.java
@@ -32,12 +32,12 @@
*/
public class PreIndexData {
- private final List<SearchIndexableData> mDataToUpdate;
+ private final Map<String, List<SearchIndexableData>> mDataToUpdate;
private final Map<String, Set<String>> mNonIndexableKeys;
private final List<Pair<String, String>> mSiteMapPairs;
public PreIndexData() {
- mDataToUpdate = new ArrayList<>();
+ mDataToUpdate = new HashMap<>();
mNonIndexableKeys = new HashMap<>();
mSiteMapPairs = new ArrayList<>();
}
@@ -46,7 +46,7 @@
return mNonIndexableKeys;
}
- public List<SearchIndexableData> getDataToUpdate() {
+ public Map<String, List<SearchIndexableData>> getDataToUpdate() {
return mDataToUpdate;
}
@@ -58,8 +58,17 @@
mNonIndexableKeys.put(authority, keys);
}
- public void addDataToUpdate(List<? extends SearchIndexableData> data) {
- mDataToUpdate.addAll(data);
+ public void addDataToUpdate(String authority, List<? extends SearchIndexableData> data) {
+ if (data.isEmpty()) {
+ return;
+ }
+
+ List<SearchIndexableData> indexableData = mDataToUpdate.get(authority);
+ if (indexableData == null) {
+ mDataToUpdate.put(authority, new ArrayList<>(data));
+ } else {
+ indexableData.addAll(data);
+ }
}
public void addSiteMapPairs(List<Pair<String, String>> siteMapPairs) {
diff --git a/src/com/android/settings/intelligence/search/indexing/PreIndexDataCollector.java b/src/com/android/settings/intelligence/search/indexing/PreIndexDataCollector.java
index fbd3209..a859113 100644
--- a/src/com/android/settings/intelligence/search/indexing/PreIndexDataCollector.java
+++ b/src/com/android/settings/intelligence/search/indexing/PreIndexDataCollector.java
@@ -49,7 +49,7 @@
import android.net.Uri;
import android.provider.SearchIndexableResource;
import android.provider.SearchIndexablesContract;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Log;
@@ -111,12 +111,14 @@
final Context context = mContext.createPackageContext(packageName, 0);
final Uri uriForResources = buildUriForXmlResources(authority);
- mIndexData.addDataToUpdate(getIndexablesForXmlResourceUri(context, packageName,
- uriForResources, SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS));
+ mIndexData.addDataToUpdate(authority, getIndexablesForXmlResourceUri(
+ context, packageName, uriForResources,
+ SearchIndexablesContract.INDEXABLES_XML_RES_COLUMNS));
final Uri uriForRawData = buildUriForRawData(authority);
- mIndexData.addDataToUpdate(getIndexablesForRawDataUri(context, packageName,
- uriForRawData, SearchIndexablesContract.INDEXABLES_RAW_COLUMNS));
+ mIndexData.addDataToUpdate(authority, getIndexablesForRawDataUri(
+ context, packageName, uriForRawData,
+ SearchIndexablesContract.INDEXABLES_RAW_COLUMNS));
final Uri uriForSiteMap = buildUriForSiteMap(authority);
mIndexData.addSiteMapPairs(getSiteMapFromProvider(context, uriForSiteMap));
diff --git a/src/com/android/settings/intelligence/search/indexing/XmlParserUtils.java b/src/com/android/settings/intelligence/search/indexing/XmlParserUtils.java
index 6e7db64..46a8740 100644
--- a/src/com/android/settings/intelligence/search/indexing/XmlParserUtils.java
+++ b/src/com/android/settings/intelligence/search/indexing/XmlParserUtils.java
@@ -18,7 +18,7 @@
import android.content.Context;
import android.content.res.TypedArray;
-import android.support.annotation.Nullable;
+import androidx.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
diff --git a/src/com/android/settings/intelligence/search/query/DatabaseResultTask.java b/src/com/android/settings/intelligence/search/query/DatabaseResultTask.java
index 65d190a..07f9863 100644
--- a/src/com/android/settings/intelligence/search/query/DatabaseResultTask.java
+++ b/src/com/android/settings/intelligence/search/query/DatabaseResultTask.java
@@ -23,7 +23,7 @@
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.util.Log;
import android.util.Pair;
@@ -63,6 +63,7 @@
IndexColumns.ICON,
IndexColumns.INTENT_ACTION,
IndexColumns.DATA_PACKAGE,
+ IndexColumns.DATA_AUTHORITY,
IndexColumns.INTENT_TARGET_PACKAGE,
IndexColumns.INTENT_TARGET_CLASS,
IndexColumns.DATA_KEY_REF,
diff --git a/src/com/android/settings/intelligence/search/query/InputDeviceResultTask.java b/src/com/android/settings/intelligence/search/query/InputDeviceResultTask.java
index e98ea0d..4cad4cc 100644
--- a/src/com/android/settings/intelligence/search/query/InputDeviceResultTask.java
+++ b/src/com/android/settings/intelligence/search/query/InputDeviceResultTask.java
@@ -22,8 +22,8 @@
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.icu.text.ListFormatter;
-import android.support.annotation.NonNull;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
import android.util.Log;
import android.view.InputDevice;
import android.view.inputmethod.InputMethodInfo;
diff --git a/src/com/android/settings/intelligence/search/query/InstalledAppResultTask.java b/src/com/android/settings/intelligence/search/query/InstalledAppResultTask.java
index 741d803..6732765 100644
--- a/src/com/android/settings/intelligence/search/query/InstalledAppResultTask.java
+++ b/src/com/android/settings/intelligence/search/query/InstalledAppResultTask.java
@@ -73,6 +73,12 @@
| PackageManager.MATCH_INSTANT);
for (ApplicationInfo info : appsInfo) {
+ if (!info.enabled
+ && mPackageManager.getApplicationEnabledSetting(info.packageName)
+ != PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER) {
+ // Disabled by something other than user, skip.
+ continue;
+ }
final CharSequence label = info.loadLabel(mPackageManager);
final int wordDiff = SearchQueryUtils.getWordDifference(label.toString(), mQuery);
if (wordDiff == SearchQueryUtils.NAME_NO_MATCH) {
diff --git a/src/com/android/settings/intelligence/search/query/SearchQueryTask.java b/src/com/android/settings/intelligence/search/query/SearchQueryTask.java
index be0546b..4354d1d 100644
--- a/src/com/android/settings/intelligence/search/query/SearchQueryTask.java
+++ b/src/com/android/settings/intelligence/search/query/SearchQueryTask.java
@@ -17,7 +17,7 @@
package com.android.settings.intelligence.search.query;
import android.content.Context;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import com.android.settings.intelligence.overlay.FeatureFactory;
import com.android.settings.intelligence.search.SearchResult;
diff --git a/src/com/android/settings/intelligence/search/savedqueries/SavedQueryLoader.java b/src/com/android/settings/intelligence/search/savedqueries/SavedQueryLoader.java
index 9d0316c..0897efe 100644
--- a/src/com/android/settings/intelligence/search/savedqueries/SavedQueryLoader.java
+++ b/src/com/android/settings/intelligence/search/savedqueries/SavedQueryLoader.java
@@ -19,7 +19,7 @@
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import com.android.settings.intelligence.search.SearchResult;
import com.android.settings.intelligence.search.indexing.IndexDatabaseHelper;
diff --git a/src/com/android/settings/intelligence/search/savedqueries/SavedQueryPayload.java b/src/com/android/settings/intelligence/search/savedqueries/SavedQueryPayload.java
index 264eee9..9a8a6fe 100644
--- a/src/com/android/settings/intelligence/search/savedqueries/SavedQueryPayload.java
+++ b/src/com/android/settings/intelligence/search/savedqueries/SavedQueryPayload.java
@@ -17,7 +17,7 @@
package com.android.settings.intelligence.search.savedqueries;
import android.os.Parcel;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import com.android.settings.intelligence.search.ResultPayload;
diff --git a/src/com/android/settings/intelligence/search/sitemap/SiteMapManager.java b/src/com/android/settings/intelligence/search/sitemap/SiteMapManager.java
index 315cd4f..8811624 100644
--- a/src/com/android/settings/intelligence/search/sitemap/SiteMapManager.java
+++ b/src/com/android/settings/intelligence/search/sitemap/SiteMapManager.java
@@ -19,7 +19,7 @@
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
-import android.support.annotation.WorkerThread;
+import androidx.annotation.WorkerThread;
import android.text.TextUtils;
import android.util.Log;
diff --git a/src/com/android/settings/intelligence/suggestions/SuggestionParser.java b/src/com/android/settings/intelligence/suggestions/SuggestionParser.java
index f7cecd2..0058d65 100644
--- a/src/com/android/settings/intelligence/suggestions/SuggestionParser.java
+++ b/src/com/android/settings/intelligence/suggestions/SuggestionParser.java
@@ -25,7 +25,7 @@
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.service.settings.suggestions.Suggestion;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.Log;
diff --git a/src/com/android/settings/intelligence/suggestions/eligibility/AccountEligibilityChecker.java b/src/com/android/settings/intelligence/suggestions/eligibility/AccountEligibilityChecker.java
index 447dc77..2d26d4b 100644
--- a/src/com/android/settings/intelligence/suggestions/eligibility/AccountEligibilityChecker.java
+++ b/src/com/android/settings/intelligence/suggestions/eligibility/AccountEligibilityChecker.java
@@ -20,7 +20,7 @@
import android.accounts.AccountManager;
import android.content.Context;
import android.content.pm.ResolveInfo;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.util.Log;
public class AccountEligibilityChecker {
diff --git a/src/com/android/settings/intelligence/suggestions/eligibility/CandidateSuggestionFilter.java b/src/com/android/settings/intelligence/suggestions/eligibility/CandidateSuggestionFilter.java
index 5268ca7..cf8d2b9 100644
--- a/src/com/android/settings/intelligence/suggestions/eligibility/CandidateSuggestionFilter.java
+++ b/src/com/android/settings/intelligence/suggestions/eligibility/CandidateSuggestionFilter.java
@@ -25,8 +25,8 @@
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.NonNull;
+import androidx.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
diff --git a/src/com/android/settings/intelligence/suggestions/eligibility/ConnectivityEligibilityChecker.java b/src/com/android/settings/intelligence/suggestions/eligibility/ConnectivityEligibilityChecker.java
index 9318c98..ec0a3ee 100644
--- a/src/com/android/settings/intelligence/suggestions/eligibility/ConnectivityEligibilityChecker.java
+++ b/src/com/android/settings/intelligence/suggestions/eligibility/ConnectivityEligibilityChecker.java
@@ -20,7 +20,7 @@
import android.content.pm.ResolveInfo;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.util.Log;
public class ConnectivityEligibilityChecker {
diff --git a/src/com/android/settings/intelligence/suggestions/eligibility/DismissedChecker.java b/src/com/android/settings/intelligence/suggestions/eligibility/DismissedChecker.java
index ba24baf..428d6dd 100644
--- a/src/com/android/settings/intelligence/suggestions/eligibility/DismissedChecker.java
+++ b/src/com/android/settings/intelligence/suggestions/eligibility/DismissedChecker.java
@@ -19,7 +19,7 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ResolveInfo;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.format.DateUtils;
import android.util.Log;
diff --git a/src/com/android/settings/intelligence/suggestions/eligibility/FeatureEligibilityChecker.java b/src/com/android/settings/intelligence/suggestions/eligibility/FeatureEligibilityChecker.java
index 1308515..697a867 100644
--- a/src/com/android/settings/intelligence/suggestions/eligibility/FeatureEligibilityChecker.java
+++ b/src/com/android/settings/intelligence/suggestions/eligibility/FeatureEligibilityChecker.java
@@ -18,7 +18,7 @@
import android.content.Context;
import android.content.pm.ResolveInfo;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
diff --git a/src/com/android/settings/intelligence/suggestions/model/CandidateSuggestion.java b/src/com/android/settings/intelligence/suggestions/model/CandidateSuggestion.java
index c468ab9..2502e2a 100644
--- a/src/com/android/settings/intelligence/suggestions/model/CandidateSuggestion.java
+++ b/src/com/android/settings/intelligence/suggestions/model/CandidateSuggestion.java
@@ -27,7 +27,7 @@
import android.net.Uri;
import android.os.Bundle;
import android.service.settings.suggestions.Suggestion;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.Log;
@@ -182,14 +182,17 @@
// First get override data
final Bundle overrideData = getOverrideData(metaData);
// Get icon
- if (metaData.containsKey(META_DATA_PREFERENCE_ICON)) {
- iconRes = metaData.getInt(META_DATA_PREFERENCE_ICON);
- } else {
- iconRes = mResolveInfo.activityInfo.icon;
- }
- if (iconRes != 0) {
- icon = Icon.createWithResource(
- mResolveInfo.activityInfo.packageName, iconRes);
+ icon = getIconFromBundle(overrideData, META_DATA_PREFERENCE_ICON);
+ if (icon == null) {
+ if (metaData.containsKey(META_DATA_PREFERENCE_ICON)) {
+ iconRes = metaData.getInt(META_DATA_PREFERENCE_ICON);
+ } else {
+ iconRes = mResolveInfo.activityInfo.icon;
+ }
+ if (iconRes != 0) {
+ icon = Icon.createWithResource(
+ mResolveInfo.activityInfo.packageName, iconRes);
+ }
}
// Get title
title = getStringFromBundle(overrideData, META_DATA_PREFERENCE_TITLE);
@@ -241,6 +244,14 @@
return bundle.getString(key);
}
+ /** Extracts an Icon object from bundle. */
+ private Icon getIconFromBundle(Bundle bundle, String key) {
+ if (bundle == null || TextUtils.isEmpty(key)) {
+ return null;
+ }
+ return bundle.getParcelable(key);
+ }
+
private Bundle getOverrideData(Bundle metadata) {
if (metadata == null || !metadata.containsKey(META_DATA_PREFERENCE_SUMMARY_URI)) {
Log.d(TAG, "Metadata null or has no info about summary_uri");
diff --git a/src/com/android/settings/intelligence/suggestions/model/SuggestionCategoryRegistry.java b/src/com/android/settings/intelligence/suggestions/model/SuggestionCategoryRegistry.java
index 84b2332..4c2cfb4 100644
--- a/src/com/android/settings/intelligence/suggestions/model/SuggestionCategoryRegistry.java
+++ b/src/com/android/settings/intelligence/suggestions/model/SuggestionCategoryRegistry.java
@@ -16,7 +16,7 @@
package com.android.settings.intelligence.suggestions.model;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.text.format.DateUtils;
import java.util.ArrayList;
diff --git a/src/com/android/settings/intelligence/suggestions/ranking/SuggestionEventStore.java b/src/com/android/settings/intelligence/suggestions/ranking/SuggestionEventStore.java
index 1f5f7c0..bf3b4ed 100644
--- a/src/com/android/settings/intelligence/suggestions/ranking/SuggestionEventStore.java
+++ b/src/com/android/settings/intelligence/suggestions/ranking/SuggestionEventStore.java
@@ -16,11 +16,11 @@
package com.android.settings.intelligence.suggestions.ranking;
-import static android.support.annotation.VisibleForTesting.NONE;
+import static androidx.annotation.VisibleForTesting.NONE;
import android.content.Context;
import android.content.SharedPreferences;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import android.util.Log;
import java.util.Arrays;
diff --git a/src/com/android/settings/intelligence/suggestions/ranking/SuggestionRanker.java b/src/com/android/settings/intelligence/suggestions/ranking/SuggestionRanker.java
index e62262e..61c08e9 100644
--- a/src/com/android/settings/intelligence/suggestions/ranking/SuggestionRanker.java
+++ b/src/com/android/settings/intelligence/suggestions/ranking/SuggestionRanker.java
@@ -18,7 +18,7 @@
import android.content.Context;
import android.service.settings.suggestions.Suggestion;
-import android.support.annotation.VisibleForTesting;
+import androidx.annotation.VisibleForTesting;
import com.android.settings.intelligence.overlay.FeatureFactory;