From 64c57a8c9649a1c264f667710538f65d1a8ea0b4 Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Thu, 19 Apr 2018 15:17:24 -0700 Subject: [PATCH] Don't consider resources < 0 as invalid The only invalid resource ID is '0'. All other resource IDs are valid; even negative resource IDs. With the introduction of namespaces in AAPT2, resource IDs start with 0x80, 0x81, ... [ie. because Java only supports signed types, they are considered negative]. For app transition animations negative resource IDs were incorrectly considered "invalid". Change-Id: Ic8837975d8811826bb9b6635d44a0ac004daad36 Fixes: 70716301 Test: Manual. Run multi-split APK and see that transition animations work when defined in a split Test: Manual. Open a textbox and see the keyboard animates correctly. --- .../com/android/server/wm/AppTransition.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java index 0dc06b27a6050..48b6e51eacfbd 100644 --- a/services/core/java/com/android/server/wm/AppTransition.java +++ b/services/core/java/com/android/server/wm/AppTransition.java @@ -82,6 +82,7 @@ import android.app.ActivityManager; import android.content.ComponentName; import android.content.Context; import android.content.res.Configuration; +import android.content.res.ResourceId; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; @@ -555,25 +556,25 @@ public class AppTransition implements Dump { } Animation loadAnimationAttr(LayoutParams lp, int animAttr, int transit) { - int anim = 0; + int resId = ResourceId.ID_NULL; Context context = mContext; if (animAttr >= 0) { AttributeCache.Entry ent = getCachedAnimations(lp); if (ent != null) { context = ent.context; - anim = ent.array.getResourceId(animAttr, 0); + resId = ent.array.getResourceId(animAttr, 0); } } - anim = updateToTranslucentAnimIfNeeded(anim, transit); - if (anim != 0) { - return AnimationUtils.loadAnimation(context, anim); + resId = updateToTranslucentAnimIfNeeded(resId, transit); + if (ResourceId.isValid(resId)) { + return AnimationUtils.loadAnimation(context, resId); } return null; } Animation loadAnimationRes(LayoutParams lp, int resId) { Context context = mContext; - if (resId >= 0) { + if (ResourceId.isValid(resId)) { AttributeCache.Entry ent = getCachedAnimations(lp); if (ent != null) { context = ent.context; @@ -584,18 +585,12 @@ public class AppTransition implements Dump { } private Animation loadAnimationRes(String packageName, int resId) { - int anim = 0; - Context context = mContext; - if (resId >= 0) { + if (ResourceId.isValid(resId)) { AttributeCache.Entry ent = getCachedAnimations(packageName, resId); if (ent != null) { - context = ent.context; - anim = resId; + return AnimationUtils.loadAnimation(ent.context, resId); } } - if (anim != 0) { - return AnimationUtils.loadAnimation(context, anim); - } return null; }