FileDocCategorySizeDatePackage
VoiceInteractionServiceInfo.javaAPI DocAndroid 5.1 API5362Thu Mar 12 22:22:10 GMT 2015android.service.voice

VoiceInteractionServiceInfo

public class VoiceInteractionServiceInfo extends Object
hide

Fields Summary
static final String
TAG
private String
mParseError
private android.content.pm.ServiceInfo
mServiceInfo
private String
mSessionService
private String
mRecognitionService
private String
mSettingsActivity
Constructors Summary
public VoiceInteractionServiceInfo(android.content.pm.PackageManager pm, android.content.ComponentName comp)


        
              
        this(pm, pm.getServiceInfo(comp, PackageManager.GET_META_DATA));
    
public VoiceInteractionServiceInfo(android.content.pm.PackageManager pm, android.content.ComponentName comp, int userHandle)

        this(pm, AppGlobals.getPackageManager().getServiceInfo(comp,
                PackageManager.GET_META_DATA, userHandle));
    
public VoiceInteractionServiceInfo(android.content.pm.PackageManager pm, android.content.pm.ServiceInfo si)

        if (!Manifest.permission.BIND_VOICE_INTERACTION.equals(si.permission)) {
            mParseError = "Service does not require permission "
                    + Manifest.permission.BIND_VOICE_INTERACTION;
            return;
        }

        XmlResourceParser parser = null;
        try {
            parser = si.loadXmlMetaData(pm, VoiceInteractionService.SERVICE_META_DATA);
            if (parser == null) {
                mParseError = "No " + VoiceInteractionService.SERVICE_META_DATA
                        + " meta-data for " + si.packageName;
                return;
            }

            Resources res = pm.getResourcesForApplication(si.applicationInfo);

            AttributeSet attrs = Xml.asAttributeSet(parser);

            int type;
            while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
                    && type != XmlPullParser.START_TAG) {
            }

            String nodeName = parser.getName();
            if (!"voice-interaction-service".equals(nodeName)) {
                mParseError = "Meta-data does not start with voice-interaction-service tag";
                return;
            }

            TypedArray array = res.obtainAttributes(attrs,
                    com.android.internal.R.styleable.VoiceInteractionService);
            mSessionService = array.getString(
                    com.android.internal.R.styleable.VoiceInteractionService_sessionService);
            mRecognitionService = array.getString(
                    com.android.internal.R.styleable.VoiceInteractionService_recognitionService);
            mSettingsActivity = array.getString(
                    com.android.internal.R.styleable.VoiceInteractionService_settingsActivity);
            array.recycle();
            if (mSessionService == null) {
                mParseError = "No sessionService specified";
                return;
            }
            /* Not yet time
            if (mRecognitionService == null) {
                mParseError = "No recogitionService specified";
                return;
            } */
        } catch (XmlPullParserException e) {
            mParseError = "Error parsing voice interation service meta-data: " + e;
            Log.w(TAG, "error parsing voice interaction service meta-data", e);
            return;
        } catch (IOException e) {
            mParseError = "Error parsing voice interation service meta-data: " + e;
            Log.w(TAG, "error parsing voice interaction service meta-data", e);
            return;
        } catch (PackageManager.NameNotFoundException e) {
            mParseError = "Error parsing voice interation service meta-data: " + e;
            Log.w(TAG, "error parsing voice interaction service meta-data", e);
            return;
        } finally {
            if (parser != null) parser.close();
        }
        mServiceInfo = si;
    
Methods Summary
public java.lang.StringgetParseError()

        return mParseError;
    
public java.lang.StringgetRecognitionService()

        return mRecognitionService;
    
public android.content.pm.ServiceInfogetServiceInfo()

        return mServiceInfo;
    
public java.lang.StringgetSessionService()

        return mSessionService;
    
public java.lang.StringgetSettingsActivity()

        return mSettingsActivity;