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

Commit 79b74884 authored by Govinda Wasserman's avatar Govinda Wasserman
Browse files

Move assistant handle behavior to background thread

Test: Tested locally
Test: atest AssistHandleBehaviorControllerTest
BUG:140034473
FIX:140034473
Change-Id: I0a24240c4153b3d0d02f3390263fb7168e6c98db
parent e138ead6
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -372,11 +372,18 @@ final class AssistHandleReminderExpBehavior implements BehaviorController {
        long currentTimestamp = SystemClock.uptimeMillis();
        mLearningTimeElapsed += currentTimestamp - mLastLearningTimestamp;
        mLastLearningTimestamp = currentTimestamp;
        Settings.Secure.putLong(
                mContext.getContentResolver(), LEARNING_TIME_ELAPSED_KEY, mLearningTimeElapsed);

        mIsLearned =
                mLearningCount >= getLearningCount() || mLearningTimeElapsed >= getLearningTimeMs();

        mHandler.post(this::recordLearnTimeElapsed);
    }

    private void recordLearnTimeElapsed() {
        if (mContext != null) {
            Settings.Secure.putLong(
                    mContext.getContentResolver(), LEARNING_TIME_ELAPSED_KEY, mLearningTimeElapsed);
        }
    }

    private void resetConsecutiveTaskSwitches() {
+5 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.os.AsyncTask;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
@@ -161,8 +162,10 @@ public class AssistManager implements ConfigurationChangedReceiver {
        mAssistUtils = new AssistUtils(context);
        mAssistDisclosure = new AssistDisclosure(context, new Handler());
        mPhoneStateMonitor = new PhoneStateMonitor(context);
        mHandleController =
                new AssistHandleBehaviorController(context, mAssistUtils, new Handler());
        final HandlerThread assistHandleThread = new HandlerThread("AssistHandleThread");
        assistHandleThread.start();
        mHandleController = new AssistHandleBehaviorController(
                context, mAssistUtils, assistHandleThread.getThreadHandler());

        registerVoiceInteractionSessionListener();
        mInterestingConfigChanges = new InterestingConfigChanges(ActivityInfo.CONFIG_ORIENTATION