|
@ -16,168 +16,228 @@ import android.telephony.TelephonyManager;
|
16
|
16
|
|
17
|
17
|
import com.ailk.common.data.IData;
|
18
|
18
|
import com.ailk.common.data.impl.DataMap;
|
|
19
|
import com.mashape.relocation.conn.util.InetAddressUtils;
|
19
|
20
|
import com.wade.mobile.frame.IWadeMobile;
|
20
|
21
|
import com.wade.mobile.frame.plugin.Plugin;
|
21
|
22
|
import com.wade.mobile.util.FuncConstant;
|
22
|
23
|
import com.wade.mobile.util.Messages;
|
23
|
24
|
|
|
25
|
public class MobileInfo extends Plugin {
|
|
26
|
public String platform = "Android";
|
24
|
27
|
|
25
|
|
public class MobileInfo extends Plugin{
|
26
|
|
public String platform = "Android";
|
27
|
|
|
28
|
|
public MobileInfo(IWadeMobile wademobile) {
|
29
|
|
super(wademobile);
|
30
|
|
}
|
31
|
|
|
32
|
|
public void getTerminalType(JSONArray params) throws Exception{
|
33
|
|
callback("a");//终端类型为android
|
34
|
|
}
|
35
|
|
|
36
|
|
/**
|
37
|
|
* 获取系统信息
|
38
|
|
* @param key
|
39
|
|
* @return
|
40
|
|
* @throws Exception
|
41
|
|
*/
|
42
|
|
public void getSysInfo(JSONArray params) throws Exception {
|
43
|
|
if(params.length()<1){
|
44
|
|
throw new Exception(Messages.EXCEPTION_PARAM);
|
45
|
|
}
|
46
|
|
String key = params.getString(0).toUpperCase();
|
47
|
|
if(key.equals(FuncConstant.PLATFORM)){
|
48
|
|
callback(this.getPlatform());
|
49
|
|
}else if(key.equals(FuncConstant.IMEI)){
|
50
|
|
callback(this.getImei());
|
51
|
|
}else if(key.equals(FuncConstant.UUID)){
|
52
|
|
callback(this.getUuid());
|
53
|
|
}else if(key.equals(FuncConstant.SIMNUMBER)){
|
54
|
|
callback(this.getSimNumber());
|
55
|
|
}else if(key.equals(FuncConstant.IMSI)){
|
56
|
|
callback(this.getImsi());
|
57
|
|
}else if(key.equals(FuncConstant.OSVERSION)){
|
58
|
|
callback(this.getOSVersion());
|
59
|
|
}else if(key.equals(FuncConstant.SDKVERSION)){
|
60
|
|
callback(this.getSDKVersion());
|
61
|
|
}else if(key.equals(FuncConstant.TIMEZONEID)){
|
62
|
|
callback(this.getTimeZoneID());
|
63
|
|
}else if(key.equals(FuncConstant.MODEL)){
|
64
|
|
callback(this.getModel());
|
65
|
|
}else if(key.equals(FuncConstant.MANUFACTURER)){
|
66
|
|
callback(this.getManufacturer());
|
67
|
|
}else if(key.equals(FuncConstant.ALL)){
|
68
|
|
}else{
|
69
|
|
callback(Messages.NO_INFO);
|
70
|
|
}
|
71
|
|
}
|
72
|
|
public String getAll() throws SocketException{
|
73
|
|
IData data = new DataMap();
|
74
|
|
data.put(FuncConstant.PLATFORM, this.getPlatform());
|
75
|
|
data.put(FuncConstant.IMEI, this.getImei());
|
76
|
|
data.put(FuncConstant.UUID, this.getUuid());
|
77
|
|
data.put(FuncConstant.SIMNUMBER, this.getSimNumber());
|
78
|
|
data.put(FuncConstant.IMSI, this.getImsi());
|
79
|
|
data.put(FuncConstant.OSVERSION, this.getOSVersion());
|
80
|
|
data.put(FuncConstant.SDKVERSION, this.getSDKVersion());
|
81
|
|
data.put(FuncConstant.TIMEZONEID, this.getTimeZoneID());
|
82
|
|
data.put(FuncConstant.MODEL, this.getModel());
|
83
|
|
data.put(FuncConstant.MANUFACTURER, this.getManufacturer());
|
84
|
|
data.put(FuncConstant.MAC, this.getMac());
|
85
|
|
data.put(FuncConstant.IP, this.getIP());
|
86
|
|
data.put(FuncConstant.BRAND, this.getBrand());
|
87
|
|
return data.toString();
|
88
|
|
}
|
89
|
|
|
90
|
|
public String getPlatform() {
|
91
|
|
return platform;
|
92
|
|
}
|
93
|
|
|
94
|
|
public String getUuid() {
|
95
|
|
String uuid = Settings.Secure.getString(this.context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
96
|
|
return uuid;
|
97
|
|
}
|
98
|
|
|
99
|
|
public String getTelNumber() {
|
100
|
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
101
|
|
return manager.getLine1Number();
|
102
|
|
}
|
103
|
|
|
104
|
|
public String getImei() {
|
105
|
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
106
|
|
return manager.getDeviceId();
|
107
|
|
}
|
108
|
|
|
109
|
|
public String getSimNumber() {
|
110
|
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
111
|
|
return manager.getSimSerialNumber();
|
112
|
|
}
|
113
|
|
|
114
|
|
public String getImsi() {
|
115
|
|
TelephonyManager manager = (TelephonyManager) this.context.getSystemService(Context.TELEPHONY_SERVICE);
|
116
|
|
return manager.getSubscriberId();
|
117
|
|
}
|
118
|
|
|
119
|
|
public String getOSVersion() {
|
120
|
|
String osversion = android.os.Build.VERSION.RELEASE;
|
121
|
|
return osversion;
|
122
|
|
}
|
123
|
|
|
124
|
|
public String getSDKVersion() {
|
125
|
|
String sdkversion = android.os.Build.VERSION.SDK;
|
126
|
|
return sdkversion;
|
127
|
|
}
|
128
|
|
|
129
|
|
public String getTimeZoneID() {
|
130
|
|
TimeZone tz = TimeZone.getDefault();
|
131
|
|
return (tz.getID());
|
132
|
|
}
|
133
|
|
|
134
|
|
public String getManufacturer(){
|
135
|
|
String manufacturer = android.os.Build.MANUFACTURER;
|
136
|
|
return manufacturer;
|
137
|
|
}
|
138
|
|
public String getBrand(){
|
139
|
|
String brand = android.os.Build.BRAND;
|
140
|
|
return brand;
|
141
|
|
}
|
142
|
|
public String getModel() {
|
143
|
|
String model = android.os.Build.MODEL;
|
144
|
|
return model;
|
145
|
|
}
|
146
|
|
|
147
|
|
public String getProductName() {
|
148
|
|
String productname = android.os.Build.PRODUCT;
|
149
|
|
return productname;
|
150
|
|
}
|
151
|
|
|
152
|
|
/*****************network*************************/
|
153
|
|
public void getNetInfo(JSONArray params) throws Exception {
|
154
|
|
if(params.length()<1){
|
155
|
|
throw new Exception(Messages.EXCEPTION_PARAM);
|
156
|
|
}
|
157
|
|
String key = params.getString(0).toUpperCase();
|
158
|
|
if(key.equals(FuncConstant.MAC)){
|
159
|
|
callback(getMac());
|
160
|
|
}else if(key.equals(FuncConstant.IP)){
|
161
|
|
callback(getIP());
|
162
|
|
}
|
163
|
|
}
|
164
|
|
|
165
|
|
public String getMac() {
|
166
|
|
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
167
|
|
WifiInfo info = wifi.getConnectionInfo();
|
168
|
|
return info.getMacAddress();
|
169
|
|
}
|
170
|
|
|
171
|
|
public String getIP() throws SocketException {
|
172
|
|
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();){
|
173
|
|
NetworkInterface intf = en.nextElement();
|
174
|
|
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
|
175
|
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
176
|
|
if (!inetAddress.isLoopbackAddress()) {
|
177
|
|
return inetAddress.getHostAddress().toString();
|
178
|
|
}
|
179
|
|
}
|
180
|
|
}
|
181
|
|
return null;
|
|
28
|
public MobileInfo(IWadeMobile wademobile) {
|
|
29
|
super(wademobile);
|
182
|
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
|
|
183
|
243
|
}
|