我是靠谱客的博主 朴素白猫,这篇文章主要介绍目前已知最牛逼的获取安卓手机双IMEI的代码,包括山寨机,现在分享给大家,希望可以做个参考。

来自于:http://www.sum16.com/desinger/android-get-double-imei-include-made-in-china.html

 

复制代码
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
import java.util.ArrayList; import java.util.List; import android.content.Context; import android.telephony.TelephonyManager; import android.widget.Toast; public class getImei { Context context = null; public getImei(Context _context) { context = _context; } public String getimei() { try { TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); String imei = tm.getDeviceId(); List<String> IMEIS = new ArrayList<String>(); if (checkimei(imei.trim())) { IMEIS.add(imei.trim()); } try{ TelephonyManager telephonyManager1 = (TelephonyManager)context.getSystemService("phone1"); String imeiphone1= telephonyManager1.getDeviceId(); if (imeiphone1 != null && checkimei(imeiphone1)) { if (!IMEIS.contains(imeiphone1)) { IMEIS.add(imeiphone1); } } } catch (Exception e) { } try{ TelephonyManager telephonyManager2 = (TelephonyManager)context.getSystemService("phone2"); String imeiphone2= telephonyManager2.getDeviceId(); if (imeiphone2 != null && checkimei(imeiphone2)) { if (!IMEIS.contains(imeiphone2)) { IMEIS.add(imeiphone2); } } } catch (Exception e) { } List<String> imeis = IMEI_initQualcommDoubleSim(); if (imeis != null && imeis.size() > 0) { for (String item : imeis) { if (!IMEIS.contains(item)) { IMEIS.add(item); } } } imeis = IMEI_initMtkSecondDoubleSim(); if (imeis != null && imeis.size() > 0) { for (String item : imeis) { if (!IMEIS.contains(item)) { IMEIS.add(item); } } } imeis = IMEI_initMtkDoubleSim(); if (imeis != null && imeis.size() > 0) { for (String item : imeis) { if (!IMEIS.contains(item)) { IMEIS.add(item); } } } imeis = IMEI_initSpreadDoubleSim(); if (imeis != null && imeis.size() > 0) { for (String item : imeis) { if (!IMEIS.contains(item)) { IMEIS.add(item); } } } StringBuffer IMEI_SB = new StringBuffer(); Integer TIMES_TEMP = 1; for (String item : IMEIS) { if (TIMES_TEMP > 1) { IMEI_SB.append('n'); } IMEI_SB.append(item); // params.put("IMEI" + TIMES_TEMP, item); TIMES_TEMP++; } String imeis_tmp = IMEI_SB.toString().trim(); if ("".equals(imeis_tmp)) { imeis_tmp = "no_imei_1"; } return imeis_tmp; // // TextView_imei.setText(IMEI_SB.toString()); // // WriteFile("imei", IMEI_SB.toString()); } catch (Exception e) { Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show(); return "no_imei_2"; } } private Boolean checkimeisame(String imei) { char firstchar = '0'; if (imei.length() > 0) { firstchar = imei.charAt(0); } Boolean issame = true; for (int i = 0; i < imei.length(); i++) { char ch = imei.charAt(i); if (firstchar != ch) { issame = false; break; } } return issame; // if (issame) { // // 全是相同字符; // } else { // // 包含不同字符 // } } private Boolean checkimei(String IMEI) { Integer LEN = IMEI.length(); if (LEN > 10 && LEN < 20 && !checkimeisame(IMEI.trim())) { return true; } return false; } private List<String> IMEI_initMtkDoubleSim() { try { TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); Class<?> c = Class.forName("com.android.internal.telephony.Phone"); Integer simId_1, simId_2; try { java.lang.reflect.Field fields1 = c.getField("GEMINI_SIM_1"); fields1.setAccessible(true); simId_1 = (Integer) fields1.get(null); java.lang.reflect.Field fields2 = c.getField("GEMINI_SIM_2"); fields2.setAccessible(true); simId_2 = (Integer) fields2.get(null); } catch (Exception ex) { simId_1 = 0; simId_2 = 1; } // java.lang.reflect.Method m = TelephonyManager.class // .getDeclaredMethod("getSubscriberIdGemini", int.class); // String imsi_1 = (String) m.invoke(tm, simId_1); // String imsi_2 = (String) m.invoke(tm, simId_2); java.lang.reflect.Method m1 = TelephonyManager.class .getDeclaredMethod("getDeviceIdGemini", int.class); String imei_1 = ((String) m1.invoke(tm, simId_1)).trim(); String imei_2 = ((String) m1.invoke(tm, simId_2)).trim(); // java.lang.reflect.Method mx = TelephonyManager.class // .getDeclaredMethod("getPhoneTypeGemini", int.class); // Integer phoneType_1 = (Integer) mx.invoke(tm, simId_1); // Integer phoneType_2 = (Integer) mx.invoke(tm, simId_2); // String defaultImsi = ""; // if (TextUtils.isEmpty(imsi_1) && (!TextUtils.isEmpty(imsi_2))) { // defaultImsi = imsi_2; // } // if (TextUtils.isEmpty(imsi_2) && (!TextUtils.isEmpty(imsi_1))) { // defaultImsi = imsi_1; // } List<String> imeis = new ArrayList<String>(); if (checkimei(imei_1)) { imeis.add(imei_1); } if (checkimei(imei_2)) { imeis.add(imei_2); } return imeis; } catch (Exception e) { // ��MTK return null; } } private List<String> IMEI_initMtkSecondDoubleSim() { try { TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); Class<?> c = Class.forName("com.android.internal.telephony.Phone"); Integer simId_1, simId_2; try { java.lang.reflect.Field fields1 = c.getField("GEMINI_SIM_1"); fields1.setAccessible(true); simId_1 = (Integer) fields1.get(null); java.lang.reflect.Field fields2 = c.getField("GEMINI_SIM_2"); fields2.setAccessible(true); simId_2 = (Integer) fields2.get(null); } catch (Exception ex) { simId_1 = 0; simId_2 = 1; } java.lang.reflect.Method mx = TelephonyManager.class.getMethod( "getDefault", int.class); TelephonyManager tm1 = (TelephonyManager) mx.invoke(tm, simId_1); TelephonyManager tm2 = (TelephonyManager) mx.invoke(tm, simId_2); // String imsi_1 = tm1.getSubscriberId(); // String imsi_2 = tm2.getSubscriberId(); String imei_1 = (tm1.getDeviceId()).trim(); String imei_2 = (tm2.getDeviceId()).trim(); // // Integer phoneType_1 = tm1.getPhoneType(); // Integer phoneType_2 = tm2.getPhoneType(); // String defaultImsi = ""; // if (TextUtils.isEmpty(imsi_1) && (!TextUtils.isEmpty(imsi_2))) { // defaultImsi = imsi_2; // } // if (TextUtils.isEmpty(imsi_2) && (!TextUtils.isEmpty(imsi_1))) { // defaultImsi = imsi_1; // } List<String> imeis = new ArrayList<String>(); if (checkimei(imei_1)) { imeis.add(imei_1); } if (checkimei(imei_2)) { imeis.add(imei_2); } return imeis; } catch (Exception e) { return null; } } private List<String> IMEI_initSpreadDoubleSim() { try { Class<?> c = Class .forName("com.android.internal.telephony.PhoneFactory"); java.lang.reflect.Method m = c.getMethod("getServiceName", String.class, int.class); String spreadTmService = (String) m.invoke(c, Context.TELEPHONY_SERVICE, 1); TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); // String imsi_1 = tm.getSubscriberId(); String imei_1 = (tm.getDeviceId()).trim(); // Integer phoneType_1 = tm.getPhoneType(); TelephonyManager tm1 = (TelephonyManager) context .getSystemService(spreadTmService); // String imsi_2 = tm1.getSubscriberId(); String imei_2 = (tm1.getDeviceId()).trim(); // Integer phoneType_2 = tm1.getPhoneType(); // String defaultImsi = ""; // if (TextUtils.isEmpty(imsi_1) && (!TextUtils.isEmpty(imsi_2))) { // defaultImsi = imsi_2; // } // if (TextUtils.isEmpty(imsi_2) && (!TextUtils.isEmpty(imsi_1))) { // defaultImsi = imsi_1; // } List<String> imeis = new ArrayList<String>(); if (checkimei(imei_1)) { imeis.add(imei_1); } if (checkimei(imei_2)) { imeis.add(imei_2); } return imeis; } catch (Exception e) { return null; } } public List<String> IMEI_initQualcommDoubleSim() { try { TelephonyManager tm = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); Class<?> cx = Class .forName("android.telephony.MSimTelephonyManager"); Object obj = context.getSystemService("phone_msim"); Integer simId_1 = 0; Integer simId_2 = 1; // // java.lang.reflect.Method mx = cx.getMethod("getDataState"); // // int stateimei_1 = (Integer) mx.invoke(cx.newInstance()); // int stateimei_2 = tm.getDataState(); // java.lang.reflect.Method mde = cx.getMethod("getDefault"); java.lang.reflect.Method md = cx .getMethod("getDeviceId", int.class); // java.lang.reflect.Method ms = cx.getMethod("getSubscriberId", // int.class); // java.lang.reflect.Method mp = cx.getMethod("getPhoneType"); // Object obj = mde.invoke(cx); String imei_1 = ((String) md.invoke(obj, simId_1)).trim(); String imei_2 = ((String) md.invoke(obj, simId_2)).trim(); // String imsi_1 = (String) ms.invoke(obj, simId_1); // String imsi_2 = (String) ms.invoke(obj, simId_2); // int statephoneType_1 = tm.getDataState(); // int statephoneType_2 = (Integer) mx.invoke(obj); List<String> imeis = new ArrayList<String>(); if (checkimei(imei_1)) { imeis.add(imei_1); } if (checkimei(imei_2)) { imeis.add(imei_2); } return imeis; // Log.e("tag", statephoneType_1 + "---" + statephoneType_2); // Class<?> msc = Class.forName("android.telephony.MSimSmsManager"); // for (Method m : msc.getMethods()) { // if (m.getName().equals("sendTextMessage")) { // m.getParameterTypes(); // } // Log.e("tag", m.getName()); // } } catch (Exception e) { return null; } } }

 

 

最后

以上就是朴素白猫最近收集整理的关于目前已知最牛逼的获取安卓手机双IMEI的代码,包括山寨机的全部内容,更多相关目前已知最牛逼内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部