use of android.content.pm.ServiceInfo in project android_frameworks_base by DirtyUnicorns.
the class DevicePolicyManagerService method getPermittedInputMethodsForCurrentUser.
@Override
public List getPermittedInputMethodsForCurrentUser() {
UserInfo currentUser;
try {
currentUser = mInjector.getIActivityManager().getCurrentUser();
} catch (RemoteException e) {
Slog.e(LOG_TAG, "Failed to make remote calls to get current user", e);
// Activity managed is dead, just allow all IMEs
return null;
}
int userId = currentUser.id;
synchronized (this) {
List<String> result = null;
// If we have multiple profiles we return the intersection of the
// permitted lists. This can happen in cases where we have a device
// and profile owner.
int[] profileIds = mUserManager.getProfileIdsWithDisabled(userId);
for (int profileId : profileIds) {
// Just loop though all admins, only device or profiles
// owners can have permitted lists set.
DevicePolicyData policy = getUserDataUnchecked(profileId);
final int N = policy.mAdminList.size();
for (int j = 0; j < N; j++) {
ActiveAdmin admin = policy.mAdminList.get(j);
List<String> fromAdmin = admin.permittedInputMethods;
if (fromAdmin != null) {
if (result == null) {
result = new ArrayList<String>(fromAdmin);
} else {
result.retainAll(fromAdmin);
}
}
}
}
// If we have a permitted list add all system input methods.
if (result != null) {
InputMethodManager inputMethodManager = mContext.getSystemService(InputMethodManager.class);
List<InputMethodInfo> imes = inputMethodManager.getInputMethodList();
long id = mInjector.binderClearCallingIdentity();
try {
if (imes != null) {
for (InputMethodInfo ime : imes) {
ServiceInfo serviceInfo = ime.getServiceInfo();
ApplicationInfo applicationInfo = serviceInfo.applicationInfo;
if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
result.add(serviceInfo.packageName);
}
}
}
} finally {
mInjector.binderRestoreCallingIdentity(id);
}
}
return result;
}
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by DirtyUnicorns.
the class DevicePolicyManagerService method getPermittedAccessibilityServicesForUser.
@Override
public List getPermittedAccessibilityServicesForUser(int userId) {
if (!mHasFeature) {
return null;
}
synchronized (this) {
List<String> result = null;
// If we have multiple profiles we return the intersection of the
// permitted lists. This can happen in cases where we have a device
// and profile owner.
int[] profileIds = mUserManager.getProfileIdsWithDisabled(userId);
for (int profileId : profileIds) {
// Just loop though all admins, only device or profiles
// owners can have permitted lists set.
DevicePolicyData policy = getUserDataUnchecked(profileId);
final int N = policy.mAdminList.size();
for (int j = 0; j < N; j++) {
ActiveAdmin admin = policy.mAdminList.get(j);
List<String> fromAdmin = admin.permittedAccessiblityServices;
if (fromAdmin != null) {
if (result == null) {
result = new ArrayList<>(fromAdmin);
} else {
result.retainAll(fromAdmin);
}
}
}
}
// If we have a permitted list add all system accessibility services.
if (result != null) {
long id = mInjector.binderClearCallingIdentity();
try {
UserInfo user = getUserInfo(userId);
if (user.isManagedProfile()) {
userId = user.profileGroupId;
}
AccessibilityManager accessibilityManager = getAccessibilityManagerForUser(userId);
List<AccessibilityServiceInfo> installedServices = accessibilityManager.getInstalledAccessibilityServiceList();
if (installedServices != null) {
for (AccessibilityServiceInfo service : installedServices) {
ServiceInfo serviceInfo = service.getResolveInfo().serviceInfo;
ApplicationInfo applicationInfo = serviceInfo.applicationInfo;
if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
result.add(serviceInfo.packageName);
}
}
}
} finally {
mInjector.binderRestoreCallingIdentity(id);
}
}
return result;
}
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
the class CustomTile method setTileIcon.
private void setTileIcon() {
try {
PackageManager pm = mContext.getPackageManager();
int flags = PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE;
if (isSystemApp(pm)) {
flags |= PackageManager.MATCH_DISABLED_COMPONENTS;
}
ServiceInfo info = pm.getServiceInfo(mComponent, flags);
int icon = info.icon != 0 ? info.icon : info.applicationInfo.icon;
// Update the icon if its not set or is the default icon.
boolean updateIcon = mTile.getIcon() == null || iconEquals(mTile.getIcon(), mDefaultIcon);
mDefaultIcon = icon != 0 ? android.graphics.drawable.Icon.createWithResource(mComponent.getPackageName(), icon) : null;
if (updateIcon) {
mTile.setIcon(mDefaultIcon);
}
// Update the label if there is no label.
if (mTile.getLabel() == null) {
mTile.setLabel(info.loadLabel(pm));
}
} catch (Exception e) {
mDefaultIcon = null;
}
}
use of android.content.pm.ServiceInfo in project android_frameworks_base by DirtyUnicorns.
the class AccessibilityManagerService method readInstalledAccessibilityServiceLocked.
private boolean readInstalledAccessibilityServiceLocked(UserState userState) {
mTempAccessibilityServiceInfoList.clear();
List<ResolveInfo> installedServices = mPackageManager.queryIntentServicesAsUser(new Intent(AccessibilityService.SERVICE_INTERFACE), PackageManager.GET_SERVICES | PackageManager.GET_META_DATA | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, mCurrentUserId);
for (int i = 0, count = installedServices.size(); i < count; i++) {
ResolveInfo resolveInfo = installedServices.get(i);
ServiceInfo serviceInfo = resolveInfo.serviceInfo;
if (!android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE.equals(serviceInfo.permission)) {
Slog.w(LOG_TAG, "Skipping accessibilty service " + new ComponentName(serviceInfo.packageName, serviceInfo.name).flattenToShortString() + ": it does not require the permission " + android.Manifest.permission.BIND_ACCESSIBILITY_SERVICE);
continue;
}
AccessibilityServiceInfo accessibilityServiceInfo;
try {
accessibilityServiceInfo = new AccessibilityServiceInfo(resolveInfo, mContext);
mTempAccessibilityServiceInfoList.add(accessibilityServiceInfo);
} catch (XmlPullParserException | IOException xppe) {
Slog.e(LOG_TAG, "Error while initializing AccessibilityServiceInfo", xppe);
}
}
if (!mTempAccessibilityServiceInfoList.equals(userState.mInstalledServices)) {
userState.mInstalledServices.clear();
userState.mInstalledServices.addAll(mTempAccessibilityServiceInfoList);
mTempAccessibilityServiceInfoList.clear();
return true;
}
mTempAccessibilityServiceInfoList.clear();
return false;
}
Aggregations