use of android.content.pm.ServiceInfo in project android_frameworks_base by ResurrectionRemix.
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);
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by ResurrectionRemix.
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 android_frameworks_base by ResurrectionRemix.
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 android_frameworks_base by ResurrectionRemix.
the class ManagedServices method queryPackageForServices.
protected Set<ComponentName> queryPackageForServices(String packageName, int userId) {
Set<ComponentName> installed = new ArraySet<>();
final PackageManager pm = mContext.getPackageManager();
Intent queryIntent = new Intent(mConfig.serviceInterface);
if (!TextUtils.isEmpty(packageName)) {
queryIntent.setPackage(packageName);
}
List<ResolveInfo> installedServices = pm.queryIntentServicesAsUser(queryIntent, PackageManager.GET_SERVICES | PackageManager.GET_META_DATA, userId);
if (DEBUG)
Slog.v(TAG, mConfig.serviceInterface + " services: " + installedServices);
if (installedServices != null) {
for (int i = 0, count = installedServices.size(); i < count; i++) {
ResolveInfo resolveInfo = installedServices.get(i);
ServiceInfo info = resolveInfo.serviceInfo;
ComponentName component = new ComponentName(info.packageName, info.name);
if (!mConfig.bindPermission.equals(info.permission)) {
Slog.w(TAG, "Skipping " + getCaption() + " service " + info.packageName + "/" + info.name + ": it does not require the permission " + mConfig.bindPermission);
continue;
}
installed.add(component);
}
}
return installed;
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by ResurrectionRemix.
the class ZenModeHelper method addAutomaticZenRule.
public String addAutomaticZenRule(AutomaticZenRule automaticZenRule, String reason) {
if (!isSystemRule(automaticZenRule)) {
ServiceInfo owner = getServiceInfo(automaticZenRule.getOwner());
if (owner == null) {
throw new IllegalArgumentException("Owner is not a condition provider service");
}
int ruleInstanceLimit = -1;
if (owner.metaData != null) {
ruleInstanceLimit = owner.metaData.getInt(ConditionProviderService.META_DATA_RULE_INSTANCE_LIMIT, -1);
}
if (ruleInstanceLimit > 0 && ruleInstanceLimit < (getCurrentInstanceCount(automaticZenRule.getOwner()) + 1)) {
throw new IllegalArgumentException("Rule instance limit exceeded");
}
}
ZenModeConfig newConfig;
synchronized (mConfig) {
if (mConfig == null) {
throw new AndroidRuntimeException("Could not create rule");
}
if (DEBUG) {
Log.d(TAG, "addAutomaticZenRule rule= " + automaticZenRule + " reason=" + reason);
}
newConfig = mConfig.copy();
ZenRule rule = new ZenRule();
populateZenRule(automaticZenRule, rule, true);
newConfig.automaticRules.put(rule.id, rule);
if (setConfigLocked(newConfig, reason, true)) {
return rule.id;
} else {
throw new AndroidRuntimeException("Could not create rule");
}
}
}
Aggregations