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

Commit 5d37481b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add binder unhandled exception notification" into main

parents ca4be53f 4235ddb0
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1110,6 +1110,21 @@ public class Binder implements IBinder {
            @Nullable String[] args) {
    }

    /**
     * Called whenever the stub implementation throws an exception which isn't propagated to the
     * remote caller by the binder. If this method isn't overridden, this exception is swallowed,
     * and some default return values are propagated to the caller.
     *
     * <br> <b> This should not throw. </b> Doing so would defeat the purpose of this handler, and
     * suppress the exception it is handling.
     *
     * @param code The transaction code being handled
     * @param e The exception which was thrown.
     * @hide
     */
    protected void onUnhandledException(int code, int flags, Exception e) {
    }

    /**
     * @param in The raw file descriptor that an input data stream can be read from.
     * @param out The raw file descriptor that normal command messages should be written to.
@@ -1408,10 +1423,15 @@ public class Binder implements IBinder {
                } else {
                    Log.w(TAG, "Caught a RuntimeException from the binder stub implementation.", e);
                }
                onUnhandledException(code, flags, e);
            } else {
                // Clear the parcel before writing the exception.
                reply.setDataSize(0);
                reply.setDataPosition(0);
                // The writeException below won't do anything useful if this is the case.
                if (Parcel.getExceptionCode(e) == 0) {
                    onUnhandledException(code, flags, e);
                }
                reply.writeException(e);
            }
            res = true;
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ filegroup {
        "BinderProxyCountingTestApp/src/**/*.java",
        "BinderProxyCountingTestService/src/**/*.java",
        "BinderDeathRecipientHelperApp/src/**/*.java",
        "AppThatCallsBinderMethods/src/**/*.kt",
    ],
    visibility: ["//visibility:private"],
}
@@ -141,6 +142,7 @@ android_test {
        ":BinderFrozenStateChangeCallbackTestApp",
        ":BinderProxyCountingTestApp",
        ":BinderProxyCountingTestService",
        ":AppThatCallsBinderMethods",
    ],
}

+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
        <option name="test-file-name" value="BinderFrozenStateChangeCallbackTestApp.apk" />
        <option name="test-file-name" value="BinderProxyCountingTestApp.apk" />
        <option name="test-file-name" value="BinderProxyCountingTestService.apk" />
        <option name="test-file-name" value="AppThatCallsBinderMethods.apk" />
    </target_preparer>

    <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+20 −0
Original line number Diff line number Diff line
// Copyright (C) 2024 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

android_test_helper_app {
    name: "AppThatCallsBinderMethods",
    srcs: ["src/**/*.kt"],
    platform_apis: true,
    static_libs: ["coretests-aidl"],
}
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ Copyright (C) 2024 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.android.frameworks.coretests.methodcallerhelperapp">
    <application>
        <receiver android:name="com.android.frameworks.coretests.methodcallerhelperapp.CallMethodsReceiver"
                  android:exported="true"/>
    </application>

</manifest>
Loading