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

Commit bb850191 authored by Zach Johnson's avatar Zach Johnson
Browse files

Simplify getMessageAccessPermission

Bug: 145171640
Test: compile & run
Change-Id: I547a80b322c6e8bc815fd13bb1037faafdd8b2d2
parent 76e48bbd
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -1771,7 +1771,15 @@ public class AdapterService extends Service {

            enforceBluetoothPermission(service);

            return service.getMessageAccessPermission(device);
            SharedPreferences prefs = service.getSharedPreferences(
                    MESSAGE_ACCESS_PERMISSION_PREFERENCE_FILE,
                    Context.MODE_PRIVATE);
            if (!prefs.contains(device.getAddress())) {
                return BluetoothDevice.ACCESS_UNKNOWN;
            }
            return prefs.getBoolean(device.getAddress(), false)
                    ? BluetoothDevice.ACCESS_ALLOWED
                    : BluetoothDevice.ACCESS_REJECTED;
        }

        @Override
@@ -2604,16 +2612,6 @@ public class AdapterService extends Service {
        return true;
    }

    int getMessageAccessPermission(BluetoothDevice device) {
        SharedPreferences pref = getSharedPreferences(MESSAGE_ACCESS_PERMISSION_PREFERENCE_FILE,
                Context.MODE_PRIVATE);
        if (!pref.contains(device.getAddress())) {
            return BluetoothDevice.ACCESS_UNKNOWN;
        }
        return pref.getBoolean(device.getAddress(), false) ? BluetoothDevice.ACCESS_ALLOWED
                : BluetoothDevice.ACCESS_REJECTED;
    }

    boolean setMessageAccessPermission(BluetoothDevice device, int value) {
        SharedPreferences pref = getSharedPreferences(MESSAGE_ACCESS_PERMISSION_PREFERENCE_FILE,
                Context.MODE_PRIVATE);