Search in sources :

Example 91 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 92 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 93 with ServiceInfo

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

the class MidiService method onUnlockUser.

private void onUnlockUser() {
    mPackageMonitor.register(mContext, null, true);
    Intent intent = new Intent(MidiDeviceService.SERVICE_INTERFACE);
    List<ResolveInfo> resolveInfos = mPackageManager.queryIntentServices(intent, PackageManager.GET_META_DATA);
    if (resolveInfos != null) {
        int count = resolveInfos.size();
        for (int i = 0; i < count; i++) {
            ServiceInfo serviceInfo = resolveInfos.get(i).serviceInfo;
            if (serviceInfo != null) {
                addPackageDeviceServer(serviceInfo);
            }
        }
    }
    PackageInfo info;
    try {
        info = mPackageManager.getPackageInfo(MidiManager.BLUETOOTH_MIDI_SERVICE_PACKAGE, 0);
    } catch (PackageManager.NameNotFoundException e) {
        info = null;
    }
    if (info != null && info.applicationInfo != null) {
        mBluetoothServiceUid = info.applicationInfo.uid;
    } else {
        mBluetoothServiceUid = -1;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) Intent(android.content.Intent)

Example 94 with ServiceInfo

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

the class TvInputManagerService method buildTvInputListLocked.

private void buildTvInputListLocked(int userId, String[] updatedPackages) {
    UserState userState = getOrCreateUserStateLocked(userId);
    userState.packageSet.clear();
    if (DEBUG)
        Slog.d(TAG, "buildTvInputList");
    PackageManager pm = mContext.getPackageManager();
    List<ResolveInfo> services = pm.queryIntentServicesAsUser(new Intent(TvInputService.SERVICE_INTERFACE), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, userId);
    List<TvInputInfo> inputList = new ArrayList<>();
    for (ResolveInfo ri : services) {
        ServiceInfo si = ri.serviceInfo;
        if (!android.Manifest.permission.BIND_TV_INPUT.equals(si.permission)) {
            Slog.w(TAG, "Skipping TV input " + si.name + ": it does not require the permission " + android.Manifest.permission.BIND_TV_INPUT);
            continue;
        }
        ComponentName component = new ComponentName(si.packageName, si.name);
        if (hasHardwarePermission(pm, component)) {
            ServiceState serviceState = userState.serviceStateMap.get(component);
            if (serviceState == null) {
                // New hardware input found. Create a new ServiceState and connect to the
                // service to populate the hardware list.
                serviceState = new ServiceState(component, userId);
                userState.serviceStateMap.put(component, serviceState);
                updateServiceConnectionLocked(component, userId);
            } else {
                inputList.addAll(serviceState.hardwareInputList);
            }
        } else {
            try {
                TvInputInfo info = new TvInputInfo.Builder(mContext, ri).build();
                inputList.add(info);
            } catch (Exception e) {
                Slog.e(TAG, "failed to load TV input " + si.name, e);
                continue;
            }
        }
        userState.packageSet.add(si.packageName);
    }
    Map<String, TvInputState> inputMap = new HashMap<>();
    for (TvInputInfo info : inputList) {
        if (DEBUG) {
            Slog.d(TAG, "add " + info.getId());
        }
        TvInputState inputState = userState.inputMap.get(info.getId());
        if (inputState == null) {
            inputState = new TvInputState();
        }
        inputState.info = info;
        inputMap.put(info.getId(), inputState);
    }
    for (String inputId : inputMap.keySet()) {
        if (!userState.inputMap.containsKey(inputId)) {
            notifyInputAddedLocked(userState, inputId);
        } else if (updatedPackages != null) {
            // Notify the package updates
            ComponentName component = inputMap.get(inputId).info.getComponent();
            for (String updatedPackage : updatedPackages) {
                if (component.getPackageName().equals(updatedPackage)) {
                    updateServiceConnectionLocked(component, userId);
                    notifyInputUpdatedLocked(userState, inputId);
                    break;
                }
            }
        }
    }
    for (String inputId : userState.inputMap.keySet()) {
        if (!inputMap.containsKey(inputId)) {
            TvInputInfo info = userState.inputMap.get(inputId).info;
            ServiceState serviceState = userState.serviceStateMap.get(info.getComponent());
            if (serviceState != null) {
                abortPendingCreateSessionRequestsLocked(serviceState, inputId, userId);
            }
            notifyInputRemovedLocked(userState, inputId);
        }
    }
    userState.inputMap.clear();
    userState.inputMap = inputMap;
}
Also used : HashMap(java.util.HashMap) TvInputInfo(android.media.tv.TvInputInfo) ArrayList(java.util.ArrayList) Intent(android.content.Intent) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) OperationApplicationException(android.content.OperationApplicationException) ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) PackageManager(android.content.pm.PackageManager) ComponentName(android.content.ComponentName)

Example 95 with ServiceInfo

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

the class RemoteDisplayProviderWatcher method scanPackages.

private void scanPackages() {
    if (!mRunning) {
        return;
    }
    // Add providers for all new services.
    // Reorder the list so that providers left at the end will be the ones to remove.
    int targetIndex = 0;
    Intent intent = new Intent(RemoteDisplayState.SERVICE_INTERFACE);
    for (ResolveInfo resolveInfo : mPackageManager.queryIntentServicesAsUser(intent, 0, mUserId)) {
        ServiceInfo serviceInfo = resolveInfo.serviceInfo;
        if (serviceInfo != null && verifyServiceTrusted(serviceInfo)) {
            int sourceIndex = findProvider(serviceInfo.packageName, serviceInfo.name);
            if (sourceIndex < 0) {
                RemoteDisplayProviderProxy provider = new RemoteDisplayProviderProxy(mContext, new ComponentName(serviceInfo.packageName, serviceInfo.name), mUserId);
                provider.start();
                mProviders.add(targetIndex++, provider);
                mCallback.addProvider(provider);
            } else if (sourceIndex >= targetIndex) {
                RemoteDisplayProviderProxy provider = mProviders.get(sourceIndex);
                // restart the provider if needed
                provider.start();
                provider.rebindIfDisconnected();
                Collections.swap(mProviders, sourceIndex, targetIndex++);
            }
        }
    }
    // Remove providers for missing services.
    if (targetIndex < mProviders.size()) {
        for (int i = mProviders.size() - 1; i >= targetIndex; i--) {
            RemoteDisplayProviderProxy provider = mProviders.get(i);
            mCallback.removeProvider(provider);
            mProviders.remove(provider);
            provider.stop();
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

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