use of android.os.PersistableBundle in project android_frameworks_base by AOSPA.
the class ShortcutInfo method fixUpIntentExtras.
/**
* Extract extras from {@link #mIntents} and set them to {@link #mIntentPersistableExtrases}
* as {@link PersistableBundle}, and remove extras from the original intents.
*/
private void fixUpIntentExtras() {
if (mIntents == null) {
mIntentPersistableExtrases = null;
return;
}
mIntentPersistableExtrases = new PersistableBundle[mIntents.length];
for (int i = 0; i < mIntents.length; i++) {
final Intent intent = mIntents[i];
final Bundle extras = intent.getExtras();
if (extras == null) {
mIntentPersistableExtrases[i] = null;
} else {
mIntentPersistableExtrases[i] = new PersistableBundle(extras);
intent.replaceExtras((Bundle) null);
}
}
}
use of android.os.PersistableBundle in project android_packages_apps_Settings by LineageOS.
the class RestrictedDashboardFragment method ensurePin.
private void ensurePin() {
if (!mChallengeSucceeded && !mChallengeRequested && mRestrictionsManager.hasRestrictionsProvider()) {
Intent intent = mRestrictionsManager.createLocalApprovalIntent();
if (intent != null) {
mChallengeRequested = true;
mChallengeSucceeded = false;
PersistableBundle request = new PersistableBundle();
request.putString(RestrictionsManager.REQUEST_KEY_MESSAGE, getResources().getString(R.string.restr_pin_enter_admin_pin));
intent.putExtra(RestrictionsManager.EXTRA_REQUEST_BUNDLE, request);
startActivityForResult(intent, REQUEST_PIN_CHALLENGE);
}
}
}
use of android.os.PersistableBundle in project android_packages_apps_Settings by LineageOS.
the class ConditionManager method saveToXml.
private void saveToXml() {
if (DEBUG)
Log.d(TAG, "Writing to " + mXmlFile.toString());
try {
XmlSerializer serializer = Xml.newSerializer();
FileWriter writer = new FileWriter(mXmlFile);
serializer.setOutput(writer);
serializer.startDocument("UTF-8", true);
serializer.startTag("", TAG_CONDITIONS);
final int N = mConditions.size();
for (int i = 0; i < N; i++) {
PersistableBundle bundle = new PersistableBundle();
if (mConditions.get(i).saveState(bundle)) {
serializer.startTag("", TAG_CONDITION);
final String clz = mConditions.get(i).getClass().getSimpleName();
serializer.attribute("", ATTR_CLASS, clz);
bundle.saveToXml(serializer);
serializer.endTag("", TAG_CONDITION);
}
}
serializer.endTag("", TAG_CONDITIONS);
serializer.flush();
writer.close();
} catch (XmlPullParserException | IOException e) {
Log.w(TAG, "Problem writing " + FILE_NAME, e);
}
}
use of android.os.PersistableBundle in project android_packages_apps_Settings by LineageOS.
the class ConditionManager method readFromXml.
private void readFromXml(File xmlFile, ArrayList<Condition> conditions) {
if (DEBUG)
Log.d(TAG, "Reading from " + xmlFile.toString());
try {
XmlPullParser parser = Xml.newPullParser();
FileReader in = new FileReader(xmlFile);
parser.setInput(in);
int state = parser.getEventType();
while (state != XmlPullParser.END_DOCUMENT) {
if (TAG_CONDITION.equals(parser.getName())) {
int depth = parser.getDepth();
String clz = parser.getAttributeValue("", ATTR_CLASS);
if (!clz.startsWith(PKG)) {
clz = PKG + clz;
}
Condition condition = createCondition(Class.forName(clz));
PersistableBundle bundle = PersistableBundle.restoreFromXml(parser);
if (DEBUG)
Log.d(TAG, "Reading " + clz + " -- " + bundle);
if (condition != null) {
condition.restoreState(bundle);
conditions.add(condition);
} else {
Log.e(TAG, "failed to add condition: " + clz);
}
while (parser.getDepth() > depth) {
parser.next();
}
}
state = parser.next();
}
in.close();
} catch (XmlPullParserException | IOException | ClassNotFoundException e) {
Log.w(TAG, "Problem reading " + FILE_NAME, e);
}
}
use of android.os.PersistableBundle in project android_packages_apps_Settings by LineageOS.
the class WifiCallingSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.wifi_calling_settings);
mButtonWfcMode = (ListPreference) findPreference(BUTTON_WFC_MODE);
mButtonWfcMode.setOnPreferenceChangeListener(this);
mButtonWfcRoamingMode = (ListPreference) findPreference(BUTTON_WFC_ROAMING_MODE);
mButtonWfcRoamingMode.setOnPreferenceChangeListener(this);
mUpdateAddress = (Preference) findPreference(PREFERENCE_EMERGENCY_ADDRESS);
mUpdateAddress.setOnPreferenceClickListener(mUpdateAddressListener);
mIntentFilter = new IntentFilter();
mIntentFilter.addAction(ImsManager.ACTION_IMS_REGISTRATION_ERROR);
CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
boolean isWifiOnlySupported = true;
if (configManager != null) {
PersistableBundle b = configManager.getConfig();
if (b != null) {
mEditableWfcMode = b.getBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_MODE_BOOL);
mEditableWfcRoamingMode = b.getBoolean(CarrierConfigManager.KEY_EDITABLE_WFC_ROAMING_MODE_BOOL);
isWifiOnlySupported = b.getBoolean(CarrierConfigManager.KEY_CARRIER_WFC_SUPPORTS_WIFI_ONLY_BOOL, true);
}
}
if (!isWifiOnlySupported) {
mButtonWfcMode.setEntries(R.array.wifi_calling_mode_choices_without_wifi_only);
mButtonWfcMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only);
mButtonWfcRoamingMode.setEntries(R.array.wifi_calling_mode_choices_v2_without_wifi_only);
mButtonWfcRoamingMode.setEntryValues(R.array.wifi_calling_mode_values_without_wifi_only);
}
}
Aggregations