Skip to content

Commit f89a310

Browse files
committed
Join available imeis
1 parent 8e5b8c0 commit f89a310

File tree

3 files changed

+74
-3
lines changed

3 files changed

+74
-3
lines changed

Adjust/adjust/src/main/java/com/adjust/sdk/PackageBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ private void injectConfig(Map<String, String> parameters) {
277277
if (adjustConfig.readMobileEquipmentIdentity) {
278278
TelephonyManager telephonyManager = (TelephonyManager)adjustConfig.context.getSystemService(Context.TELEPHONY_SERVICE);
279279

280-
PackageBuilder.addString(parameters, "device_id", Util.getTelephonyId(telephonyManager));
281-
PackageBuilder.addString(parameters, "imei", Util.getIMEI(telephonyManager, 0));
282-
PackageBuilder.addString(parameters, "meid", Util.getMEID(telephonyManager, 0));
280+
PackageBuilder.addString(parameters, "device_ids", Util.getTelephonyIds(telephonyManager));
281+
PackageBuilder.addString(parameters, "imeis", Util.getIMEIs(telephonyManager));
282+
PackageBuilder.addString(parameters, "meids", Util.getMEIDs(telephonyManager));
283283
}
284284
}
285285

Adjust/adjust/src/main/java/com/adjust/sdk/Reflection.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ public static String getTelephonyId(TelephonyManager telephonyManager) {
136136
}
137137
}
138138

139+
public static String getTelephonyId(TelephonyManager telephonyManager, int index) {
140+
// return telephonyManager.getDeviceId();
141+
try {
142+
return (String) invokeInstanceMethod(telephonyManager, "getDeviceId", new Class[]{int.class}, index);
143+
} catch (Exception e) {
144+
return null;
145+
}
146+
}
147+
139148
private static Object getAdvertisingInfoObject(Context context)
140149
throws Exception {
141150
return invokeStaticMethod("com.google.android.gms.ads.identifier.AdvertisingIdClient",

Adjust/adjust/src/main/java/com/adjust/sdk/Util.java

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
import java.security.MessageDigest;
3535
import java.text.DecimalFormat;
3636
import java.text.SimpleDateFormat;
37+
import java.util.ArrayList;
3738
import java.util.HashMap;
39+
import java.util.List;
3840
import java.util.Locale;
3941
import java.util.Map;
4042
import java.util.Random;
@@ -147,6 +149,66 @@ public static String getMEID(TelephonyManager telephonyManager, int index) {
147149
return Reflection.getMeid(telephonyManager, index);
148150
}
149151

152+
public static String getTelephonyId(TelephonyManager telephonyManager, int index) {
153+
return Reflection.getTelephonyId(telephonyManager, index);
154+
}
155+
156+
public static String getTelephonyIds(TelephonyManager telephonyManager) {
157+
List<String> telephonyIds = new ArrayList<String>();
158+
159+
String telephonyId0 = getTelephonyId(telephonyManager, 0);
160+
if (telephonyId0 != null) {
161+
telephonyIds.add(telephonyId0);
162+
}
163+
164+
for (int i = 1; i < 10; i++) {
165+
String telephonyId = getTelephonyId(telephonyManager, i);
166+
if (telephonyId == null) {
167+
break;
168+
}
169+
telephonyIds.add(telephonyId);
170+
}
171+
172+
return TextUtils.join(",", telephonyIds);
173+
}
174+
175+
public static String getIMEIs(TelephonyManager telephonyManager) {
176+
List<String> imeis = new ArrayList<String>();
177+
178+
String imei0 = getIMEI(telephonyManager, 0);
179+
if (imei0!= null) {
180+
imeis.add(imei0);
181+
}
182+
183+
for (int i = 1; i < 10; i++) {
184+
String imei = getIMEI(telephonyManager, i);
185+
if (imei == null) {
186+
break;
187+
}
188+
imeis.add(imei);
189+
}
190+
191+
return TextUtils.join(",", imeis);
192+
}
193+
194+
public static String getMEIDs(TelephonyManager telephonyManager) {
195+
List<String> meids = new ArrayList<String>();
196+
197+
String meid0 = getMEID(telephonyManager, 0);
198+
if (meid0 != null) {
199+
meids.add(meid0);
200+
}
201+
202+
for (int i = 1; i < 10; i++) {
203+
String meid = getMEID(telephonyManager, i);
204+
if (meid == null) {
205+
break;
206+
}
207+
meids.add(meid);
208+
}
209+
210+
return TextUtils.join(",", meids);
211+
}
150212

151213
public static <T> T readObject(Context context, String filename, String objectName, Class<T> type) {
152214
Closeable closable = null;

0 commit comments

Comments
 (0)