use of android.content.pm.IPackageManager in project cornerstone by Onskreen.
the class ActivityManagerService method revokeUriPermission.
public void revokeUriPermission(IApplicationThread caller, Uri uri, int modeFlags) {
enforceNotIsolatedCaller("revokeUriPermission");
synchronized (this) {
final ProcessRecord r = getRecordForAppLocked(caller);
if (r == null) {
throw new SecurityException("Unable to find app for caller " + caller + " when revoking permission to uri " + uri);
}
if (uri == null) {
Slog.w(TAG, "revokeUriPermission: null uri");
return;
}
modeFlags &= (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
if (modeFlags == 0) {
return;
}
final IPackageManager pm = AppGlobals.getPackageManager();
final String authority = uri.getAuthority();
ProviderInfo pi = null;
ContentProviderRecord cpr = mProviderMap.getProviderByName(authority, r.userId);
if (cpr != null) {
pi = cpr.info;
} else {
try {
pi = pm.resolveContentProvider(authority, PackageManager.GET_URI_PERMISSION_PATTERNS, r.userId);
} catch (RemoteException ex) {
}
}
if (pi == null) {
Slog.w(TAG, "No content provider found for permission revoke: " + uri.toSafeString());
return;
}
revokeUriPermissionLocked(r.uid, uri, modeFlags);
}
}
use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class RetailDemoModeService method isDemoLauncherDisabled.
boolean isDemoLauncherDisabled() {
int enabledState = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
try {
final IPackageManager iPm = AppGlobals.getPackageManager();
final String demoLauncherComponent = getContext().getString(R.string.config_demoModeLauncherComponent);
enabledState = iPm.getComponentEnabledSetting(ComponentName.unflattenFromString(demoLauncherComponent), mCurrentUserId);
} catch (RemoteException re) {
Slog.e(TAG, "Error retrieving demo launcher enabled setting", re);
}
return enabledState == PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class AppOpsService method readUid.
void readUid(XmlPullParser parser, String pkgName) throws NumberFormatException, XmlPullParserException, IOException {
int uid = Integer.parseInt(parser.getAttributeValue(null, "n"));
String isPrivilegedString = parser.getAttributeValue(null, "p");
boolean isPrivileged = false;
if (isPrivilegedString == null) {
try {
IPackageManager packageManager = ActivityThread.getPackageManager();
if (packageManager != null) {
ApplicationInfo appInfo = ActivityThread.getPackageManager().getApplicationInfo(pkgName, 0, UserHandle.getUserId(uid));
if (appInfo != null) {
isPrivileged = (appInfo.privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
}
} else {
// Could not load data, don't add to cache so it will be loaded later.
return;
}
} catch (RemoteException e) {
Slog.w(TAG, "Could not contact PackageManager", e);
}
} else {
isPrivileged = Boolean.parseBoolean(isPrivilegedString);
}
int outerDepth = parser.getDepth();
int type;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
continue;
}
String tagName = parser.getName();
if (tagName.equals("op")) {
Op op = new Op(uid, pkgName, Integer.parseInt(parser.getAttributeValue(null, "n")));
String mode = parser.getAttributeValue(null, "m");
if (mode != null) {
op.mode = Integer.parseInt(mode);
}
String time = parser.getAttributeValue(null, "t");
if (time != null) {
op.time = Long.parseLong(time);
}
time = parser.getAttributeValue(null, "r");
if (time != null) {
op.rejectTime = Long.parseLong(time);
}
String dur = parser.getAttributeValue(null, "d");
if (dur != null) {
op.duration = Integer.parseInt(dur);
}
String proxyUid = parser.getAttributeValue(null, "pu");
if (proxyUid != null) {
op.proxyUid = Integer.parseInt(proxyUid);
}
String proxyPackageName = parser.getAttributeValue(null, "pp");
if (proxyPackageName != null) {
op.proxyPackageName = proxyPackageName;
}
UidState uidState = getUidStateLocked(uid, true);
if (uidState.pkgOps == null) {
uidState.pkgOps = new ArrayMap<>();
}
Ops ops = uidState.pkgOps.get(pkgName);
if (ops == null) {
ops = new Ops(pkgName, uidState, isPrivileged);
uidState.pkgOps.put(pkgName, ops);
}
ops.put(op.op, op);
} else {
Slog.w(TAG, "Unknown element under <pkg>: " + parser.getName());
XmlUtils.skipCurrentTag(parser);
}
}
}
use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class Bmgr method backupNowAllPackages.
private void backupNowAllPackages() {
int userId = UserHandle.USER_SYSTEM;
IPackageManager mPm = IPackageManager.Stub.asInterface(ServiceManager.getService("package"));
if (mPm == null) {
System.err.println(PM_NOT_RUNNING_ERR);
return;
}
List<PackageInfo> installedPackages = null;
try {
installedPackages = mPm.getInstalledPackages(0, userId).getList();
} catch (RemoteException e) {
System.err.println(e.toString());
System.err.println(PM_NOT_RUNNING_ERR);
}
if (installedPackages != null) {
List<String> packages = new ArrayList<>();
for (PackageInfo pi : installedPackages) {
try {
if (mBmgr.isAppEligibleForBackup(pi.packageName)) {
packages.add(pi.packageName);
}
} catch (RemoteException e) {
System.err.println(e.toString());
System.err.println(BMGR_NOT_RUNNING_ERR);
}
}
backupNowPackages(packages);
}
}
use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class UidDetailProvider method buildUidDetail.
/**
* Build {@link UidDetail} object, blocking until all {@link Drawable}
* lookup is finished.
*/
private UidDetail buildUidDetail(int uid) {
final Resources res = mContext.getResources();
final PackageManager pm = mContext.getPackageManager();
final UidDetail detail = new UidDetail();
detail.label = pm.getNameForUid(uid);
detail.icon = pm.getDefaultActivityIcon();
// handle special case labels
switch(uid) {
case android.os.Process.SYSTEM_UID:
detail.label = res.getString(R.string.process_kernel_label);
detail.icon = pm.getDefaultActivityIcon();
return detail;
case TrafficStats.UID_REMOVED:
detail.label = res.getString(UserManager.supportsMultipleUsers() ? R.string.data_usage_uninstalled_apps_users : R.string.data_usage_uninstalled_apps);
detail.icon = pm.getDefaultActivityIcon();
return detail;
case TrafficStats.UID_TETHERING:
final ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
detail.label = res.getString(Utils.getTetheringLabel(cm));
detail.icon = pm.getDefaultActivityIcon();
return detail;
}
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
// Handle keys that are actually user handles
if (isKeyForUser(uid)) {
final int userHandle = getUserIdForKey(uid);
final UserInfo info = um.getUserInfo(userHandle);
if (info != null) {
detail.label = Utils.getUserLabel(mContext, info);
detail.icon = Utils.getUserIcon(mContext, um, info);
return detail;
}
}
// otherwise fall back to using packagemanager labels
final String[] packageNames = pm.getPackagesForUid(uid);
final int length = packageNames != null ? packageNames.length : 0;
try {
final int userId = UserHandle.getUserId(uid);
UserHandle userHandle = new UserHandle(userId);
IPackageManager ipm = AppGlobals.getPackageManager();
if (length == 1) {
final ApplicationInfo info = ipm.getApplicationInfo(packageNames[0], 0, /* no flags */
userId);
if (info != null) {
detail.label = info.loadLabel(pm).toString();
detail.icon = um.getBadgedIconForUser(info.loadIcon(pm), new UserHandle(userId));
}
} else if (length > 1) {
detail.detailLabels = new CharSequence[length];
detail.detailContentDescriptions = new CharSequence[length];
for (int i = 0; i < length; i++) {
final String packageName = packageNames[i];
final PackageInfo packageInfo = pm.getPackageInfo(packageName, 0);
final ApplicationInfo appInfo = ipm.getApplicationInfo(packageName, 0, /* no flags */
userId);
if (appInfo != null) {
detail.detailLabels[i] = appInfo.loadLabel(pm).toString();
detail.detailContentDescriptions[i] = um.getBadgedLabelForUser(detail.detailLabels[i], userHandle);
if (packageInfo.sharedUserLabel != 0) {
detail.label = pm.getText(packageName, packageInfo.sharedUserLabel, packageInfo.applicationInfo).toString();
detail.icon = um.getBadgedIconForUser(appInfo.loadIcon(pm), userHandle);
}
}
}
}
detail.contentDescription = um.getBadgedLabelForUser(detail.label, userHandle);
} catch (NameNotFoundException e) {
Log.w(TAG, "Error while building UI detail for uid " + uid, e);
} catch (RemoteException e) {
Log.w(TAG, "Error while building UI detail for uid " + uid, e);
}
if (TextUtils.isEmpty(detail.label)) {
detail.label = Integer.toString(uid);
}
return detail;
}
Aggregations