From a9f4bffbfc9802ca86a813de2bccea9572f710af Mon Sep 17 00:00:00 2001 From: yingrenw Date: Thu, 6 Jul 2017 18:37:35 +0800 Subject: [PATCH 1/2] Launcher3: Can't search out local app by Chinese Description: Chinese content type is Character.OTHER_LETTER. When key matches,it check the content type. And if type is Character.OTHER_LETTER, it doesn't support search and break. When the content type is Character.OTHER_LETTER, make it work normally. Bug: 63534074 Change-Id: I3713f24c9206fe16a8da2a23e6c90d68079dd533 --- .../launcher3/allapps/search/DefaultAppSearchAlgorithm.java | 3 ++- .../allapps/search/DefaultAppSearchAlgorithmTest.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java b/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java index 8a0fd46f7c..43033024f2 100644 --- a/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java +++ b/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithm.java @@ -132,7 +132,8 @@ public class DefaultAppSearchAlgorithm implements SearchAlgorithm { // Always a break point for a symbol return true; default: - return false; + // Always a break point at first character + return prevType == Character.UNASSIGNED; } } } diff --git a/tests/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithmTest.java b/tests/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithmTest.java index 20b23b070f..58dc0c43e1 100644 --- a/tests/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithmTest.java +++ b/tests/src/com/android/launcher3/allapps/search/DefaultAppSearchAlgorithmTest.java @@ -71,6 +71,10 @@ public class DefaultAppSearchAlgorithmTest extends InstrumentationTestCase { // match lower case words assertTrue(mAlgorithm.matches(getInfo("elephant"), "e")); + assertTrue(mAlgorithm.matches(getInfo("电子邮件"), "电")); + assertTrue(mAlgorithm.matches(getInfo("电子邮件"), "电子")); + assertFalse(mAlgorithm.matches(getInfo("电子邮件"), "子")); + assertFalse(mAlgorithm.matches(getInfo("电子邮件"), "邮件")); } private AppInfo getInfo(String title) { From f5b4b8097239411bdad28be71d50ae883bd82278 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 12 Jul 2017 12:09:37 -0700 Subject: [PATCH 2/2] Fixing widget id restore broadcast. Ignoring thw broadcast if its not for the main widget host, or if the Launcher DB is already in use. Launcher already handles missing widget-Id map broadcast, by binding a new widgetId at runtime. Bug: 63389280 Change-Id: Iaa9774d6d7adde3711cba9615328020e2b2e66aa --- .../launcher3/AppWidgetsRestoredReceiver.java | 22 ++++++++++++++++++- .../launcher3/provider/RestoreDbTask.java | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java index 70be7dae45..6e33d2a556 100644 --- a/src/com/android/launcher3/AppWidgetsRestoredReceiver.java +++ b/src/com/android/launcher3/AppWidgetsRestoredReceiver.java @@ -9,10 +9,12 @@ import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.os.Handler; +import android.support.annotation.WorkerThread; import android.util.Log; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.model.LoaderTask; +import com.android.launcher3.provider.RestoreDbTask; import com.android.launcher3.util.ContentWriter; public class AppWidgetsRestoredReceiver extends BroadcastReceiver { @@ -22,6 +24,12 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { if (AppWidgetManager.ACTION_APPWIDGET_HOST_RESTORED.equals(intent.getAction())) { + int hostId = intent.getIntExtra(AppWidgetManager.EXTRA_HOST_ID, 0); + Log.d(TAG, "Widget ID map received for host:" + hostId); + if (hostId != Launcher.APPWIDGET_HOST_ID) { + return; + } + final int[] oldIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_OLD_IDS); final int[] newIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); if (oldIds.length == newIds.length) { @@ -42,11 +50,23 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { /** * Updates the app widgets whose id has changed during the restore process. */ + @WorkerThread static void restoreAppWidgetIds(Context context, PendingResult asyncResult, int[] oldWidgetIds, int[] newWidgetIds) { + AppWidgetHost appWidgetHost = new AppWidgetHost(context, Launcher.APPWIDGET_HOST_ID); + if (!RestoreDbTask.isPending(context)) { + // Someone has already gone through our DB once, probably LoaderTask. Skip any further + // modifications of the DB. + Log.e(TAG, "Skipping widget ID remap as DB already in use"); + for (int widgetId : newWidgetIds) { + Log.d(TAG, "Deleting widgetId: " + widgetId); + appWidgetHost.deleteAppWidgetId(widgetId); + } + asyncResult.finish(); + return; + } final ContentResolver cr = context.getContentResolver(); final AppWidgetManager widgets = AppWidgetManager.getInstance(context); - AppWidgetHost appWidgetHost = new AppWidgetHost(context, Launcher.APPWIDGET_HOST_ID); for (int i = 0; i < oldWidgetIds.length; i++) { Log.i(TAG, "Widget state restore id " + oldWidgetIds[i] + " => " + newWidgetIds[i]); diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java index 00e2644a5b..5230160085 100644 --- a/src/com/android/launcher3/provider/RestoreDbTask.java +++ b/src/com/android/launcher3/provider/RestoreDbTask.java @@ -134,7 +134,7 @@ public class RestoreDbTask { } public static void setPending(Context context, boolean isPending) { - FileLog.d(TAG, "Restore data received through full backup"); + FileLog.d(TAG, "Restore data received through full backup " + isPending); Utilities.getPrefs(context).edit().putBoolean(RESTORE_TASK_PENDING, isPending).commit(); } }