use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
the class ChooserActivity method filterServiceTargets.
void filterServiceTargets(String packageName, List<ChooserTarget> targets) {
if (targets == null) {
return;
}
final PackageManager pm = getPackageManager();
for (int i = targets.size() - 1; i >= 0; i--) {
final ChooserTarget target = targets.get(i);
final ComponentName targetName = target.getComponentName();
if (packageName != null && packageName.equals(targetName.getPackageName())) {
// Anything from the original target's package is fine.
continue;
}
boolean remove;
try {
final ActivityInfo ai = pm.getActivityInfo(targetName, 0);
remove = !ai.exported || ai.permission != null;
} catch (NameNotFoundException e) {
Log.e(TAG, "Target " + target + " returned by " + packageName + " component not found");
remove = true;
}
if (remove) {
targets.remove(i);
}
}
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
the class BroadcastRecord method cleanupDisabledPackageReceiversLocked.
boolean cleanupDisabledPackageReceiversLocked(String packageName, Set<String> filterByClasses, int userId, boolean doit) {
if ((userId != UserHandle.USER_ALL && this.userId != userId) || receivers == null) {
return false;
}
boolean didSomething = false;
Object o;
for (int i = receivers.size() - 1; i >= 0; i--) {
o = receivers.get(i);
if (!(o instanceof ResolveInfo)) {
continue;
}
ActivityInfo info = ((ResolveInfo) o).activityInfo;
final boolean sameComponent = packageName == null || (info.applicationInfo.packageName.equals(packageName) && (filterByClasses == null || filterByClasses.contains(info.name)));
if (sameComponent) {
if (!doit) {
return true;
}
didSomething = true;
receivers.remove(i);
if (i < nextReceiver) {
nextReceiver--;
}
}
}
nextReceiver = Math.min(nextReceiver, receivers.size());
return didSomething;
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
the class SuggestionsAdapter method getActivityIcon.
/**
* Gets the activity or application icon for an activity.
*
* @param component Name of an activity.
* @return A drawable, or {@code null} if neither the acitivy or the application
* have an icon set.
*/
private Drawable getActivityIcon(ComponentName component) {
PackageManager pm = mContext.getPackageManager();
final ActivityInfo activityInfo;
try {
activityInfo = pm.getActivityInfo(component, PackageManager.GET_META_DATA);
} catch (NameNotFoundException ex) {
Log.w(LOG_TAG, ex.toString());
return null;
}
int iconId = activityInfo.getIconResource();
if (iconId == 0)
return null;
String pkg = component.getPackageName();
Drawable drawable = pm.getDrawable(pkg, iconId, activityInfo.applicationInfo);
if (drawable == null) {
Log.w(LOG_TAG, "Invalid icon resource " + iconId + " for " + component.flattenToShortString());
return null;
}
return drawable;
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
the class KeyguardBottomAreaView method bindCameraPrewarmService.
public void bindCameraPrewarmService() {
Intent intent = getCameraIntent();
ActivityInfo targetInfo = PreviewInflater.getTargetActivityInfo(mContext, intent, KeyguardUpdateMonitor.getCurrentUser(), true);
if (targetInfo != null && targetInfo.metaData != null) {
String clazz = targetInfo.metaData.getString(MediaStore.META_DATA_STILL_IMAGE_CAMERA_PREWARM_SERVICE);
if (clazz != null) {
Intent serviceIntent = new Intent();
serviceIntent.setClassName(targetInfo.packageName, clazz);
serviceIntent.setAction(CameraPrewarmService.ACTION_PREWARM);
try {
if (getContext().bindServiceAsUser(serviceIntent, mPrewarmConnection, Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE, new UserHandle(UserHandle.USER_CURRENT))) {
mPrewarmBound = true;
}
} catch (SecurityException e) {
Log.w(TAG, "Unable to bind to prewarm service package=" + targetInfo.packageName + " class=" + clazz, e);
}
}
}
}
use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.
the class UsbSettingsManager method packageMatchesLocked.
// Checks to see if a package matches a device or accessory.
// Only one of device and accessory should be non-null.
private boolean packageMatchesLocked(ResolveInfo info, String metaDataName, UsbDevice device, UsbAccessory accessory) {
ActivityInfo ai = info.activityInfo;
XmlResourceParser parser = null;
try {
parser = ai.loadXmlMetaData(mPackageManager, metaDataName);
if (parser == null) {
Slog.w(TAG, "no meta-data for " + info);
return false;
}
XmlUtils.nextElement(parser);
while (parser.getEventType() != XmlPullParser.END_DOCUMENT) {
String tagName = parser.getName();
if (device != null && "usb-device".equals(tagName)) {
DeviceFilter filter = DeviceFilter.read(parser);
if (filter.matches(device)) {
return true;
}
} else if (accessory != null && "usb-accessory".equals(tagName)) {
AccessoryFilter filter = AccessoryFilter.read(parser);
if (filter.matches(accessory)) {
return true;
}
}
XmlUtils.nextElement(parser);
}
} catch (Exception e) {
Slog.w(TAG, "Unable to load component info " + info.toString(), e);
} finally {
if (parser != null)
parser.close();
}
return false;
}
Aggregations