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
Bug: 361157077
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b246d74057cd44b618ccc21784cbd9f397c7e115)
Merged-In: I47a60bd082356f789cfe636d757341c9ed83347f

Change-Id: I47a60bd082356f789cfe636d757341c9ed83347f
diff --git a/core/java/android/os/RemoteCallbackList.java b/core/java/android/os/RemoteCallbackList.java
index 01b1e5e1..91c482fa 100644
--- a/core/java/android/os/RemoteCallbackList.java
+++ b/core/java/android/os/RemoteCallbackList.java
@@ -194,15 +194,27 @@
             }
         }
 
-        public void maybeSubscribeToFrozenCallback() throws RemoteException {
+        void maybeSubscribeToFrozenCallback() throws RemoteException {
             if (mFrozenCalleePolicy != FROZEN_CALLEE_POLICY_UNSET) {
-                mBinder.addFrozenStateChangeCallback(this);
+                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) {
-                mBinder.removeFrozenStateChangeCallback(this);
+                try {
+                    mBinder.removeFrozenStateChangeCallback(this);
+                } catch (UnsupportedOperationException e) {
+                    // The kernel does not support frozen notifications. Ignore the error and move
+                    // on.
+                }
             }
         }