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);
}
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);
}
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);
}
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();
}
}
}
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);
}
Aggregations