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

Commit 5ab87b53 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge changes from topic "oct6"

* changes:
  Upgrade AndroidFrameworkBinderIdentity to fatal.
  Tighten up Binder.clearCallingIdentity() usage.
  Tighten up Binder.clearCallingIdentity() usage.
  Tighten up Binder.clearCallingIdentity() usage.
parents 16ce0ef4 f1ecf223
Loading
Loading
Loading
Loading
+42 −14
Original line number Diff line number Diff line
@@ -342,44 +342,72 @@ public final class BluetoothHidDevice implements BluetoothProfile {

        @Override
        public void onAppStatusChanged(BluetoothDevice pluggedDevice, boolean registered) {
            clearCallingIdentity();
            final long token = clearCallingIdentity();
            try {
                mExecutor.execute(() -> mCallback.onAppStatusChanged(pluggedDevice, registered));
            } finally {
                restoreCallingIdentity(token);
            }
        }

        @Override
        public void onConnectionStateChanged(BluetoothDevice device, int state) {
            clearCallingIdentity();
            final long token = clearCallingIdentity();
            try {
                mExecutor.execute(() -> mCallback.onConnectionStateChanged(device, state));
            } finally {
                restoreCallingIdentity(token);
            }
        }

        @Override
        public void onGetReport(BluetoothDevice device, byte type, byte id, int bufferSize) {
            clearCallingIdentity();
            final long token = clearCallingIdentity();
            try {
                mExecutor.execute(() -> mCallback.onGetReport(device, type, id, bufferSize));
            } finally {
                restoreCallingIdentity(token);
            }
        }

        @Override
        public void onSetReport(BluetoothDevice device, byte type, byte id, byte[] data) {
            clearCallingIdentity();
            final long token = clearCallingIdentity();
            try {
                mExecutor.execute(() -> mCallback.onSetReport(device, type, id, data));
            } finally {
                restoreCallingIdentity(token);
            }
        }

        @Override
        public void onSetProtocol(BluetoothDevice device, byte protocol) {
            clearCallingIdentity();
            final long token = clearCallingIdentity();
            try {
                mExecutor.execute(() -> mCallback.onSetProtocol(device, protocol));
            } finally {
                restoreCallingIdentity(token);
            }
        }

        @Override
        public void onInterruptData(BluetoothDevice device, byte reportId, byte[] data) {
            clearCallingIdentity();
            final long token = clearCallingIdentity();
            try {
                mExecutor.execute(() -> mCallback.onInterruptData(device, reportId, data));
            } finally {
                restoreCallingIdentity(token);
            }
        }

        @Override
        public void onVirtualCableUnplug(BluetoothDevice device) {
            clearCallingIdentity();
            final long token = clearCallingIdentity();
            try {
                mExecutor.execute(() -> mCallback.onVirtualCableUnplug(device));
            } finally {
                restoreCallingIdentity(token);
            }
        }
    }

+3 −3
Original line number Diff line number Diff line
@@ -604,7 +604,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
            Slog.d(TAG, "Persisting Bluetooth Setting: " + value);
        }
        // waive WRITE_SECURE_SETTINGS permission check
        long callingIdentity = Binder.clearCallingIdentity();
        final long callingIdentity = Binder.clearCallingIdentity();
        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.BLUETOOTH_ON, value);
        Binder.restoreCallingIdentity(callingIdentity);
    }
@@ -2378,7 +2378,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        int foregroundUser;
        int callingUser = UserHandle.getCallingUserId();
        int callingUid = Binder.getCallingUid();
        long callingIdentity = Binder.clearCallingIdentity();
        final long callingIdentity = Binder.clearCallingIdentity();
        UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        UserInfo ui = um.getProfileParent(callingUser);
        int parentUser = (ui != null) ? ui.id : UserHandle.USER_NULL;
@@ -2605,7 +2605,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    }

    private boolean isBluetoothDisallowed() {
        long callingIdentity = Binder.clearCallingIdentity();
        final long callingIdentity = Binder.clearCallingIdentity();
        try {
            return mContext.getSystemService(UserManager.class)
                    .hasUserRestriction(UserManager.DISALLOW_BLUETOOTH, UserHandle.SYSTEM);