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

Commit 96396ceb authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13323088 from e01e46dc to 25Q3-release

Change-Id: Icad0a5402bced8d8783c898abb8523f01ee29185
parents 7463a781 e01e46dc
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ aconfig_declarations_group {
        "aconfig_settingslib_flags_java_lib",
        "aconfig_trade_in_mode_flags_java_lib",
        "adpf_flags_java_lib",
        "android.adaptiveauth.flags-aconfig-java",
        "android.app.appfunctions.flags-aconfig-java",
        "android.app.assist.flags-aconfig-java",
        "android.app.contextualsearch.flags-aconfig-java",
@@ -1665,20 +1664,6 @@ java_aconfig_library {
    min_sdk_version: "30",
}

// Adaptive Auth
aconfig_declarations {
    name: "android.adaptiveauth.flags-aconfig",
    package: "android.adaptiveauth",
    container: "system",
    srcs: ["core/java/android/adaptiveauth/*.aconfig"],
}

java_aconfig_library {
    name: "android.adaptiveauth.flags-aconfig-java",
    aconfig_declarations: "android.adaptiveauth.flags-aconfig",
    defaults: ["framework-minus-apex-aconfig-java-defaults"],
}

// CrashRecovery Module
aconfig_declarations {
    name: "android.crashrecovery.flags-aconfig",
+2 −1
Original line number Diff line number Diff line
@@ -48,7 +48,8 @@ public class AconfigPackagePerfTest {
        return Arrays.asList(new Object[][] {{false}, {true}});
    }

    private static final Set<String> PLATFORM_CONTAINERS = Set.of("system", "vendor", "product");
    private static final Set<String> PLATFORM_CONTAINERS =
        Set.of("system", "system_ext", "vendor", "product");
    private static List<parsed_flag> sFlags;

    @BeforeClass
+0 −9
Original line number Diff line number Diff line
package: "android.adaptiveauth"
container: "system"

flag {
  name: "report_biometric_auth_attempts"
  namespace: "biometrics"
  description: "Control the usage of the biometric auth signal in adaptive auth"
  bug: "285053096"
}
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -3471,7 +3471,7 @@ public abstract class PackageManager {
    /**
     * Feature for {@link #getSystemAvailableFeatures} and
     * {@link #hasSystemFeature}: The device can communicate using Near-Field
     * Communications (NFC).
     * Communications (NFC), acting as a reader.
     */
    @SdkConstant(SdkConstantType.FEATURE)
    public static final String FEATURE_NFC = "android.hardware.nfc";
+100 −0
Original line number Diff line number Diff line
@@ -14,56 +14,78 @@
 * limitations under the License.
 */

package android.view;
package android.util;

import android.annotation.NonNull;
import android.os.Handler;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

/**
 * A utility class to manage a list of {@link ListenerWrapper}. This class is not thread safe.
 * A utility class to manage a list of {@link Consumer} and {@link Executor} pairs. This class
 * is thread safe because all the effects are dispatched through the handler.
 * @param <T> the type of the value to be reported.
 * @hide
 */
@RavenwoodKeepWholeClass
public class ListenerGroup<T> {
    private final List<ListenerWrapper<T>> mListeners = new ArrayList<>();

    /**
     * The set of listeners to be managed. All modifications should be done on {@link #mHandler}.
     */
    private final ArrayMap<Consumer<T>, Executor> mListeners =
            new ArrayMap<>();
    @NonNull
    private T mLastValue;
    @NonNull
    private final Handler mHandler;

    /**
     * Constructs a {@link ListenerGroup} that will replay the last reported value whenever a new
     * listener is registered.
     * @param value the initial value
     * @param handler a handler to synchronize access to shared resources.
     */
    public ListenerGroup(@NonNull T value) {
        mLastValue = value;
    public ListenerGroup(@NonNull T value, @NonNull Handler handler) {
        mLastValue = Objects.requireNonNull(value);
        mHandler = Objects.requireNonNull(handler);
    }

    /**
     * Relays the value to all the registered {@link java.util.function.Consumer}
     * Relays the value to all the registered {@link java.util.function.Consumer}. The relay is
     * initiated on the {@link Handler} provided in the constructor and then switched to the
     * {@link Executor} that was registered with the {@link Consumer}.
     */
    public void accept(@NonNull T value) {
        mLastValue = Objects.requireNonNull(value);
        Objects.requireNonNull(value);
        mHandler.post(() -> {
            mLastValue = value;
            for (int i = 0; i < mListeners.size(); i++) {
            mListeners.get(i).accept(value);
                final Consumer<T> consumer = mListeners.keyAt(i);
                final Executor executor = mListeners.get(consumer);
                executor.execute(() -> consumer.accept(value));
            }
        });
    }

    /**
     * Adds a {@link Consumer} to the group and replays the last reported value. If the
     * {@link Consumer} is already present then this is a no op.
     * Adds a {@link Consumer} to the group and replays the last reported value. The replay is
     * initiated from the {@link Handler} provided in the constructor and run on the
     * {@link Executor}. If the {@link Consumer} is already present then this is a no op.
     */
    public void addListener(@NonNull Executor executor, @NonNull Consumer<T> consumer) {
        if (isConsumerPresent(consumer)) {
        Objects.requireNonNull(executor, "Executor must not be null.");
        Objects.requireNonNull(consumer, "Consumer must not be null.");
        mHandler.post(() -> {
            if (mListeners.containsKey(consumer)) {
                return;
            }
        final ListenerWrapper<T> listenerWrapper = new ListenerWrapper<>(executor, consumer);
        mListeners.add(listenerWrapper);
        listenerWrapper.accept(mLastValue);
            mListeners.put(consumer, executor);
            executor.execute(() -> consumer.accept(mLastValue));
        });
    }

    /**
@@ -71,29 +93,8 @@ public class ListenerGroup<T> {
     * is a no op.
     */
    public void removeListener(@NonNull Consumer<T> consumer) {
        final int index = computeIndex(consumer);
        if (index > -1) {
            mListeners.remove(index);
        }
    }

    /**
     * Returns {@code true} if the {@link Consumer} is present in the list, {@code false}
     * otherwise.
     */
    public boolean isConsumerPresent(Consumer<T> consumer) {
        return computeIndex(consumer) > -1;
    }

    /**
     * Returns the index of the matching {@link ListenerWrapper} if present, {@code -1} otherwise.
     */
    private int computeIndex(Consumer<T> consumer) {
        for (int i = 0; i < mListeners.size(); i++) {
            if (mListeners.get(i).isConsumerSame(consumer)) {
                return i;
            }
        }
        return -1;
        mHandler.post(() -> {
            mListeners.remove(consumer);
        });
    }
}
Loading