use of android.os.PersistableBundle in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DeviceInfoSettings method onPreferenceTreeClick.
@Override
public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey().equals(KEY_FIRMWARE_VERSION) || preference.getKey().equals(KEY_MOD_VERSION)) {
System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1);
mHits[mHits.length - 1] = SystemClock.uptimeMillis();
if (mHits[0] >= (SystemClock.uptimeMillis() - 500)) {
if (mUm.hasUserRestriction(UserManager.DISALLOW_FUN)) {
if (mFunDisallowedAdmin != null && !mFunDisallowedBySystem) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), mFunDisallowedAdmin);
}
Log.d(LOG_TAG, "Sorry, no fun for you!");
return false;
}
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.putExtra("is_lineage", preference.getKey().equals(KEY_MOD_VERSION));
intent.setClassName("android", com.android.internal.app.PlatLogoActivity.class.getName());
try {
startActivity(intent);
} catch (Exception e) {
Log.e(LOG_TAG, "Unable to start activity " + intent.toString());
}
}
} else if (preference.getKey().equals(KEY_BUILD_NUMBER)) {
// Don't enable developer options for secondary users.
if (!mUm.isAdminUser())
return true;
// Don't enable developer options until device has been provisioned
if (!Utils.isDeviceProvisioned(getActivity())) {
return true;
}
if (mUm.hasUserRestriction(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
if (mDebuggingFeaturesDisallowedAdmin != null && !mDebuggingFeaturesDisallowedBySystem) {
RestrictedLockUtils.sendShowAdminSupportDetailsIntent(getActivity(), mDebuggingFeaturesDisallowedAdmin);
}
return true;
}
if (mDevHitCountdown > 0) {
mDevHitCountdown--;
if (mDevHitCountdown == 0) {
getActivity().getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE).edit().putBoolean(DevelopmentSettings.PREF_SHOW, true).apply();
if (mDevHitToast != null) {
mDevHitToast.cancel();
}
mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_on_cm, Toast.LENGTH_LONG);
mDevHitToast.show();
// This is good time to index the Developer Options
Index.getInstance(getActivity().getApplicationContext()).updateFromClassNameResource(DevelopmentSettings.class.getName(), true, true);
} else if (mDevHitCountdown > 0 && mDevHitCountdown < (TAPS_TO_BE_A_DEVELOPER - 2)) {
if (mDevHitToast != null) {
mDevHitToast.cancel();
}
mDevHitToast = Toast.makeText(getActivity(), getResources().getQuantityString(R.plurals.show_dev_countdown_cm, mDevHitCountdown, mDevHitCountdown), Toast.LENGTH_SHORT);
mDevHitToast.show();
}
} else if (mDevHitCountdown < 0) {
if (mDevHitToast != null) {
mDevHitToast.cancel();
}
mDevHitToast = Toast.makeText(getActivity(), R.string.show_dev_already_cm, Toast.LENGTH_LONG);
mDevHitToast.show();
}
} else if (preference.getKey().equals(KEY_SECURITY_PATCH)) {
if (getPackageManager().queryIntentActivities(preference.getIntent(), 0).isEmpty()) {
// Don't send out the intent to stop crash
Log.w(LOG_TAG, "Stop click action on " + KEY_SECURITY_PATCH + ": " + "queryIntentActivities() returns empty");
return true;
}
} else if (preference.getKey().equals(KEY_BUILD_TYPE)) {
sendFeedback();
} else if (preference.getKey().equals(KEY_DEVICE_FEEDBACK)) {
sendFeedback();
} else if (preference.getKey().equals(KEY_SYSTEM_UPDATE_SETTINGS)) {
CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
PersistableBundle b = configManager.getConfig();
if (b != null && b.getBoolean(CarrierConfigManager.KEY_CI_ACTION_ON_SYS_UPDATE_BOOL)) {
ciActionOnSysUpdate(b);
}
} else if (preference.getKey().equals(KEY_KERNEL_VERSION)) {
setStringSummary(KEY_KERNEL_VERSION, getKernelVersion());
return true;
}
return super.onPreferenceTreeClick(preference);
}
use of android.os.PersistableBundle in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiCallingSettings method getCarrierActivityIntent.
/*
* Get the Intent to launch carrier emergency address management activity.
* Return null when no activity found.
*/
private static Intent getCarrierActivityIntent(Context context) {
// Retrive component name from carrirt config
CarrierConfigManager configManager = context.getSystemService(CarrierConfigManager.class);
if (configManager == null)
return null;
PersistableBundle bundle = configManager.getConfig();
if (bundle == null)
return null;
String carrierApp = bundle.getString(CarrierConfigManager.KEY_WFC_EMERGENCY_ADDRESS_CARRIER_APP_STRING);
if (TextUtils.isEmpty(carrierApp))
return null;
ComponentName componentName = ComponentName.unflattenFromString(carrierApp);
if (componentName == null)
return null;
// Build and return intent
Intent intent = new Intent();
intent.setComponent(componentName);
return intent;
}
use of android.os.PersistableBundle in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SimStatus method updatePreference.
private void updatePreference() {
if (mPhone.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA) {
// only show area info when SIM country is Brazil
if (COUNTRY_ABBREVIATION_BRAZIL.equals(mTelephonyManager.getSimCountryIso(mSir.getSubscriptionId()))) {
mShowLatestAreaInfo = true;
}
}
PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSir.getSubscriptionId());
mShowICCID = carrierConfig.getBoolean(CarrierConfigManager.KEY_SHOW_ICCID_IN_SIM_STATUS_BOOL);
// If formattedNumber is null or empty, it'll display as "Unknown".
setSummaryText(KEY_PHONE_NUMBER, DeviceInfoUtils.getFormattedPhoneNumber(getContext(), mSir));
if (!mShowICCID) {
removePreferenceFromScreen(KEY_ICCID);
} else {
// Get ICCID, which is SIM serial number
String iccid = mTelephonyManager.getSimSerialNumber(mSir.getSubscriptionId());
setSummaryText(KEY_ICCID, iccid);
}
if (!mShowLatestAreaInfo) {
removePreferenceFromScreen(KEY_LATEST_AREA_INFO);
}
}
use of android.os.PersistableBundle in project android_frameworks_base by ResurrectionRemix.
the class ShortcutManagerTestUtils method makePersistableBundle.
public static PersistableBundle makePersistableBundle(Object... keysAndValues) {
assertTrue((keysAndValues.length % 2) == 0);
if (keysAndValues.length == 0) {
return null;
}
final PersistableBundle ret = new PersistableBundle();
for (int i = keysAndValues.length - 2; i >= 0; i -= 2) {
final String key = keysAndValues[i].toString();
final Object value = keysAndValues[i + 1];
if (value == null) {
ret.putString(key, null);
} else if (value instanceof Integer) {
ret.putInt(key, (Integer) value);
} else if (value instanceof String) {
ret.putString(key, (String) value);
} else if (value instanceof PersistableBundle) {
ret.putPersistableBundle(key, (PersistableBundle) value);
} else {
fail("Type not supported yet: " + value.getClass().getName());
}
}
return ret;
}
use of android.os.PersistableBundle in project android_frameworks_base by ResurrectionRemix.
the class ShortcutManagerTest2 method testShortcutInfoSaveAndLoad_forBackup.
public void testShortcutInfoSaveAndLoad_forBackup() {
setCaller(CALLING_PACKAGE_1, USER_0);
final Icon bmp32x32 = Icon.createWithBitmap(BitmapFactory.decodeResource(getTestContext().getResources(), R.drawable.black_32x32));
PersistableBundle pb = new PersistableBundle();
pb.putInt("k", 1);
ShortcutInfo sorig = new ShortcutInfo.Builder(mClientContext).setId("id").setActivity(new ComponentName(mClientContext, ShortcutActivity2.class)).setIcon(bmp32x32).setTitle("title").setText("text").setDisabledMessage("dismes").setCategories(set(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION, "xyz")).setIntent(makeIntent("action", ShortcutActivity.class, "key", "val")).setRank(123).setExtras(pb).build();
ShortcutInfo sorig2 = new ShortcutInfo.Builder(mClientContext).setId("id2").setTitle("x").setActivity(new ComponentName(mClientContext, ShortcutActivity2.class)).setIntent(makeIntent("action", ShortcutActivity.class, "key", "val")).setRank(456).build();
mManager.addDynamicShortcuts(list(sorig, sorig2));
// Dynamic shortcuts won't be backed up, so we need to pin it.
setCaller(LAUNCHER_1, USER_0);
mLauncherApps.pinShortcuts(CALLING_PACKAGE_1, list("id", "id2"), HANDLE_USER_0);
// Do backup & restore.
backupAndRestore();
// Load user-0.
mService.handleUnlockUser(USER_0);
ShortcutInfo si;
si = mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "id", USER_0);
assertEquals(CALLING_PACKAGE_1, si.getPackage());
assertEquals("id", si.getId());
assertEquals(ShortcutActivity2.class.getName(), si.getActivity().getClassName());
assertEquals(null, si.getIcon());
assertEquals("title", si.getTitle());
assertEquals("text", si.getText());
assertEquals("dismes", si.getDisabledMessage());
assertEquals(set(ShortcutInfo.SHORTCUT_CATEGORY_CONVERSATION, "xyz"), si.getCategories());
assertEquals("action", si.getIntent().getAction());
assertEquals("val", si.getIntent().getStringExtra("key"));
assertEquals(0, si.getRank());
assertEquals(1, si.getExtras().getInt("k"));
assertEquals(ShortcutInfo.FLAG_PINNED | ShortcutInfo.FLAG_STRINGS_RESOLVED, si.getFlags());
// No icon.
assertNull(si.getBitmapPath());
assertEquals(0, si.getIconResourceId());
// Note when restored from backup, it's no longer dynamic, so shouldn't have a rank.
si = mService.getPackageShortcutForTest(CALLING_PACKAGE_1, "id2", USER_0);
assertEquals(0, si.getRank());
}
Aggregations