use of android.content.pm.ServiceInfo in project platform_frameworks_base by android.
the class TextServicesManagerService method buildSpellCheckerMapLocked.
private static void buildSpellCheckerMapLocked(Context context, ArrayList<SpellCheckerInfo> list, HashMap<String, SpellCheckerInfo> map, TextServicesSettings settings) {
list.clear();
map.clear();
final PackageManager pm = context.getPackageManager();
// Note: We do not specify PackageManager.MATCH_ENCRYPTION_* flags here because the default
// behavior of PackageManager is exactly what we want. It by default picks up appropriate
// services depending on the unlock state for the specified user.
final List<ResolveInfo> services = pm.queryIntentServicesAsUser(new Intent(SpellCheckerService.SERVICE_INTERFACE), PackageManager.GET_META_DATA, settings.getCurrentUserId());
final int N = services.size();
for (int i = 0; i < N; ++i) {
final ResolveInfo ri = services.get(i);
final ServiceInfo si = ri.serviceInfo;
final ComponentName compName = new ComponentName(si.packageName, si.name);
if (!android.Manifest.permission.BIND_TEXT_SERVICE.equals(si.permission)) {
Slog.w(TAG, "Skipping text service " + compName + ": it does not require the permission " + android.Manifest.permission.BIND_TEXT_SERVICE);
continue;
}
if (DBG)
Slog.d(TAG, "Add: " + compName);
try {
final SpellCheckerInfo sci = new SpellCheckerInfo(context, ri);
if (sci.getSubtypeCount() <= 0) {
Slog.w(TAG, "Skipping text service " + compName + ": it does not contain subtypes.");
continue;
}
list.add(sci);
map.put(sci.getId(), sci);
} catch (XmlPullParserException e) {
Slog.w(TAG, "Unable to load the spell checker " + compName, e);
} catch (IOException e) {
Slog.w(TAG, "Unable to load the spell checker " + compName, e);
}
}
if (DBG) {
Slog.d(TAG, "buildSpellCheckerMapLocked: " + list.size() + "," + map.size());
}
}
use of android.content.pm.ServiceInfo in project platform_frameworks_base by android.
the class MetaDataTest method testServiceWithData.
@SmallTest
public void testServiceWithData() throws Exception {
ComponentName cn = new ComponentName(mContext, LocalService.class);
ServiceInfo si = mContext.getPackageManager().getServiceInfo(cn, PackageManager.GET_META_DATA);
checkMetaData(cn, si);
si = mContext.getPackageManager().getServiceInfo(cn, 0);
assertNull("Meta data returned when not requested", si.metaData);
}
use of android.content.pm.ServiceInfo in project platform_frameworks_base by android.
the class NetworkScorerAppManagerTest method mockRecommendationServiceAvailable.
private void mockRecommendationServiceAvailable(final String packageName, int packageUid) {
final ResolveInfo serviceInfo = new ResolveInfo();
serviceInfo.serviceInfo = new ServiceInfo();
serviceInfo.serviceInfo.name = ".RecommendationService";
serviceInfo.serviceInfo.packageName = packageName;
serviceInfo.serviceInfo.applicationInfo = new ApplicationInfo();
serviceInfo.serviceInfo.applicationInfo.uid = packageUid;
final int flags = 0;
when(mMockPm.resolveService(Mockito.argThat(new ArgumentMatcher<Intent>() {
@Override
public boolean matchesObject(Object object) {
Intent intent = (Intent) object;
return NetworkScoreManager.ACTION_RECOMMEND_NETWORKS.equals(intent.getAction()) && packageName.equals(intent.getPackage());
}
}), Mockito.eq(flags))).thenReturn(serviceInfo);
}
use of android.content.pm.ServiceInfo in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class ZenModeHelper method getServiceInfo.
private ServiceInfo getServiceInfo(ComponentName owner) {
Intent queryIntent = new Intent();
queryIntent.setComponent(owner);
List<ResolveInfo> installedServices = mPm.queryIntentServicesAsUser(queryIntent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, UserHandle.getCallingUserId());
if (installedServices != null) {
for (int i = 0, count = installedServices.size(); i < count; i++) {
ResolveInfo resolveInfo = installedServices.get(i);
ServiceInfo info = resolveInfo.serviceInfo;
if (mServiceConfig.bindPermission.equals(info.permission)) {
return info;
}
}
}
return null;
}
Aggregations