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);
}
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;
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by crdroidandroid.
the class NetworkScorerAppManagerTest method buildResolveInfo.
private ResolveInfoHolder buildResolveInfo(String packageName, int packageUid, boolean hasReceiverPermission, boolean hasScorePermission, boolean hasConfigActivity, boolean hasServiceInfo) throws Exception {
Mockito.when(mMockPm.checkPermission(permission.SCORE_NETWORKS, packageName)).thenReturn(hasScorePermission ? PackageManager.PERMISSION_GRANTED : PackageManager.PERMISSION_DENIED);
ResolveInfo resolveInfo = new ResolveInfo();
resolveInfo.activityInfo = new ActivityInfo();
resolveInfo.activityInfo.packageName = packageName;
resolveInfo.activityInfo.applicationInfo = new ApplicationInfo();
resolveInfo.activityInfo.applicationInfo.uid = packageUid;
if (hasReceiverPermission) {
resolveInfo.activityInfo.permission = permission.BROADCAST_NETWORK_PRIVILEGED;
}
ResolveInfo configActivityInfo = null;
if (hasConfigActivity) {
configActivityInfo = new ResolveInfo();
configActivityInfo.activityInfo = new ActivityInfo();
configActivityInfo.activityInfo.name = ".ConfigActivity";
}
ResolveInfo serviceInfo = null;
if (hasServiceInfo) {
serviceInfo = new ResolveInfo();
serviceInfo.serviceInfo = new ServiceInfo();
serviceInfo.serviceInfo.name = ".ScoringService";
}
return new ResolveInfoHolder(resolveInfo, configActivityInfo, serviceInfo);
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by crdroidandroid.
the class TtsEngines method getEngineInfo.
private EngineInfo getEngineInfo(ResolveInfo resolve, PackageManager pm) {
ServiceInfo service = resolve.serviceInfo;
if (service != null) {
EngineInfo engine = new EngineInfo();
// Using just the package name isn't great, since it disallows having
// multiple engines in the same package, but that's what the existing API does.
engine.name = service.packageName;
CharSequence label = service.loadLabel(pm);
engine.label = TextUtils.isEmpty(label) ? engine.name : label.toString();
engine.icon = service.getIconResource();
engine.priority = resolve.priority;
engine.system = isSystemEngine(service);
return engine;
}
return null;
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by crdroidandroid.
the class AccessibilityServiceInfo method loadDescription.
/**
* The localized description of the accessibility service.
* <p>
* <strong>Statically set from
* {@link AccessibilityService#SERVICE_META_DATA meta-data}.</strong>
* </p>
* @return The localized description.
*/
public String loadDescription(PackageManager packageManager) {
if (mDescriptionResId == 0) {
return mNonLocalizedDescription;
}
ServiceInfo serviceInfo = mResolveInfo.serviceInfo;
CharSequence description = packageManager.getText(serviceInfo.packageName, mDescriptionResId, serviceInfo.applicationInfo);
if (description != null) {
return description.toString().trim();
}
return null;
}
Aggregations