Search in sources :

Example 66 with PersistableBundle

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);
        }
    }
}
Also used : PersistableBundle(android.os.PersistableBundle) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent)

Example 67 with PersistableBundle

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);
        }
    }
}
Also used : PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent)

Example 68 with PersistableBundle

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);
    }
}
Also used : PersistableBundle(android.os.PersistableBundle) FileWriter(java.io.FileWriter) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) XmlSerializer(org.xmlpull.v1.XmlSerializer)

Example 69 with PersistableBundle

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);
    }
}
Also used : PersistableBundle(android.os.PersistableBundle) XmlPullParser(org.xmlpull.v1.XmlPullParser) FileReader(java.io.FileReader) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException)

Example 70 with PersistableBundle

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);
    }
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) IntentFilter(android.content.IntentFilter) PersistableBundle(android.os.PersistableBundle)

Aggregations

PersistableBundle (android.os.PersistableBundle)321 CarrierConfigManager (android.telephony.CarrierConfigManager)87 ComponentName (android.content.ComponentName)67 Intent (android.content.Intent)63 ShortcutInfo (android.content.pm.ShortcutInfo)48 Test (org.junit.Test)35 Bundle (android.os.Bundle)28 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)25 IOException (java.io.IOException)21 Icon (android.graphics.drawable.Icon)17 JobInfo (android.app.job.JobInfo)15 IntentFilter (android.content.IntentFilter)15 Account (android.accounts.Account)14 Activity (android.app.Activity)12 TelephonyManager (android.telephony.TelephonyManager)12 SmallTest (android.test.suitebuilder.annotation.SmallTest)12 XmlPullParser (org.xmlpull.v1.XmlPullParser)12 Before (org.junit.Before)11 PendingIntent (android.app.PendingIntent)9 PackageManager (android.content.pm.PackageManager)9