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);
}
}
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;
}
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;
}
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));
}
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);
}
Aggregations