Search in sources :

Example 16 with PersistableBundle

use of android.os.PersistableBundle in project android_frameworks_base by ResurrectionRemix.

the class RestrictionsReceiver method onReceive.

/**
     * Intercept standard Restrictions Provider broadcasts.  Implementations
     * should not override this method; it is better to implement the
     * convenience callbacks for each action.
     */
@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    if (RestrictionsManager.ACTION_REQUEST_PERMISSION.equals(action)) {
        String packageName = intent.getStringExtra(RestrictionsManager.EXTRA_PACKAGE_NAME);
        String requestType = intent.getStringExtra(RestrictionsManager.EXTRA_REQUEST_TYPE);
        String requestId = intent.getStringExtra(RestrictionsManager.EXTRA_REQUEST_ID);
        PersistableBundle request = (PersistableBundle) intent.getParcelableExtra(RestrictionsManager.EXTRA_REQUEST_BUNDLE);
        onRequestPermission(context, packageName, requestType, requestId, request);
    }
}
Also used : PersistableBundle(android.os.PersistableBundle)

Example 17 with PersistableBundle

use of android.os.PersistableBundle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ApnSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    final Activity activity = getActivity();
    final int subId = activity.getIntent().getIntExtra(SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    fillOperatorIccidset();
    Log.d(TAG, "onCreate: subId = " + subId);
    mMobileStateFilter = new IntentFilter(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
    setIfOnlyAvailableForAdmins(true);
    mSubscriptionInfo = SubscriptionManager.from(activity).getActiveSubscriptionInfo(subId);
    mUiccController = UiccController.getInstance();
    CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
    PersistableBundle b = configManager.getConfig();
    mHideImsApn = b.getBoolean(CarrierConfigManager.KEY_HIDE_IMS_APN_BOOL);
    mAllowAddingApns = b.getBoolean(CarrierConfigManager.KEY_ALLOW_ADDING_APNS_BOOL);
    mUserManager = UserManager.get(activity);
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) IntentFilter(android.content.IntentFilter) PersistableBundle(android.os.PersistableBundle) Activity(android.app.Activity)

Example 18 with PersistableBundle

use of android.os.PersistableBundle in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ApnEditor method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.apn_editor);
    sNotSet = getResources().getString(R.string.apn_not_set);
    mName = (EditTextPreference) findPreference("apn_name");
    mApn = (EditTextPreference) findPreference("apn_apn");
    mProxy = (EditTextPreference) findPreference("apn_http_proxy");
    mPort = (EditTextPreference) findPreference("apn_http_port");
    mUser = (EditTextPreference) findPreference("apn_user");
    mServer = (EditTextPreference) findPreference("apn_server");
    mPassword = (EditTextPreference) findPreference("apn_password");
    mMmsProxy = (EditTextPreference) findPreference("apn_mms_proxy");
    mMmsPort = (EditTextPreference) findPreference("apn_mms_port");
    mMmsc = (EditTextPreference) findPreference("apn_mmsc");
    mMcc = (EditTextPreference) findPreference("apn_mcc");
    mMnc = (EditTextPreference) findPreference("apn_mnc");
    mApnType = (EditTextPreference) findPreference("apn_type");
    mAuthType = (ListPreference) findPreference(KEY_AUTH_TYPE);
    mAuthType.setOnPreferenceChangeListener(this);
    mProtocol = (ListPreference) findPreference(KEY_PROTOCOL);
    mProtocol.setOnPreferenceChangeListener(this);
    mRoamingProtocol = (ListPreference) findPreference(KEY_ROAMING_PROTOCOL);
    mRoamingProtocol.setOnPreferenceChangeListener(this);
    mCarrierEnabled = (SwitchPreference) findPreference(KEY_CARRIER_ENABLED);
    mBearerMulti = (MultiSelectListPreference) findPreference(KEY_BEARER_MULTI);
    mBearerMulti.setOnPreferenceChangeListener(this);
    mMvnoType = (ListPreference) findPreference(KEY_MVNO_TYPE);
    mMvnoType.setOnPreferenceChangeListener(this);
    mMvnoMatchData = (EditTextPreference) findPreference("mvno_match_data");
    mRes = getResources();
    final Intent intent = getIntent();
    final String action = intent.getAction();
    mSubId = intent.getIntExtra(ApnSettings.SUB_ID, SubscriptionManager.INVALID_SUBSCRIPTION_ID);
    mDisableEditor = intent.getBooleanExtra("DISABLE_EDITOR", false);
    mFirstTime = icicle == null;
    mReadOnlyApn = false;
    mReadOnlyApnTypes = null;
    mReadOnlyApnFields = null;
    if (action.equals(Intent.ACTION_EDIT)) {
        Uri uri = intent.getData();
        if (!uri.isPathPrefixMatch(Telephony.Carriers.CONTENT_URI)) {
            Log.e(TAG, "Edit request not for carrier table. Uri: " + uri);
            finish();
            return;
        }
        CarrierConfigManager configManager = (CarrierConfigManager) getSystemService(Context.CARRIER_CONFIG_SERVICE);
        if (configManager != null) {
            PersistableBundle b = configManager.getConfig();
            if (b != null) {
                mReadOnlyApnTypes = b.getStringArray(CarrierConfigManager.KEY_READ_ONLY_APN_TYPES_STRING_ARRAY);
                mReadOnlyApnFields = b.getStringArray(CarrierConfigManager.KEY_READ_ONLY_APN_FIELDS_STRING_ARRAY);
            }
        }
        mUri = uri;
    } else if (action.equals(Intent.ACTION_INSERT)) {
        if (mFirstTime || icicle.getInt(SAVED_POS) == 0) {
            Uri uri = intent.getData();
            if (!uri.isPathPrefixMatch(Telephony.Carriers.CONTENT_URI)) {
                Log.e(TAG, "Insert request not for carrier table. Uri: " + uri);
                finish();
                return;
            }
            mUri = getContentResolver().insert(uri, new ContentValues());
        } else {
            mUri = ContentUris.withAppendedId(Telephony.Carriers.CONTENT_URI, icicle.getInt(SAVED_POS));
        }
        mNewApn = true;
        mMvnoTypeStr = intent.getStringExtra(ApnSettings.MVNO_TYPE);
        mMvnoMatchDataStr = intent.getStringExtra(ApnSettings.MVNO_MATCH_DATA);
        // original activity if they requested a result.
        if (mUri == null) {
            Log.w(TAG, "Failed to insert new telephony provider into " + getIntent().getData());
            finish();
            return;
        }
        // The new entry was created, so assume all will end well and
        // set the result to be returned.
        setResult(RESULT_OK, (new Intent()).setAction(mUri.toString()));
    } else {
        finish();
        return;
    }
    mCursor = getActivity().managedQuery(mUri, sProjection, null, null);
    mCursor.moveToFirst();
    mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
    Log.d(TAG, "onCreate: EDITED " + mCursor.getInt(EDITED_INDEX));
    // if it's not a USER_EDITED apn, check if it's read-only
    if (mCursor.getInt(EDITED_INDEX) != Telephony.Carriers.USER_EDITED && apnTypesMatch(mReadOnlyApnTypes, mCursor.getString(TYPE_INDEX))) {
        Log.d(TAG, "onCreate: apnTypesMatch; read-only APN");
        mReadOnlyApn = true;
        disableAllFields();
    } else if (!ArrayUtils.isEmpty(mReadOnlyApnFields)) {
        disableFields(mReadOnlyApnFields);
    }
    for (int i = 0; i < getPreferenceScreen().getPreferenceCount(); i++) {
        getPreferenceScreen().getPreference(i).setOnPreferenceChangeListener(this);
    }
    fillUi();
}
Also used : CarrierConfigManager(android.telephony.CarrierConfigManager) ContentValues(android.content.ContentValues) PersistableBundle(android.os.PersistableBundle) Intent(android.content.Intent) Uri(android.net.Uri)

Example 19 with PersistableBundle

use of android.os.PersistableBundle in project cw-omnibus by commonsguy.

the class DemoJobService method onStartJob.

@Override
public boolean onStartJob(JobParameters params) {
    PersistableBundle pb = params.getExtras();
    if (pb.getBoolean(MainActivity.KEY_DOWNLOAD, false)) {
        job = new DownloadThread(params);
        job.start();
        return (true);
    }
    Log.d(getClass().getSimpleName(), "job invoked");
    return (false);
}
Also used : PersistableBundle(android.os.PersistableBundle)

Example 20 with PersistableBundle

use of android.os.PersistableBundle in project android_frameworks_base by DirtyUnicorns.

the class ShortcutPackage method parseShortcut.

private static ShortcutInfo parseShortcut(XmlPullParser parser, String packageName, @UserIdInt int userId) throws IOException, XmlPullParserException {
    String id;
    ComponentName activityComponent;
    // Icon icon;
    String title;
    int titleResId;
    String titleResName;
    String text;
    int textResId;
    String textResName;
    String disabledMessage;
    int disabledMessageResId;
    String disabledMessageResName;
    Intent intentLegacy;
    PersistableBundle intentPersistableExtrasLegacy = null;
    ArrayList<Intent> intents = new ArrayList<>();
    int rank;
    PersistableBundle extras = null;
    long lastChangedTimestamp;
    int flags;
    int iconResId;
    String iconResName;
    String bitmapPath;
    ArraySet<String> categories = null;
    id = ShortcutService.parseStringAttribute(parser, ATTR_ID);
    activityComponent = ShortcutService.parseComponentNameAttribute(parser, ATTR_ACTIVITY);
    title = ShortcutService.parseStringAttribute(parser, ATTR_TITLE);
    titleResId = ShortcutService.parseIntAttribute(parser, ATTR_TITLE_RES_ID);
    titleResName = ShortcutService.parseStringAttribute(parser, ATTR_TITLE_RES_NAME);
    text = ShortcutService.parseStringAttribute(parser, ATTR_TEXT);
    textResId = ShortcutService.parseIntAttribute(parser, ATTR_TEXT_RES_ID);
    textResName = ShortcutService.parseStringAttribute(parser, ATTR_TEXT_RES_NAME);
    disabledMessage = ShortcutService.parseStringAttribute(parser, ATTR_DISABLED_MESSAGE);
    disabledMessageResId = ShortcutService.parseIntAttribute(parser, ATTR_DISABLED_MESSAGE_RES_ID);
    disabledMessageResName = ShortcutService.parseStringAttribute(parser, ATTR_DISABLED_MESSAGE_RES_NAME);
    intentLegacy = ShortcutService.parseIntentAttributeNoDefault(parser, ATTR_INTENT_LEGACY);
    rank = (int) ShortcutService.parseLongAttribute(parser, ATTR_RANK);
    lastChangedTimestamp = ShortcutService.parseLongAttribute(parser, ATTR_TIMESTAMP);
    flags = (int) ShortcutService.parseLongAttribute(parser, ATTR_FLAGS);
    iconResId = (int) ShortcutService.parseLongAttribute(parser, ATTR_ICON_RES_ID);
    iconResName = ShortcutService.parseStringAttribute(parser, ATTR_ICON_RES_NAME);
    bitmapPath = ShortcutService.parseStringAttribute(parser, ATTR_BITMAP_PATH);
    final int outerDepth = parser.getDepth();
    int type;
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
        if (type != XmlPullParser.START_TAG) {
            continue;
        }
        final int depth = parser.getDepth();
        final String tag = parser.getName();
        if (ShortcutService.DEBUG_LOAD) {
            Slog.d(TAG, String.format("  depth=%d type=%d name=%s", depth, type, tag));
        }
        switch(tag) {
            case TAG_INTENT_EXTRAS_LEGACY:
                intentPersistableExtrasLegacy = PersistableBundle.restoreFromXml(parser);
                continue;
            case TAG_INTENT:
                intents.add(parseIntent(parser));
                continue;
            case TAG_EXTRAS:
                extras = PersistableBundle.restoreFromXml(parser);
                continue;
            case TAG_CATEGORIES:
                // This just contains string-array.
                continue;
            case TAG_STRING_ARRAY_XMLUTILS:
                if (NAME_CATEGORIES.equals(ShortcutService.parseStringAttribute(parser, ATTR_NAME_XMLUTILS))) {
                    final String[] ar = XmlUtils.readThisStringArrayXml(parser, TAG_STRING_ARRAY_XMLUTILS, null);
                    categories = new ArraySet<>(ar.length);
                    for (int i = 0; i < ar.length; i++) {
                        categories.add(ar[i]);
                    }
                }
                continue;
        }
        throw ShortcutService.throwForInvalidTag(depth, tag);
    }
    if (intentLegacy != null) {
        // For the legacy file format which supported only one intent per shortcut.
        ShortcutInfo.setIntentExtras(intentLegacy, intentPersistableExtrasLegacy);
        intents.clear();
        intents.add(intentLegacy);
    }
    return new ShortcutInfo(userId, id, packageName, activityComponent, /* icon =*/
    null, title, titleResId, titleResName, text, textResId, textResName, disabledMessage, disabledMessageResId, disabledMessageResName, categories, intents.toArray(new Intent[intents.size()]), rank, extras, lastChangedTimestamp, flags, iconResId, iconResName, bitmapPath);
}
Also used : PersistableBundle(android.os.PersistableBundle) ShortcutInfo(android.content.pm.ShortcutInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

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