Loading src/java/com/android/internal/telephony/SMSDispatcher.java +44 −7 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,8 @@ import static android.telephony.SmsManager.RESULT_ERROR_LIMIT_EXCEEDED; import static android.telephony.SmsManager.RESULT_ERROR_NO_SERVICE; import static android.telephony.SmsManager.RESULT_ERROR_NO_SERVICE; import static android.telephony.SmsManager.RESULT_ERROR_NULL_PDU; import static android.telephony.SmsManager.RESULT_ERROR_NULL_PDU; import static android.telephony.SmsManager.RESULT_ERROR_RADIO_OFF; import static android.telephony.SmsManager.RESULT_ERROR_RADIO_OFF; import static android.telephony.SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED; import static android.telephony.SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.UserIdInt; Loading Loading @@ -313,7 +315,25 @@ public abstract class SMSDispatcher extends Handler { case EVENT_STOP_SENDING: case EVENT_STOP_SENDING: { { SmsTracker tracker = (SmsTracker) msg.obj; SmsTracker tracker = (SmsTracker) msg.obj; if (msg.arg1 == ConfirmDialogListener.SHORT_CODE_MSG) { if (msg.arg2 == ConfirmDialogListener.NEVER_ALLOW) { tracker.onFailed(mContext, RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED, 0/*errorCode*/); Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - " + "sending SHORT_CODE_NEVER_ALLOWED error code."); } else { tracker.onFailed(mContext, RESULT_ERROR_SHORT_CODE_NOT_ALLOWED, 0/*errorCode*/); Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - " + "sending SHORT_CODE_NOT_ALLOWED error code."); } } else if (msg.arg1 == ConfirmDialogListener.RATE_LIMIT) { tracker.onFailed(mContext, RESULT_ERROR_LIMIT_EXCEEDED, 0/*errorCode*/); tracker.onFailed(mContext, RESULT_ERROR_LIMIT_EXCEEDED, 0/*errorCode*/); Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - " + "sending LIMIT_EXCEEDED error code."); } else { Rlog.e(TAG, "SMSDispatcher: EVENT_STOP_SENDING - unexpected cases."); } mPendingTrackerCount--; mPendingTrackerCount--; break; break; } } Loading Loading @@ -1068,7 +1088,10 @@ public abstract class SMSDispatcher extends Handler { case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW: case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW: Rlog.w(TAG, "User denied this app from sending to premium SMS"); Rlog.w(TAG, "User denied this app from sending to premium SMS"); sendMessage(obtainMessage(EVENT_STOP_SENDING, tracker)); Message msg = obtainMessage(EVENT_STOP_SENDING, tracker); msg.arg1 = ConfirmDialogListener.SHORT_CODE_MSG; msg.arg2 = ConfirmDialogListener.NEVER_ALLOW; sendMessage(msg); return false; // reject this message return false; // reject this message case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER: case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER: Loading Loading @@ -1131,7 +1154,9 @@ public abstract class SMSDispatcher extends Handler { Resources r = Resources.getSystem(); Resources r = Resources.getSystem(); Spanned messageText = Html.fromHtml(r.getString(R.string.sms_control_message, appLabel)); Spanned messageText = Html.fromHtml(r.getString(R.string.sms_control_message, appLabel)); ConfirmDialogListener listener = new ConfirmDialogListener(tracker, null); // Construct ConfirmDialogListenter for Rate Limit handling ConfirmDialogListener listener = new ConfirmDialogListener(tracker, null, ConfirmDialogListener.RATE_LIMIT); AlertDialog d = new AlertDialog.Builder(mContext) AlertDialog d = new AlertDialog.Builder(mContext) .setTitle(R.string.sms_control_title) .setTitle(R.string.sms_control_title) Loading Loading @@ -1172,8 +1197,10 @@ public abstract class SMSDispatcher extends Handler { Context.LAYOUT_INFLATER_SERVICE); Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.sms_short_code_confirmation_dialog, null); View layout = inflater.inflate(R.layout.sms_short_code_confirmation_dialog, null); // Construct ConfirmDialogListenter for short code message sending ConfirmDialogListener listener = new ConfirmDialogListener(tracker, ConfirmDialogListener listener = new ConfirmDialogListener(tracker, (TextView)layout.findViewById(R.id.sms_short_code_remember_undo_instruction)); (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); TextView messageView = (TextView) layout.findViewById(R.id.sms_short_code_confirm_message); Loading Loading @@ -1634,10 +1661,15 @@ public abstract class SMSDispatcher extends Handler { private Button mNegativeButton; private Button mNegativeButton; private boolean mRememberChoice; // default is unchecked private boolean mRememberChoice; // default is unchecked private final TextView mRememberUndoInstruction; private final TextView mRememberUndoInstruction; private int mConfirmationType; // 0 - Short Code Msg Sending; 1 - Rate Limit Exceeded private static final int SHORT_CODE_MSG = 0; // Short Code Msg private static final int RATE_LIMIT = 1; // Rate Limit Exceeded private static final int NEVER_ALLOW = 1; // Never Allow ConfirmDialogListener(SmsTracker tracker, TextView textView) { ConfirmDialogListener(SmsTracker tracker, TextView textView, int confirmationType) { mTracker = tracker; mTracker = tracker; mRememberUndoInstruction = textView; mRememberUndoInstruction = textView; mConfirmationType = confirmationType; } } void setPositiveButton(Button button) { void setPositiveButton(Button button) { Loading Loading @@ -1670,10 +1702,13 @@ public abstract class SMSDispatcher extends Handler { EventLog.writeEvent(EventLogTags.EXP_DET_SMS_DENIED_BY_USER, EventLog.writeEvent(EventLogTags.EXP_DET_SMS_DENIED_BY_USER, mTracker.mAppInfo.applicationInfo == null ? mTracker.mAppInfo.applicationInfo == null ? -1 : mTracker.mAppInfo.applicationInfo.uid); -1 : mTracker.mAppInfo.applicationInfo.uid); sendMessage(obtainMessage(EVENT_STOP_SENDING, mTracker)); Message msg = obtainMessage(EVENT_STOP_SENDING, mTracker); msg.arg1 = mConfirmationType; if (mRememberChoice) { if (mRememberChoice) { newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW; newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW; msg.arg2 = ConfirmDialogListener.NEVER_ALLOW; } } sendMessage(msg); } } setPremiumSmsPermission(mTracker.mAppInfo.packageName, newSmsPermission); setPremiumSmsPermission(mTracker.mAppInfo.packageName, newSmsPermission); } } Loading @@ -1681,7 +1716,9 @@ public abstract class SMSDispatcher extends Handler { @Override @Override public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) { Rlog.d(TAG, "dialog dismissed: don't send SMS"); Rlog.d(TAG, "dialog dismissed: don't send SMS"); sendMessage(obtainMessage(EVENT_STOP_SENDING, mTracker)); Message msg = obtainMessage(EVENT_STOP_SENDING, mTracker); msg.arg1 = mConfirmationType; sendMessage(msg); } } @Override @Override Loading Loading
src/java/com/android/internal/telephony/SMSDispatcher.java +44 −7 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,8 @@ import static android.telephony.SmsManager.RESULT_ERROR_LIMIT_EXCEEDED; import static android.telephony.SmsManager.RESULT_ERROR_NO_SERVICE; import static android.telephony.SmsManager.RESULT_ERROR_NO_SERVICE; import static android.telephony.SmsManager.RESULT_ERROR_NULL_PDU; import static android.telephony.SmsManager.RESULT_ERROR_NULL_PDU; import static android.telephony.SmsManager.RESULT_ERROR_RADIO_OFF; import static android.telephony.SmsManager.RESULT_ERROR_RADIO_OFF; import static android.telephony.SmsManager.RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED; import static android.telephony.SmsManager.RESULT_ERROR_SHORT_CODE_NOT_ALLOWED; import android.annotation.Nullable; import android.annotation.Nullable; import android.annotation.UserIdInt; import android.annotation.UserIdInt; Loading Loading @@ -313,7 +315,25 @@ public abstract class SMSDispatcher extends Handler { case EVENT_STOP_SENDING: case EVENT_STOP_SENDING: { { SmsTracker tracker = (SmsTracker) msg.obj; SmsTracker tracker = (SmsTracker) msg.obj; if (msg.arg1 == ConfirmDialogListener.SHORT_CODE_MSG) { if (msg.arg2 == ConfirmDialogListener.NEVER_ALLOW) { tracker.onFailed(mContext, RESULT_ERROR_SHORT_CODE_NEVER_ALLOWED, 0/*errorCode*/); Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - " + "sending SHORT_CODE_NEVER_ALLOWED error code."); } else { tracker.onFailed(mContext, RESULT_ERROR_SHORT_CODE_NOT_ALLOWED, 0/*errorCode*/); Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - " + "sending SHORT_CODE_NOT_ALLOWED error code."); } } else if (msg.arg1 == ConfirmDialogListener.RATE_LIMIT) { tracker.onFailed(mContext, RESULT_ERROR_LIMIT_EXCEEDED, 0/*errorCode*/); tracker.onFailed(mContext, RESULT_ERROR_LIMIT_EXCEEDED, 0/*errorCode*/); Rlog.d(TAG, "SMSDispatcher: EVENT_STOP_SENDING - " + "sending LIMIT_EXCEEDED error code."); } else { Rlog.e(TAG, "SMSDispatcher: EVENT_STOP_SENDING - unexpected cases."); } mPendingTrackerCount--; mPendingTrackerCount--; break; break; } } Loading Loading @@ -1068,7 +1088,10 @@ public abstract class SMSDispatcher extends Handler { case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW: case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW: Rlog.w(TAG, "User denied this app from sending to premium SMS"); Rlog.w(TAG, "User denied this app from sending to premium SMS"); sendMessage(obtainMessage(EVENT_STOP_SENDING, tracker)); Message msg = obtainMessage(EVENT_STOP_SENDING, tracker); msg.arg1 = ConfirmDialogListener.SHORT_CODE_MSG; msg.arg2 = ConfirmDialogListener.NEVER_ALLOW; sendMessage(msg); return false; // reject this message return false; // reject this message case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER: case SmsUsageMonitor.PREMIUM_SMS_PERMISSION_ASK_USER: Loading Loading @@ -1131,7 +1154,9 @@ public abstract class SMSDispatcher extends Handler { Resources r = Resources.getSystem(); Resources r = Resources.getSystem(); Spanned messageText = Html.fromHtml(r.getString(R.string.sms_control_message, appLabel)); Spanned messageText = Html.fromHtml(r.getString(R.string.sms_control_message, appLabel)); ConfirmDialogListener listener = new ConfirmDialogListener(tracker, null); // Construct ConfirmDialogListenter for Rate Limit handling ConfirmDialogListener listener = new ConfirmDialogListener(tracker, null, ConfirmDialogListener.RATE_LIMIT); AlertDialog d = new AlertDialog.Builder(mContext) AlertDialog d = new AlertDialog.Builder(mContext) .setTitle(R.string.sms_control_title) .setTitle(R.string.sms_control_title) Loading Loading @@ -1172,8 +1197,10 @@ public abstract class SMSDispatcher extends Handler { Context.LAYOUT_INFLATER_SERVICE); Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.sms_short_code_confirmation_dialog, null); View layout = inflater.inflate(R.layout.sms_short_code_confirmation_dialog, null); // Construct ConfirmDialogListenter for short code message sending ConfirmDialogListener listener = new ConfirmDialogListener(tracker, ConfirmDialogListener listener = new ConfirmDialogListener(tracker, (TextView)layout.findViewById(R.id.sms_short_code_remember_undo_instruction)); (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); TextView messageView = (TextView) layout.findViewById(R.id.sms_short_code_confirm_message); Loading Loading @@ -1634,10 +1661,15 @@ public abstract class SMSDispatcher extends Handler { private Button mNegativeButton; private Button mNegativeButton; private boolean mRememberChoice; // default is unchecked private boolean mRememberChoice; // default is unchecked private final TextView mRememberUndoInstruction; private final TextView mRememberUndoInstruction; private int mConfirmationType; // 0 - Short Code Msg Sending; 1 - Rate Limit Exceeded private static final int SHORT_CODE_MSG = 0; // Short Code Msg private static final int RATE_LIMIT = 1; // Rate Limit Exceeded private static final int NEVER_ALLOW = 1; // Never Allow ConfirmDialogListener(SmsTracker tracker, TextView textView) { ConfirmDialogListener(SmsTracker tracker, TextView textView, int confirmationType) { mTracker = tracker; mTracker = tracker; mRememberUndoInstruction = textView; mRememberUndoInstruction = textView; mConfirmationType = confirmationType; } } void setPositiveButton(Button button) { void setPositiveButton(Button button) { Loading Loading @@ -1670,10 +1702,13 @@ public abstract class SMSDispatcher extends Handler { EventLog.writeEvent(EventLogTags.EXP_DET_SMS_DENIED_BY_USER, EventLog.writeEvent(EventLogTags.EXP_DET_SMS_DENIED_BY_USER, mTracker.mAppInfo.applicationInfo == null ? mTracker.mAppInfo.applicationInfo == null ? -1 : mTracker.mAppInfo.applicationInfo.uid); -1 : mTracker.mAppInfo.applicationInfo.uid); sendMessage(obtainMessage(EVENT_STOP_SENDING, mTracker)); Message msg = obtainMessage(EVENT_STOP_SENDING, mTracker); msg.arg1 = mConfirmationType; if (mRememberChoice) { if (mRememberChoice) { newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW; newSmsPermission = SmsUsageMonitor.PREMIUM_SMS_PERMISSION_NEVER_ALLOW; msg.arg2 = ConfirmDialogListener.NEVER_ALLOW; } } sendMessage(msg); } } setPremiumSmsPermission(mTracker.mAppInfo.packageName, newSmsPermission); setPremiumSmsPermission(mTracker.mAppInfo.packageName, newSmsPermission); } } Loading @@ -1681,7 +1716,9 @@ public abstract class SMSDispatcher extends Handler { @Override @Override public void onCancel(DialogInterface dialog) { public void onCancel(DialogInterface dialog) { Rlog.d(TAG, "dialog dismissed: don't send SMS"); Rlog.d(TAG, "dialog dismissed: don't send SMS"); sendMessage(obtainMessage(EVENT_STOP_SENDING, mTracker)); Message msg = obtainMessage(EVENT_STOP_SENDING, mTracker); msg.arg1 = mConfirmationType; sendMessage(msg); } } @Override @Override Loading