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

Commit 806af8b7 authored by Sihua Ma's avatar Sihua Ma Committed by Android (Google) Code Review
Browse files

Merge "Move adapter conversion flag to aconfig" into main

parents 340e8ba2 cfc16672
Loading
Loading
Loading
Loading
+19 −22
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.appwidget;

import static android.appwidget.flags.Flags.remoteAdapterConversion;

import android.annotation.BroadcastBehavior;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -566,11 +568,9 @@ public class AppWidgetManager {
    private void tryAdapterConversion(
            FunctionalUtils.RemoteExceptionIgnoringConsumer<RemoteViews> action,
            RemoteViews original, String failureMsg) {
        final boolean isConvertingAdapter = RemoteViews.isAdapterConversionEnabled()
        if (remoteAdapterConversion()
                && (mHasPostedLegacyLists = mHasPostedLegacyLists
                        || (original != null && original.hasLegacyLists()));

        if (isConvertingAdapter) {
                        || (original != null && original.hasLegacyLists()))) {
            final RemoteViews viewsCopy = new RemoteViews(original);
            Runnable updateWidgetWithTask = () -> {
                try {
@@ -587,15 +587,14 @@ public class AppWidgetManager {
            }

            updateWidgetWithTask.run();
            return;
        }

        } else {
            try {
                action.acceptOrThrow(original);
            } catch (RemoteException re) {
                throw re.rethrowFromSystemServer();
            }
        }
    }

    /**
     * Set the RemoteViews to use for the specified appWidgetIds.
@@ -838,22 +837,20 @@ public class AppWidgetManager {
            return;
        }

        if (!RemoteViews.isAdapterConversionEnabled()) {
        if (remoteAdapterConversion()) {
            if (Looper.myLooper() == Looper.getMainLooper()) {
                mHasPostedLegacyLists = true;
                createUpdateExecutorIfNull().execute(() -> notifyCollectionWidgetChange(
                        appWidgetIds, viewId));
            } else {
                notifyCollectionWidgetChange(appWidgetIds, viewId);
            }
        } else {
            try {
                mService.notifyAppWidgetViewDataChanged(mPackageName, appWidgetIds, viewId);
            } catch (RemoteException re) {
                throw re.rethrowFromSystemServer();
            }

            return;
        }

        if (Looper.myLooper() == Looper.getMainLooper()) {
            mHasPostedLegacyLists = true;
            createUpdateExecutorIfNull().execute(() -> notifyCollectionWidgetChange(appWidgetIds,
                    viewId));
        } else {
            notifyCollectionWidgetChange(appWidgetIds, viewId);
        }
    }

+7 −0
Original line number Diff line number Diff line
@@ -6,3 +6,10 @@ flag {
  description: "Enable support for generated previews in AppWidgetManager"
  bug: "306546610"
}

flag {
  name: "remote_adapter_conversion"
  namespace: "app_widgets"
  description: "Enable adapter conversion to RemoteCollectionItemsAdapter"
  bug: "245950570"
}
 No newline at end of file
+4 −15
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.widget;

import static android.appwidget.flags.Flags.remoteAdapterConversion;
import static android.view.inputmethod.Flags.FLAG_HOME_SCREEN_HANDWRITING_DELEGATOR;

import android.annotation.AttrRes;
@@ -36,7 +37,6 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityOptions;
import android.app.ActivityThread;
import android.app.AppGlobals;
import android.app.Application;
import android.app.LoadedApk;
import android.app.PendingIntent;
@@ -108,7 +108,6 @@ import android.widget.AdapterView.OnItemClickListener;
import android.widget.CompoundButton.OnCheckedChangeListener;

import com.android.internal.R;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.util.Preconditions;
import com.android.internal.widget.IRemoteViewsFactory;

@@ -4950,21 +4949,11 @@ public class RemoteViews implements Parcelable, Filter {
     */
    @Deprecated
    public void setRemoteAdapter(@IdRes int viewId, Intent intent) {
        if (isAdapterConversionEnabled()) {
        if (remoteAdapterConversion()) {
            addAction(new SetRemoteCollectionItemListAdapterAction(viewId, intent));
            return;
        }
        } else {
            addAction(new SetRemoteViewsAdapterIntent(viewId, intent));
        }

    /**
     * @hide
     * @return True if the remote adapter conversion is enabled
     */
    public static boolean isAdapterConversionEnabled() {
        return AppGlobals.getIntCoreSetting(
                SystemUiDeviceConfigFlags.REMOTEVIEWS_ADAPTER_CONVERSION,
                SystemUiDeviceConfigFlags.REMOTEVIEWS_ADAPTER_CONVERSION_DEFAULT ? 1 : 0) != 0;
    }

    /**
+0 −18
Original line number Diff line number Diff line
@@ -518,24 +518,6 @@ public final class SystemUiDeviceConfigFlags {
     */
    public static final String TASK_MANAGER_SHOW_FOOTER_DOT = "task_manager_show_footer_dot";

    /**
     * (boolean) Whether to enable the adapter conversion in RemoteViews
     */
    public static final String REMOTEVIEWS_ADAPTER_CONVERSION =
            "CursorControlFeature__remoteviews_adapter_conversion";

    /**
     * The key name used in app core settings for {@link #REMOTEVIEWS_ADAPTER_CONVERSION}
     */
    public static final String KEY_REMOTEVIEWS_ADAPTER_CONVERSION =
            "systemui__remoteviews_adapter_conversion";

    /**
     * Default value for whether the adapter conversion is enabled or not. This is set for
     * RemoteViews and should not be a common practice.
     */
    public static final boolean REMOTEVIEWS_ADAPTER_CONVERSION_DEFAULT = false;

    /**
     * (boolean) Whether the task manager should show a stop button if the app is allowlisted
     * by the user.
+0 −7
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.widget.WidgetFlags;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;

import java.util.ArrayList;
import java.util.HashMap;
@@ -163,12 +162,6 @@ final class CoreSettingsObserver extends ContentObserver {
                WidgetFlags.KEY_MAGNIFIER_ASPECT_RATIO, float.class,
                WidgetFlags.MAGNIFIER_ASPECT_RATIO_DEFAULT));

        sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
                DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.REMOTEVIEWS_ADAPTER_CONVERSION,
                SystemUiDeviceConfigFlags.KEY_REMOTEVIEWS_ADAPTER_CONVERSION, boolean.class,
                SystemUiDeviceConfigFlags.REMOTEVIEWS_ADAPTER_CONVERSION_DEFAULT));

        sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
                TextFlags.NAMESPACE, TextFlags.ENABLE_NEW_CONTEXT_MENU,
                TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU, boolean.class,