private void loadData(Bundle savedInstanceState, Uri appUri) { mAppSettings = new ApiDataAccessObject(this).getApiAppSettings(appUri); // get application name and icon from package manager String appName; Drawable appIcon = null; PackageManager pm = getApplicationContext().getPackageManager(); try { ApplicationInfo ai = pm.getApplicationInfo(mAppSettings.getPackageName(), 0); appName = (String) pm.getApplicationLabel(ai); appIcon = pm.getApplicationIcon(ai); } catch (PackageManager.NameNotFoundException e) { // fallback appName = mAppSettings.getPackageName(); } mAppNameView.setText(appName); mAppIconView.setImageDrawable(appIcon); Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build(); Log.d(Constants.TAG, "accountsUri: " + accountsUri); Uri allowedKeysUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ALLOWED_KEYS).build(); Log.d(Constants.TAG, "allowedKeysUri: " + allowedKeysUri); startListFragments(savedInstanceState, accountsUri, allowedKeysUri); }
private void showAdvancedInfo() { String certificate = null; // advanced info: package certificate SHA-256 try { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(mAppSettings.getPackageCertificate()); byte[] digest = md.digest(); certificate = new String(Hex.encode(digest)); } catch (NoSuchAlgorithmException e) { Log.e(Constants.TAG, "Should not happen!", e); } AdvancedAppSettingsDialogFragment dialogFragment = AdvancedAppSettingsDialogFragment.newInstance(mAppSettings.getPackageName(), certificate); dialogFragment.show(getSupportFragmentManager(), "advancedDialog"); }
private void startApp() { Intent i; PackageManager manager = getPackageManager(); try { i = manager.getLaunchIntentForPackage(mAppSettings.getPackageName()); if (i == null) throw new PackageManager.NameNotFoundException(); // start like the Android launcher would do i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); i.addCategory(Intent.CATEGORY_LAUNCHER); startActivity(i); } catch (PackageManager.NameNotFoundException e) { Log.e(Constants.TAG, "startApp", e); } }