Преглед на файлове

Merge branch 'master' of http://114.215.100.48:3000/ipu/android-share.git

huangbo преди 9 години
родител
ревизия
f43d1543bd

+ 44 - 8
display-server/web/biz/js/plugin/basic.js

@ -35,18 +35,54 @@ require(["domReady!","wadeMobile","util"], function(doc,WadeMobile) {
35 35
			},'PLATFORM');
36 36
		},'OSVERSION');
37 37
		var spans=infoDivs.eq(1).find("span");
38
		// IMEI:获取移动设备国际身份码
39
		WadeMobile.getSysInfo(function(info){
40
			spans.eq(0).html(info);
41
		},'IMEI');
42
		// MAC:获取移动设备的MAC地址
38
		// MAC:获取移动设备的MAC地址。
43 39
		WadeMobile.getNetInfo(function(info){
44
			spans.eq(1).html(info);
40
			spans.eq(0).html(info);
45 41
		},'MAC');
46
		// 获取IP地址
42
		// IP:获取移动设备的IPV4地址
47 43
		WadeMobile.getNetInfo(function(info){
48
			spans.eq(2).html(info);
44
			spans.eq(1).html(info);
49 45
		},'IP');
46
		// IMEI:获取移动设备国际身份码。 
47
		WadeMobile.getSysInfo(function(info){
48
			spans.eq(2).html(info);
49
		},'IMEI');
50
		// IMSI:获取国际移动用户识别码,区别移动用户的标志,储存在SIM卡中。 
51
		WadeMobile.getSysInfo(function(info){
52
			spans.eq(3).html(info);
53
		},'IMSI');
54
		// MODEL:获取手机型号。 
55
		WadeMobile.getSysInfo(function(info){
56
			spans.eq(4).html(info);
57
		},'MODEL');
58
		// UUID:通用唯一识别码,软件唯一标识。 
59
		WadeMobile.getSysInfo(function(info){
60
			spans.eq(5).html(info);
61
		},'UUID');
62
		// MANUFACTURER:获取制造商信息。 
63
		WadeMobile.getSysInfo(function(info){
64
			spans.eq(6).html(info);
65
		},'MANUFACTURER');
66
		// BRAND:获取手机品牌。 
67
		WadeMobile.getSysInfo(function(info){
68
			spans.eq(7).html(info);
69
		},'BRAND');
70
		// SDKVERSION:获取SDK版本。 
71
		WadeMobile.getSysInfo(function(info){
72
			spans.eq(8).html(info);
73
		},'SDKVERSION');
74
		// SIMNUMBER:SIM卡的序号 
75
		WadeMobile.getSysInfo(function(info){
76
			spans.eq(9).html(info);
77
		},'SIMNUMBER');
78
		// TIMEZONEID:国际时区 
79
		WadeMobile.getSysInfo(function(info){
80
			spans.eq(10).html(info);
81
		},'TIMEZONEID');
82
		// PRODUCTNAME:产品名称
83
		WadeMobile.getSysInfo(function(info){
84
			spans.eq(11).html(info);
85
		},'PRODUCTNAME');
50 86
		
51 87
		$("#info_list").show();
52 88
		$("#info_space").hide();

+ 13 - 4
display-server/web/template/webapp/plugin/Basic.html

@ -73,10 +73,19 @@
73 73
				<div class="content">
74 74
					<div class="main" id="info">
75 75
						<div class="title">Android版本(点击获取数据)</div>
76
						<div class="info">
77
							IMEI:<span>暂未获取数据</span><br />
78
							MAC:<span>暂未获取数据</span><br />
79
							IP:<span>暂未获取数据</span>
76
						<div class="content info">
77
							MAC:<span>暂未获取数据</span><br/>
78
							IP:<span>暂未获取数据</span><br/>
79
							IMEI:<span>暂未获取数据</span><br/>
80
							IMSI:<span>暂未获取数据</span><br/>
81
							MODEL:<span>暂未获取数据</span><br/>
82
							UUID:<span>暂未获取数据</span><br/>
83
							MANUFACTURER:<span>暂未获取数据</span><br/>
84
							BRAND:<span>暂未获取数据</span><br/>
85
							SDKVERSION:<span>暂未获取数据</span><br/>
86
							SIMNUMBER:<span>暂未获取数据</span><br/>
87
							TIMEZONEID:<span>暂未获取数据</span><br/>
88
							PRODUCTNAME:<span>暂未获取数据</span><br/>
80 89
						</div>
81 90
					</div>
82 91
				</div>

BIN
wade-mobile-common/libs/wade-mobile-func.jar


+ 217 - 157
wade-mobile-func/src/com/wade/mobile/func/MobileInfo.java

@ -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
}

+ 3 - 0
wade-mobile-func/src/com/wade/mobile/util/FuncConstant.java

@ -12,10 +12,13 @@ public class FuncConstant {
12 12
	public static final String MODEL = "MODEL";
13 13
	public static final String MANUFACTURER = "MANUFACTURER";
14 14
	public static final String BRAND = "BRAND";
15
	public static final String PRODUCTNAME = "PRODUCTNAME";
15 16
	public static final String ALL = "ALL";
16 17

17 18
	public static final String MAC = "MAC";
18 19
	public static final String IP = "IP";
20
	public static final String IPV4 = "IPV4";
21
	public static final String IPV6 = "IPV6";
19 22
	
20 23
	public static final String CONTENT = "CONTENT";
21 24
	public static final String SENDER = "SENDER";