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

Commit 514c102f authored by Diya Bera's avatar Diya Bera
Browse files

Fix flaky test

Test: atest HidlToAidlSensorAdapterTest
Fixes: 317403648
Fixes: 317830073

Change-Id: Id070a7147bf9898c8b24f8e180fd24b775ceb91a
parent c29a0598
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ public class HidlToAidlSensorAdapter extends Sensor implements IHwBinder.DeathRe
                gestureAvailabilityDispatcher, () -> mCurrentUserId, getUserSwitchCallback()));
        mLockoutTracker = new LockoutFrameworkImpl(getContext(),
                userId -> mLockoutResetDispatcher.notifyLockoutResetCallbacks(
                        getSensorProperties().sensorId));
                        getSensorProperties().sensorId), getHandler());
    }

    @Override
+15 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.biometrics.sensors.fingerprint.hidl;
import static android.Manifest.permission.RESET_FINGERPRINT_LOCKOUT;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@@ -81,19 +82,30 @@ public class LockoutFrameworkImpl implements LockoutTracker {
            @NonNull LockoutResetCallback lockoutResetCallback) {
        this(context, lockoutResetCallback, (userId) -> PendingIntent.getBroadcast(context, userId,
                new Intent(ACTION_LOCKOUT_RESET).putExtra(KEY_LOCKOUT_RESET_USER, userId),
                PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));
                PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE),
                null /* handler */);
    }

    public LockoutFrameworkImpl(@NonNull Context context,
            @NonNull LockoutResetCallback lockoutResetCallback,
            @NonNull Handler handler) {
        this(context, lockoutResetCallback, (userId) -> PendingIntent.getBroadcast(context, userId,
                new Intent(ACTION_LOCKOUT_RESET).putExtra(KEY_LOCKOUT_RESET_USER, userId),
                PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE),
                handler);
    }

    @VisibleForTesting
    LockoutFrameworkImpl(@NonNull Context context,
            @NonNull LockoutResetCallback lockoutResetCallback,
            @NonNull Function<Integer, PendingIntent> lockoutResetIntent) {
            @NonNull Function<Integer, PendingIntent> lockoutResetIntent,
            @Nullable Handler handler) {
        mLockoutResetCallback = lockoutResetCallback;
        mTimedLockoutCleared = new SparseBooleanArray();
        mFailedAttempts = new SparseIntArray();
        mAlarmManager = context.getSystemService(AlarmManager.class);
        mLockoutReceiver = new LockoutReceiver();
        mHandler = new Handler(Looper.getMainLooper());
        mHandler = handler == null ? new Handler(Looper.getMainLooper()) : handler;
        mLockoutResetIntent = lockoutResetIntent;

        context.registerReceiver(mLockoutReceiver, new IntentFilter(ACTION_LOCKOUT_RESET),
+0 −2
Original line number Diff line number Diff line
@@ -65,7 +65,6 @@ import com.android.server.biometrics.sensors.fingerprint.aidl.FingerprintProvide
import com.android.server.biometrics.sensors.fingerprint.aidl.FingerprintResetLockoutClient;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
@@ -248,7 +247,6 @@ public class HidlToAidlSensorAdapterTest {
    }

    @Test
    @Ignore("b/317403648")
    public void lockoutPermanentResetViaClient() {
        setLockoutPermanent();