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

Commit b246d740 authored by Yu-Ting Tseng's avatar Yu-Ting Tseng
Browse files

Add fallback to FROZEN_CALLEE_POLICY_UNSET

Update RemoteCallbackList to silently fall back to
FROZEN_CALLEE_POLICY_UNSET when the kernel does not support the frozen
notification feature. Eventually the kernel support will be everywhere,
but before that happens we need this fallback to allow various code
paths to start being soaked without breaking things.

Flag: android.os.binder_frozen_state_change_callback
Test: atest android.os.cts.RemoteCallbackListTest
Change-Id: I47a60bd082356f789cfe636d757341c9ed83347f
Bug: 361157077
parent fd1412ee
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -194,15 +194,27 @@ public class RemoteCallbackList<E extends IInterface> {
            }
        }

        public void maybeSubscribeToFrozenCallback() throws RemoteException {
        void maybeSubscribeToFrozenCallback() throws RemoteException {
            if (mFrozenCalleePolicy != FROZEN_CALLEE_POLICY_UNSET) {
                try {
                    mBinder.addFrozenStateChangeCallback(this);
                } catch (UnsupportedOperationException e) {
                    // The kernel does not support frozen notifications. In this case we want to
                    // silently fall back to FROZEN_CALLEE_POLICY_UNSET. This is done by simply
                    // ignoring the error and moving on. mCurrentState would always be
                    // STATE_UNFROZEN and all callbacks are invoked immediately.
                }
            }
        }

        public void maybeUnsubscribeFromFrozenCallback() {
        void maybeUnsubscribeFromFrozenCallback() {
            if (mFrozenCalleePolicy != FROZEN_CALLEE_POLICY_UNSET) {
                try {
                    mBinder.removeFrozenStateChangeCallback(this);
                } catch (UnsupportedOperationException e) {
                    // The kernel does not support frozen notifications. Ignore the error and move
                    // on.
                }
            }
        }