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

Commit 9281084a authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Android Build Cherrypicker Worker
Browse files

PointerIcon: Ensure bitmap size and hotspot are scaled consistently

The density-dependent size of the bitmap is already casted to an int
before we scale it by pointerScale. However, the hotspot did not follow
the same scaling logic, since it was not casted to int before applying
pointerScale. In this CL, we make both the scaling logics consistent.

Bug: 385663202
Test: manual
Flag: EXEMPT bug fix
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:626edb8f8c5450fafaee96aaf702cb9e01c55ab8)
Merged-In: I375008e5603a9e50e4e7132c8faffda3a1cdd765
Change-Id: I375008e5603a9e50e4e7132c8faffda3a1cdd765
parent 4109b479
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -514,10 +514,14 @@ public final class PointerIcon implements Parcelable {
            final TypedArray a = resources.obtainAttributes(
                    parser, com.android.internal.R.styleable.PointerIcon);
            bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0);
            hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0)
                    * pointerScale;
            hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0)
                    * pointerScale;
            // Cast the hotspot dimensions to int before scaling to match the scaling logic of
            // the bitmap, whose intrinsic size is also an int before it is scaled.
            final int unscaledHotSpotX =
                    (int) a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0);
            final int unscaledHotSpotY =
                    (int) a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0);
            hotSpotX = unscaledHotSpotX * pointerScale;
            hotSpotY = unscaledHotSpotY * pointerScale;
            a.recycle();
        } catch (Exception ex) {
            throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex);