Search in sources :

Example 66 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class SubscriptionController method setDefaultDataSubId.

@UnsupportedAppUsage
@Override
public void setDefaultDataSubId(int subId) {
    enforceModifyPhoneState("setDefaultDataSubId");
    final long identity = Binder.clearCallingIdentity();
    try {
        if (subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
            throw new RuntimeException("setDefaultDataSubId called with DEFAULT_SUB_ID");
        }
        ProxyController proxyController = ProxyController.getInstance();
        int len = TelephonyManager.from(mContext).getActiveModemCount();
        logdl("[setDefaultDataSubId] num phones=" + len + ", subId=" + subId);
        if (SubscriptionManager.isValidSubscriptionId(subId)) {
            // Only re-map modems if the new default data sub is valid
            RadioAccessFamily[] rafs = new RadioAccessFamily[len];
            boolean atLeastOneMatch = false;
            for (int phoneId = 0; phoneId < len; phoneId++) {
                Phone phone = PhoneFactory.getPhone(phoneId);
                int raf;
                int id = phone.getSubId();
                if (id == subId) {
                    // TODO Handle the general case of N modems and M subscriptions.
                    raf = proxyController.getMaxRafSupported();
                    atLeastOneMatch = true;
                } else {
                    // TODO Handle the general case of N modems and M subscriptions.
                    raf = proxyController.getMinRafSupported();
                }
                logdl("[setDefaultDataSubId] phoneId=" + phoneId + " subId=" + id + " RAF=" + raf);
                rafs[phoneId] = new RadioAccessFamily(phoneId, raf);
            }
            if (atLeastOneMatch) {
                proxyController.setRadioCapability(rafs);
            } else {
                if (DBG)
                    logdl("[setDefaultDataSubId] no valid subId's found - not updating.");
            }
        }
        int previousDefaultSub = getDefaultSubId();
        setGlobalSetting(Settings.Global.MULTI_SIM_DATA_CALL_SUBSCRIPTION, subId);
        MultiSimSettingController.getInstance().notifyDefaultDataSubChanged();
        broadcastDefaultDataSubIdChanged(subId);
        if (previousDefaultSub != getDefaultSubId()) {
            sendDefaultChangedBroadcast(getDefaultSubId());
        }
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
Also used : RadioAccessFamily(android.telephony.RadioAccessFamily) DataEnabledOverride(com.android.internal.telephony.dataconnection.DataEnabledOverride) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 67 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class WapPushOverSms method isDuplicateNotification.

@UnsupportedAppUsage
private static boolean isDuplicateNotification(Context context, NotificationInd nInd) {
    final byte[] rawLocation = nInd.getContentLocation();
    if (rawLocation != null) {
        String location = new String(rawLocation);
        String[] selectionArgs = new String[] { location };
        Cursor cursor = null;
        try {
            cursor = context.getContentResolver().query(Telephony.Mms.CONTENT_URI, new String[] { Telephony.Mms._ID }, LOCATION_SELECTION, new String[] { Integer.toString(PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND), new String(rawLocation) }, null);
            if (cursor != null && cursor.getCount() > 0) {
                // We already received the same notification before.
                return true;
            }
        } catch (SQLiteException e) {
            Rlog.e(TAG, "failed to query existing notification ind", e);
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    return false;
}
Also used : Cursor(android.database.Cursor) SQLiteException(android.database.sqlite.SQLiteException) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 68 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class WapPushOverSms method getDeliveryOrReadReportThreadId.

@UnsupportedAppUsage
private static long getDeliveryOrReadReportThreadId(Context context, GenericPdu pdu) {
    String messageId;
    if (pdu instanceof DeliveryInd) {
        messageId = new String(((DeliveryInd) pdu).getMessageId());
    } else if (pdu instanceof ReadOrigInd) {
        messageId = new String(((ReadOrigInd) pdu).getMessageId());
    } else {
        Rlog.e(TAG, "WAP Push data is neither delivery or read report type: " + pdu.getClass().getCanonicalName());
        return -1L;
    }
    Cursor cursor = null;
    try {
        cursor = context.getContentResolver().query(Telephony.Mms.CONTENT_URI, new String[] { Telephony.Mms.THREAD_ID }, THREAD_ID_SELECTION, new String[] { DatabaseUtils.sqlEscapeString(messageId), Integer.toString(PduHeaders.MESSAGE_TYPE_SEND_REQ) }, null);
        if (cursor != null && cursor.moveToFirst()) {
            return cursor.getLong(0);
        }
    } catch (SQLiteException e) {
        Rlog.e(TAG, "Failed to query delivery or read report thread id", e);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return -1L;
}
Also used : DeliveryInd(com.google.android.mms.pdu.DeliveryInd) ReadOrigInd(com.google.android.mms.pdu.ReadOrigInd) Cursor(android.database.Cursor) SQLiteException(android.database.sqlite.SQLiteException) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 69 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class SMSDispatcher method handleConfirmShortCode.

/**
 * Post an alert for user confirmation when sending to a potential short code.
 *
 * @param isPremium true if the destination is known to be a premium short code
 * @param trackers the SmsTracker array for the current message.
 */
@UnsupportedAppUsage
protected void handleConfirmShortCode(boolean isPremium, SmsTracker[] trackers) {
    if (denyIfQueueLimitReached(trackers)) {
        // queue limit reached; error was returned to caller
        return;
    }
    int detailsId;
    if (isPremium) {
        detailsId = R.string.sms_premium_short_code_details;
    } else {
        detailsId = R.string.sms_short_code_details;
    }
    CharSequence appLabel = getAppLabel(trackers[0].getAppPackageName(), trackers[0].mUserId);
    Resources r = Resources.getSystem();
    Spanned messageText = Html.fromHtml(r.getString(R.string.sms_short_code_confirm_message, appLabel, trackers[0].mDestAddress));
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.sms_short_code_confirmation_dialog, null);
    // Construct ConfirmDialogListenter for short code message sending
    ConfirmDialogListener listener = new ConfirmDialogListener(trackers, (TextView) layout.findViewById(R.id.sms_short_code_remember_undo_instruction), ConfirmDialogListener.SHORT_CODE_MSG);
    TextView messageView = (TextView) layout.findViewById(R.id.sms_short_code_confirm_message);
    messageView.setText(messageText);
    ViewGroup detailsLayout = (ViewGroup) layout.findViewById(R.id.sms_short_code_detail_layout);
    TextView detailsView = (TextView) detailsLayout.findViewById(R.id.sms_short_code_detail_message);
    detailsView.setText(detailsId);
    CheckBox rememberChoice = (CheckBox) layout.findViewById(R.id.sms_short_code_remember_choice_checkbox);
    rememberChoice.setOnCheckedChangeListener(listener);
    AlertDialog d = new AlertDialog.Builder(mContext).setView(layout).setPositiveButton(r.getString(R.string.sms_short_code_confirm_allow), listener).setNegativeButton(r.getString(R.string.sms_short_code_confirm_deny), listener).setOnCancelListener(listener).create();
    d.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    d.show();
    listener.setPositiveButton(d.getButton(DialogInterface.BUTTON_POSITIVE));
    listener.setNegativeButton(d.getButton(DialogInterface.BUTTON_NEGATIVE));
}
Also used : AlertDialog(android.app.AlertDialog) ViewGroup(android.view.ViewGroup) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) Resources(android.content.res.Resources) Spanned(android.text.Spanned) View(android.view.View) TextView(android.widget.TextView) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Example 70 with UnsupportedAppUsage

use of android.compat.annotation.UnsupportedAppUsage in project android_frameworks_opt_telephony by LineageOS.

the class SubscriptionController method broadcastDefaultDataSubIdChanged.

@UnsupportedAppUsage
private void broadcastDefaultDataSubIdChanged(int subId) {
    // Broadcast an Intent for default data sub change
    if (DBG)
        logdl("[broadcastDefaultDataSubIdChanged] subId=" + subId);
    Intent intent = new Intent(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
    SubscriptionManager.putSubscriptionIdExtra(intent, subId);
    mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
Also used : PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) UnsupportedAppUsage(android.compat.annotation.UnsupportedAppUsage)

Aggregations

UnsupportedAppUsage (android.compat.annotation.UnsupportedAppUsage)71 Message (android.os.Message)18 SmsMessage (android.telephony.SmsMessage)9 Intent (android.content.Intent)6 SipPhone (com.android.internal.telephony.sip.SipPhone)6 SmsCbMessage (android.telephony.SmsCbMessage)5 Cursor (android.database.Cursor)4 PendingIntent (android.app.PendingIntent)3 PackageManager (android.content.pm.PackageManager)3 AsyncResult (android.os.AsyncResult)3 PersistableBundle (android.os.PersistableBundle)3 CarrierConfigManager (android.telephony.CarrierConfigManager)3 SubscriptionInfo (android.telephony.SubscriptionInfo)3 SQLException (android.database.SQLException)2 SQLiteException (android.database.sqlite.SQLiteException)2 PowerManager (android.os.PowerManager)2 RadioAccessFamily (android.telephony.RadioAccessFamily)2 ImsException (com.android.ims.ImsException)2 ImsUtInterface (com.android.ims.ImsUtInterface)2 AppState (com.android.internal.telephony.uicc.IccCardApplicationStatus.AppState)2