Search in sources :

Example 76 with ServiceInfo

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

the class EnableAccessibilityController method getInstalledSpeakingAccessibilityServiceComponent.

@Nullable
public static ComponentName getInstalledSpeakingAccessibilityServiceComponent(Context context) {
    List<AccessibilityServiceInfo> services = getInstalledSpeakingAccessibilityServices(context);
    if (services.isEmpty()) {
        return null;
    }
    ServiceInfo serviceInfo = services.get(0).getResolveInfo().serviceInfo;
    return new ComponentName(serviceInfo.packageName, serviceInfo.name);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ComponentName(android.content.ComponentName) Nullable(android.annotation.Nullable)

Example 77 with ServiceInfo

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

the class AccessibilityManagerServiceTest method testGetAccessibilityServicesList.

@LargeTest
public void testGetAccessibilityServicesList() throws Exception {
    boolean firstMockServiceInstalled = false;
    boolean secondMockServiceInstalled = false;
    String packageName = getContext().getPackageName();
    String firstMockServiceClassName = MyFirstMockAccessibilityService.class.getName();
    String secondMockServiceClassName = MySecondMockAccessibilityService.class.getName();
    // look for the two mock services
    for (AccessibilityServiceInfo info : mManagerService.getInstalledAccessibilityServiceList(UserHandle.USER_CURRENT)) {
        ServiceInfo serviceInfo = info.getResolveInfo().serviceInfo;
        if (packageName.equals(serviceInfo.packageName)) {
            if (firstMockServiceClassName.equals(serviceInfo.name)) {
                firstMockServiceInstalled = true;
            } else if (secondMockServiceClassName.equals(serviceInfo.name)) {
                secondMockServiceInstalled = true;
            }
        }
    }
    // check expected result
    assertTrue("First mock service must be installed", firstMockServiceInstalled);
    assertTrue("Second mock service must be installed", secondMockServiceInstalled);
}
Also used : AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) ServiceInfo(android.content.pm.ServiceInfo) AccessibilityServiceInfo(android.accessibilityservice.AccessibilityServiceInfo) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 78 with ServiceInfo

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

the class InputMethodUtilsTest 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 79 with ServiceInfo

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

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)

Example 80 with ServiceInfo

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

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)

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