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

Commit dfa9b305 authored by Guojing Yuan's avatar Guojing Yuan Committed by Android (Google) Code Review
Browse files

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

parents b68c209b 9f7cbe51
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(),