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

Commit 6d7d86b5 authored by Guojing Yuan's avatar Guojing Yuan Committed by Automerger Merge Worker
Browse files

Merge "Add permission check while creating CompanionDeviceService" into sc-dev...

Merge "Add permission check while creating CompanionDeviceService" into sc-dev am: dfa9b305 am: 59a90d21

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15394690

Change-Id: Iab0187d6b05b7e2c540aa8dc7c3d956b6af69626
parents d0aaaeca 59a90d21
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package com.android.server.companion;

import static android.Manifest.permission.BIND_COMPANION_DEVICE_SERVICE;
import static android.bluetooth.le.ScanSettings.CALLBACK_TYPE_ALL_MATCHES;
import static android.bluetooth.le.ScanSettings.SCAN_MODE_BALANCED;
import static android.content.Context.BIND_IMPORTANT;
@@ -1197,6 +1198,12 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
                    + " has " + packageResolveInfos.size());
            return new ServiceConnector.NoOp<>();
        }
        String servicePermission = packageResolveInfos.get(0).serviceInfo.permission;
        if (!BIND_COMPANION_DEVICE_SERVICE.equals(servicePermission)) {
            Slog.w(LOG_TAG, "Binding CompanionDeviceService must have "
                    + BIND_COMPANION_DEVICE_SERVICE + " permission.");
            return new ServiceConnector.NoOp<>();
        }
        ComponentName componentName = packageResolveInfos.get(0).serviceInfo.getComponentName();
        Slog.i(LOG_TAG, "Initializing CompanionDeviceService binding for " + componentName);
        return new ServiceConnector.Impl<ICompanionDeviceService>(getContext(),