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

Commit ee329728 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

Add hidden API to get current user of HID Device (3/3)

Bug: 69136526
Test: test with apps using HID Device profile
Change-Id: I76b7cc1c2c5eb9e993cda81f3dde6760cc3b75fc
parent 2cd38cb3
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -453,6 +453,15 @@ public class HidDeviceService extends ProfileService {

            return service.getDevicesMatchingConnectionStates(states);
        }

        @Override
        public String getUserAppName() {
            HidDeviceService service = getService();
            if (service == null) {
                return "";
            }
            return service.getUserAppName();
        }
    }

    @Override
@@ -614,6 +623,15 @@ public class HidDeviceService extends ProfileService {
                && mHidDeviceNativeInterface.reportError(error);
    }

    synchronized String getUserAppName() {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        if (mUserUid < Process.FIRST_APPLICATION_UID) {
            return "";
        }
        String appName = getPackageManager().getNameForUid(mUserUid);
        return appName != null ? appName : "";
    }

    @Override
    protected boolean start() {
        if (DBG) {