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

Commit 4eac1165 authored by Alice Kuo's avatar Alice Kuo
Browse files

Use finally block for Binder.restoreCallingIdentity

1. Use final for Binder.clearCallingIdentity() to protect not being overwritten.
2. Protect it in the finally block of the try statement to avoid missing restore the CallingIdentity as exception.

Bug: 189819183
Test: Manual test
Ignore-AOSP-First: prevent merge conflict
Change-Id: I2dd4cfc1aacecb0b77fa4c82b48b24b284271779
parent 0cc9fe2c
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -614,9 +614,13 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        }
        // waive WRITE_SECURE_SETTINGS permission check
        final long callingIdentity = Binder.clearCallingIdentity();
        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.BLUETOOTH_ON, value);
        try {
            Settings.Global.putInt(mContext.getContentResolver(),
                    Settings.Global.BLUETOOTH_ON, value);
        } finally {
            Binder.restoreCallingIdentity(callingIdentity);
        }
    }

    /**
     * Returns true if the Bluetooth Adapter's name and address is