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

Commit bd6c0d1a authored by William Escande's avatar William Escande
Browse files

SystemServer: Make unidirectional call oneway

Test: atest boot test with the CL to fix the syncrhonous
Flag: Exempt, must have for aosp/3009913 that cannot be flagged
Bug: 324420709
Change-Id: Ic5648f18f7956e29c25b3001b26551aac558dfee
parent 93821176
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -50,9 +50,9 @@ interface IBluetooth
    int getState();

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT},anyOf={android.Manifest.permission.INTERACT_ACROSS_USERS,android.Manifest.permission.MANAGE_USERS})")
    boolean enable(boolean quietMode, in AttributionSource attributionSource);
    oneway void enable(boolean quietMode, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    boolean disable(in AttributionSource attributionSource);
    oneway void disable(in AttributionSource attributionSource);

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.LOCAL_MAC_ADDRESS})")
    String getAddress(in AttributionSource attributionSource);
@@ -161,9 +161,9 @@ interface IBluetooth
    boolean setSimAccessPermission(in BluetoothDevice device, int value, in AttributionSource attributionSource);

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void registerCallback(in IBluetoothCallback callback, in AttributionSource attributionSource);
    oneway void registerCallback(in IBluetoothCallback callback, in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void unregisterCallback(in IBluetoothCallback callback, in AttributionSource attributionSource);
    oneway void unregisterCallback(in IBluetoothCallback callback, in AttributionSource attributionSource);

    // For Socket
    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
@@ -231,9 +231,9 @@ interface IBluetooth
    oneway void requestActivityInfo(in IBluetoothActivityEnergyInfoListener listener, in AttributionSource attributionSource);

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void startBrEdr(in AttributionSource attributionSource);
    oneway void startBrEdr(in AttributionSource attributionSource);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
    void stopBle(in AttributionSource attributionSource);
    oneway void stopBle(in AttributionSource attributionSource);

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED,android.Manifest.permission.MODIFY_PHONE_STATE})")
    int connectAllEnabledProfiles(in BluetoothDevice device, in AttributionSource attributionSource);
@@ -310,7 +310,7 @@ interface IBluetooth
    IBinder getBluetoothScan();

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    void unregAllGattClient(in AttributionSource attributionSource);
    oneway void unregAllGattClient(in AttributionSource attributionSource);

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    IBinder getProfile(int profile);
+9 −11
Original line number Diff line number Diff line
@@ -2217,29 +2217,29 @@ public class AdapterService extends Service {
        }

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

            return service.enable(quietMode);
            service.enable(quietMode);
        }

        @Override
        public boolean disable(AttributionSource attributionSource) {
        public void disable(AttributionSource attributionSource) {
            AdapterService service = getService();
            if (service == null
                    || !callerIsSystemOrActiveOrManagedUser(service, TAG, "disable")
                    || !Utils.checkConnectPermissionForDataDelivery(
                            service, attributionSource, "AdapterService disable")) {
                return false;
                return;
            }

            return service.disable();
            service.disable();
        }

        @Override
@@ -4519,12 +4519,12 @@ public class AdapterService extends Service {
                android.Manifest.permission.INTERACT_ACROSS_USERS,
                android.Manifest.permission.MANAGE_USERS,
            })
    public synchronized boolean enable(boolean quietMode) {
    public synchronized void enable(boolean quietMode) {
        // Enforce the user restriction for disallowing Bluetooth if it was set.
        if (mUserManager.hasUserRestrictionForUser(
                UserManager.DISALLOW_BLUETOOTH, UserHandle.SYSTEM)) {
            debugLog("enable() called when Bluetooth was disallowed");
            return false;
            return;
        }
        if (Flags.fastBindToApp()) {
            // The call to init must be done on the main thread
@@ -4534,13 +4534,11 @@ public class AdapterService extends Service {
        debugLog("enable() - Enable called with quiet mode status =  " + quietMode);
        mQuietmode = quietMode;
        mAdapterStateMachine.sendMessage(AdapterState.BLE_TURN_ON);
        return true;
    }

    boolean disable() {
    void disable() {
        debugLog("disable() called with mRunningProfiles.size() = " + mRunningProfiles.size());
        mAdapterStateMachine.sendMessage(AdapterState.USER_TURN_OFF);
        return true;
    }

    public String getName() {
+4 −4
Original line number Diff line number Diff line
@@ -32,13 +32,13 @@ class AdapterBinder(rawBinder: IBinder) {
        "[Binder=" + adapterBinder.hashCode() + ", createdAt=" + timeToLog(createdAt) + "]"

    @Throws(RemoteException::class)
    fun disable(source: AttributionSource): Boolean {
        return adapterBinder.disable(source)
    fun disable(source: AttributionSource) {
        adapterBinder.disable(source)
    }

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

    @Throws(RemoteException::class)
+3 −9
Original line number Diff line number Diff line
@@ -1814,9 +1814,7 @@ class BluetoothManagerService {

                        // Do enable request
                        try {
                            if (!mAdapter.enable(mQuietEnable, mContext.getAttributionSource())) {
                                Log.e(TAG, "IBluetooth.enable() returned false");
                            }
                            mAdapter.enable(mQuietEnable, mContext.getAttributionSource());
                        } catch (RemoteException e) {
                            Log.e(TAG, "Unable to call enable()", e);
                        }
@@ -2089,9 +2087,7 @@ class BluetoothManagerService {
            } else if (mAdapter != null) {
                // Enable bluetooth
                try {
                    if (!mAdapter.enable(mQuietEnable, mContext.getAttributionSource())) {
                        Log.e(TAG, "IBluetooth.enable() returned false");
                    }
                    mAdapter.enable(mQuietEnable, mContext.getAttributionSource());
                } catch (RemoteException e) {
                    Log.e(TAG, "Unable to call enable()", e);
                }
@@ -2117,9 +2113,7 @@ class BluetoothManagerService {
        try {
            if (mAdapter != null) {
                Log.d(TAG, "handleDisable: Sending off request.");
                if (!mAdapter.disable(mContext.getAttributionSource())) {
                    Log.e(TAG, "IBluetooth.disable() returned false");
                }
                mAdapter.disable(mContext.getAttributionSource());
            }
        } catch (RemoteException e) {
            Log.e(TAG, "Unable to call disable()", e);