|
@@ -10,6 +10,7 @@ import android.os.Bundle
|
10
|
10
|
import android.os.IBinder
|
11
|
11
|
import android.util.Log
|
12
|
12
|
import cn.com.microtrust.firewall.aidl.IAFWService
|
|
13
|
+import com.xhly.corelib.utils.AppUtils
|
13
|
14
|
|
14
|
15
|
|
15
|
16
|
object AfwUtils {
|
|
@@ -98,27 +99,63 @@ object AfwUtils {
|
98
|
99
|
}
|
99
|
100
|
return sb.toString()
|
100
|
101
|
}
|
101
|
|
- fun getNetAppWhiteList():String{
|
102
|
|
- val sb=StringBuffer()
|
103
|
|
- sb.append("白名单应用")
|
|
102
|
+ fun getNetAppWhiteList(context: Context):ArrayList<String>{
|
|
103
|
+ val appList= arrayListOf<String>()
|
104
|
104
|
try {
|
|
105
|
+ var getAllAppList = AppUtils.GetAllAppList(context)
|
105
|
106
|
if (iafwService != null) {
|
106
|
107
|
val afwRes = iafwService!!.whiteRules
|
107
|
108
|
val data = afwRes.data
|
108
|
109
|
for (i in data.indices) {
|
109
|
110
|
Log.i(TAG, "whiteRules=" + data[i])
|
110
|
|
- sb.append(data[i])
|
|
111
|
+ try {
|
|
112
|
+ //转换成功则认为是APP否则是网址
|
|
113
|
+ val toInt = data[i].toInt()
|
|
114
|
+ getAllAppList.forEach { appInfo ->
|
|
115
|
+ if (getUUid(context,appInfo.packageName).toInt() == toInt) {
|
|
116
|
+ appList.add(appInfo.packageName)
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+ }catch (e:Exception){
|
|
120
|
+
|
|
121
|
+ }
|
111
|
122
|
}
|
112
|
123
|
} else {
|
113
|
124
|
Log.i(TAG, "iafwService=null")
|
114
|
|
- sb.append("iafwService=null")
|
115
|
125
|
}
|
116
|
126
|
} catch (e: java.lang.Exception) {
|
117
|
127
|
e.printStackTrace()
|
118
|
128
|
Log.e(TAG, e.toString())
|
119
|
|
- sb.append("有问题$e")
|
120
|
129
|
}
|
121
|
|
- return sb.toString()
|
|
130
|
+ return appList
|
|
131
|
+ }
|
|
132
|
+
|
|
133
|
+ /**
|
|
134
|
+ * 获得网址白名单
|
|
135
|
+ */
|
|
136
|
+ fun getUrlWhiteList():ArrayList<String>{
|
|
137
|
+ val urlList= arrayListOf<String>()
|
|
138
|
+ try {
|
|
139
|
+ if (iafwService != null) {
|
|
140
|
+ val afwRes = iafwService!!.whiteRules
|
|
141
|
+ val data = afwRes.data
|
|
142
|
+ for (i in data.indices) {
|
|
143
|
+ Log.i(TAG, "whiteRules=" + data[i])
|
|
144
|
+ try {
|
|
145
|
+ //转换成功则认为是APP否则是网址
|
|
146
|
+ data[i].toInt()
|
|
147
|
+ }catch (e:Exception){
|
|
148
|
+ urlList.add(data[i])
|
|
149
|
+ }
|
|
150
|
+ }
|
|
151
|
+ } else {
|
|
152
|
+ Log.i(TAG, "iafwService=null")
|
|
153
|
+ }
|
|
154
|
+ } catch (e: java.lang.Exception) {
|
|
155
|
+ e.printStackTrace()
|
|
156
|
+ Log.e(TAG, e.toString())
|
|
157
|
+ }
|
|
158
|
+ return urlList
|
122
|
159
|
}
|
123
|
160
|
|
124
|
161
|
/**
|