Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25600774 authored by Yogisha Dixit's avatar Yogisha Dixit
Browse files

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
parent 5e7c89c3
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -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) {