This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
openpdroid_network_location.patch
159 lines (155 loc) · 7.47 KB
/
openpdroid_network_location.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
diff --git a/services/java/com/android/server/PrivacyTelephonyRegistry.java b/services/java/com/android/server/PrivacyTelephonyRegistry.java
index fcba495..be948ae 100644
--- a/services/java/com/android/server/PrivacyTelephonyRegistry.java
+++ b/services/java/com/android/server/PrivacyTelephonyRegistry.java
@@ -53,8 +53,11 @@ public class PrivacyTelephonyRegistry extends TelephonyRegistry{
private static final int PERMISSION_SERVICE_STATE = 4;
+ private Context context;
+
public PrivacyTelephonyRegistry(Context context) {
super(context);
+ this.context = context;
pSetMan = new PrivacySettingsManager(context, IPrivacySettingsManager.Stub.asInterface(ServiceManager.getService("privacy")));
try{
registerPrivacy();
@@ -146,128 +149,27 @@ public class PrivacyTelephonyRegistry extends TelephonyRegistry{
} catch(Exception e){
Log.e(P_TAG,"failed to register privacy broadcastreceiver");
}
- if (events != 0) {
- /* Checks permission and throws Security exception */
- checkListenerPermission(events);
-
- synchronized (mRecords) {
- // register
- Record r = null;
- find_and_add: {
- IBinder b = callback.asBinder();
- final int N = mRecords.size();
- for (int i = 0; i < N; i++) {
- r = mRecords.get(i);
- if (b == r.binder) {
- break find_and_add;
- }
- }
- r = new Record();
- r.binder = b;
- r.callback = callback;
- r.pkgForDebug = pkgForDebug;
- mRecords.add(r);
- }
- int send = events & (events ^ r.events);
- r.events = events;
- if (notifyNow) {
- if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
-// try {
-// //not forward now, wait for next
-// //r.callback.onServiceStateChanged(new ServiceState(mServiceState));
-// } catch (RemoteException ex) {
-// remove(r.binder);
-// }
- }
- if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
- try {
- int gsmSignalStrength = mSignalStrength.getGsmSignalStrength();
- r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
- : gsmSignalStrength));
- } catch (RemoteException ex) {
- remove(r.binder);
- }
- }
- if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
- try {
- r.callback.onMessageWaitingIndicatorChanged(mMessageWaiting);
- } catch (RemoteException ex) {
- remove(r.binder);
- }
- }
- if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
- try {
- r.callback.onCallForwardingIndicatorChanged(mCallForwarding);
- } catch (RemoteException ex) {
- remove(r.binder);
- }
- }
- if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
-// try {
-// //we do not forward now!
-// //r.callback.onCellLocationChanged(new Bundle(mCellLocation));
-// } catch (RemoteException ex) {
-// remove(r.binder);
-// }
- }
- if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
- try {
- r.callback.onCallStateChanged(mCallState, mCallIncomingNumber);
- } catch (RemoteException ex) {
- remove(r.binder);
- }
- }
- if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
- try {
- r.callback.onDataConnectionStateChanged(mDataConnectionState,
- mDataConnectionNetworkType);
- } catch (RemoteException ex) {
- remove(r.binder);
- }
- }
- if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
- try {
- r.callback.onDataActivity(mDataActivity);
- } catch (RemoteException ex) {
- remove(r.binder);
- }
- }
- if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
- try {
- r.callback.onSignalStrengthsChanged(mSignalStrength);
- } catch (RemoteException ex) {
- remove(r.binder);
- }
- }
- if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
- try {
- r.callback.onOtaspChanged(mOtaspMode);
- } catch (RemoteException ex) {
- remove(r.binder);
- }
- }
- if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
-// try {
-// //we also do not forward now
-// //r.callback.onCellInfoChanged(new CellInfo(mCellInfo));
-// } catch (RemoteException ex) {
-// remove(r.binder);
-// }
- }
- }
- }
- } else {
- remove(callback.asBinder());
- }
+
+ if(!isPackageAllowed(PERMISSION_CELL_LOCATION, pkgForDebug) || !isPackageAllowed(PERMISSION_CELL_INFO, pkgForDebug)) {
+ Log.i(P_TAG, "package: " + pkgForDebug + " is now listening. notifyNow: false. isAllowed: false");
+ super.listen(pkgForDebug, callback, events, false);
+ } else {
+ Log.i(P_TAG, "package: " + pkgForDebug + " is now listening. notifyNow: " + notifyNow + ". isAllowed: true");
+ super.listen(pkgForDebug, callback, events, notifyNow);
+ }
}
private boolean isPackageAllowed(int PERMISSION, String packageName){
+ if(pSetMan == null) pSetMan = new PrivacySettingsManager(context, IPrivacySettingsManager.Stub.asInterface(ServiceManager.getService("privacy")));
PrivacySettings settings = pSetMan.getSettings(packageName, Process.myUid());
- if(settings == null) return false;
+ if(settings == null){
+ Log.e(P_TAG,"package: " + packageName + " allowed, no settings");
+ return true;
+ }
switch(PERMISSION){
case PERMISSION_CELL_LOCATION:
- if(((settings.getLocationNetworkSetting() != PrivacySettings.REAL) || (settings.getLocationGpsSetting() != PrivacySettings.REAL)))
+ if(settings.getLocationNetworkSetting() != PrivacySettings.REAL)
return false;
else
return true;