use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.
the class Pm method getResources.
private Resources getResources(PackageItemInfo pii) {
Resources res = mResourceCache.get(pii.packageName);
if (res != null)
return res;
try {
ApplicationInfo ai = mPm.getApplicationInfo(pii.packageName, 0, 0);
AssetManager am = new AssetManager();
am.addAssetPath(ai.publicSourceDir);
res = new Resources(am, null, null);
mResourceCache.put(pii.packageName, res);
return res;
} catch (RemoteException e) {
System.err.println(e.toString());
System.err.println(PM_NOT_RUNNING_ERR);
return null;
}
}
use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.
the class DeviceAdminInfo method loadDescription.
/**
* Load user-visible description associated with this device admin.
*
* @param pm Supply a PackageManager used to load the device admin's
* resources.
*/
public CharSequence loadDescription(PackageManager pm) throws NotFoundException {
if (mReceiver.activityInfo.descriptionRes != 0) {
String packageName = mReceiver.resolvePackageName;
ApplicationInfo applicationInfo = null;
if (packageName == null) {
packageName = mReceiver.activityInfo.packageName;
applicationInfo = mReceiver.activityInfo.applicationInfo;
}
return pm.getText(packageName, mReceiver.activityInfo.descriptionRes, applicationInfo);
}
throw new NotFoundException();
}
use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.
the class BackupAgent method fullBackupFile.
/**
* Write an entire file as part of a full-backup operation. The file's contents
* will be delivered to the backup destination along with the metadata necessary
* to place it with the proper location and permissions on the device where the
* data is restored.
*
* @param file The file to be backed up. The file must exist and be readable by
* the caller.
* @param output The destination to which the backed-up file data will be sent.
*/
public final void fullBackupFile(File file, FullBackupDataOutput output) {
// Look up where all of our various well-defined dir trees live on this device
String mainDir;
String filesDir;
String dbDir;
String spDir;
String cacheDir;
String libDir;
String efDir = null;
String filePath;
ApplicationInfo appInfo = getApplicationInfo();
try {
mainDir = new File(appInfo.dataDir).getCanonicalPath();
filesDir = getFilesDir().getCanonicalPath();
dbDir = getDatabasePath("foo").getParentFile().getCanonicalPath();
spDir = getSharedPrefsFile("foo").getParentFile().getCanonicalPath();
cacheDir = getCacheDir().getCanonicalPath();
libDir = (appInfo.nativeLibraryDir == null) ? null : new File(appInfo.nativeLibraryDir).getCanonicalPath();
// may or may not have external files access to attempt backup/restore there
if (Process.myUid() != Process.SYSTEM_UID) {
File efLocation = getExternalFilesDir(null);
if (efLocation != null) {
efDir = efLocation.getCanonicalPath();
}
}
// Now figure out which well-defined tree the file is placed in, working from
// most to least specific. We also specifically exclude the lib and cache dirs.
filePath = file.getCanonicalPath();
} catch (IOException e) {
Log.w(TAG, "Unable to obtain canonical paths");
return;
}
if (filePath.startsWith(cacheDir) || filePath.startsWith(libDir)) {
Log.w(TAG, "lib and cache files are not backed up");
return;
}
final String domain;
String rootpath = null;
if (filePath.startsWith(dbDir)) {
domain = FullBackup.DATABASE_TREE_TOKEN;
rootpath = dbDir;
} else if (filePath.startsWith(spDir)) {
domain = FullBackup.SHAREDPREFS_TREE_TOKEN;
rootpath = spDir;
} else if (filePath.startsWith(filesDir)) {
domain = FullBackup.DATA_TREE_TOKEN;
rootpath = filesDir;
} else if (filePath.startsWith(mainDir)) {
domain = FullBackup.ROOT_TREE_TOKEN;
rootpath = mainDir;
} else if ((efDir != null) && filePath.startsWith(efDir)) {
domain = FullBackup.MANAGED_EXTERNAL_TREE_TOKEN;
rootpath = efDir;
} else {
Log.w(TAG, "File " + filePath + " is in an unsupported location; skipping");
return;
}
// And now that we know where it lives, semantically, back it up appropriately
Log.i(TAG, "backupFile() of " + filePath + " => domain=" + domain + " rootpath=" + rootpath);
FullBackup.backupToTar(getPackageName(), domain, null, rootpath, filePath, output.getData());
}
use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.
the class WallpaperInfo method loadAuthor.
/**
* Return a string indicating the author(s) of this wallpaper.
*/
public CharSequence loadAuthor(PackageManager pm) throws NotFoundException {
if (mAuthorResource <= 0)
throw new NotFoundException();
String packageName = mService.resolvePackageName;
ApplicationInfo applicationInfo = null;
if (packageName == null) {
packageName = mService.serviceInfo.packageName;
applicationInfo = mService.serviceInfo.applicationInfo;
}
return pm.getText(packageName, mAuthorResource, applicationInfo);
}
use of android.content.pm.ApplicationInfo in project android_frameworks_base by ParanoidAndroid.
the class BatteryStats method dumpCheckinLocked.
@SuppressWarnings("unused")
public void dumpCheckinLocked(PrintWriter pw, String[] args, List<ApplicationInfo> apps) {
prepareForDumpLocked();
boolean isUnpluggedOnly = false;
for (String arg : args) {
if ("-u".equals(arg)) {
if (LOCAL_LOGV)
Log.v("BatteryStats", "Dumping unplugged data");
isUnpluggedOnly = true;
}
}
if (apps != null) {
SparseArray<ArrayList<String>> uids = new SparseArray<ArrayList<String>>();
for (int i = 0; i < apps.size(); i++) {
ApplicationInfo ai = apps.get(i);
ArrayList<String> pkgs = uids.get(ai.uid);
if (pkgs == null) {
pkgs = new ArrayList<String>();
uids.put(ai.uid, pkgs);
}
pkgs.add(ai.packageName);
}
SparseArray<? extends Uid> uidStats = getUidStats();
final int NU = uidStats.size();
String[] lineArgs = new String[2];
for (int i = 0; i < NU; i++) {
int uid = uidStats.keyAt(i);
ArrayList<String> pkgs = uids.get(uid);
if (pkgs != null) {
for (int j = 0; j < pkgs.size(); j++) {
lineArgs[0] = Integer.toString(uid);
lineArgs[1] = pkgs.get(j);
dumpLine(pw, 0, /* uid */
"i", /* category */
UID_DATA, (Object[]) lineArgs);
}
}
}
}
if (isUnpluggedOnly) {
dumpCheckinLocked(pw, STATS_SINCE_UNPLUGGED, -1);
} else {
dumpCheckinLocked(pw, STATS_SINCE_CHARGED, -1);
dumpCheckinLocked(pw, STATS_SINCE_UNPLUGGED, -1);
}
}
Aggregations