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
This commit is contained in:
Yogisha Dixit
2021-03-03 18:50:00 +00:00
parent 5e7c89c36e
commit 2560077478

View File

@@ -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) {