|
140
|
isEncrypt = false;
|
|
141
|
}
|
|
142
|
storageCallback("getOfflineCache",callback);
|
|
143
|
return execute("getOfflineCache", [key,defValue,isEncrypt],err);
|
|
144
|
},removeOfflineCache:function(key,err){
|
|
145
|
execute("removeOfflineCache", [key],err);
|
|
146
|
},clearOfflineCache:function(err){
|
|
147
|
execute("clearOfflineCache", [],err);
|
|
148
|
},writeFile:function(content,fileName,type,isSdcard,err){
|
|
149
|
execute("writeFile",[content,fileName,type,isSdcard],err);
|
|
150
|
},appendFile:function(content,fileName,type,isSdcard,err){
|
|
151
|
execute("appendFile",[content,fileName,type,isSdcard],err);
|
|
152
|
},readFile:function(callback,fileName,type,isSdcard,isEscape,err){
|
|
153
|
storageCallback("readFile",callback,isEscape);
|
|
154
|
execute("readFile",[fileName,type,isSdcard,isEscape],err);
|
|
155
|
},openFile:function(filename,type,isSdcard,err){
|
|
156
|
execute("openFile", [filename,type,isSdcard],err);
|
|
157
|
},deleteFile:function(filename,type,isSdcard,err){
|
|
158
|
execute("deleteFile", [filename,type,isSdcard],err);
|
|
159
|
},getAllFile:function(callback,filename,type,isSdcard,err){
|
|
160
|
storageCallback("getAllFile", callback);
|
|
161
|
execute("getAllFile", [filename,type,isSdcard],err);
|
|
162
|
},getRelativePath:function(callback,filename,type,err){
|
|
163
|
storageCallback("getRelativePath",callback);
|
|
164
|
execute("getRelativePath", [filename,type],err);
|
|
165
|
},cleanResource:function(type,isSdcard,err){
|
|
166
|
execute("cleanResource",[type,isSdcard],err);
|
|
167
|
},shareByBluetooth:function(err){
|
|
168
|
execute("shareByBluetooth", [],err);
|
|
169
|
},openBrowser:function(url,err){
|
|
170
|
execute("openBrowser",[url],err);
|
|
171
|
},openIpuBrowser:function(url,hasTitle,err){
|
|
172
|
execute("openIpuBrowser",[url,hasTitle],err);
|
|
173
|
},setSmsListener:function(callback,telString,err){
|
|
174
|
storageCallback("setSmsListener", callback);
|
|
175
|
execute("setSmsListener", [telString],err);
|
|
176
|
},audioRecord:function(callback,auto,err){
|
|
177
|
if(auto == undefined) {
|
|
178
|
auto = false; //false-按住录音,true-自动录音
|
|
179
|
}
|
|
180
|
storageCallback("audioRecord",callback);
|
|
181
|
execute("audioRecord", [auto],err);
|
|
182
|
},audioPlay:function(audioPath,hasRipple,err){
|
|
183
|
if (hasRipple == undefined) {
|
|
184
|
hasRipple = true; //true-弹出波纹,false-无效果
|
|
185
|
}
|
|
186
|
execute("audioPlay",[audioPath,hasRipple],err);
|
|
187
|
},logCat:function(msg,title,err){
|
|
188
|
//将日志输出至LogCat控制台(异步)
|
|
189
|
execute("logCat",[msg,title],err);
|
|
190
|
},execSQL:function(dbName,sql,bindArgs,limit,offset,callback,err){
|
|
191
|
if(bindArgs == undefined){
|
|
192
|
bindArgs = new Wade.DataMap();
|
|
193
|
}
|
|
194
|
if(limit == null)
|
|
195
|
limit = "";
|
|
196
|
else if(!isNaN(limit))
|
|
197
|
limit = "\"" + limit + "\"";
|
|
198
|
|
|
199
|
if(offset == null)
|
|
200
|
offset = "";
|
|
201
|
else if(!isNaN(offset))
|
|
202
|
offset = "\"" + offset + "\"";
|
|
203
|
|
|
204
|
storageCallback("execSQL",callback);
|
|
205
|
execute("execSQL",[dbName,sql,bindArgs.toString(),limit,offset],err);
|
|
206
|
},insert:function(dbName,table,datas,callback,err){
|
|
207
|
if(datas==undefined){
|
|
208
|
datas = new Wade.DataMap();
|
|
209
|
}
|
|
210
|
storageCallback("insert",callback);
|
|
211
|
execute("insert",[dbName,table,datas.toString()],err);
|
|
212
|
},delete:function(dbName,table,condSQL,conds,callback,err){
|
|
213
|
if(conds==undefined){
|
|
214
|
conds = new Wade.DataMap();
|
|
215
|
}
|
|
216
|
storageCallback("delete",callback);
|
|
217
|
execute("delete",[dbName,table,condSQL,conds.toString()],err);
|
|
218
|
},update:function(dbName,table,datas,condSQL,conds,callback,err){
|
|
219
|
if(datas==undefined){
|
|
220
|
datas = new Wade.DataMap();
|
|
221
|
}
|
|
222
|
if(conds==undefined){
|
|
223
|
conds = new Wade.DataMap();
|
|
224
|
}
|
|
225
|
storageCallback("update",callback);
|
|
226
|
execute("update",[dbName,table,datas.toString(),condSQL,conds.toString()],err);
|
|
227
|
},select:function(dbName,table,columns,condSQL,conds,limit,offset,callback,err){
|
|
228
|
if(columns == null){
|
|
229
|
columns = new Array();
|
|
230
|
}
|
|
231
|
if(conds == null){
|
|
232
|
conds = new Wade.DataMap();
|
|
233
|
}
|
|
234
|
if(limit == null)
|
|
235
|
limit = "";
|
|
236
|
else if(!isNaN(limit))
|
|
237
|
limit = "\"" + limit + "\"";
|
|
238
|
|
|
239
|
if(offset == null)
|
|
240
|
offset = "";
|
|
241
|
else if(!isNaN(offset))
|
|
242
|
offset = "\"" + offset + "\"";
|
|
243
|
|
|
244
|
storageCallback("select",callback);
|
|
245
|
execute("select",[dbName,table,columns,condSQL,conds.toString(),limit,offset],err);
|
|
246
|
},selectFirst:function(dbName,table,columns,condSQL,conds,callback,err){
|
|
247
|
this.select(dbName,table,columns,condSQL,conds,1,0,callback,err);
|
|
248
|
},registerForPush:function(account,callback,err){
|
|
249
|
storageCallback("registerForPush",callback);
|
|
250
|
execute("registerForPush",[account],err);
|
|
251
|
},unregisterForPush:function(callback){
|
|
252
|
storageCallback("unregisterForPush",callback);
|
|
253
|
execute("unregisterForPush", []);
|
|
254
|
},sendText:function(account,content,callback,err){
|
|
255
|
storageCallback("sendText",callback);
|
|
256
|
execute("sendText", [account,content],err);
|
|
257
|
},setCallbackForPush:function(callback){
|
|
258
|
execute("setCallbackForPush", [callback]);
|
|
259
|
},registerForPushWithYunba:function(account,callback,err){
|
|
260
|
storageCallback("registerForPushWithYunba",callback);
|
|
261
|
execute("registerForPushWithYunba",[account],err);
|
|
262
|
},unregisterForPushWithYunba:function(callback){
|
|
263
|
storageCallback("unregisterForPushWithYunba",callback);
|
|
264
|
execute("unregisterForPushWithYunba", []);
|
|
265
|
},sendTextWithYunba:function(account,content,callback,err){
|
|
266
|
storageCallback("sendTextWithYunba",callback);
|
|
267
|
execute("sendTextWithYunba", [account,content],err);
|
|
268
|
},setCallbackForPushWithYunba:function(callback){
|
|
269
|
execute("setCallbackForPushWithYunba", [callback]);
|
|
270
|
},aliPay:function(tradeNo,subject,body,price,callback,err){
|
|
271
|
storageCallback("aliPay",callback);
|
|
272
|
execute("aliPay",[tradeNo,subject,body,price],err);
|
|
273
|
},uploadWithServlet:function(filePath,dataAction,param,callback,err){
|
|
274
|
if(typeof(filePath)=="string"){
|
|
275
|
filePath = [filePath];
|
|
276
|
}
|
|
277
|
storageCallback("uploadWithServlet",callback);
|
|
278
|
execute("uploadWithServlet",[filePath,dataAction,param],err);
|
|
279
|
},downloadWithServlet:function(savePath,dataAction,param,callback,err){
|
|
280
|
storageCallback("downloadWithServlet",callback);
|
|
281
|
execute("downloadWithServlet",[savePath,dataAction,param],err);
|
|
282
|
},uploadFile:function(filePath,servletUrl,callback,err){
|
|
283
|
storageCallback("uploadFile",callback);
|
|
284
|
execute("uploadFile",[filePath,servletUrl],err);
|
|
285
|
},downloadFile:function(savePath,servletUrl,callback,err){
|
|
286
|
storageCallback("downloadFile",callback);
|
|
287
|
execute("downloadFile",[savePath,servletUrl],err);
|
|
288
|
},recordVideo:function(callback,compressRatio,timeLimit,err){
|
|
289
|
storageCallback("recordVideo",callback);
|
|
290
|
execute("recordVideo",[compressRatio,timeLimit],err);
|
|
291
|
},playVideo:function(videoPath,callback,err){
|
|
292
|
storageCallback("playVideo",callback);
|
|
293
|
execute("playVideo",[videoPath],err);
|
|
294
|
},getContacts:function(callback,err){
|
|
295
|
storageCallback("getContacts",callback);
|
|
296
|
execute("getContacts",[], err);
|
|
297
|
},openKeyboard:function(value,err){
|
|
298
|
execute("openKeyboard",[value],err);
|
|
299
|
},setScreenLock:function(dataParam,callback,err){
|
|
300
|
storageCallback("setScreenLock",callback);
|
|
301
|
execute("setScreenLock",[dataParam],err);
|
|
302
|
},getScreenLockState:function(callback,err){
|
|
303
|
storageCallback("getScreenLockState",callback);
|
|
304
|
execute("getScreenLockState",[],err);
|
|
305
|
},screenUnlock:function(forgetPageAction,callback,err){
|
|
306
|
storageCallback("screenUnlock",callback);
|
|
307
|
execute("screenUnlock",[forgetPageAction],err);
|
|
308
|
},initNfc:function(cmds,callbackName,err) {
|
|
309
|
execute("initNfc", [cmds, callbackName], err);
|
|
310
|
},scanSingle:function(callback){
|
|
311
|
storageCallback("scanSingle",callback);
|
|
312
|
execute("scanSingle",[]);
|
|
313
|
},scanMultiple:function(callback){
|
|
314
|
storageCallback("scanMultiple",callback);
|
|
315
|
execute("scanMultiple",[]);
|
|
316
|
},showNotification:function(content,title,icon,id){
|
|
317
|
execute("showNotification",[content,title,icon,id]);
|
|
318
|
},startListen:function(callback,err){
|
|
319
|
if(callback){
|
|
320
|
storageCallback("startListen",callback);
|
|
321
|
}
|
|
322
|
execute("startListen",[],err);
|
|
323
|
},voiceSpeak:function(content,err){
|
|
324
|
execute("voiceSpeak",[content],err);
|
|
325
|
},shareTextQQFriend:function(content){
|
|
326
|
execute("shareTextQQFriend",[content]);
|
|
327
|
},shareTextWeChatFriend:function(content){
|
|
328
|
execute("shareTextWeChatFriend",[content]);
|
|
329
|
},shareFileQQFriend:function(type,content){
|
|
330
|
execute("shareFileQQFriend",[type,content]);
|
|
331
|
},shareFileWeChatFriend:function(type,content){
|
|
332
|
execute("shareFileWeChatFriend",[type,content]);
|
|
333
|
},shareTextMore:function(content){
|
|
334
|
execute("shareTextMore",[content]);
|
|
335
|
},shareFileMore:function(type,content){
|
|
336
|
execute("shareFileMore",[type,content]);
|
|
337
|
},shareImageBymail:function(param){
|
|
338
|
execute("shareImageBymail",[param]);
|
|
339
|
},baiduLocation:function(callback,err){
|
|
340
|
storageCallback("baiduLocation",callback);
|
|
341
|
execute("baiduLocation",[],err);
|
|
342
|
},baiduMapLocation:function(callback,err){
|
|
343
|
execute("baiduMapLocation",[],err);
|
|
344
|
},baiduMapPosition:function(pointParam,err){
|
|
345
|
execute("baiduMapPosition",[pointParam.toString()],err);
|
|
346
|
},addPolygon:function(markParams,err){
|
|
347
|
execute("addPolygon",[markParams.toString()],err);
|
|
348
|
},clickBaiduMap:function(callback,err){
|
|
349
|
storageCallback("clickBaiduMap",callback);
|
|
350
|
execute("clickBaiduMap",[],err);
|
|
351
|
},videoCompressor:function(param){
|
|
352
|
execute("videoCompressor",[param]);
|
|
353
|
},sweetAlert:function(param){
|
|
354
|
execute("sweetAlert",[param]);
|
|
355
|
},sweetConfirm:function(param){
|
|
356
|
execute("sweetConfirm",[param]);
|
|
357
|
},sweetLoading:function(param){
|
|
358
|
execute("sweetLoading",[param]);
|
|
359
|
},poiCitySearch:function(city,keyword,err){
|
|
360
|
execute("poiCitySearch",[city,keyword],err);
|
|
361
|
},poiNearbySearch:function(latlon,radius,keyword,err){
|
|
362
|
execute("poiNearbySearch",[latlon.toString(),radius,keyword],err);
|
|
363
|
},poiBoundsSearch:function(swParam,neParam,keyword,err){
|
|
364
|
execute("poiBoundsSearch",[swParam.toString(),neParam.toString(),keyword],err);
|
|
365
|
},lbsLocalSearch:function(ak,geoTableId,q,region,err){
|
|
366
|
execute("lbsLocalSearch",[ak,geoTableId,q,region],err);
|
|
367
|
},lbsNearbySearch:function(ak,geoTableId,q,loc,radius,err){
|
|
368
|
execute("lbsNearbySearch",[ak,geoTableId,q,loc,radius],err);
|
|
369
|
},lbsBoundsSearch:function(ak,geoTableId,q,bounds,err){
|
|
370
|
execute("lbsBoundsSearch",[ak,geoTableId,q,bounds],err);
|
|
371
|
},testUnRegister:function(callback){
|
|
372
|
execute("testUnRegister",[]);
|
|
373
|
},openPathMenu:function(param){
|
|
374
|
execute("openPathMenu",[param]);
|
|
375
|
},closePathMenu:function(){
|
|
376
|
execute("closePathMenu",[]);
|
|
377
|
},clearBackStack:function(){
|
|
378
|
if(WadeMobile.isAndroid()){
|
|
379
|
execute("clearBackStack",[]);
|
|
380
|
}
|
|
381
|
}
|
|
382
|
|
|
383
|
|
|
384
|
};
|
|
385
|
})();
|
|
386
|
|
|
387
|
var WadeMobile;
|
|
388
|
function execute(action, args, error, success) {
|
|
389
|
/*循环依赖,懒加载*/
|
|
390
|
if(!WadeMobile){
|
|
391
|
WadeMobile = require("wadeMobile")
|
|
392
|
}
|
|
393
|
return WadeMobile.execute(action, args, error, success)
|
|
394
|
}
|
|
395
|
function storageCallback(action,callback) {
|
|
396
|
/*循环依赖,懒加载*/
|
|
397
|
if(!WadeMobile){
|
|
398
|
WadeMobile = require("wadeMobile")
|
|
399
|
}
|
|
400
|
WadeMobile.callback.storageCallback(action,callback)
|
|
401
|
}
|
|
402
|
|
|
403
|
return ExpandMobile;
|
|
404
|
});
|
|
@ -1,243 +1,251 @@
|
1
|
|
package com.ai.ipu.mobile.plugin;
|
2
|
|
|
3
|
|
import java.net.InetAddress;
|
4
|
|
import java.net.NetworkInterface;
|
5
|
|
import java.net.SocketException;
|
6
|
|
import java.util.Enumeration;
|
7
|
|
import java.util.TimeZone;
|
8
|
|
|
9
|
|
import org.json.JSONArray;
|
10
|
|
|
11
|
|
import android.content.Context;
|
12
|
|
import android.net.wifi.WifiInfo;
|
13
|
|
import android.net.wifi.WifiManager;
|
14
|
|
import android.provider.Settings;
|
15
|
|
import android.telephony.TelephonyManager;
|
16
|
|
|
17
|
|
import com.ai.ipu.mobile.frame.IIpuMobile;
|
18
|
|
import com.ai.ipu.mobile.frame.plugin.Plugin;
|
19
|
|
import com.ai.ipu.mobile.util.FuncConstant;
|
20
|
|
import com.ai.ipu.mobile.util.Messages;
|
21
|
|
import com.ailk.common.data.IData;
|
22
|
|
import com.ailk.common.data.impl.DataMap;
|
23
|
|
import com.mashape.relocation.conn.util.InetAddressUtils;
|
24
|
|
|
25
|
|
public class MobileInfo extends Plugin {
|
26
|
|
public String platform = "Android";
|
27
|
|
|
28
|
|
public MobileInfo(IIpuMobile ipumobile) {
|
29
|
|
super(ipumobile);
|
30
|
|
}
|
31
|
|
|
32
|
|
public void getTerminalType(JSONArray params) throws Exception {
|
33
|
|
callback("a");// 终端类型为android
|
34
|
|
}
|
35
|
|
|
36
|
|
/**
|
37
|
|
* 获取系统信息
|
38
|
|
*
|
39
|
|
* @param key
|
40
|
|
* @return
|
41
|
|
* @throws Exception
|
42
|
|
*/
|
43
|
|
public void getSysInfo(JSONArray params) throws Exception {
|
44
|
|
if (params.length() < 1) {
|
45
|
|
throw new Exception(Messages.EXCEPTION_PARAM);
|
46
|
|
}
|
47
|
|
String key = params.getString(0).toUpperCase();
|
48
|
|
if (key.equals(FuncConstant.PLATFORM)) {
|
49
|
|
callback(this.getPlatform());
|
50
|
|
}
|
51
|
|
else if (key.equals(FuncConstant.IMEI)) {
|
52
|
|
callback(this.getImei());
|
53
|
|
}
|
54
|
|
else if (key.equals(FuncConstant.UUID)) {
|
55
|
|
callback(this.getUuid());
|
56
|
|
}
|
57
|
|
else if (key.equals(FuncConstant.SIMNUMBER)) {
|
58
|
|
callback(this.getSimNumber());
|
59
|
|
}
|
60
|
|
else if (key.equals(FuncConstant.IMSI)) {
|
61
|
|
callback(this.getImsi());
|
62
|
|
}
|
63
|
|
else if (key.equals(FuncConstant.OSVERSION)) {
|
64
|
|
callback(this.getOSVersion());
|
65
|
|
}
|
66
|
|
else if (key.equals(FuncConstant.SDKVERSION)) {
|
67
|
|
callback(this.getSDKVersion());
|
68
|
|
}
|
69
|
|
else if (key.equals(FuncConstant.TIMEZONEID)) {
|
70
|
|
callback(this.getTimeZoneID());
|
71
|
|
}
|
72
|
|
else if (key.equals(FuncConstant.MODEL)) {
|
73
|
|
callback(this.getModel());
|
74
|
|
}
|
75
|
|
else if (key.equals(FuncConstant.MANUFACTURER)) {
|
76
|
|
callback(this.getManufacturer());
|
77
|
|
}
|
78
|
|
else if (key.equals(FuncConstant.BRAND)) {
|
79
|
|
callback(this.getBrand());
|
80
|
|
}
|
81
|
|
else if (key.equals(FuncConstant.PRODUCTNAME)) {
|
82
|
|
callback(this.getProductName());
|
83
|
|
}
|
84
|
|
else if (key.equals(FuncConstant.ALL)) {
|
85
|
|
callback(this.getAll());
|
86
|
|
}
|
87
|
|
else {
|
88
|
|
callback(Messages.NO_INFO);
|
89
|
|
}
|
90
|
|
}
|
91
|
|
|
92
|
|
public String getAll() throws SocketException {
|
93
|
|
IData data = new DataMap();
|
94
|
|
data.put(FuncConstant.PLATFORM, this.getPlatform());
|
95
|
|
data.put(FuncConstant.IMEI, this.getImei());
|
96
|
|
data.put(FuncConstant.UUID, this.getUuid());
|
97
|
|
data.put(FuncConstant.SIMNUMBER, this.getSimNumber());
|
98
|
|
data.put(FuncConstant.IMSI, this.getImsi());
|
99
|
|
data.put(FuncConstant.OSVERSION, this.getOSVersion());
|
100
|
|
data.put(FuncConstant.SDKVERSION, this.getSDKVersion());
|
101
|
|
data.put(FuncConstant.TIMEZONEID, this.getTimeZoneID());
|
102
|
|
data.put(FuncConstant.MODEL, this.getModel());
|
103
|
|
data.put(FuncConstant.MANUFACTURER, this.getManufacturer());
|
104
|
|
data.put(FuncConstant.MAC, this.getMac());
|
105
|
|
data.put(FuncConstant.IP, this.getIP());
|
106
|
|
data.put(FuncConstant.IPV6, this.getIPV6());
|
107
|
|
data.put(FuncConstant.BRAND, this.getBrand());
|
108
|
|
data.put(FuncConstant.PRODUCTNAME, this.getProductName());
|
109
|
|
return data.toString();
|
110
|
|
}
|
111
|
|
|
112
|
|
public String getPlatform() {
|
113
|
|
return platform;
|
114
|
|
}
|
115
|
|
|
116
|
|
public String getUuid() {
|
117
|
|
String uuid = Settings.Secure.getString(this.context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
118
|
|
return uuid;
|
119
|
|
}
|
120
|
|
|
121
|
|
public String getTelNumber() {
|
122
|
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
123
|
|
return manager.getLine1Number();
|
124
|
|
}
|
125
|
|
|
126
|
|
public String getImei() {
|
127
|
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
128
|
|
return manager.getDeviceId();
|
129
|
|
}
|
130
|
|
|
131
|
|
public String getSimNumber() {
|
132
|
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
133
|
|
return manager.getSimSerialNumber();
|
134
|
|
}
|
135
|
|
|
136
|
|
public String getImsi() {
|
137
|
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
138
|
|
return manager.getSubscriberId();
|
139
|
|
}
|
140
|
|
|
141
|
|
public String getOSVersion() {
|
142
|
|
String osversion = android.os.Build.VERSION.RELEASE;
|
143
|
|
return osversion;
|
144
|
|
}
|
145
|
|
|
146
|
|
public String getSDKVersion() {
|
147
|
|
String sdkversion = android.os.Build.VERSION.SDK;
|
148
|
|
return sdkversion;
|
149
|
|
}
|
150
|
|
|
151
|
|
public String getTimeZoneID() {
|
152
|
|
TimeZone tz = TimeZone.getDefault();
|
153
|
|
return (tz.getID());
|
154
|
|
}
|
155
|
|
|
156
|
|
public String getManufacturer() {
|
157
|
|
String manufacturer = android.os.Build.MANUFACTURER;
|
158
|
|
return manufacturer;
|
159
|
|
}
|
160
|
|
|
161
|
|
public String getBrand() {
|
162
|
|
String brand = android.os.Build.BRAND;
|
163
|
|
return brand;
|
164
|
|
}
|
165
|
|
|
166
|
|
public String getModel() {
|
167
|
|
String model = android.os.Build.MODEL;
|
168
|
|
return model;
|
169
|
|
}
|
170
|
|
|
171
|
|
public String getProductName() {
|
172
|
|
String productname = android.os.Build.PRODUCT;
|
173
|
|
return productname;
|
174
|
|
}
|
175
|
|
|
176
|
|
/***************** network *************************/
|
177
|
|
public void getNetInfo(JSONArray params) throws Exception {
|
178
|
|
if (params.length() < 1) {
|
179
|
|
throw new Exception(Messages.EXCEPTION_PARAM);
|
180
|
|
}
|
181
|
|
String key = params.getString(0).toUpperCase();
|
182
|
|
if (key.equals(FuncConstant.MAC)) {
|
183
|
|
callback(getMac());
|
184
|
|
}
|
185
|
|
else if (key.equals(FuncConstant.IP)) {
|
186
|
|
callback(getIP());
|
187
|
|
}
|
188
|
|
else if (key.equals(FuncConstant.IPV4)) {
|
189
|
|
callback(getIPV4());
|
190
|
|
}
|
191
|
|
else if (key.equals(FuncConstant.IPV6)) {
|
192
|
|
callback(getIPV6());
|
193
|
|
}
|
194
|
|
}
|
195
|
|
|
196
|
|
public String getMac() {
|
197
|
|
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
198
|
|
WifiInfo info = wifi.getConnectionInfo();
|
199
|
|
return info.getMacAddress();
|
200
|
|
}
|
201
|
|
|
202
|
|
public String getIP() throws SocketException {
|
203
|
|
return getIPV4();
|
204
|
|
}
|
205
|
|
|
206
|
|
/**
|
207
|
|
* 获取IPV6地址
|
208
|
|
*/
|
209
|
|
public String getIPV6() throws SocketException {
|
210
|
|
String ipv6 = null;
|
211
|
|
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
|
212
|
|
NetworkInterface intf = en.nextElement();
|
213
|
|
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
214
|
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
215
|
|
String ipv6s = inetAddress.getHostAddress();
|
216
|
|
if (ipv6s.contains("::") && ipv6s.contains("%")) {
|
217
|
|
ipv6 = ipv6s.substring(0, ipv6s.indexOf("%"));
|
218
|
|
if (InetAddressUtils.isIPv6Address(ipv6)) {
|
219
|
|
return ipv6;
|
220
|
|
}
|
221
|
|
}
|
222
|
|
}
|
223
|
|
}
|
224
|
|
return null;
|
225
|
|
}
|
226
|
|
|
227
|
|
/**
|
228
|
|
* 获取IPV4地址
|
229
|
|
*/
|
230
|
|
public String getIPV4() throws SocketException {
|
231
|
|
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
|
232
|
|
NetworkInterface intf = en.nextElement();
|
233
|
|
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
234
|
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
235
|
|
if (!inetAddress.isLoopbackAddress() && InetAddressUtils.isIPv4Address(inetAddress.getHostAddress())) {
|
236
|
|
return inetAddress.getHostAddress().toString();
|
237
|
|
}
|
238
|
|
}
|
239
|
|
}
|
240
|
|
return null;
|
241
|
|
}
|
242
|
|
|
243
|
|
}
|
|
1
|
package com.ai.ipu.mobile.plugin;
|
|
2
|
|
|
3
|
import java.net.InetAddress;
|
|
4
|
import java.net.NetworkInterface;
|
|
5
|
import java.net.SocketException;
|
|
6
|
import java.util.Enumeration;
|
|
7
|
import java.util.TimeZone;
|
|
8
|
|
|
9
|
import org.json.JSONArray;
|
|
10
|
|
|
11
|
import android.content.Context;
|
|
12
|
import android.net.wifi.WifiInfo;
|
|
13
|
import android.net.wifi.WifiManager;
|
|
14
|
import android.provider.Settings;
|
|
15
|
import android.telephony.TelephonyManager;
|
|
16
|
|
|
17
|
import com.ai.ipu.mobile.frame.IIpuMobile;
|
|
18
|
import com.ai.ipu.mobile.frame.plugin.Plugin;
|
|
19
|
import com.ai.ipu.mobile.ui.UiTool;
|
|
20
|
import com.ai.ipu.mobile.util.FuncConstant;
|
|
21
|
import com.ai.ipu.mobile.util.Messages;
|
|
22
|
import com.ailk.common.data.IData;
|
|
23
|
import com.ailk.common.data.impl.DataMap;
|
|
24
|
import com.mashape.relocation.conn.util.InetAddressUtils;
|
|
25
|
|
|
26
|
public class MobileInfo extends Plugin {
|
|
27
|
public String platform = "Android";
|
|
28
|
|
|
29
|
public MobileInfo(IIpuMobile ipumobile) {
|
|
30
|
super(ipumobile);
|
|
31
|
}
|
|
32
|
|
|
33
|
public void getTerminalType(JSONArray params) throws Exception {
|
|
34
|
callback("a");// 终端类型为android
|
|
35
|
}
|
|
36
|
|
|
37
|
/**
|
|
38
|
* 获取系统信息
|
|
39
|
*
|
|
40
|
* @param key
|
|
41
|
* @return
|
|
42
|
* @throws Exception
|
|
43
|
*/
|
|
44
|
public void getSysInfo(JSONArray params) throws Exception {
|
|
45
|
if (params.length() < 1) {
|
|
46
|
throw new Exception(Messages.EXCEPTION_PARAM);
|
|
47
|
}
|
|
48
|
String key = params.getString(0).toUpperCase();
|
|
49
|
if (key.equals(FuncConstant.PLATFORM)) {
|
|
50
|
callback(this.getPlatform());
|
|
51
|
}
|
|
52
|
else if (key.equals(FuncConstant.IMEI)) {
|
|
53
|
callback(this.getImei());
|
|
54
|
}
|
|
55
|
else if (key.equals(FuncConstant.UUID)) {
|
|
56
|
callback(this.getUuid());
|
|
57
|
}
|
|
58
|
else if (key.equals(FuncConstant.SIMNUMBER)) {
|
|
59
|
callback(this.getSimNumber());
|
|
60
|
}
|
|
61
|
else if (key.equals(FuncConstant.IMSI)) {
|
|
62
|
callback(this.getImsi());
|
|
63
|
}
|
|
64
|
else if (key.equals(FuncConstant.OSVERSION)) {
|
|
65
|
callback(this.getOSVersion());
|
|
66
|
}
|
|
67
|
else if (key.equals(FuncConstant.SDKVERSION)) {
|
|
68
|
callback(this.getSDKVersion());
|
|
69
|
}
|
|
70
|
else if (key.equals(FuncConstant.TIMEZONEID)) {
|
|
71
|
callback(this.getTimeZoneID());
|
|
72
|
}
|
|
73
|
else if (key.equals(FuncConstant.MODEL)) {
|
|
74
|
callback(this.getModel());
|
|
75
|
}
|
|
76
|
else if (key.equals(FuncConstant.MANUFACTURER)) {
|
|
77
|
callback(this.getManufacturer());
|
|
78
|
}
|
|
79
|
else if (key.equals(FuncConstant.BRAND)) {
|
|
80
|
callback(this.getBrand());
|
|
81
|
}
|
|
82
|
else if (key.equals(FuncConstant.PRODUCTNAME)) {
|
|
83
|
callback(this.getProductName());
|
|
84
|
}
|
|
85
|
else if(key.equals(FuncConstant.STATUSBARHEIGHT)){
|
|
86
|
callback(this.getStatusBarHeight());
|
|
87
|
}
|
|
88
|
else if (key.equals(FuncConstant.ALL)) {
|
|
89
|
callback(this.getAll());
|
|
90
|
}
|
|
91
|
else {
|
|
92
|
callback(Messages.NO_INFO);
|
|
93
|
}
|
|
94
|
}
|
|
95
|
|
|
96
|
public String getAll() throws SocketException {
|
|
97
|
IData data = new DataMap();
|
|
98
|
data.put(FuncConstant.PLATFORM, this.getPlatform());
|
|
99
|
data.put(FuncConstant.IMEI, this.getImei());
|
|
100
|
data.put(FuncConstant.UUID, this.getUuid());
|
|
101
|
data.put(FuncConstant.SIMNUMBER, this.getSimNumber());
|
|
102
|
data.put(FuncConstant.IMSI, this.getImsi());
|
|
103
|
data.put(FuncConstant.OSVERSION, this.getOSVersion());
|
|
104
|
data.put(FuncConstant.SDKVERSION, this.getSDKVersion());
|
|
105
|
data.put(FuncConstant.TIMEZONEID, this.getTimeZoneID());
|
|
106
|
data.put(FuncConstant.MODEL, this.getModel());
|
|
107
|
data.put(FuncConstant.MANUFACTURER, this.getManufacturer());
|
|
108
|
data.put(FuncConstant.MAC, this.getMac());
|
|
109
|
data.put(FuncConstant.IP, this.getIP());
|
|
110
|
data.put(FuncConstant.IPV6, this.getIPV6());
|
|
111
|
data.put(FuncConstant.BRAND, this.getBrand());
|
|
112
|
data.put(FuncConstant.PRODUCTNAME, this.getProductName());
|
|
113
|
return data.toString();
|
|
114
|
}
|
|
115
|
|
|
116
|
public String getPlatform() {
|
|
117
|
return platform;
|
|
118
|
}
|
|
119
|
|
|
120
|
public String getUuid() {
|
|
121
|
String uuid = Settings.Secure.getString(this.context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
|
122
|
return uuid;
|
|
123
|
}
|
|
124
|
|
|
125
|
public String getTelNumber() {
|
|
126
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
127
|
return manager.getLine1Number();
|
|
128
|
}
|
|
129
|
|
|
130
|
public String getImei() {
|
|
131
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
132
|
return manager.getDeviceId();
|
|
133
|
}
|
|
134
|
|
|
135
|
public String getSimNumber() {
|
|
136
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
137
|
return manager.getSimSerialNumber();
|
|
138
|
}
|
|
139
|
|
|
140
|
public String getImsi() {
|
|
141
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
142
|
return manager.getSubscriberId();
|
|
143
|
}
|
|
144
|
|
|
145
|
public String getOSVersion() {
|
|
146
|
String osversion = android.os.Build.VERSION.RELEASE;
|
|
147
|
return osversion;
|
|
148
|
}
|
|
149
|
|
|
150
|
public String getSDKVersion() {
|
|
151
|
String sdkversion = android.os.Build.VERSION.SDK;
|
|
152
|
return sdkversion;
|
|
153
|
}
|
|
154
|
|
|
155
|
public String getTimeZoneID() {
|
|
156
|
TimeZone tz = TimeZone.getDefault();
|
|
157
|
return (tz.getID());
|
|
158
|
}
|
|
159
|
|
|
160
|
public String getManufacturer() {
|
|
161
|
String manufacturer = android.os.Build.MANUFACTURER;
|
|
162
|
return manufacturer;
|
|
163
|
}
|
|
164
|
|
|
165
|
public String getBrand() {
|
|
166
|
String brand = android.os.Build.BRAND;
|
|
167
|
return brand;
|
|
168
|
}
|
|
169
|
|
|
170
|
public String getModel() {
|
|
171
|
String model = android.os.Build.MODEL;
|
|
172
|
return model;
|
|
173
|
}
|
|
174
|
|
|
175
|
public String getProductName() {
|
|
176
|
String productname = android.os.Build.PRODUCT;
|
|
177
|
return productname;
|
|
178
|
}
|
|
179
|
|
|
180
|
/***************** network *************************/
|
|
181
|
public void getNetInfo(JSONArray params) throws Exception {
|
|
182
|
if (params.length() < 1) {
|
|
183
|
throw new Exception(Messages.EXCEPTION_PARAM);
|
|
184
|
}
|
|
185
|
String key = params.getString(0).toUpperCase();
|
|
186
|
if (key.equals(FuncConstant.MAC)) {
|
|
187
|
callback(getMac());
|
|
188
|
}
|
|
189
|
else if (key.equals(FuncConstant.IP)) {
|
|
190
|
callback(getIP());
|
|
191
|
}
|
|
192
|
else if (key.equals(FuncConstant.IPV4)) {
|
|
193
|
callback(getIPV4());
|
|
194
|
}
|
|
195
|
else if (key.equals(FuncConstant.IPV6)) {
|
|
196
|
callback(getIPV6());
|
|
197
|
}
|
|
198
|
}
|
|
199
|
|
|
200
|
public String getMac() {
|
|
201
|
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
|
202
|
WifiInfo info = wifi.getConnectionInfo();
|
|
203
|
return info.getMacAddress();
|
|
204
|
}
|
|
205
|
|
|
206
|
public String getIP() throws SocketException {
|
|
207
|
return getIPV4();
|
|
208
|
}
|
|
209
|
|
|
210
|
/**
|
|
211
|
* 获取IPV6地址
|
|
212
|
*/
|
|
213
|
public String getIPV6() throws SocketException {
|
|
214
|
String ipv6 = null;
|
|
215
|
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
|
|
216
|
NetworkInterface intf = en.nextElement();
|
|
217
|
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
|
218
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
|
219
|
String ipv6s = inetAddress.getHostAddress();
|
|
220
|
if (ipv6s.contains("::") && ipv6s.contains("%")) {
|
|
221
|
ipv6 = ipv6s.substring(0, ipv6s.indexOf("%"));
|
|
222
|
if (InetAddressUtils.isIPv6Address(ipv6)) {
|
|
223
|
return ipv6;
|
|
224
|
}
|
|
225
|
}
|
|
226
|
}
|
|
227
|
}
|
|
228
|
return null;
|
|
229
|
}
|
|
230
|
|
|
231
|
/**
|
|
232
|
* 获取IPV4地址
|
|
233
|
*/
|
|
234
|
public String getIPV4() throws SocketException {
|
|
235
|
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
|
|
236
|
NetworkInterface intf = en.nextElement();
|
|
237
|
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
|
238
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
|
239
|
if (!inetAddress.isLoopbackAddress() && InetAddressUtils.isIPv4Address(inetAddress.getHostAddress())) {
|
|
240
|
return inetAddress.getHostAddress().toString();
|
|
241
|
}
|
|
242
|
}
|
|
243
|
}
|
|
244
|
return null;
|
|
245
|
}
|
|
246
|
|
|
247
|
public String getStatusBarHeight(){
|
|
248
|
return String.valueOf(UiTool.getStatusBarHeight(context));
|
|
249
|
}
|
|
250
|
|
|
251
|
}
|
|
@ -1,29 +1,30 @@
|
1
|
|
package com.ai.ipu.mobile.util;
|
2
|
|
|
3
|
|
public class FuncConstant {
|
4
|
|
public static final String PLATFORM = "PLATFORM";
|
5
|
|
public static final String IMEI = "IMEI";
|
6
|
|
public static final String UUID = "UUID";
|
7
|
|
public static final String SIMNUMBER = "SIMNUMBER";
|
8
|
|
public static final String IMSI = "IMSI";
|
9
|
|
public static final String OSVERSION = "OSVERSION";
|
10
|
|
public static final String SDKVERSION = "SDKVERSION";
|
11
|
|
public static final String TIMEZONEID = "TIMEZONEID";
|
12
|
|
public static final String MODEL = "MODEL";
|
13
|
|
public static final String MANUFACTURER = "MANUFACTURER";
|
14
|
|
public static final String BRAND = "BRAND";
|
15
|
|
public static final String PRODUCTNAME = "PRODUCTNAME";
|
16
|
|
public static final String ALL = "ALL";
|
17
|
|
|
18
|
|
public static final String MAC = "MAC";
|
19
|
|
public static final String IP = "IP";
|
20
|
|
public static final String IPV4 = "IPV4";
|
21
|
|
public static final String IPV6 = "IPV6";
|
22
|
|
|
23
|
|
public static final String CONTENT = "CONTENT";
|
24
|
|
public static final String SENDER = "SENDER";
|
25
|
|
public static final String TIME = "TIME";
|
26
|
|
|
27
|
|
public static final int APP_FILES = 0;
|
28
|
|
public static final int SDCARD_APP_FILES = 1;
|
29
|
|
}
|
|
1
|
package com.ai.ipu.mobile.util;
|
|
2
|
|
|
3
|
public class FuncConstant {
|
|
4
|
public static final String PLATFORM = "PLATFORM";
|
|
5
|
public static final String IMEI = "IMEI";
|
|
6
|
public static final String UUID = "UUID";
|
|
7
|
public static final String SIMNUMBER = "SIMNUMBER";
|
|
8
|
public static final String IMSI = "IMSI";
|
|
9
|
public static final String OSVERSION = "OSVERSION";
|
|
10
|
public static final String SDKVERSION = "SDKVERSION";
|
|
11
|
public static final String TIMEZONEID = "TIMEZONEID";
|
|
12
|
public static final String MODEL = "MODEL";
|
|
13
|
public static final String MANUFACTURER = "MANUFACTURER";
|
|
14
|
public static final String BRAND = "BRAND";
|
|
15
|
public static final String PRODUCTNAME = "PRODUCTNAME";
|
|
16
|
public static final String STATUSBARHEIGHT = "STATUSBARHEIGHT";
|
|
17
|
public static final String ALL = "ALL";
|
|
18
|
|
|
19
|
public static final String MAC = "MAC";
|
|
20
|
public static final String IP = "IP";
|
|
21
|
public static final String IPV4 = "IPV4";
|
|
22
|
public static final String IPV6 = "IPV6";
|
|
23
|
|
|
24
|
public static final String CONTENT = "CONTENT";
|
|
25
|
public static final String SENDER = "SENDER";
|
|
26
|
public static final String TIME = "TIME";
|
|
27
|
|
|
28
|
public static final int APP_FILES = 0;
|
|
29
|
public static final int SDCARD_APP_FILES = 1;
|
|
30
|
}
|