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

Commit 9377a19e authored by William Escande's avatar William Escande
Browse files

SystemServer: One unique method to call Enable

Bug: 311772251
Test: None
Flag: Exempt refactor
Change-Id: Ifbd1649eb9adc6463626fefd883969a2d6b61f14
parent 8abf193e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -49,8 +49,8 @@ interface IBluetooth
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    int getState();

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    oneway void enable(boolean quietMode, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)")
    oneway void offToBleOn(boolean quietMode, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    oneway void disable(in AttributionSource attributionSource);

+8 −8
Original line number Diff line number Diff line
@@ -2294,16 +2294,16 @@ public class AdapterService extends Service {
        }

        @Override
        public void enable(boolean quietMode, AttributionSource source) {
        public void offToBleOn(boolean quietMode, AttributionSource source) {
            AdapterService service = getService();
            if (service == null
                    || !callerIsSystemOrActiveOrManagedUser(service, TAG, "enable")
                    || !Utils.checkConnectPermissionForDataDelivery(
                            service, source, "AdapterService enable")) {
                    || !callerIsSystemOrActiveOrManagedUser(service, TAG, "offToBleOn")) {
                return;
            }

            service.enable(quietMode);
            service.enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED, null);

            service.offToBleOn(quietMode);
        }

        @Override
@@ -4583,11 +4583,11 @@ public class AdapterService extends Service {
        return BluetoothAdapter.STATE_OFF;
    }

    public synchronized void enable(boolean quietMode) {
    public synchronized void offToBleOn(boolean quietMode) {
        // Enforce the user restriction for disallowing Bluetooth if it was set.
        if (mUserManager.hasUserRestrictionForUser(
                UserManager.DISALLOW_BLUETOOTH, UserHandle.SYSTEM)) {
            Log.d(TAG, "enable() called when Bluetooth was disallowed");
            Log.d(TAG, "offToBleOn() called when Bluetooth was disallowed");
            return;
        }
        if (Flags.fastBindToApp()) {
@@ -4595,7 +4595,7 @@ public class AdapterService extends Service {
            mHandler.post(() -> init());
        }

        Log.i(TAG, "enable() - Enable called with quiet mode status =  " + quietMode);
        Log.i(TAG, "offToBleOn() - Enable called with quiet mode status =  " + quietMode);
        mQuietmode = quietMode;
        mAdapterStateMachine.sendMessage(AdapterState.BLE_TURN_ON);
    }
+2 −2
Original line number Diff line number Diff line
@@ -409,7 +409,7 @@ public class AdapterServiceTest {
            Context ctx,
            IBluetoothCallback callback,
            AdapterNativeInterface nativeInterface) {
        adapter.enable(false);
        adapter.offToBleOn(false);
        if (Flags.fastBindToApp()) {
            TestUtils.syncHandler(looper, 0); // when fastBindToApp is enable init need to be run
        }
@@ -620,7 +620,7 @@ public class AdapterServiceTest {
    public void testGattStartTimeout() {
        assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF);

        mAdapterService.enable(false);
        mAdapterService.offToBleOn(false);
        if (Flags.fastBindToApp()) {
            syncHandler(0); // when fastBindToApp is enable init need to be run
        }
+0 −1
Original line number Diff line number Diff line
Landroid/bluetooth/IBluetooth$Stub;->TRANSACTION_enable:I
Landroid/bluetooth/IBluetoothManager$Stub;->TRANSACTION_enable:I
+2 −2
Original line number Diff line number Diff line
@@ -39,8 +39,8 @@ class AdapterBinder(rawBinder: IBinder) {
    }

    @Throws(RemoteException::class)
    fun enable(quietMode: Boolean, source: AttributionSource) {
        adapterBinder.enable(quietMode, source)
    fun offToBleOn(quietMode: Boolean, source: AttributionSource) {
        adapterBinder.offToBleOn(quietMode, source)
    }

    @Throws(RemoteException::class)
Loading