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

Commit efc66d30 authored by lpeter's avatar lpeter
Browse files

Just get VoiceInteractionManagerService once in Activity.java

During testing the testActivityTransitionsAnimation, it usually
takes 400us ~ 1ms to get the VoiceInteractionManagerService, it
would be better to get VoiceInteractionManagerService once
and keep it instead of getting VoiceInteractionManagerService
again in the other stages.

Test: atest CtsVoiceInteractionTestCases
Bug: 261791888
Change-Id: I46daa11f2281a8db96056ca99520a0c3fe41e4ec
parent e2c82f46
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -1010,6 +1010,8 @@ public class Activity extends ContextThemeWrapper

    private ComponentCallbacksController mCallbacksController;

    @Nullable private IVoiceInteractionManagerService mVoiceInteractionManagerService;

    private final WindowControllerCallback mWindowControllerCallback =
            new WindowControllerCallback() {
        /**
@@ -1619,18 +1621,17 @@ public class Activity extends ContextThemeWrapper

    private void notifyVoiceInteractionManagerServiceActivityEvent(
            @VoiceInteractionSession.VoiceInteractionActivityEventType int type) {

        final IVoiceInteractionManagerService service =
                IVoiceInteractionManagerService.Stub.asInterface(
        if (mVoiceInteractionManagerService == null) {
            mVoiceInteractionManagerService = IVoiceInteractionManagerService.Stub.asInterface(
                    ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
        if (service == null) {
            if (mVoiceInteractionManagerService == null) {
                Log.w(TAG, "notifyVoiceInteractionManagerServiceActivityEvent: Can not get "
                        + "VoiceInteractionManagerService");
                return;
            }

        }
        try {
            service.notifyActivityEventChanged(mToken, type);
            mVoiceInteractionManagerService.notifyActivityEventChanged(mToken, type);
        } catch (RemoteException e) {
            // Empty
        }