use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class CompatModePackages method saveCompatModes.
void saveCompatModes() {
HashMap<String, Integer> pkgs;
synchronized (mService) {
pkgs = new HashMap<String, Integer>(mPackages);
}
FileOutputStream fos = null;
try {
fos = mFile.startWrite();
XmlSerializer out = new FastXmlSerializer();
out.setOutput(fos, StandardCharsets.UTF_8.name());
out.startDocument(null, true);
out.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
out.startTag(null, "compat-packages");
final IPackageManager pm = AppGlobals.getPackageManager();
final int screenLayout = mService.mConfiguration.screenLayout;
final int smallestScreenWidthDp = mService.mConfiguration.smallestScreenWidthDp;
final Iterator<Map.Entry<String, Integer>> it = pkgs.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Integer> entry = it.next();
String pkg = entry.getKey();
int mode = entry.getValue();
if (mode == 0) {
continue;
}
ApplicationInfo ai = null;
try {
ai = pm.getApplicationInfo(pkg, 0, 0);
} catch (RemoteException e) {
}
if (ai == null) {
continue;
}
CompatibilityInfo info = new CompatibilityInfo(ai, screenLayout, smallestScreenWidthDp, false);
if (info.alwaysSupportsScreen()) {
continue;
}
if (info.neverSupportsScreen()) {
continue;
}
out.startTag(null, "pkg");
out.attribute(null, "name", pkg);
out.attribute(null, "mode", Integer.toString(mode));
out.endTag(null, "pkg");
}
out.endTag(null, "compat-packages");
out.endDocument();
mFile.finishWrite(fos);
} catch (java.io.IOException e1) {
Slog.w(TAG, "Error writing compat packages", e1);
if (fos != null) {
mFile.failWrite(fos);
}
}
}
use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class IntentFirewall method logIntent.
private static void logIntent(int intentType, Intent intent, int callerUid, String resolvedType) {
// The component shouldn't be null, but let's double check just to be safe
ComponentName cn = intent.getComponent();
String shortComponent = null;
if (cn != null) {
shortComponent = cn.flattenToShortString();
}
String callerPackages = null;
int callerPackageCount = 0;
IPackageManager pm = AppGlobals.getPackageManager();
if (pm != null) {
try {
String[] callerPackagesArray = pm.getPackagesForUid(callerUid);
if (callerPackagesArray != null) {
callerPackageCount = callerPackagesArray.length;
callerPackages = joinPackages(callerPackagesArray);
}
} catch (RemoteException ex) {
Slog.e(TAG, "Remote exception while retrieving packages", ex);
}
}
EventLogTags.writeIfwIntentMatched(intentType, shortComponent, callerUid, callerPackageCount, callerPackages, intent.getAction(), resolvedType, intent.getDataString(), intent.getFlags());
}
use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class SenderPackageFilter method matches.
@Override
public boolean matches(IntentFirewall ifw, ComponentName resolvedComponent, Intent intent, int callerUid, int callerPid, String resolvedType, int receivingUid) {
IPackageManager pm = AppGlobals.getPackageManager();
int packageUid = -1;
try {
// USER_SYSTEM here is not important. Only app id is used and getPackageUid() will
// return a uid whether the app is installed for a user or not.
packageUid = pm.getPackageUid(mPackageName, PackageManager.MATCH_UNINSTALLED_PACKAGES, UserHandle.USER_SYSTEM);
} catch (RemoteException ex) {
// handled below
}
if (packageUid == -1) {
return false;
}
return UserHandle.isSameApp(packageUid, callerUid);
}
use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class GLImpl method allowIndirectBuffers.
private static boolean allowIndirectBuffers(String appName) {
boolean result = false;
int version = 0;
IPackageManager pm = AppGlobals.getPackageManager();
try {
ApplicationInfo applicationInfo = pm.getApplicationInfo(appName, 0, UserHandle.myUserId());
if (applicationInfo != null) {
version = applicationInfo.targetSdkVersion;
}
} catch (android.os.RemoteException e) {
// ignore
}
Log.e("OpenGLES", String.format("Application %s (SDK target %d) called a GL11 Pointer method with an indirect Buffer.", appName, version));
if (version <= Build.VERSION_CODES.CUPCAKE) {
result = true;
}
return result;
}
use of android.content.pm.IPackageManager in project android_frameworks_base by DirtyUnicorns.
the class AccountManagerService method checkUidPermission.
private boolean checkUidPermission(String permission, int uid, String opPackageName) {
final long identity = Binder.clearCallingIdentity();
try {
IPackageManager pm = ActivityThread.getPackageManager();
if (pm.checkUidPermission(permission, uid) != PackageManager.PERMISSION_GRANTED) {
return false;
}
final int opCode = AppOpsManager.permissionToOpCode(permission);
return (opCode == AppOpsManager.OP_NONE || mAppOpsManager.noteOpNoThrow(opCode, uid, opPackageName) == AppOpsManager.MODE_ALLOWED);
} catch (RemoteException e) {
/* ignore - local call */
} finally {
Binder.restoreCallingIdentity(identity);
}
return false;
}
Aggregations