Search in sources :

Example 96 with ServiceInfo

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

the class AccessibilityManager method getAccessibilityServiceList.

/**
     * Returns the {@link ServiceInfo}s of the installed accessibility services.
     *
     * @return An unmodifiable list with {@link ServiceInfo}s.
     *
     * @deprecated Use {@link #getInstalledAccessibilityServiceList()}
     */
@Deprecated
public List<ServiceInfo> getAccessibilityServiceList() {
    List<AccessibilityServiceInfo> infos = getInstalledAccessibilityServiceList();
    List<ServiceInfo> services = new ArrayList<>();
    final int infoCount = infos.size();
    for (int i = 0; i < infoCount; i++) {
        AccessibilityServiceInfo info = infos.get(i);
        services.add(info.getResolveInfo().serviceInfo);
    }
    return Collections.unmodifiableList(services);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 97 with ServiceInfo

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

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 98 with ServiceInfo

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

the class NetworkScorerAppManagerTest method buildResolveInfo.

private ResolveInfoHolder buildResolveInfo(String packageName, int packageUid, boolean hasReceiverPermission, boolean hasScorePermission, boolean hasConfigActivity, boolean hasServiceInfo) throws Exception {
    Mockito.when(mMockPm.checkPermission(permission.SCORE_NETWORKS, packageName)).thenReturn(hasScorePermission ? PackageManager.PERMISSION_GRANTED : PackageManager.PERMISSION_DENIED);
    ResolveInfo resolveInfo = new ResolveInfo();
    resolveInfo.activityInfo = new ActivityInfo();
    resolveInfo.activityInfo.packageName = packageName;
    resolveInfo.activityInfo.applicationInfo = new ApplicationInfo();
    resolveInfo.activityInfo.applicationInfo.uid = packageUid;
    if (hasReceiverPermission) {
        resolveInfo.activityInfo.permission = permission.BROADCAST_NETWORK_PRIVILEGED;
    }
    ResolveInfo configActivityInfo = null;
    if (hasConfigActivity) {
        configActivityInfo = new ResolveInfo();
        configActivityInfo.activityInfo = new ActivityInfo();
        configActivityInfo.activityInfo.name = ".ConfigActivity";
    }
    ResolveInfo serviceInfo = null;
    if (hasServiceInfo) {
        serviceInfo = new ResolveInfo();
        serviceInfo.serviceInfo = new ServiceInfo();
        serviceInfo.serviceInfo.name = ".ScoringService";
    }
    return new ResolveInfoHolder(resolveInfo, configActivityInfo, serviceInfo);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ActivityInfo(android.content.pm.ActivityInfo) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 99 with ServiceInfo

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

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 100 with ServiceInfo

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

the class AccessibilityServiceInfo method loadDescription.

/**
     * The localized description of the accessibility service.
     * <p>
     *    <strong>Statically set from
     *    {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
     * </p>
     * @return The localized description.
     */
public String loadDescription(PackageManager packageManager) {
    if (mDescriptionResId == 0) {
        return mNonLocalizedDescription;
    }
    ServiceInfo serviceInfo = mResolveInfo.serviceInfo;
    CharSequence description = packageManager.getText(serviceInfo.packageName, mDescriptionResId, serviceInfo.applicationInfo);
    if (description != null) {
        return description.toString().trim();
    }
    return null;
}
Also used : ServiceInfo(android.content.pm.ServiceInfo)

Aggregations

ServiceInfo (android.content.pm.ServiceInfo)236 ResolveInfo (android.content.pm.ResolveInfo)120 Intent (android.content.Intent)99 ComponentName (android.content.ComponentName)95 PackageManager (android.content.pm.PackageManager)60 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)16 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)14 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