-
Notifications
You must be signed in to change notification settings - Fork 30
/
openpdroid_4.3_packages_apps_Mms.patch
115 lines (111 loc) · 5.06 KB
/
openpdroid_4.3_packages_apps_Mms.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
diff --git a/src/com/android/mms/transaction/HttpUtils.java b/src/com/android/mms/transaction/HttpUtils.java
index b6c878c..7c1ac7b 100644
--- a/src/com/android/mms/transaction/HttpUtils.java
+++ b/src/com/android/mms/transaction/HttpUtils.java
@@ -46,6 +46,22 @@ import android.util.Log;
import com.android.mms.LogTag;
import com.android.mms.MmsConfig;
+
+//-------------------------------------------------
+import com.android.internal.telephony.PhoneConstants;
+import android.net.Uri;
+import android.database.Cursor;
+import android.os.ServiceManager;
+import android.privacy.IPrivacySettingsManager;
+import android.privacy.PrivacySettingsManager;
+import android.privacy.PrivacySettings;
+import android.provider.Telephony;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+//-------------------------------------------------
+
+
public class HttpUtils {
private static final String TAG = LogTag.TRANSACTION;
@@ -62,7 +78,55 @@ public class HttpUtils {
// setting, this should no longer be static. We should call
// getHttpAcceptLanguage instead.
private static final String HDR_VALUE_ACCEPT_LANGUAGE;
+
+
+ //-------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------
+ private static PrivacySettingsManager pSetMan;
+
+ private static class APNInfo{
+ public String MMSCenterUrl;
+ public String MMSPort;
+ public String MMSProxy;
+
+ public APNInfo(){
+ //init to prevent nullpointer exception
+ MMSCenterUrl = "";
+ MMSPort = "";
+ MMSProxy = "";
+ }
+ }
+
+ private static List<APNInfo> getAPN(Context context){
+ final Cursor apnCursor = context.getContentResolver().query(Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"), null, null, null, null);
+ if (apnCursor == null) {
+ return Collections.emptyList();
+ } else {
+ final List<APNInfo> results = new ArrayList<APNInfo>();
+ if (apnCursor.moveToFirst()) {
+ do{
+ final String type = apnCursor.getString(apnCursor.getColumnIndex(Telephony.Carriers.TYPE));
+ if (!TextUtils.isEmpty(type) && ( type.equalsIgnoreCase(PhoneConstants.APN_TYPE_ALL) || type.equalsIgnoreCase(PhoneConstants.APN_TYPE_MMS))) {
+ final String mmsc = apnCursor.getString(apnCursor.getColumnIndex(Telephony.Carriers.MMSC));
+ final String mmsProxy = apnCursor.getString(apnCursor.getColumnIndex(Telephony.Carriers.MMSPROXY));
+ final String port = apnCursor.getString(apnCursor.getColumnIndex(Telephony.Carriers.MMSPORT));
+ final APNInfo apn = new APNInfo();
+ apn.MMSCenterUrl = mmsc;
+ apn.MMSProxy = mmsProxy;
+ apn.MMSPort = port;
+ results.add(apn);
+ }
+ } while (apnCursor.moveToNext());
+ }
+ apnCursor.close();
+ return results;
+ }
+ }
+
+
+ //-------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------
+
+
static {
HDR_VALUE_ACCEPT_LANGUAGE = getCurrentAcceptLanguage(Locale.getDefault());
}
@@ -113,7 +177,30 @@ public class HttpUtils {
}
AndroidHttpClient client = null;
-
+
+ //-------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------
+ if(pSetMan == null) pSetMan = new PrivacySettingsManager(context, IPrivacySettingsManager.Stub.asInterface(ServiceManager.getService("privacy")));
+ final List<APNInfo> apn = getAPN(context);
+ boolean isMMSTransaction = false;
+ APNInfo tmp;
+ for(int i = 0; i < apn.size(); i++){
+ tmp = apn.get(i);
+ if(tmp.MMSProxy.equals(proxyHost) || tmp.MMSPort.equals(String.valueOf(proxyPort)) || tmp.MMSCenterUrl.equals(url)){
+ isMMSTransaction = true;
+ break;
+ }
+ }
+ if(isMMSTransaction){
+ PrivacySettings settings = pSetMan.getSettings(context.getPackageName());
+ if(settings != null && settings.getSendMmsSetting() != PrivacySettings.REAL){
+ pSetMan.notification(context.getPackageName(), 0, PrivacySettings.EMPTY, PrivacySettings.DATA_SEND_MMS, null, null);
+ throw new IOException("401");
+ } else{
+ pSetMan.notification(context.getPackageName(), 0, PrivacySettings.REAL, PrivacySettings.DATA_SEND_MMS, null, null);
+ }
+ }
+ //-------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------
+
try {
// Make sure to use a proxy which supports CONNECT.
URI hostUrl = new URI(url);