Merge "Specify REQUEST_RECONFIGURE_APPWIDGET when dropping on Setup target" into sc-dev am: 91c27f28c6
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/14517560
Change-Id: I8bfff690e5d3415220b2b6df82080179101300e1
diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java
index 7c8041c..c8a72cd 100644
--- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java
+++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java
@@ -111,11 +111,6 @@
public void initialize(Task task) {
mTask = task;
- if (task.key.userId != UserHandle.myUserId()) {
- setNoLimit();
- return;
- }
-
THREAD_POOL_EXECUTOR.execute(() -> {
final AppUsageLimit usageLimit = mLauncherApps.getAppUsageLimit(
task.getTopComponent().getPackageName(),
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7b67807..559e89e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -139,6 +139,7 @@
import com.android.launcher3.model.ItemInstallQueue;
import com.android.launcher3.model.ModelUtils;
import com.android.launcher3.model.ModelWriter;
+import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
@@ -2316,24 +2317,43 @@
try {
final LauncherAppWidgetProviderInfo appWidgetInfo;
+ String reason = "";
if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)) {
// If the provider is not ready, bind as a pending widget.
appWidgetInfo = null;
+ reason = "the provider not ready.";
} else if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) {
// The widget id is not valid. Try to find the widget based on the provider info.
appWidgetInfo = mAppWidgetManager.findProvider(item.providerName, item.user);
+ if (appWidgetInfo == null) {
+ if (WidgetsModel.GO_DISABLE_WIDGETS) {
+ reason = "widgets are disabled on go device.";
+ } else {
+ reason = "WidgetManagerHelper cannot find a provider from provider info.";
+ }
+ }
} else {
appWidgetInfo = mAppWidgetManager.getLauncherAppWidgetInfo(item.appWidgetId);
+ if (appWidgetInfo == null) {
+ if (item.appWidgetId <= LauncherAppWidgetInfo.CUSTOM_WIDGET_ID) {
+ reason = "CustomWidgetManager cannot find provider from that widget id .";
+ } else {
+ reason = "AppWidgetManager cannot find provider for that widget id."
+ + " It could be due to AppWidgetService is not available, or the"
+ + " appWidgetId has not been bound to a the provider yet, or you"
+ + " don't have access to that appWidgetId.";
+ }
+ }
}
// If the provider is ready, but the width is not yet restored, try to restore it.
if (!item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)
&& (item.restoreStatus != LauncherAppWidgetInfo.RESTORE_COMPLETED)) {
if (appWidgetInfo == null) {
- Log.d(TAG, "Removing restored widget: id=" + item.appWidgetId
- + " belongs to component " + item.providerName
- + ", as the provider is null");
+ FileLog.d(TAG, "Removing restored widget: id=" + item.appWidgetId
+ + " belongs to component " + item.providerName + " user " + item.user
+ + ", as the provider is null and " + reason);
getModelWriter().deleteItemFromDatabase(item);
return null;
}