summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViews.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2018-08-22 15:18:37 -0700
committerSunny Goyal <sunnygoyal@google.com>2018-08-22 16:09:43 -0700
commit0279453309d19d96d53a30203469df37a2c75548 (patch)
tree3e57368dfd89f62b366bd93bb4c846c14647feb6 /core/java/android/widget/RemoteViews.java
parentd821df2b425a9be8ec633a04ca5c33ee5cd6a04f (diff)
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
Diffstat (limited to 'core/java/android/widget/RemoteViews.java')
-rw-r--r--core/java/android/widget/RemoteViews.java66
1 files changed, 22 insertions, 44 deletions
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 8fa8ef88a3ad..35ff6cc23499 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -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