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

Commit 4d2af8ec authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move ContextualSearchHapticManager to MainThreadInitialiedObject" into main

parents 71c3d1f0 7966dd78
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import com.android.launcher3.dagger.LauncherAppComponent;
import com.android.launcher3.dagger.LauncherBaseAppComponent;
import com.android.launcher3.model.WellbeingModel;
import com.android.quickstep.util.AsyncClockEventDelegate;
import com.android.quickstep.util.ContextualSearchHapticManager;

/**
 * Launcher Quickstep base component for Dagger injection.
@@ -35,6 +34,4 @@ public interface QuickstepBaseAppComponent extends LauncherBaseAppComponent {
    WellbeingModel getWellbeingModel();

    AsyncClockEventDelegate getAsyncClockEventDelegate();

    ContextualSearchHapticManager getContextualSearchHapticManager();
}
+1 −3
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.view.ViewConfiguration;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.android.launcher3.LauncherApplication;
import com.android.launcher3.R;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
@@ -62,8 +61,7 @@ public class NavHandleLongPressHandler implements ResourceBasedOverride {
        mContext = context;
        mStatsLogManager = StatsLogManager.newInstance(context);
        mVibratorWrapper = VibratorWrapper.INSTANCE.get(mContext);
        mContextualSearchHapticManager = ((LauncherApplication) context.getApplicationContext())
                .getAppComponent().getContextualSearchHapticManager();
        mContextualSearchHapticManager = ContextualSearchHapticManager.INSTANCE.get(context);
        mContextualSearchInvoker = ContextualSearchInvoker.newInstance(mContext);
    }

+9 −5
Original line number Diff line number Diff line
@@ -21,17 +21,15 @@ import android.os.VibrationEffect
import android.os.VibrationEffect.Composition
import android.os.Vibrator
import com.android.launcher3.dagger.ApplicationContext
import com.android.launcher3.dagger.LauncherAppSingleton
import com.android.launcher3.util.MainThreadInitializedObject
import com.android.launcher3.util.SafeCloseable
import com.android.launcher3.util.VibratorWrapper
import com.android.quickstep.DeviceConfigWrapper.Companion.get
import javax.inject.Inject
import kotlin.math.pow

/** Manages haptics relating to Contextual Search invocations. */
@LauncherAppSingleton
class ContextualSearchHapticManager
@Inject
internal constructor(@ApplicationContext private val context: Context) {
internal constructor(@ApplicationContext private val context: Context) : SafeCloseable {

    private var searchEffect = createSearchEffect()
    private var contextualSearchStateManager = ContextualSearchStateManager.INSTANCE[context]
@@ -98,4 +96,10 @@ internal constructor(@ApplicationContext private val context: Context) {
            VibratorWrapper.INSTANCE[context].vibrate(composition.compose())
        }
    }

    override fun close() {}

    companion object {
        @JvmField val INSTANCE = MainThreadInitializedObject { ContextualSearchHapticManager(it) }
    }
}
+1 −4
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.app.contextualsearch.ContextualSearchManager.FEATURE_CONTEXTUAL_S
import android.content.Context
import android.util.Log
import com.android.internal.app.AssistUtils
import com.android.launcher3.LauncherApplication
import com.android.launcher3.R
import com.android.launcher3.logging.StatsLogManager
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_LAUNCH_ASSISTANT_FAILED_SERVICE_ERROR
@@ -57,9 +56,7 @@ internal constructor(
        TopTaskTracker.INSTANCE[context],
        SystemUiProxy.INSTANCE[context],
        StatsLogManager.newInstance(context),
        (context.applicationContext as LauncherApplication)
            .appComponent
            .contextualSearchHapticManager,
        ContextualSearchHapticManager.INSTANCE[context],
        context.getSystemService(ContextualSearchManager::class.java),
    )