public DatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth, boolean yearOptional) { this(context, context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB ? com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert : com.android.internal.R.style.Theme_Dialog_Alert, callBack, year, monthOfYear, dayOfMonth, yearOptional); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static boolean isLargeHeap(Context context) { return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0; }
public static File getPatchTempDirectory(Context context) { ApplicationInfo applicationInfo = context.getApplicationInfo(); if (applicationInfo == null) { // Looks like running on a test Context, so just return without patching. return null; } return new File(applicationInfo.dataDir, ShareConstants.PATCH_TEMP_DIRECTORY_NAME); }
/** * data dir, such as /data/data/tinker.sample.android/tinker * @param context * @return */ public static File getPatchDirectory(Context context) { ApplicationInfo applicationInfo = context.getApplicationInfo(); if (applicationInfo == null) { // Looks like running on a test Context, so just return without patching. return null; } return new File(applicationInfo.dataDir, ShareConstants.PATCH_DIRECTORY_NAME); }
static File getSharedPrefsDir(Context ctxt) { return(new File(new File(ctxt.getApplicationInfo().dataDir), "shared_prefs")); }
/** * Execute command to print all keys and values stored in the shared preferences which match * the optional given prefix */ private void doPrint(PrintStream writer, List<String> args) { String rootPath = mAppContext.getApplicationInfo().dataDir + "/shared_prefs"; String offsetPrefix = args.isEmpty() ? "" : args.get(0); String keyPrefix = (args.size() > 1) ? args.get(1) : ""; printRecursive(writer, rootPath, "", offsetPrefix, keyPrefix); }
private CharSequence getAppLabel() { PackageManager pm = mContext.getPackageManager(); return pm.getApplicationLabel(mContext.getApplicationInfo()); } }
public static List<String> getSharedPreferenceTags(Context context) { ArrayList<String> tags = new ArrayList<String>(); String rootPath = context.getApplicationInfo().dataDir + "/shared_prefs"; File root = new File(rootPath); if (root.exists()) { for (File file : root.listFiles()) { String fileName = file.getName(); if (fileName.endsWith(PREFS_SUFFIX)) { tags.add(fileName.substring(0, fileName.length() - PREFS_SUFFIX.length())); } } } Collections.sort(tags); return tags; }
private static boolean isLayoutDirectionRTL(Context context) { ApplicationInfo applicationInfo = context.getApplicationInfo(); if ((SDK_INT >= JELLY_BEAN_MR1) && (applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0) { int layoutDirection = getLayoutDirection(context); return layoutDirection == View.LAYOUT_DIRECTION_RTL; } return false; }
@NonNull @Override public File getFile(@NonNull Context context, @NonNull String fileName) { File dir; if (Build.VERSION.SDK_INT >= 21) { dir = context.getNoBackupFilesDir(); } else { dir = new File(context.getApplicationInfo().dataDir, "no_backup"); } return new File(dir, fileName); } },
public static List<String> getSharedPreferenceTags(Context context) { ArrayList<String> tags = new ArrayList<>(); String rootPath = context.getApplicationInfo().dataDir + "/shared_prefs"; File root = new File(rootPath); if (root.exists()) { for (File file : root.listFiles()) { String fileName = file.getName(); if (fileName.endsWith(PREFS_SUFFIX)) { tags.add(fileName.substring(0, fileName.length() - PREFS_SUFFIX.length())); } } } Collections.sort(tags); return tags; }
public static synchronized String getChannelOrThrow(final Context context) throws IOException { final ApplicationInfo info = context.getApplicationInfo(); return PackerCommon.readChannel(new File(info.sourceDir)); }
public String getAppLable(Context context) { PackageManager packageManager = context.getPackageManager(); ApplicationInfo applicationInfo = null; try { applicationInfo = packageManager.getApplicationInfo(context.getApplicationInfo().packageName, 0); } catch (final NameNotFoundException e) { } return (String) (applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo) : "Unknown"); }
protected String uniqueKey(String key) { key += mContext.getApplicationInfo().packageName; return Encryption.getMD5ForString(key); }
public static boolean isInMainProcess(Context context) { String mainProcessName = null; ApplicationInfo applicationInfo = context.getApplicationInfo(); if (applicationInfo != null) { mainProcessName = applicationInfo.processName; } if (isNullOrNil(mainProcessName)) { mainProcessName = context.getPackageName(); } String processName = getProcessName(context); if (processName == null || processName.length() == 0) { processName = ""; } return mainProcessName.equals(processName); }
public CacheEntityDao(Context context) { super(new CacheSQLHelper(context)); String encryptionKey = context.getApplicationInfo().packageName; mEncryption = new Encryption(encryptionKey); }
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); }
@Test @Config(minSdk = Build.VERSION_CODES.N) public void setUpApplicationState_shouldCreateStorageDirs_Nplus() throws Exception { bootstrapWrapper.callSetUpApplicationState(); ApplicationInfo applicationInfo = ApplicationProvider.getApplicationContext() .getApplicationInfo(); assertThat(applicationInfo.credentialProtectedDataDir).isNotNull(); assertThat(new File(applicationInfo.credentialProtectedDataDir).isDirectory()).isTrue(); assertThat(applicationInfo.deviceProtectedDataDir).isNotNull(); assertThat(new File(applicationInfo.deviceProtectedDataDir).isDirectory()).isTrue(); }
@Test public void setUpApplicationState_shouldCreateStorageDirs() throws Exception { bootstrapWrapper.callSetUpApplicationState(); ApplicationInfo applicationInfo = ApplicationProvider.getApplicationContext() .getApplicationInfo(); assertThat(applicationInfo.sourceDir).isNotNull(); assertThat(new File(applicationInfo.sourceDir).exists()).isTrue(); assertThat(applicationInfo.publicSourceDir).isNotNull(); assertThat(new File(applicationInfo.publicSourceDir).exists()).isTrue(); assertThat(applicationInfo.dataDir).isNotNull(); assertThat(new File(applicationInfo.dataDir).isDirectory()).isTrue(); }
@Test public void getXml() throws Exception { XmlResourceParser in = packageManager.getXml( ApplicationProvider.getApplicationContext().getPackageName(), R.xml.dialog_preferences, ApplicationProvider.getApplicationContext().getApplicationInfo()); assertThat(in).isNotNull(); }