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

Commit 309f4d50 authored by Guojing Yuan's avatar Guojing Yuan
Browse files

[CDM perm sync] Add DELIVER_COMPANION_MESSAGE permission check

Fix: 235480929

Test: removed the permission from test app and it fails.
Change-Id: Ifa86cf803372ca6c8d831aa2b3abbcd22e622625
parent 8172ec48
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package com.android.server.companion;

import static android.Manifest.permission.DELIVER_COMPANION_MESSAGES;
import static android.Manifest.permission.MANAGE_COMPANION_DEVICES;
import static android.content.pm.PackageManager.CERT_INPUT_SHA256;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
@@ -621,6 +622,9 @@ public class CompanionDeviceManagerService extends SystemService {
                        + " message(Base64)=" + Base64.encodeToString(message, 0));
            }

            getContext().enforceCallingOrSelfPermission(DELIVER_COMPANION_MESSAGES,
                    "dispatchMessage");

            AssociationInfo association = getAssociationWithCallerChecks(associationId);
            if (association == null) {
                throw new IllegalArgumentException("Association with ID " + associationId + " "