forked from morristech/PDroid2.0_Framework_Patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CM10.1_Mms.patch
125 lines (121 loc) · 5.83 KB
/
CM10.1_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
116
117
118
119
120
121
122
123
124
125
--- /media/ROM-Speicher/CM10.1/packages/apps/Mms/src/com/android/mms/transaction/HttpUtils.java 2013-04-02 21:48:26.981167101 +0545
+++ pang/packages/apps/Mms/src/com/android/mms/transaction/HttpUtils.java 2013-02-05 01:07:08.738642570 +0545
@@ -46,6 +46,24 @@ import android.util.Log;
import com.android.mms.LogTag;
import com.android.mms.MmsConfig;
+
+//-------------------------------------------------
+import com.android.internal.telephony.Phone;
+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.privacy.utilities.PrivacyDebugger;
+import android.provider.Telephony;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import com.android.internal.telephony.PhoneConstants;
+//-------------------------------------------------
+
+
public class HttpUtils {
private static final String TAG = LogTag.TRANSACTION;
@@ -62,7 +80,56 @@ 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();
+ PrivacyDebugger.i(TAG,"getApn - number of results: " + results.size());
+ return results;
+ }
+ }
+
+
+ //-------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------
+
+
static {
HDR_VALUE_ACCEPT_LANGUAGE = getCurrentAcceptLanguage(Locale.getDefault());
}
@@ -113,7 +180,39 @@ 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;
+ PrivacyDebugger.i(TAG,"httpConnection - found mms transaction");
+ break;
+ }
+ }
+ if(isMMSTransaction){
+ PrivacySettings settings = pSetMan.getSettings(context.getPackageName());
+ if(settings != null && settings.getSendMmsSetting() != PrivacySettings.REAL) {
+ if(settings.isDefaultDenyObject())
+ pSetMan.notification(context.getPackageName(), 0, PrivacySettings.ERROR, PrivacySettings.DATA_SEND_MMS, null, null);
+ else
+ pSetMan.notification(context.getPackageName(), 0, PrivacySettings.EMPTY, PrivacySettings.DATA_SEND_MMS, null, null);
+ PrivacyDebugger.i(TAG,"httpConnection - going to block outgoing mms");
+ throw new IOException("401");
+ } else {
+ if(settings != null && settings.isDefaultDenyObject())
+ pSetMan.notification(context.getPackageName(), 0, PrivacySettings.ERROR, PrivacySettings.DATA_SEND_MMS, null, null);
+ else
+ pSetMan.notification(context.getPackageName(), 0, PrivacySettings.REAL, PrivacySettings.DATA_SEND_MMS, null, null);
+ PrivacyDebugger.i(TAG,"httpConnection - going to allow outgoing mms");
+ }
+ }
+ //-------------------------------------------------------------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------
+
try {
// Make sure to use a proxy which supports CONNECT.
URI hostUrl = new URI(url);