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

Commit fbcf2081 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

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
parent 17b2f5d4
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -81,6 +81,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;
@@ -554,16 +555,16 @@ public class AppTransition implements Dump {
    }

    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 @@ public class AppTransition implements Dump {

    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 @@ public class AppTransition implements Dump {
    }

    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;