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

Commit 375d1105 authored by Eugene Susla's avatar Eugene Susla Committed by android-build-merger
Browse files

Merge "[DO NOT MERGE] Make TCMS multi-user-aware" into pi-dev

am: 7924167a

Change-Id: I145e70a05762a330fc15732beabe4f49a99ed79e
parents 8ef2b626 7924167a
Loading
Loading
Loading
Loading
+28 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.util;

import android.os.RemoteException;
import android.util.ExceptionUtils;

import java.util.function.Consumer;
import java.util.function.Supplier;
@@ -36,12 +37,26 @@ public class FunctionalUtils {
    }

    /**
     *
     * Wraps a given {@code action} into one that ignores any {@link RemoteException}s
     */
    public static <T> Consumer<T> ignoreRemoteException(RemoteExceptionIgnoringConsumer<T> action) {
        return action;
    }

    /**
     * Wraps the given {@link ThrowingRunnable} into one that handles any exceptions using the
     * provided {@code handler}
     */
    public static Runnable handleExceptions(ThrowingRunnable r, Consumer<Throwable> handler) {
        return () -> {
            try {
                r.run();
            } catch (Throwable t) {
                handler.accept(t);
            }
        };
    }

    /**
     * An equivalent of {@link Runnable} that allows throwing checked exceptions
     *
@@ -49,8 +64,18 @@ public class FunctionalUtils {
     * to be handled within it
     */
    @FunctionalInterface
    public interface ThrowingRunnable {
    @SuppressWarnings("FunctionalInterfaceMethodChanged")
    public interface ThrowingRunnable extends Runnable {
        void runOrThrow() throws Exception;

        @Override
        default void run() {
            try {
                runOrThrow();
            } catch (Exception ex) {
                throw ExceptionUtils.propagate(ex);
            }
        }
    }

    /**
@@ -80,7 +105,7 @@ public class FunctionalUtils {
            try {
                acceptOrThrow(t);
            } catch (Exception ex) {
                throw new RuntimeException(ex);
                throw ExceptionUtils.propagate(ex);
            }
        }
    }
+221 −194

File changed.

Preview size limit exceeded, changes collapsed.