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

Commit bd805bbc 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

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

Change-Id: I1c27615308364a0c41cd0cae7e5c4c826a995c91
parents 0fdb31ff 205bda07
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -527,12 +527,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,
@@ -541,6 +542,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);
    }