List of usage examples for android.content Context getApplicationInfo
public abstract ApplicationInfo getApplicationInfo();
From source file:com.amazon.cordova.plugin.ADMMessageHandler.java
private static String getAppName(Context context) { CharSequence appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo()); return (String) appName; }
From source file:Main.java
public static boolean isLocalBuild(Context context) { boolean localVersionCode = false; try {//www . j av a 2 s . c o m PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); localVersionCode = packageInfo.versionCode == 1; } catch (PackageManager.NameNotFoundException ignored) { } return 0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) && localVersionCode; }
From source file:pl.lawiusz.lockscreenvisualizerxposed.SettingsActivity.java
@SuppressLint("SetWorldReadable") private static void makePrefsReadable(Context context) { File prefsDir = new File(context.getApplicationInfo().dataDir, "shared_prefs"); File prefsFile = new File(prefsDir, PREFS_PUBLIC + ".xml"); if (prefsFile.exists()) { if (!prefsFile.setReadable(true, false)) { Log.e(TAG, "Error accessing shared preferences!"); } else if (BuildConfig.DEBUG) { Log.d(TAG, "Successfully chmoded prefs!"); }/* w w w.j ava 2 s. c om*/ } else Log.e(TAG, "No shared preferences file!"); }
From source file:com.squareup.picasso3.Utils.java
static int calculateMemoryCacheSize(Context context) { ActivityManager am = ContextCompat.getSystemService(context, ActivityManager.class); boolean largeHeap = (context.getApplicationInfo().flags & FLAG_LARGE_HEAP) != 0; int memoryClass = largeHeap ? am.getLargeMemoryClass() : am.getMemoryClass(); // Target ~15% of the available heap. return (int) (1024L * 1024L * memoryClass / 7); }
From source file:com.raspberry.library.util.AppUtils.java
/** * ??debug?/*from w w w . j a va2 s .c om*/ * * @param context * @return */ public static boolean isApkInDebug(Context context) { try { ApplicationInfo info = context.getApplicationInfo(); return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (Exception e) { return false; } }
From source file:Main.java
public static int isPackageMalicious(Context context, PackageInfo packageInfo) { // If the package being checked is this one, it's not malicious if (packageInfo.packageName.equals(context.getPackageName())) { return MALICIOUS_NOT; }/* w w w . j av a2 s .c om*/ // If the package being checked shares a UID with Superuser, it's // probably malicious if (packageInfo.applicationInfo.uid == context.getApplicationInfo().uid) { return MALICIOUS_UID; } // Finally we check for any permissions that other apps should not have. if (packageInfo.requestedPermissions != null) { String[] bannedPermissions = new String[] { "com.noshufou.android.su.RESPOND", "com.noshufou.android.su.provider.WRITE" }; for (String s : packageInfo.requestedPermissions) { for (int i = 0; i < 2; i++) { if (s.equals(bannedPermissions[i]) && context.getPackageManager().checkPermission(bannedPermissions[i], packageInfo.packageName) == PackageManager.PERMISSION_GRANTED) { return i + 2; } } } } return MALICIOUS_NOT; }
From source file:Main.java
@SuppressWarnings("IncompatibleBitwiseMaskOperation") public static boolean isFloatWindowOpAllowed(Context context) { if (Build.VERSION.SDK_INT >= 19) { // 19, 4.4, KITKAT final AppOpsManager manager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE); final int mode = manager.checkOp(AppOpsManager.OPSTR_SYSTEM_ALERT_WINDOW, Binder.getCallingUid(), context.getPackageName()); return AppOpsManager.MODE_ALLOWED == mode; } else {/*from ww w . j a v a 2 s . c o m*/ return (context.getApplicationInfo().flags & 1 << 27) == 1; } }
From source file:cn.whereyougo.framework.utils.PackageManagerUtil.java
/** * ?// w ww .j a va2 s. co m * * @param context * @param processName * ????+?? * @return */ public static boolean isMainProcess(Context context, String processName) { final String mainProcess = context.getApplicationInfo().processName; return mainProcess.equals(processName); }
From source file:com.google.android.gms.common.zze.java
public static String zzao(Context context) { Object obj = context.getApplicationInfo().name; if (!TextUtils.isEmpty(obj)) { return obj; }//from ww w . j av a 2 s . c om ApplicationInfo applicationInfo; String packageName = context.getPackageName(); PackageManager packageManager = context.getApplicationContext().getPackageManager(); try { applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), GOOGLE_PLAY_SERVICES_VERSION_CODE); } catch (NameNotFoundException e) { applicationInfo = null; } return applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo).toString() : packageName; }
From source file:com.vinexs.tool.Utility.java
public static String getAppName(Context context) { int stringId = context.getApplicationInfo().labelRes; if (stringId == 0) { return ""; }//from w ww.jav a2s . c om return context.getString(stringId); }