Example usage for android.telephony SubscriptionManager INVALID_SUBSCRIPTION_ID

List of usage examples for android.telephony SubscriptionManager INVALID_SUBSCRIPTION_ID

Introduction

In this page you can find the example usage for android.telephony SubscriptionManager INVALID_SUBSCRIPTION_ID.

Prototype

int INVALID_SUBSCRIPTION_ID

To view the source code for android.telephony SubscriptionManager INVALID_SUBSCRIPTION_ID.

Click Source Link

Document

An invalid subscription identifier

Usage

From source file:com.android.settings.datausage.CellDataPreference.java

@Override
protected void onRestoreInstanceState(Parcelable s) {
    CellDataState state = (CellDataState) s;
    super.onRestoreInstanceState(state.getSuperState());
    mTelephonyManager = TelephonyManager.from(getContext());
    mChecked = state.mChecked;//  w w w  . ja  v a2  s  .  co  m
    mMultiSimDialog = state.mMultiSimDialog;
    if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
        mSubId = state.mSubId;
        setKey(getKey() + mSubId);
    }
    notifyChanged();
}

From source file:com.android.settings.datausage.CellDataPreference.java

@Override
public void setTemplate(NetworkTemplate template, int subId, NetworkServices services) {
    if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
        throw new IllegalArgumentException("CellDataPreference needs a SubscriptionInfo");
    }/*from w w w  .  j  a va2 s . c  o  m*/
    mSubscriptionManager = SubscriptionManager.from(getContext());
    mTelephonyManager = TelephonyManager.from(getContext());
    if (mSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
        mSubId = subId;
        setKey(getKey() + subId);
    }
    updateChecked();
}

From source file:com.android.mms.transaction.MessagingNotification.java

public static void blockingUpdateNewIccMessageIndicator(Context context, String address, String message,
        int subId, long timeMillis) {
    final Notification.Builder noti = new Notification.Builder(context).setWhen(timeMillis);
    Contact contact = Contact.get(address, false);
    NotificationInfo info = getNewIccMessageNotificationInfo(context, true /* isSms */, address, message,
            null /* subject */, subId, timeMillis, null /* attachmentBitmap */, contact, WorkingMessage.TEXT);
    noti.setSmallIcon(R.drawable.stat_notify_sms);
    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    //        TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
    // Update the notification.
    PendingIntent pendingIntent;//from www . j av a2s  .  c om
    if (subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
        pendingIntent = PendingIntent.getActivity(context, 0, info.mClickIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
    } else {
        // Use requestCode to avoid updating all intents of previous notifications
        pendingIntent = PendingIntent.getActivity(context, ICC_NOTIFICATION_ID_BASE + subId, info.mClickIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
    }
    String title = info.mTitle;
    noti.setContentTitle(title).setContentIntent(pendingIntent)
            //taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT))
            .setCategory(Notification.CATEGORY_MESSAGE).setPriority(Notification.PRIORITY_DEFAULT);

    int defaults = 0;
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
    boolean vibrate = false;
    if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE)) {
        // The most recent change to the vibrate preference is to store a boolean
        // value in NOTIFICATION_VIBRATE. If prefs contain that preference, use that
        // first.
        vibrate = sp.getBoolean(MessagingPreferenceActivity.NOTIFICATION_VIBRATE, false);
    } else if (sp.contains(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN)) {
        // This is to support the pre-JellyBean MR1.1 version of vibrate preferences
        // when vibrate was a tri-state setting. As soon as the user opens the Messaging
        // app's settings, it will migrate this setting from NOTIFICATION_VIBRATE_WHEN
        // to the boolean value stored in NOTIFICATION_VIBRATE.
        String vibrateWhen = sp.getString(MessagingPreferenceActivity.NOTIFICATION_VIBRATE_WHEN, null);
        vibrate = "always".equals(vibrateWhen);
    }
    if (vibrate) {
        defaults |= Notification.DEFAULT_VIBRATE;
    }
    String ringtoneStr = sp.getString(MessagingPreferenceActivity.NOTIFICATION_RINGTONE, null);
    noti.setSound(TextUtils.isEmpty(ringtoneStr) ? null : Uri.parse(ringtoneStr));
    Log.d(TAG, "blockingUpdateNewIccMessageIndicator: adding sound to the notification");

    defaults |= Notification.DEFAULT_LIGHTS;

    noti.setDefaults(defaults);

    // set up delete intent
    noti.setDeleteIntent(PendingIntent.getBroadcast(context, 0, sNotificationOnDeleteIntent, 0));

    final Notification notification;
    // This sets the text for the collapsed form:
    noti.setContentText(info.formatBigMessage(context));

    if (info.mAttachmentBitmap != null) {
        // The message has a picture, show that

        notification = new Notification.BigPictureStyle(noti).bigPicture(info.mAttachmentBitmap)
                // This sets the text for the expanded picture form:
                .setSummaryText(info.formatPictureMessage(context)).build();
    } else {
        // Show a single notification -- big style with the text of the whole message
        notification = new Notification.BigTextStyle(noti).bigText(info.formatBigMessage(context)).build();
    }

    notifyUserIfFullScreen(context, title);
    nm.notify(ICC_NOTIFICATION_ID_BASE + subId, notification);
}

From source file:com.android.mms.ui.MessageUtils.java

public static void setSubIconAndLabel(int subId, String subName, TextView subView) {
    Log.i(TAG, "setSubIconAndLabel subId=" + subId);
    int textColor = 0;
    if (subView == null) {
        return;// w ww .  ja  v  a  2s . c om
    }
    int activeSubCount = SubscriptionManager.from(MmsApp.getApplication()).getActiveSubscriptionInfoCount();

    if (subName == null && activeSubCount > 1) {
        SubscriptionInfo subInfo = SubscriptionManager.from(MmsApp.getApplication())
                .getActiveSubscriptionInfo(subId);
        Log.d(TAG, "subInfo=" + subInfo);
        if (null != subInfo) {
            if ((subInfo.getSimSlotIndex() == SubscriptionManager.SIM_NOT_INSERTED)
                    || (subInfo.getSimSlotIndex() == SubscriptionManager.INVALID_SUBSCRIPTION_ID)) {
                Log.i(TAG, "current not insert sim card");
            } else {
                subName = subInfo.getDisplayName().toString();
                textColor = subInfo.getIconTint();
            }
        } else {
            Log.i(TAG, "subInfo is null ");
        }
    }

    if (subName == null || activeSubCount <= 1) {
        subView.setVisibility(View.GONE);
    } else {
        subView.setVisibility(View.VISIBLE);
        subView.setTextColor(textColor);
        subView.setText(subName);
    }
}