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

Commit 626edb8f authored by Prabir Pradhan's avatar Prabir Pradhan
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
Change-Id: I375008e5603a9e50e4e7132c8faffda3a1cdd765
Test: manual
Flag: EXEMPT bug fix
parent dfe161dd
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -514,10 +514,14 @@ public final class PointerIcon implements Parcelable {
            final TypedArray a = resources.obtainAttributes(
            final TypedArray a = resources.obtainAttributes(
                    parser, com.android.internal.R.styleable.PointerIcon);
                    parser, com.android.internal.R.styleable.PointerIcon);
            bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0);
            bitmapRes = a.getResourceId(com.android.internal.R.styleable.PointerIcon_bitmap, 0);
            hotSpotX = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotX, 0)
            // Cast the hotspot dimensions to int before scaling to match the scaling logic of
                    * pointerScale;
            // the bitmap, whose intrinsic size is also an int before it is scaled.
            hotSpotY = a.getDimension(com.android.internal.R.styleable.PointerIcon_hotSpotY, 0)
            final int unscaledHotSpotX =
                    * pointerScale;
                    (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();
            a.recycle();
        } catch (Exception ex) {
        } catch (Exception ex) {
            throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex);
            throw new IllegalArgumentException("Exception parsing pointer icon resource.", ex);