use of android.content.pm.ApplicationInfo in project platform_frameworks_base by android.
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.ApplicationInfo in project platform_frameworks_base by android.
the class PinnerService method pinCamera.
private boolean pinCamera(int userHandle) {
//camera app, we're done. otherwise, unpin and pin the new app
if (alreadyPinned(userHandle)) {
return true;
}
ApplicationInfo cameraInfo = getCameraInfo(userHandle);
if (cameraInfo == null) {
return false;
}
//unpin after checking that the camera intent has resolved
//this prevents us from thrashing when switching users with
//FBE enabled, because the intent won't resolve until the unlock
unpinCameraApp();
//pin APK
String camAPK = cameraInfo.sourceDir;
PinnedFile pf = pinFile(camAPK, 0, 0, MAX_CAMERA_PIN_SIZE);
if (pf == null) {
Slog.e(TAG, "Failed to pin " + camAPK);
return false;
}
if (DEBUG) {
Slog.i(TAG, "Pinned " + pf.mFilename);
}
mPinnedCameraFiles.add(pf);
// determine the ABI from either ApplicationInfo or Build
String arch = "arm";
if (cameraInfo.primaryCpuAbi != null && VMRuntime.is64BitAbi(cameraInfo.primaryCpuAbi)) {
arch = arch + "64";
} else {
if (VMRuntime.is64BitAbi(Build.SUPPORTED_ABIS[0])) {
arch = arch + "64";
}
}
// get the path to the odex or oat file
String baseCodePath = cameraInfo.getBaseCodePath();
String odex = null;
try {
odex = DexFile.getDexFileOutputPath(baseCodePath, arch);
} catch (IOException ioe) {
}
if (odex == null) {
return true;
}
//not pinning the oat/odex is not a fatal error
pf = pinFile(odex, 0, 0, MAX_CAMERA_PIN_SIZE);
if (pf != null) {
mPinnedCameraFiles.add(pf);
if (DEBUG) {
Slog.i(TAG, "Pinned " + pf.mFilename);
}
}
return true;
}
use of android.content.pm.ApplicationInfo in project dynamic-load-apk by singwhatiwanna.
the class DLUtils method getAppIcon.
public static Drawable getAppIcon(Context context, String apkFilepath) {
PackageManager pm = context.getPackageManager();
PackageInfo pkgInfo = getPackageInfo(context, apkFilepath);
if (pkgInfo == null) {
return null;
}
// Workaround for http://code.google.com/p/android/issues/detail?id=9151
ApplicationInfo appInfo = pkgInfo.applicationInfo;
if (Build.VERSION.SDK_INT >= 8) {
appInfo.sourceDir = apkFilepath;
appInfo.publicSourceDir = apkFilepath;
}
return pm.getApplicationIcon(appInfo);
}
use of android.content.pm.ApplicationInfo in project platform_frameworks_base by android.
the class CompatModePackages method handlePackageAddedLocked.
public void handlePackageAddedLocked(String packageName, boolean updated) {
ApplicationInfo ai = null;
try {
ai = AppGlobals.getPackageManager().getApplicationInfo(packageName, 0, 0);
} catch (RemoteException e) {
}
if (ai == null) {
return;
}
CompatibilityInfo ci = compatibilityInfoForPackageLocked(ai);
final boolean mayCompat = !ci.alwaysSupportsScreen() && !ci.neverSupportsScreen();
if (updated) {
// any current settings for it.
if (!mayCompat && mPackages.containsKey(packageName)) {
mPackages.remove(packageName);
scheduleWrite();
}
}
}
use of android.content.pm.ApplicationInfo in project platform_frameworks_base by android.
the class CompatModePackages method setPackageScreenCompatModeLocked.
public void setPackageScreenCompatModeLocked(String packageName, int mode) {
ApplicationInfo ai = null;
try {
ai = AppGlobals.getPackageManager().getApplicationInfo(packageName, 0, 0);
} catch (RemoteException e) {
}
if (ai == null) {
Slog.w(TAG, "setPackageScreenCompatMode failed: unknown package " + packageName);
return;
}
setPackageScreenCompatModeLocked(ai, mode);
}
Aggregations