Search in sources :

Example 36 with ServiceInfo

use of android.content.pm.ServiceInfo in project android_frameworks_base by ParanoidAndroid.

the class InputMethodTest method createDummyInputMethodInfo.

private static InputMethodInfo createDummyInputMethodInfo(String packageName, String name, CharSequence label, boolean isAuxIme, boolean isDefault, List<InputMethodSubtype> subtypes) {
    final ResolveInfo ri = new ResolveInfo();
    final ServiceInfo si = new ServiceInfo();
    final ApplicationInfo ai = new ApplicationInfo();
    ai.packageName = packageName;
    ai.enabled = true;
    ai.flags |= ApplicationInfo.FLAG_SYSTEM;
    si.applicationInfo = ai;
    si.enabled = true;
    si.packageName = packageName;
    si.name = name;
    si.exported = true;
    si.nonLocalizedLabel = label;
    ri.serviceInfo = si;
    return new InputMethodInfo(ri, isAuxIme, "", subtypes, 1, isDefault);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ApplicationInfo(android.content.pm.ApplicationInfo) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 37 with ServiceInfo

use of android.content.pm.ServiceInfo in project android_frameworks_base by ResurrectionRemix.

the class TrustAgentService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    ComponentName component = new ComponentName(this, getClass());
    try {
        ServiceInfo serviceInfo = getPackageManager().getServiceInfo(component, 0);
        if (!Manifest.permission.BIND_TRUST_AGENT.equals(serviceInfo.permission)) {
            throw new IllegalStateException(component.flattenToShortString() + " is not declared with the permission " + "\"" + Manifest.permission.BIND_TRUST_AGENT + "\"");
        }
    } catch (PackageManager.NameNotFoundException e) {
        Log.e(TAG, "Can't get ServiceInfo for " + component.toShortString());
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName)

Example 38 with ServiceInfo

use of android.content.pm.ServiceInfo in project android_frameworks_base by ResurrectionRemix.

the class TtsEngines method getEngineInfo.

private EngineInfo getEngineInfo(ResolveInfo resolve, PackageManager pm) {
    ServiceInfo service = resolve.serviceInfo;
    if (service != null) {
        EngineInfo engine = new EngineInfo();
        // Using just the package name isn't great, since it disallows having
        // multiple engines in the same package, but that's what the existing API does.
        engine.name = service.packageName;
        CharSequence label = service.loadLabel(pm);
        engine.label = TextUtils.isEmpty(label) ? engine.name : label.toString();
        engine.icon = service.getIconResource();
        engine.priority = resolve.priority;
        engine.system = isSystemEngine(service);
        return engine;
    }
    return null;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) EngineInfo(android.speech.tts.TextToSpeech.EngineInfo)

Example 39 with ServiceInfo

use of android.content.pm.ServiceInfo in project android_frameworks_base by ResurrectionRemix.

the class TtsEngines method getSettingsIntent.

/**
     * @return an intent that can launch the settings activity for a given tts engine.
     */
public Intent getSettingsIntent(String engine) {
    PackageManager pm = mContext.getPackageManager();
    Intent intent = new Intent(Engine.INTENT_ACTION_TTS_SERVICE);
    intent.setPackage(engine);
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(intent, PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA);
    // the package name.
    if (resolveInfos != null && resolveInfos.size() == 1) {
        ServiceInfo service = resolveInfos.get(0).serviceInfo;
        if (service != null) {
            final String settings = settingsActivityFromServiceInfo(service, pm);
            if (settings != null) {
                Intent i = new Intent();
                i.setClassName(engine, settings);
                return i;
            }
        }
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) Secure.getString(android.provider.Settings.Secure.getString)

Example 40 with ServiceInfo

use of android.content.pm.ServiceInfo in project android_frameworks_base by ResurrectionRemix.

the class CustomTile method setTileIcon.

private void setTileIcon() {
    try {
        PackageManager pm = mContext.getPackageManager();
        int flags = PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE;
        if (isSystemApp(pm)) {
            flags |= PackageManager.MATCH_DISABLED_COMPONENTS;
        }
        ServiceInfo info = pm.getServiceInfo(mComponent, flags);
        int icon = info.icon != 0 ? info.icon : info.applicationInfo.icon;
        // Update the icon if its not set or is the default icon.
        boolean updateIcon = mTile.getIcon() == null || iconEquals(mTile.getIcon(), mDefaultIcon);
        mDefaultIcon = icon != 0 ? android.graphics.drawable.Icon.createWithResource(mComponent.getPackageName(), icon) : null;
        if (updateIcon) {
            mTile.setIcon(mDefaultIcon);
        }
        // Update the label if there is no label.
        if (mTile.getLabel() == null) {
            mTile.setLabel(info.loadLabel(pm));
        }
    } catch (Exception e) {
        mDefaultIcon = null;
    }
}
Also used : ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) RemoteException(android.os.RemoteException)

Aggregations

ServiceInfo (android.content.pm.ServiceInfo)238 ResolveInfo (android.content.pm.ResolveInfo)120 Intent (android.content.Intent)99 ComponentName (android.content.ComponentName)96 PackageManager (android.content.pm.PackageManager)62 RemoteException (android.os.RemoteException)48 PendingIntent (android.app.PendingIntent)37 ApplicationInfo (android.content.pm.ApplicationInfo)35 AccessibilityServiceInfo (android.accessibilityservice.AccessibilityServiceInfo)32 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)29 IOException (java.io.IOException)28 ArrayList (java.util.ArrayList)27 InputMethodInfo (android.view.inputmethod.InputMethodInfo)21 PackageInfo (android.content.pm.PackageInfo)18 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)16 Service (android.app.Service)13 Point (android.graphics.Point)11 SpellCheckerInfo (android.view.textservice.SpellCheckerInfo)11 ArraySet (android.util.ArraySet)10 ActivityInfo (android.content.pm.ActivityInfo)9