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
This commit is contained in:
@@ -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(
|
||||
ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
|
||||
if (service == null) {
|
||||
Log.w(TAG, "notifyVoiceInteractionManagerServiceActivityEvent: Can not get "
|
||||
+ "VoiceInteractionManagerService");
|
||||
return;
|
||||
if (mVoiceInteractionManagerService == null) {
|
||||
mVoiceInteractionManagerService = IVoiceInteractionManagerService.Stub.asInterface(
|
||||
ServiceManager.getService(Context.VOICE_INTERACTION_MANAGER_SERVICE));
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user