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

Commit 63684603 authored by Evan Chen's avatar Evan Chen
Browse files

Check device icon for legacy associate method

Bug: 341057668
Test: cts
Flag: android.companion.association_device_icon
Change-Id: Ic6eef378bc24dce7331a14b3531b38a2a262b5d8
parent cd85368b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -287,7 +287,7 @@ public final class AssociationInfo implements Parcelable {
    /**
     * Get the device icon of the associated device. The device icon represents the device type.
     *
     * @return the device icon, or {@code null} if no device icon is has been set for the
     * @return the device icon, or {@code null} if no device icon has been set for the
     * associated device.
     *
     * @see AssociationRequest.Builder#setDeviceIcon(Icon)
+2 −2
Original line number Diff line number Diff line
@@ -475,8 +475,8 @@ public final class AssociationRequest implements Parcelable {
        }

        /**
         * Set the device icon for the self-managed device and this icon will be
         * displayed in the self-managed association dialog.
         * Set the device icon for the self-managed device and to display the icon in the
         * self-managed association dialog.
         *
         * @throws IllegalArgumentException if the icon is not exactly 24dp by 24dp
         * or if it is {@link Icon#TYPE_URI} or {@link Icon#TYPE_URI_ADAPTIVE_BITMAP}.
+15 −4
Original line number Diff line number Diff line
@@ -478,6 +478,15 @@ public final class CompanionDeviceManager {
        Objects.requireNonNull(callback, "Callback cannot be null");
        handler = Handler.mainIfNull(handler);

        if (Flags.associationDeviceIcon()) {
            final Icon deviceIcon = request.getDeviceIcon();

            if (deviceIcon != null && !isValidIcon(deviceIcon, mContext)) {
                throw new IllegalArgumentException("The size of the device icon must be "
                        + "24dp x 24dp to ensure proper display");
            }
        }

        try {
            mService.associate(request, new AssociationRequestCallbackProxy(handler, callback),
                    mContext.getOpPackageName(), mContext.getUserId());
@@ -542,11 +551,13 @@ public final class CompanionDeviceManager {
        Objects.requireNonNull(executor, "Executor cannot be null");
        Objects.requireNonNull(callback, "Callback cannot be null");

        if (Flags.associationDeviceIcon()) {
            final Icon deviceIcon = request.getDeviceIcon();

            if (deviceIcon != null && !isValidIcon(deviceIcon, mContext)) {
            throw new IllegalArgumentException("The size of the device icon must be 24dp x 24dp to"
                    + "ensure proper display");
                throw new IllegalArgumentException("The size of the device icon must be "
                        + "24dp x 24dp to ensure proper display");
            }
        }

        try {