Search in sources :

Example 56 with ServiceInfo

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

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)

Example 57 with ServiceInfo

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

the class ZenServiceListing method getServices.

private static int getServices(ManagedServiceSettings.Config c, List<ServiceInfo> list, PackageManager pm) {
    int services = 0;
    if (list != null) {
        list.clear();
    }
    final int user = ActivityManager.getCurrentUser();
    List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser(new Intent(c.intentAction), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, user);
    for (int i = 0, count = installedServices.size(); i < count; i++) {
        ResolveInfo resolveInfo = installedServices.get(i);
        ServiceInfo info = resolveInfo.serviceInfo;
        if (!c.permission.equals(info.permission)) {
            Slog.w(c.tag, "Skipping " + c.noun + " service " + info.packageName + "/" + info.name + ": it does not require the permission " + c.permission);
            continue;
        }
        if (list != null) {
            list.add(info);
        }
        services++;
    }
    return services;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) Intent(android.content.Intent)

Example 58 with ServiceInfo

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

the class ServiceListing method getServices.

protected static int getServices(Config c, List<ServiceInfo> list, PackageManager pm) {
    int services = 0;
    if (list != null) {
        list.clear();
    }
    final int user = ActivityManager.getCurrentUser();
    List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser(new Intent(c.intentAction), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, user);
    for (int i = 0, count = installedServices.size(); i < count; i++) {
        ResolveInfo resolveInfo = installedServices.get(i);
        ServiceInfo info = resolveInfo.serviceInfo;
        if (!c.permission.equals(info.permission)) {
            Slog.w(c.tag, "Skipping " + c.noun + " service " + info.packageName + "/" + info.name + ": it does not require the permission " + c.permission);
            continue;
        }
        if (list != null) {
            list.add(info);
        }
        services++;
    }
    return services;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) Intent(android.content.Intent)

Example 59 with ServiceInfo

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

the class VoiceInputHelper method buildUi.

public void buildUi() {
    // Get the currently selected interactor from the secure setting.
    String currentSetting = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.VOICE_INTERACTION_SERVICE);
    if (currentSetting != null && !currentSetting.isEmpty()) {
        mCurrentVoiceInteraction = ComponentName.unflattenFromString(currentSetting);
    } else {
        mCurrentVoiceInteraction = null;
    }
    ArraySet<ComponentName> interactorRecognizers = new ArraySet<>();
    // Iterate through all the available interactors and load up their info to show
    // in the preference.
    int size = mAvailableVoiceInteractions.size();
    for (int i = 0; i < size; i++) {
        ResolveInfo resolveInfo = mAvailableVoiceInteractions.get(i);
        VoiceInteractionServiceInfo info = new VoiceInteractionServiceInfo(mContext.getPackageManager(), resolveInfo.serviceInfo);
        if (info.getParseError() != null) {
            Log.w("VoiceInteractionService", "Error in VoiceInteractionService " + resolveInfo.serviceInfo.packageName + "/" + resolveInfo.serviceInfo.name + ": " + info.getParseError());
            continue;
        }
        mAvailableInteractionInfos.add(new InteractionInfo(mContext.getPackageManager(), info));
        interactorRecognizers.add(new ComponentName(resolveInfo.serviceInfo.packageName, info.getRecognitionService()));
    }
    Collections.sort(mAvailableInteractionInfos);
    // Get the currently selected recognizer from the secure setting.
    currentSetting = Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.VOICE_RECOGNITION_SERVICE);
    if (currentSetting != null && !currentSetting.isEmpty()) {
        mCurrentRecognizer = ComponentName.unflattenFromString(currentSetting);
    } else {
        mCurrentRecognizer = null;
    }
    // Iterate through all the available recognizers and load up their info to show
    // in the preference.
    size = mAvailableRecognition.size();
    for (int i = 0; i < size; i++) {
        ResolveInfo resolveInfo = mAvailableRecognition.get(i);
        ComponentName comp = new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name);
        if (interactorRecognizers.contains(comp)) {
        //continue;
        }
        ServiceInfo si = resolveInfo.serviceInfo;
        XmlResourceParser parser = null;
        String settingsActivity = null;
        try {
            parser = si.loadXmlMetaData(mContext.getPackageManager(), RecognitionService.SERVICE_META_DATA);
            if (parser == null) {
                throw new XmlPullParserException("No " + RecognitionService.SERVICE_META_DATA + " meta-data for " + si.packageName);
            }
            Resources res = mContext.getPackageManager().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 (!"recognition-service".equals(nodeName)) {
                throw new XmlPullParserException("Meta-data does not start with recognition-service tag");
            }
            TypedArray array = res.obtainAttributes(attrs, com.android.internal.R.styleable.RecognitionService);
            settingsActivity = array.getString(com.android.internal.R.styleable.RecognitionService_settingsActivity);
            array.recycle();
        } catch (XmlPullParserException e) {
            Log.e(TAG, "error parsing recognition service meta-data", e);
        } catch (IOException e) {
            Log.e(TAG, "error parsing recognition service meta-data", e);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "error parsing recognition service meta-data", e);
        } finally {
            if (parser != null)
                parser.close();
        }
        mAvailableRecognizerInfos.add(new RecognizerInfo(mContext.getPackageManager(), resolveInfo.serviceInfo, settingsActivity));
    }
    Collections.sort(mAvailableRecognizerInfos);
}
Also used : ArraySet(android.util.ArraySet) XmlResourceParser(android.content.res.XmlResourceParser) IOException(java.io.IOException) ResolveInfo(android.content.pm.ResolveInfo) VoiceInteractionServiceInfo(android.service.voice.VoiceInteractionServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) AttributeSet(android.util.AttributeSet) VoiceInteractionServiceInfo(android.service.voice.VoiceInteractionServiceInfo) TypedArray(android.content.res.TypedArray) ComponentName(android.content.ComponentName) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) Resources(android.content.res.Resources)

Example 60 with ServiceInfo

use of android.content.pm.ServiceInfo in project DroidPlugin by DroidPluginTeam.

the class StaticProcessList method onCreate.

void onCreate(Context mHostContext) throws NameNotFoundException {
    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(CATEGORY_ACTIVITY_PROXY_STUB);
    intent.setPackage(mHostContext.getPackageName());
    PackageManager pm = mHostContext.getPackageManager();
    List<ResolveInfo> activities = pm.queryIntentActivities(intent, PackageManager.GET_META_DATA);
    for (ResolveInfo activity : activities) {
        addActivityInfo(activity.activityInfo);
    }
    List<ResolveInfo> services = pm.queryIntentServices(intent, 0);
    for (ResolveInfo service : services) {
        addServiceInfo(service.serviceInfo);
    }
    PackageInfo packageInfo = pm.getPackageInfo(mHostContext.getPackageName(), PackageManager.GET_PROVIDERS);
    if (packageInfo.providers != null && packageInfo.providers.length > 0) {
        for (ProviderInfo providerInfo : packageInfo.providers) {
            if (providerInfo.name != null && providerInfo.name.startsWith(ContentProviderStub.class.getName())) {
                addProviderInfo(providerInfo);
            }
        }
    }
    mOtherProcessNames.clear();
    PackageInfo packageInfo1 = pm.getPackageInfo(mHostContext.getPackageName(), PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS | PackageManager.GET_PROVIDERS | PackageManager.GET_SERVICES);
    if (packageInfo1.activities != null) {
        for (ActivityInfo info : packageInfo1.activities) {
            if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
                mOtherProcessNames.add(info.processName);
            }
        }
    }
    if (packageInfo1.receivers != null) {
        for (ActivityInfo info : packageInfo1.receivers) {
            if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
                mOtherProcessNames.add(info.processName);
            }
        }
    }
    if (packageInfo1.providers != null) {
        for (ProviderInfo info : packageInfo1.providers) {
            if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
                mOtherProcessNames.add(info.processName);
            }
        }
    }
    if (packageInfo1.services != null) {
        for (ServiceInfo info : packageInfo1.services) {
            if (!mOtherProcessNames.contains(info.processName) && !items.containsKey(info.processName)) {
                mOtherProcessNames.add(info.processName);
            }
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ActivityInfo(android.content.pm.ActivityInfo) PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo) PackageInfo(android.content.pm.PackageInfo) Intent(android.content.Intent)

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