VoiceInteractionManagerServiceImplpublic class VoiceInteractionManagerServiceImpl extends Object
Fields Summary |
---|
static final String | TAG | final boolean | mValid | final android.content.Context | mContext | final android.os.Handler | mHandler | final Object | mLock | final int | mUser | final android.content.ComponentName | mComponent | final android.app.IActivityManager | mAm | final android.service.voice.VoiceInteractionServiceInfo | mInfo | final android.content.ComponentName | mSessionComponentName | final android.view.IWindowManager | mIWindowManager | boolean | mBound | android.service.voice.IVoiceInteractionService | mService | SessionConnection | mActiveSession | final android.content.BroadcastReceiver | mBroadcastReceiver | final android.content.ServiceConnection | mConnection |
Constructors Summary |
---|
VoiceInteractionManagerServiceImpl(android.content.Context context, android.os.Handler handler, Object lock, int userHandle, android.content.ComponentName service)
mContext = context;
mHandler = handler;
mLock = lock;
mUser = userHandle;
mComponent = service;
mAm = ActivityManagerNative.getDefault();
VoiceInteractionServiceInfo info;
try {
info = new VoiceInteractionServiceInfo(context.getPackageManager(), service);
} catch (PackageManager.NameNotFoundException e) {
Slog.w(TAG, "Voice interaction service not found: " + service);
mInfo = null;
mSessionComponentName = null;
mIWindowManager = null;
mValid = false;
return;
}
mInfo = info;
if (mInfo.getParseError() != null) {
Slog.w(TAG, "Bad voice interaction service: " + mInfo.getParseError());
mSessionComponentName = null;
mIWindowManager = null;
mValid = false;
return;
}
mValid = true;
mSessionComponentName = new ComponentName(service.getPackageName(),
mInfo.getSessionService());
mIWindowManager = IWindowManager.Stub.asInterface(
ServiceManager.getService(Context.WINDOW_SERVICE));
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mContext.registerReceiver(mBroadcastReceiver, filter, null, handler);
|
Methods Summary |
---|
public boolean | deliverNewSessionLocked(int callingPid, int callingUid, android.os.IBinder token, android.service.voice.IVoiceInteractionSession session, com.android.internal.app.IVoiceInteractor interactor)
if (mActiveSession == null || token != mActiveSession.mToken) {
Slog.w(TAG, "deliverNewSession does not match active session");
return false;
}
mActiveSession.mSession = session;
mActiveSession.mInteractor = interactor;
return true;
| public void | dumpLocked(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)
if (!mValid) {
pw.print(" NOT VALID: ");
if (mInfo == null) {
pw.println("no info");
} else {
pw.println(mInfo.getParseError());
}
return;
}
pw.print(" mComponent="); pw.println(mComponent.flattenToShortString());
pw.print(" Session service="); pw.println(mInfo.getSessionService());
pw.print(" Settings activity="); pw.println(mInfo.getSettingsActivity());
pw.print(" mBound="); pw.print(mBound); pw.print(" mService="); pw.println(mService);
if (mActiveSession != null) {
pw.println(" Active session:");
mActiveSession.dump(" ", pw);
}
| public void | finishLocked(int callingPid, int callingUid, android.os.IBinder token)
if (mActiveSession == null || token != mActiveSession.mToken) {
Slog.w(TAG, "finish does not match active session");
return;
}
mActiveSession.cancel();
mActiveSession = null;
| void | notifySoundModelsChangedLocked()
if (mService == null) {
Slog.w(TAG, "Not bound to voice interaction service " + mComponent);
}
try {
mService.soundModelsChanged();
} catch (RemoteException e) {
Slog.w(TAG, "RemoteException while calling soundModelsChanged", e);
}
| void | shutdownLocked()
try {
if (mService != null) {
mService.shutdown();
}
} catch (RemoteException e) {
Slog.w(TAG, "RemoteException in shutdown", e);
}
if (mBound) {
mContext.unbindService(mConnection);
mBound = false;
}
if (mValid) {
mContext.unregisterReceiver(mBroadcastReceiver);
}
| void | startLocked()
Intent intent = new Intent(VoiceInteractionService.SERVICE_INTERFACE);
intent.setComponent(mComponent);
mBound = mContext.bindServiceAsUser(intent, mConnection,
Context.BIND_AUTO_CREATE, new UserHandle(mUser));
if (!mBound) {
Slog.w(TAG, "Failed binding to voice interaction service " + mComponent);
}
| public void | startSessionLocked(int callingPid, int callingUid, android.os.Bundle args)
if (mActiveSession != null) {
mActiveSession.cancel();
mActiveSession = null;
}
mActiveSession = new SessionConnection(args);
| public int | startVoiceActivityLocked(int callingPid, int callingUid, android.os.IBinder token, android.content.Intent intent, java.lang.String resolvedType)
try {
if (mActiveSession == null || token != mActiveSession.mToken) {
Slog.w(TAG, "startVoiceActivity does not match active session");
return ActivityManager.START_CANCELED;
}
intent = new Intent(intent);
intent.addCategory(Intent.CATEGORY_VOICE);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
return mAm.startVoiceActivity(mComponent.getPackageName(), callingPid, callingUid,
intent, resolvedType, mActiveSession.mSession, mActiveSession.mInteractor,
0, null, null, mUser);
} catch (RemoteException e) {
throw new IllegalStateException("Unexpected remote error", e);
}
|
|