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

Commit a1c41c46 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 am: dfa9b305

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

Change-Id: I320a13ba3a56fcb766e37e08909540f153816b3d
parents eb45bc8a dfa9b305
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(),