From 256007747818f1dd55ea735c92fd594473bda22b Mon Sep 17 00:00:00 2001 From: Yogisha Dixit Date: Wed, 3 Mar 2021 18:50:00 +0000 Subject: [PATCH] Do not launch configuration activity if CONFIGURATION_OPTIONAL. Test: Created a placeholder widget with CONFIGURATION_OPTIONAL and checked that configuration activity was not launched. Bug: 177977976 Change-Id: I854c9b3fb6007fd98009182f68fbf36d4571a81f --- .../widget/WidgetAddFlowHandler.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/widget/WidgetAddFlowHandler.java b/src/com/android/launcher3/widget/WidgetAddFlowHandler.java index 1ac5a3328c..93132664ef 100644 --- a/src/com/android/launcher3/widget/WidgetAddFlowHandler.java +++ b/src/com/android/launcher3/widget/WidgetAddFlowHandler.java @@ -15,6 +15,9 @@ */ package com.android.launcher3.widget; +import static android.appwidget.AppWidgetProviderInfo.WIDGET_FEATURE_CONFIGURATION_OPTIONAL; +import static android.appwidget.AppWidgetProviderInfo.WIDGET_FEATURE_RECONFIGURABLE; + import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.os.Parcel; @@ -78,8 +81,22 @@ public class WidgetAddFlowHandler implements Parcelable { return true; } + /** + * Checks whether the widget needs configuration. + * + * A widget needs configuration if (1) it has a configuration activity and (2) + * it's configuration is not optional. + * + * @return true if the widget needs configuration, false otherwise. + */ public boolean needsConfigure() { - return mProviderInfo.configure != null; + int featureFlags = mProviderInfo.widgetFeatures; + // A widget's configuration is optional only if it's configuration is marked as optional AND + // it can be reconfigured later. + boolean configurationOptional = (featureFlags & WIDGET_FEATURE_CONFIGURATION_OPTIONAL) != 0 + && (featureFlags & WIDGET_FEATURE_RECONFIGURABLE) != 0; + + return mProviderInfo.configure != null && !configurationOptional; } public LauncherAppWidgetProviderInfo getProviderInfo(Context context) {