forked from OSUSecLab/RILDefender
-
Notifications
You must be signed in to change notification settings - Fork 1
/
InboundSmsHandler.java_2ba09879c6e2bbae270e31e7e73dff79.patch
75 lines (72 loc) · 3.59 KB
/
InboundSmsHandler.java_2ba09879c6e2bbae270e31e7e73dff79.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--- /home/haohuang/backup/aosp11-RQ3A.211001.001/frameworks/opt/telephony/src/java/com/android/internal/telephony/InboundSmsHandler.java 2023-03-05 03:52:02.750060152 +0000
+++ /home/haohuang/aosp11-RQ3A.211001.001/frameworks/opt/telephony/src/java/com/android/internal/telephony/InboundSmsHandler.java 2023-03-05 21:13:11.790143625 +0000
@@ -65,6 +65,9 @@
import android.text.TextUtils;
import android.util.LocalLog;
import android.util.Pair;
+import com.android.internal.telephony.RILDefender;
+import com.android.internal.telephony.MccTable;
+import android.telephony.CellState;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
@@ -196,6 +199,8 @@
protected static final Uri sRawUriPermanentDelete =
Uri.withAppendedPath(Telephony.Sms.CONTENT_URI, "raw/permanentDelete");
+ private static final String TAG = "InboundSmsHandler";
+
@UnsupportedAppUsage
protected final Context mContext;
@UnsupportedAppUsage
@@ -792,6 +797,53 @@
SmsHeader smsHeader = sms.getUserDataHeader();
InboundSmsTracker tracker;
+ // RILDefender: handle normal SMS text messages
+ // Detected FBS SMS
+ // double averageRSSI = RILDefender.getAverageRSSIInSignalHistory();
+ CellState cs = RILDefender.getCurrentCellState();
+ boolean suspecious = false;
+
+ if (cs.getSignalStrength() < 0 && cs.getSignalStrength() > RILDefender.RSSI_THRESHOLD)
+ // check if average RSSI is over a threshold
+ suspecious = true;
+ else {
+ // check if any abnormal broadcast parameters
+ if (RILDefender.detectUnusualCellParam())
+ suspecious = true;
+ }
+
+ // add SMS to history
+ RILDefender.addSms(sms.getPdu());
+
+ if (suspecious) {
+ Rlog.d("RILDefender", "Suspecious cell state: " + cs);
+ if (RILDefender.getSp(mContext, RILDefender.SP_NAME_FBS_SMS) == RILDefender.AlertLevel.BLOCK_AND_NOTIFY.getValue()) {
+ // block and notify
+ Rlog.d("RILDefender", "Block FBS SMS and notify user");
+ Intent intent = new Intent(RILDefender.BROADCAST_NOTIFY_ACTION);
+ intent.putExtra("type", RILDefender.SP_NAME_FBS_SMS);
+ intent.putExtra("source", sms.getOriginatingAddress());
+ intent.putExtra("content", sms.getMessageBody());
+ intent.putExtra("pdu", sms.getPdu());
+ mContext.sendBroadcast(intent);
+ return 0;
+ } else if (RILDefender.getSp(mContext, RILDefender.SP_NAME_FBS_SMS) == RILDefender.AlertLevel.BLOCK.getValue()) {
+ // block without notify
+ Rlog.d("RILDefender", "Block FBS SMS from " + sms.getOriginatingAddress());
+ return 0;
+ } else if (RILDefender.getSp(mContext, RILDefender.SP_NAME_FBS_SMS) == RILDefender.AlertLevel.NOTIFY.getValue()) {
+ // notify only
+ Intent intent = new Intent(RILDefender.BROADCAST_NOTIFY_ACTION);
+ intent.putExtra("type", RILDefender.SP_NAME_FBS_SMS);
+ intent.putExtra("source", sms.getOriginatingAddress());
+ intent.putExtra("content", sms.getMessageBody());
+ intent.putExtra("pdu", sms.getPdu());
+ mContext.sendBroadcast(intent);
+ Rlog.d("RILDefender", "Notify user for the FBS SMS");
+ }
+ }
+
+
if ((smsHeader == null) || (smsHeader.concatRef == null)) {
// Message is not concatenated.
int destPort = -1;