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

Commit e786a09b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "[Stability][Bugfix] Catch DeadObjectException in TCMS." am: 8c93a720...

Merge "[Stability][Bugfix] Catch DeadObjectException in TCMS." am: 8c93a720 am: 4259e1cf am: 205bda07 am: bd805bbc

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

Change-Id: I75c0e810eaa0e5cc61a66a18b4b560ce8d1608f5
parents 1a5be8fc bd805bbc
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -528,12 +528,13 @@ public final class TextClassificationManagerService extends ITextClassifierServi
                    callback.onFailure();
                    return;
                }
                textClassifierServiceConsumer.accept(serviceState.mService);
                consumeServiceNoExceptLocked(textClassifierServiceConsumer, serviceState.mService);
            } else {
                serviceState.mPendingRequests.add(
                        new PendingRequest(
                                methodName,
                                () -> textClassifierServiceConsumer.accept(serviceState.mService),
                                () -> consumeServiceNoExceptLocked(
                                        textClassifierServiceConsumer, serviceState.mService),
                                callback::onFailure, callback.asBinder(),
                                this,
                                serviceState,
@@ -542,6 +543,16 @@ public final class TextClassificationManagerService extends ITextClassifierServi
        }
    }

    private static void consumeServiceNoExceptLocked(
            @NonNull ThrowingConsumer<ITextClassifierService> textClassifierServiceConsumer,
            @Nullable ITextClassifierService service) {
        try {
            textClassifierServiceConsumer.accept(service);
        } catch (RuntimeException | Error e) {
            Slog.e(LOG_TAG, "Exception when consume textClassifierService: " + e);
        }
    }

    private static ITextClassifierCallback wrap(ITextClassifierCallback orig) {
        return new CallbackWrapper(orig);
    }