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

Commit cfc16672 authored by Sihua Ma's avatar Sihua Ma
Browse files

Move adapter conversion flag to aconfig

Bug: 245950570
Test: N/A
Change-Id: I4ffacd448fb13864a5507d9586a07ceda09cc81a
parent 3cbe2c8b
Loading
Loading
Loading
Loading
+19 −22
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package android.appwidget;
package android.appwidget;


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

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

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


            updateWidgetWithTask.run();
            updateWidgetWithTask.run();
            return;
        } else {
        }

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


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


        if (!RemoteViews.isAdapterConversionEnabled()) {
        if (remoteAdapterConversion()) {
            if (Looper.myLooper() == Looper.getMainLooper()) {
                mHasPostedLegacyLists = true;
                createUpdateExecutorIfNull().execute(() -> notifyCollectionWidgetChange(
                        appWidgetIds, viewId));
            } else {
                notifyCollectionWidgetChange(appWidgetIds, viewId);
            }
        } else {
            try {
            try {
                mService.notifyAppWidgetViewDataChanged(mPackageName, appWidgetIds, viewId);
                mService.notifyAppWidgetViewDataChanged(mPackageName, appWidgetIds, viewId);
            } catch (RemoteException re) {
            } catch (RemoteException re) {
                throw re.rethrowFromSystemServer();
                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 Original line Diff line number Diff line
@@ -6,3 +6,10 @@ flag {
  description: "Enable support for generated previews in AppWidgetManager"
  description: "Enable support for generated previews in AppWidgetManager"
  bug: "306546610"
  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 Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.widget;
package android.widget;


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


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


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


@@ -4950,21 +4949,11 @@ public class RemoteViews implements Parcelable, Filter {
     */
     */
    @Deprecated
    @Deprecated
    public void setRemoteAdapter(@IdRes int viewId, Intent intent) {
    public void setRemoteAdapter(@IdRes int viewId, Intent intent) {
        if (isAdapterConversionEnabled()) {
        if (remoteAdapterConversion()) {
            addAction(new SetRemoteCollectionItemListAdapterAction(viewId, intent));
            addAction(new SetRemoteCollectionItemListAdapterAction(viewId, intent));
            return;
        } else {
        }
            addAction(new SetRemoteViewsAdapterIntent(viewId, intent));
            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 Original line 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";
    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
     * (boolean) Whether the task manager should show a stop button if the app is allowlisted
     * by the user.
     * by the user.
+0 −7
Original line number Original line Diff line number Diff line
@@ -30,7 +30,6 @@ import android.widget.WidgetFlags;


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


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashMap;
@@ -163,12 +162,6 @@ final class CoreSettingsObserver extends ContentObserver {
                WidgetFlags.KEY_MAGNIFIER_ASPECT_RATIO, float.class,
                WidgetFlags.KEY_MAGNIFIER_ASPECT_RATIO, float.class,
                WidgetFlags.MAGNIFIER_ASPECT_RATIO_DEFAULT));
                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>(
        sDeviceConfigEntries.add(new DeviceConfigEntry<Boolean>(
                TextFlags.NAMESPACE, TextFlags.ENABLE_NEW_CONTEXT_MENU,
                TextFlags.NAMESPACE, TextFlags.ENABLE_NEW_CONTEXT_MENU,
                TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU, boolean.class,
                TextFlags.KEY_ENABLE_NEW_CONTEXT_MENU, boolean.class,