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

Commit b15402bf authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move onExecuteFunction call to main thread instead of Binder thread" into main

parents 331b0529 654a2f2a
Loading
Loading
Loading
Loading
+28 −22
Original line number Original line Diff line number Diff line
@@ -103,15 +103,20 @@ public abstract class AppFunctionService extends Service {
                }
                }
                SafeOneTimeExecuteAppFunctionCallback safeCallback =
                SafeOneTimeExecuteAppFunctionCallback safeCallback =
                        new SafeOneTimeExecuteAppFunctionCallback(callback);
                        new SafeOneTimeExecuteAppFunctionCallback(callback);
                context.getMainExecutor().execute(
                        () -> {
                            try {
                            try {
                                onExecuteFunction.perform(
                                onExecuteFunction.perform(
                                        request,
                                        request,
                                        callingPackage,
                                        callingPackage,
                                        callingPackageSigningInfo,
                                        callingPackageSigningInfo,
                                        buildCancellationSignal(cancellationCallback),
                                        buildCancellationSignal(cancellationCallback),
                            new OutcomeReceiver<>() {
                                        new OutcomeReceiver<
                                                ExecuteAppFunctionResponse,
                                                AppFunctionException>() {
                                            @Override
                                            @Override
                                public void onResult(ExecuteAppFunctionResponse result) {
                                            public void onResult(
                                                    ExecuteAppFunctionResponse result) {
                                                safeCallback.onResult(result);
                                                safeCallback.onResult(result);
                                            }
                                            }


@@ -121,11 +126,12 @@ public abstract class AppFunctionService extends Service {
                                            }
                                            }
                                        });
                                        });
                            } catch (Exception ex) {
                            } catch (Exception ex) {
                    // Apps should handle exceptions. But if they don't, report the error on
                                // Apps should handle exceptions. But if they don't, report the
                    // behalf of them.
                                // error on behalf of them.
                                safeCallback.onError(
                                safeCallback.onError(
                                        new AppFunctionException(toErrorCode(ex), ex.getMessage()));
                                        new AppFunctionException(toErrorCode(ex), ex.getMessage()));
                            }
                            }
                        });
            }
            }
        };
        };
    }
    }