use of android.content.pm.PackageManager in project httpclient by pixmob.
the class ActionMenu method addIntentOptions.
public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
PackageManager pm = mContext.getPackageManager();
final List<ResolveInfo> lri = pm.queryIntentActivityOptions(caller, specifics, intent, 0);
final int N = lri != null ? lri.size() : 0;
if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
removeGroup(groupId);
}
for (int i = 0; i < N; i++) {
final ResolveInfo ri = lri.get(i);
Intent rintent = new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName, ri.activityInfo.name));
final MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
if (outSpecificItems != null && ri.specificIndex >= 0) {
outSpecificItems[ri.specificIndex] = item;
}
}
return N;
}
use of android.content.pm.PackageManager in project httpclient by pixmob.
the class MenuBuilder method addIntentOptions.
public int addIntentOptions(int group, int id, int categoryOrder, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
PackageManager pm = mContext.getPackageManager();
final List<ResolveInfo> lri = pm.queryIntentActivityOptions(caller, specifics, intent, 0);
final int N = lri != null ? lri.size() : 0;
if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
removeGroup(group);
}
for (int i = 0; i < N; i++) {
final ResolveInfo ri = lri.get(i);
Intent rintent = new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName, ri.activityInfo.name));
final MenuItem item = add(group, id, categoryOrder, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
if (outSpecificItems != null && ri.specificIndex >= 0) {
outSpecificItems[ri.specificIndex] = item;
}
}
return N;
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class UsbDebuggingManager method startConfirmationActivity.
/**
* @returns true if the componentName led to an Activity that was started.
*/
private boolean startConfirmationActivity(ComponentName componentName, UserHandle userHandle, String key, String fingerprints) {
PackageManager packageManager = mContext.getPackageManager();
Intent intent = createConfirmationIntent(componentName, key, fingerprints);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) {
try {
mContext.startActivityAsUser(intent, userHandle);
return true;
} catch (ActivityNotFoundException e) {
Slog.e(TAG, "unable to start adb whitelist activity: " + componentName, e);
}
}
return false;
}
use of android.content.pm.PackageManager in project androidquery by androidquery.
the class FacebookHandle method validateAppSignatureForIntent.
private boolean validateAppSignatureForIntent(Context context, Intent intent) {
PackageManager pm = context.getPackageManager();
ResolveInfo resolveInfo = pm.resolveActivity(intent, 0);
if (resolveInfo == null) {
return false;
}
String packageName = resolveInfo.activityInfo.packageName;
PackageInfo packageInfo;
try {
packageInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
} catch (NameNotFoundException e) {
return false;
}
for (Signature signature : packageInfo.signatures) {
if (signature.toCharsString().equals(FB_APP_SIGNATURE)) {
return true;
}
}
return false;
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class AudioService method killBackgroundUserProcessesWithRecordAudioPermission.
// end class AudioServiceUserRestrictionsListener
private void killBackgroundUserProcessesWithRecordAudioPermission(UserInfo oldUser) {
PackageManager pm = mContext.getPackageManager();
// Find the home activity of the user. It should not be killed to avoid expensive restart,
// when the user switches back. For managed profiles, we should kill all recording apps
ComponentName homeActivityName = null;
if (!oldUser.isManagedProfile()) {
homeActivityName = LocalServices.getService(ActivityManagerInternal.class).getHomeActivityForUser(oldUser.id);
}
final String[] permissions = { Manifest.permission.RECORD_AUDIO };
List<PackageInfo> packages;
try {
packages = AppGlobals.getPackageManager().getPackagesHoldingPermissions(permissions, 0, oldUser.id).getList();
} catch (RemoteException e) {
throw new AndroidRuntimeException(e);
}
for (int j = packages.size() - 1; j >= 0; j--) {
PackageInfo pkg = packages.get(j);
// Skip system processes
if (UserHandle.getAppId(pkg.applicationInfo.uid) < FIRST_APPLICATION_UID) {
continue;
}
// Skip packages that have permission to interact across users
if (pm.checkPermission(Manifest.permission.INTERACT_ACROSS_USERS, pkg.packageName) == PackageManager.PERMISSION_GRANTED) {
continue;
}
if (homeActivityName != null && pkg.packageName.equals(homeActivityName.getPackageName()) && pkg.applicationInfo.isSystemApp()) {
continue;
}
try {
final int uid = pkg.applicationInfo.uid;
ActivityManagerNative.getDefault().killUid(UserHandle.getAppId(uid), UserHandle.getUserId(uid), "killBackgroundUserProcessesWithAudioRecordPermission");
} catch (RemoteException e) {
Log.w(TAG, "Error calling killUid", e);
}
}
}
Aggregations