Search in sources :

Example 81 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by SudaMod.

the class SimSettings method updateSmsValues.

private void updateSmsValues() {
    final Preference simPref = findPreference(KEY_SMS);
    final SubscriptionInfo sir = mSubscriptionManager.getDefaultSmsSubscriptionInfo();
    simPref.setTitle(R.string.sms_messages_title);
    if (DBG)
        log("[updateSmsValues] mSubInfoList=" + mSubInfoList);
    if (sir != null) {
        simPref.setSummary(sir.getDisplayName());
        simPref.setEnabled(mSelectableSubInfos.size() > 1);
    } else if (sir == null) {
        simPref.setSummary(R.string.sim_selection_required_pref);
        simPref.setEnabled(mSelectableSubInfos.size() >= 1);
    }
}
Also used : Preference(android.support.v7.preference.Preference) SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 82 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project AndroidStudy by tinggengyan.

the class SIMCardUtil method hasDual.

// 判断双卡,无奈次API只出现在22之后
@TargetApi(22)
public static boolean hasDual(Context context) {
    SubscriptionManager subscriptionManager = SubscriptionManager.from(context);
    List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList();
    System.out.println(subscriptionManager.getActiveSubscriptionInfoCount());
    for (SubscriptionInfo info : activeSubscriptionInfoList) {
        System.out.println(info.getSimSlotIndex());
    }
    return false;
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager) TargetApi(android.annotation.TargetApi)

Example 83 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_CMParts by LineageOS.

the class SetupActionsFragment method rebuildItemList.

private void rebuildItemList() {
    mItems.clear();
    // general prefs
    mItems.add(new Header(getString(R.string.profile_name_title)));
    mItems.add(new ProfileNameItem(mProfile));
    if (!mNewProfileMode) {
        // triggers
        mItems.add(new Header(getString(R.string.profile_triggers_header)));
        mItems.add(generateTriggerItem(TriggerItem.WIFI));
        if (DeviceUtils.deviceSupportsBluetooth()) {
            mItems.add(generateTriggerItem(TriggerItem.BLUETOOTH));
        }
        if (DeviceUtils.deviceSupportsNfc(getActivity())) {
            mItems.add(generateTriggerItem(TriggerItem.NFC));
        }
    }
    // connection overrides
    mItems.add(new Header(getString(R.string.wireless_networks_settings_title)));
    if (DeviceUtils.deviceSupportsBluetooth()) {
        mItems.add(new ConnectionOverrideItem(PROFILE_CONNECTION_BLUETOOTH, mProfile.getSettingsForConnection(PROFILE_CONNECTION_BLUETOOTH)));
    }
    mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_GPS));
    mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_WIFI));
    mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_SYNC));
    if (DeviceUtils.deviceSupportsMobileData(getActivity())) {
        mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_MOBILEDATA));
        mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_WIFIAP));
        final List<SubscriptionInfo> subs = SubscriptionManager.from(getContext()).getActiveSubscriptionInfoList();
        if (subs != null) {
            for (SubscriptionInfo sub : subs) {
                mItems.add(generatePreferredNetworkOverrideItem(sub.getSubscriptionId()));
            }
        } else {
            if (TelephonyManager.from(getContext()).getPhoneCount() == 1) {
                mItems.add(generatePreferredNetworkOverrideItem(SubscriptionManager.INVALID_SUBSCRIPTION_ID));
            }
        }
    }
    // }
    if (DeviceUtils.deviceSupportsNfc(getActivity())) {
        mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_NFC));
    }
    // add volume streams
    mItems.add(new Header(getString(R.string.profile_volumeoverrides_title)));
    mItems.add(generateVolumeStreamItem(AudioManager.STREAM_ALARM));
    mItems.add(generateVolumeStreamItem(AudioManager.STREAM_MUSIC));
    mItems.add(generateVolumeStreamItem(AudioManager.STREAM_RING));
    mItems.add(generateVolumeStreamItem(AudioManager.STREAM_NOTIFICATION));
    // system settings
    mItems.add(new Header(getString(R.string.profile_system_settings_title)));
    mItems.add(new RingModeItem(mProfile.getRingMode()));
    mItems.add(new AirplaneModeItem(mProfile.getAirplaneMode()));
    DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (!dpm.requireSecureKeyguard()) {
        mItems.add(new LockModeItem(mProfile));
    } else {
        mItems.add(new DisabledItem(R.string.profile_lockmode_title, R.string.profile_lockmode_policy_disabled_summary));
    }
    mItems.add(new BrightnessItem(mProfile.getBrightness()));
    final Activity activity = getActivity();
    if (DeviceUtils.isDozeAvailable(activity)) {
        mItems.add(new DozeModeItem(mProfile));
    }
    if (getResources().getBoolean(com.android.internal.R.bool.config_intrusiveNotificationLed)) {
        mItems.add(new NotificationLightModeItem(mProfile));
    }
    // app groups
    mItems.add(new Header(getString(R.string.profile_app_group_category_title)));
    int groupsAdded = 0;
    ProfileGroup[] profileGroups = mProfile.getProfileGroups();
    if (profileGroups != null && profileGroups.length > 1) {
        // it will always have "other"
        for (ProfileGroup profileGroup : profileGroups) {
            // and don't' show the wildcard group
            if (mProfileManager.getNotificationGroup(profileGroup.getUuid()) != null && !mProfile.getDefaultGroup().getUuid().equals(profileGroup.getUuid())) {
                mItems.add(new AppGroupItem(mProfile, profileGroup, mProfileManager.getNotificationGroup(profileGroup.getUuid())));
                groupsAdded++;
            }
        }
        if (groupsAdded > 0) {
            // add "Other" at the end
            mItems.add(new AppGroupItem(mProfile, mProfile.getDefaultGroup(), mProfileManager.getNotificationGroup(mProfile.getDefaultGroup().getUuid())));
        }
    }
    if (mProfileManager.getNotificationGroups().length > 0) {
        // if there are notification groups available, allow them to be configured
        mItems.add(new AppGroupItem());
    } else if (groupsAdded == 0) {
        // no notification groups available at all, nothing to add/remove
        mItems.remove(mItems.get(mItems.size() - 1));
    }
    mAdapter.notifyDataSetChanged();
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) AppGroupItem(org.cyanogenmod.cmparts.profiles.actions.item.AppGroupItem) AirplaneModeItem(org.cyanogenmod.cmparts.profiles.actions.item.AirplaneModeItem) ProfileNameItem(org.cyanogenmod.cmparts.profiles.actions.item.ProfileNameItem) ConnectionOverrideItem(org.cyanogenmod.cmparts.profiles.actions.item.ConnectionOverrideItem) PartsActivity(org.cyanogenmod.cmparts.PartsActivity) Activity(android.app.Activity) SubscriptionInfo(android.telephony.SubscriptionInfo) LockModeItem(org.cyanogenmod.cmparts.profiles.actions.item.LockModeItem) BrightnessItem(org.cyanogenmod.cmparts.profiles.actions.item.BrightnessItem) DozeModeItem(org.cyanogenmod.cmparts.profiles.actions.item.DozeModeItem) Header(org.cyanogenmod.cmparts.profiles.actions.item.Header) DisabledItem(org.cyanogenmod.cmparts.profiles.actions.item.DisabledItem) NotificationLightModeItem(org.cyanogenmod.cmparts.profiles.actions.item.NotificationLightModeItem) RingModeItem(org.cyanogenmod.cmparts.profiles.actions.item.RingModeItem) ProfileGroup(cyanogenmod.app.ProfileGroup)

Example 84 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by DirtyUnicorns.

the class CellDataPreference method showMultiSimDialog.

private void showMultiSimDialog(AlertDialog.Builder builder, DialogInterface.OnClickListener listener) {
    final SubscriptionInfo currentSir = mSubscriptionManager.getActiveSubscriptionInfo(mSubId);
    final SubscriptionInfo nextSir = mSubscriptionManager.getDefaultDataSubscriptionInfo();
    final String previousName = (nextSir == null) ? getContext().getResources().getString(R.string.sim_selection_required_pref) : nextSir.getDisplayName().toString();
    builder.setTitle(R.string.sim_change_data_title);
    builder.setMessage(getContext().getString(R.string.sim_change_data_message, String.valueOf(currentSir != null ? currentSir.getDisplayName() : null), previousName));
    builder.setPositiveButton(R.string.okay, listener);
    builder.setNegativeButton(R.string.cancel, null);
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo)

Example 85 with SubscriptionInfo

use of android.telephony.SubscriptionInfo in project android_packages_apps_Settings by DirtyUnicorns.

the class DataUsageUtils method getDefaultSubscriptionId.

/**
 * Returns the default subscription if available else returns
 * SubscriptionManager#INVALID_SUBSCRIPTION_ID
 */
public static int getDefaultSubscriptionId(Context context) {
    SubscriptionManager subManager = SubscriptionManager.from(context);
    if (subManager == null) {
        return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    }
    SubscriptionInfo subscriptionInfo = subManager.getDefaultDataSubscriptionInfo();
    if (subscriptionInfo == null) {
        List<SubscriptionInfo> list = subManager.getAllSubscriptionInfoList();
        if (list.size() == 0) {
            return SubscriptionManager.INVALID_SUBSCRIPTION_ID;
        }
        subscriptionInfo = list.get(0);
    }
    return subscriptionInfo.getSubscriptionId();
}
Also used : SubscriptionInfo(android.telephony.SubscriptionInfo) SubscriptionManager(android.telephony.SubscriptionManager)

Aggregations

SubscriptionInfo (android.telephony.SubscriptionInfo)335 TelephonyManager (android.telephony.TelephonyManager)64 SubscriptionManager (android.telephony.SubscriptionManager)63 ArrayList (java.util.ArrayList)53 Test (org.junit.Test)49 Context (android.content.Context)38 Intent (android.content.Intent)38 Preference (android.support.v7.preference.Preference)27 PhoneAccountHandle (android.telecom.PhoneAccountHandle)18 IntentFilter (android.content.IntentFilter)16 Resources (android.content.res.Resources)16 ConnectivityManager (android.net.ConnectivityManager)15 Preference (androidx.preference.Preference)15 AlertDialog (android.app.AlertDialog)14 DialogInterface (android.content.DialogInterface)14 DataUsageController (com.android.settingslib.net.DataUsageController)14 View (android.view.View)13 PhoneAccount (android.telecom.PhoneAccount)11 TelecomManager (android.telecom.TelecomManager)11 PendingIntent (android.app.PendingIntent)9