Merge changes I47a60bd0,Ib777d992,Iba5b9c9e into main am: 095d91484c

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3348985

Change-Id: Ib33a09619237ad3247050bb2d7cee8f3af8b0dec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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.
+                }
             }
         }