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: I24032baa54860459d4f1b8e17a80c760c48d5579
Fixes: 70716301
Test: Manual. Run multi-split APK and see that transition animations work when defined in a split
diff --git a/services/core/java/com/android/server/wm/AppTransition.java b/services/core/java/com/android/server/wm/AppTransition.java
index c6f156b..d6e6c70 100644
--- a/services/core/java/com/android/server/wm/AppTransition.java
+++ b/services/core/java/com/android/server/wm/AppTransition.java
@@ -81,6 +81,7 @@
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;
@@ -554,16 +555,16 @@
}
Animation loadAnimationAttr(LayoutParams lp, int animAttr) {
- int anim = 0;
+ int anim = ResourceId.ID_NULL;
Context context = mContext;
- if (animAttr >= 0) {
+ if (ResourceId.isValid(animAttr)) {
AttributeCache.Entry ent = getCachedAnimations(lp);
if (ent != null) {
context = ent.context;
anim = ent.array.getResourceId(animAttr, 0);
}
}
- if (anim != 0) {
+ if (ResourceId.isValid(anim)) {
return AnimationUtils.loadAnimation(context, anim);
}
return null;
@@ -571,7 +572,7 @@
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;
@@ -582,16 +583,16 @@
}
private Animation loadAnimationRes(String packageName, int resId) {
- int anim = 0;
+ int anim = ResourceId.ID_NULL;
Context context = mContext;
- if (resId >= 0) {
+ if (ResourceId.isValid(resId)) {
AttributeCache.Entry ent = getCachedAnimations(packageName, resId);
if (ent != null) {
context = ent.context;
anim = resId;
}
}
- if (anim != 0) {
+ if (ResourceId.isValid(anim)) {
return AnimationUtils.loadAnimation(context, anim);
}
return null;