use of android.content.pm.PackageManager in project weiciyuan by qii.
the class CrashManagerConstants method loadFromContext.
public static void loadFromContext(Context context) {
CrashManagerConstants.ANDROID_VERSION = android.os.Build.VERSION.RELEASE;
CrashManagerConstants.PHONE_MODEL = android.os.Build.MODEL;
CrashManagerConstants.PHONE_MANUFACTURER = android.os.Build.MANUFACTURER;
PackageManager packageManager = context.getPackageManager();
try {
PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
CrashManagerConstants.APP_VERSION = "" + packageInfo.versionCode;
CrashManagerConstants.APP_PACKAGE = packageInfo.packageName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class OpenExternalDirectoryActivity method getAppLabel.
private static String getAppLabel(Activity activity) {
final String packageName = activity.getCallingPackage();
final PackageManager pm = activity.getPackageManager();
try {
return pm.getApplicationLabel(pm.getApplicationInfo(packageName, 0)).toString();
} catch (NameNotFoundException e) {
logInvalidScopedAccessRequest(activity, SCOPED_DIRECTORY_ACCESS_ERROR);
Log.w(TAG, "Could not get label for package " + packageName);
return null;
}
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class FilesAppPerfTest method killProviders.
private void killProviders() throws Exception {
final Context context = getInstrumentation().getContext();
final PackageManager pm = context.getPackageManager();
final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
final List<ResolveInfo> providers = pm.queryIntentContentProviders(intent, 0);
for (ResolveInfo info : providers) {
final String packageName = info.providerInfo.packageName;
am.killBackgroundProcesses(packageName);
}
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class IconUtils method loadPackageIcon.
public static Drawable loadPackageIcon(Context context, String authority, int icon) {
if (icon != 0) {
if (authority != null) {
final PackageManager pm = context.getPackageManager();
final ProviderInfo info = pm.resolveContentProvider(authority, 0);
if (info != null) {
return pm.getDrawable(info.packageName, icon, info.applicationInfo);
}
} else {
return context.getDrawable(icon);
}
}
return null;
}
use of android.content.pm.PackageManager in project platform_frameworks_base by android.
the class AccessPoint method getSavedNetworkSummary.
public String getSavedNetworkSummary() {
WifiConfiguration config = mConfig;
if (config != null) {
PackageManager pm = mContext.getPackageManager();
String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
int userId = UserHandle.getUserId(config.creatorUid);
ApplicationInfo appInfo = null;
if (config.creatorName != null && config.creatorName.equals(systemName)) {
appInfo = mContext.getApplicationInfo();
} else {
try {
IPackageManager ipm = AppGlobals.getPackageManager();
appInfo = ipm.getApplicationInfo(config.creatorName, 0, /* flags */
userId);
} catch (RemoteException rex) {
}
}
if (appInfo != null && !appInfo.packageName.equals(mContext.getString(R.string.settings_package)) && !appInfo.packageName.equals(mContext.getString(R.string.certinstaller_package))) {
return mContext.getString(R.string.saved_network, appInfo.loadLabel(pm));
}
}
return "";
}
Aggregations