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

Commit 44dbb19a authored by Govinda Wasserman's avatar Govinda Wasserman Committed by Android (Google) Code Review
Browse files

Merge "Suppress Assistant handles when device is not provisioned" into rvc-dev

parents e6c5da62 5b0a350a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.os.Handler;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.Log;
import android.view.accessibility.AccessibilityManager;

@@ -61,6 +62,7 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac

    private static final long DEFAULT_SHOWN_FREQUENCY_THRESHOLD_MS = 0;
    private static final long DEFAULT_SHOW_AND_GO_DURATION_MS = TimeUnit.SECONDS.toMillis(3);
    private static final String SETTINGS_SECURE_USER_SETUP_COMPLETE = "user_setup_complete";

    /**
     * This is the default behavior that will be used once the system is up. It will be set once the
@@ -203,6 +205,10 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
    }

    private boolean handlesUnblocked(boolean ignoreThreshold) {
        if (!isUserSetupComplete()) {
            return false;
        }

        long timeSinceHidden = SystemClock.elapsedRealtime() - mHandlesLastHiddenAt;
        boolean notThrottled = ignoreThreshold || timeSinceHidden >= getShownFrequencyThreshold();
        ComponentName assistantComponent =
@@ -284,6 +290,11 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
        mShowAndGoEndsAt = 0;
    }

    private boolean isUserSetupComplete() {
        return Settings.Secure.getInt(
                mContext.getContentResolver(), SETTINGS_SECURE_USER_SETUP_COMPLETE, 0) == 1;
    }

    @VisibleForTesting
    void setInGesturalModeForTest(boolean inGesturalMode) {
        mInGesturalMode = inGesturalMode;