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

Commit 02794533 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Fixing static instant of OnClickHandler is getting modified at runtime

Bug: 113071278
Test: atest core/tests/coretests/src/android/widget/RemoteViewsTest.java
Change-Id: Ie32e897a7a82e8dced49927312b43273e2e90db9
parent d821df2b
Loading
Loading
Loading
Loading
+22 −44
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.widget;

import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;

import android.annotation.ColorInt;
import android.annotation.DimenRes;
import android.annotation.NonNull;
@@ -364,29 +362,12 @@ public class RemoteViews implements Parcelable, Filter {
    /** @hide */
    public static class OnClickHandler {

        private int mEnterAnimationId;

        @UnsupportedAppUsage
        public boolean onClickHandler(View view, PendingIntent pendingIntent,
                Intent fillInIntent) {
            return onClickHandler(view, pendingIntent, fillInIntent, WINDOWING_MODE_UNDEFINED);
        }

        public boolean onClickHandler(View view, PendingIntent pendingIntent,
                Intent fillInIntent, int windowingMode) {
        public boolean onClickHandler(View view, PendingIntent pendingIntent, Intent fillInIntent) {
            try {
                // TODO: Unregister this handler if PendingIntent.FLAG_ONE_SHOT?
                Context context = view.getContext();
                ActivityOptions opts;
                if (mEnterAnimationId != 0) {
                    opts = ActivityOptions.makeCustomAnimation(context, mEnterAnimationId, 0);
                } else {
                    opts = ActivityOptions.makeBasic();
                }

                if (windowingMode != WINDOWING_MODE_UNDEFINED) {
                    opts.setLaunchWindowingMode(windowingMode);
                }
                ActivityOptions opts = getActivityOptions(context);
                context.startIntentSender(
                        pendingIntent.getIntentSender(), fillInIntent,
                        Intent.FLAG_ACTIVITY_NEW_TASK,
@@ -402,8 +383,26 @@ public class RemoteViews implements Parcelable, Filter {
            return true;
        }

        public void setEnterAnimationId(int enterAnimationId) {
            mEnterAnimationId = enterAnimationId;
        /** @hide */
        protected ActivityOptions getActivityOptions(Context context) {
            if (context.getResources().getBoolean(
                    com.android.internal.R.bool.config_overrideRemoteViewsActivityTransition)) {
                TypedArray windowStyle = context.getTheme().obtainStyledAttributes(
                        com.android.internal.R.styleable.Window);
                int windowAnimations = windowStyle.getResourceId(
                        com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
                TypedArray windowAnimationStyle = context.obtainStyledAttributes(
                        windowAnimations, com.android.internal.R.styleable.WindowAnimation);
                int enterAnimationId = windowAnimationStyle.getResourceId(com.android.internal.R
                        .styleable.WindowAnimation_activityOpenRemoteViewsEnterAnimation, 0);
                windowStyle.recycle();
                windowAnimationStyle.recycle();

                if (enterAnimationId != 0) {
                    return ActivityOptions.makeCustomAnimation(context, enterAnimationId, 0);
                }
            }
            return ActivityOptions.makeBasic();
        }
    }

@@ -3324,8 +3323,6 @@ public class RemoteViews implements Parcelable, Filter {
        RemoteViews rvToApply = getRemoteViewsToApply(context);

        View result = inflateView(context, rvToApply, parent);
        loadTransitionOverride(context, handler);

        rvToApply.performApply(result, parent, handler);

        return result;
@@ -3355,24 +3352,6 @@ public class RemoteViews implements Parcelable, Filter {
        return v;
    }

    private static void loadTransitionOverride(Context context,
            RemoteViews.OnClickHandler handler) {
        if (handler != null && context.getResources().getBoolean(
                com.android.internal.R.bool.config_overrideRemoteViewsActivityTransition)) {
            TypedArray windowStyle = context.getTheme().obtainStyledAttributes(
                    com.android.internal.R.styleable.Window);
            int windowAnimations = windowStyle.getResourceId(
                    com.android.internal.R.styleable.Window_windowAnimationStyle, 0);
            TypedArray windowAnimationStyle = context.obtainStyledAttributes(
                    windowAnimations, com.android.internal.R.styleable.WindowAnimation);
            handler.setEnterAnimationId(windowAnimationStyle.getResourceId(
                    com.android.internal.R.styleable.
                            WindowAnimation_activityOpenRemoteViewsEnterAnimation, 0));
            windowStyle.recycle();
            windowAnimationStyle.recycle();
        }
    }

    /**
     * Implement this interface to receive a callback when
     * {@link #applyAsync} or {@link #reapplyAsync} is finished.
@@ -3445,7 +3424,6 @@ public class RemoteViews implements Parcelable, Filter {
            mHandler = handler;

            mResult = result;
            loadTransitionOverride(context, handler);
        }

        @Override
+7 −5
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;

import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.PendingIntent;
import android.app.RemoteInput;
import android.content.Context;
@@ -113,7 +114,7 @@ public class NotificationRemoteInputManager implements Dumpable {
            } catch (RemoteException e) {
            }
            return mCallback.handleRemoteViewClick(view, pendingIntent, fillInIntent,
                    () -> superOnClickHandler(view, pendingIntent, fillInIntent));
                    () -> super.onClickHandler(view, pendingIntent, fillInIntent));
        }

        private void logActionClick(View view) {
@@ -151,10 +152,11 @@ public class NotificationRemoteInputManager implements Dumpable {
            return null;
        }

        private boolean superOnClickHandler(View view, PendingIntent pendingIntent,
                Intent fillInIntent) {
            return super.onClickHandler(view, pendingIntent, fillInIntent,
                    WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY);
        @Override
        protected ActivityOptions getActivityOptions(Context context) {
            ActivityOptions options = super.getActivityOptions(context);
            options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY);
            return options;
        }

        private boolean handleRemoteInput(View view, PendingIntent pendingIntent) {