Skip to content

Commit 83fc959

Browse files
committed
Merge pull request #57 from adjust/development
Send "tracking enabled"
2 parents 204765a + 8d98ac0 commit 83fc959

File tree

8 files changed

+64
-29
lines changed

8 files changed

+64
-29
lines changed

Adjust/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ android {
2525
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
2626
defaultConfig {
2727
versionCode 11
28-
versionName '3.3.4'
28+
versionName '3.3.5'
2929
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
3030
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
3131
}

Adjust/src/com/adjust/sdk/ActivityHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ private void initInternal(boolean fromBundle) {
278278
fbAttributionId = Util.getAttributionId(context);
279279
userAgent = Util.getUserAgent(context);
280280

281-
String gpsAdid = Util.getGpsAdid(context);
282-
if (gpsAdid == null) {
281+
String playAdId = Util.getPlayAdId(context);
282+
if (playAdId == null) {
283283
logger.info("Unable to get Google Play Services Advertising ID at start time");
284284
}
285285

Adjust/src/com/adjust/sdk/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public interface Constants {
1919
int THIRTY_MINUTES = 30 * ONE_MINUTE;
2020

2121
String BASE_URL = "https://app.adjust.io";
22-
String CLIENT_SDK = "android3.3.4";
22+
String CLIENT_SDK = "android3.3.5";
2323
String LOGTAG = "Adjust";
2424

2525
String SESSION_STATE_FILENAME = "AdjustIoActivityState";

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,10 @@ private Map<String, String> getDefaultParameters() {
258258
addString(parameters, "android_uuid", uuid);
259259
addString(parameters, "fb_id", fbAttributionId);
260260
addString(parameters, "environment", environment);
261-
String gpsAdid = Util.getGpsAdid(context);
262-
addString(parameters, "gps_adid", gpsAdid);
261+
String playAdId = Util.getPlayAdId(context);
262+
addString(parameters, "gps_adid", playAdId);
263+
Boolean isTrackingEnabled = Util.isPlayTrackingEnabled(context);
264+
addBoolean(parameters, "tracking_enabled", isTrackingEnabled);
263265

264266
// session related (used for events as well)
265267
addInt(parameters, "session_count", sessionCount);
@@ -351,4 +353,14 @@ private void addMapJson(Map<String, String> parameters, String key, Map<String,
351353

352354
addString(parameters, key, jsonString);
353355
}
356+
357+
private void addBoolean(Map<String, String> parameters, String key, Boolean value) {
358+
if (value == null) {
359+
return;
360+
}
361+
362+
int intValue = value? 1 : 0;
363+
364+
addInt(parameters, key, intValue);
365+
}
354366
}

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

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -349,41 +349,59 @@ public static String dateFormat(long date) {
349349
return dateFormat.format(date);
350350
}
351351

352-
public static String getGpsAdid(Context context) {
352+
public static String getPlayAdId(Context context) {
353353
try {
354-
Class AdvertisingIdClientClass = Class.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient");
354+
Object AdvertisingInfoObject = getPlayAdvertisingInfoObject(context);
355355

356-
Class[] cArg = new Class[1];
357-
cArg[0] = Context.class;
358-
Method getAdvertisingInfoMethod = AdvertisingIdClientClass.getMethod("getAdvertisingIdInfo", cArg);
356+
Class AdvertisingInfoClass = AdvertisingInfoObject.getClass();
359357

360-
Object AdvertisingInfoObject = getAdvertisingInfoMethod.invoke(null, context);
358+
Method getIdMethod = AdvertisingInfoClass.getMethod("getId");
361359

362-
Class AdvertisingInfoClass = AdvertisingInfoObject.getClass();
360+
Object getIdObject = getIdMethod.invoke(AdvertisingInfoObject);
363361

364-
Method isLimitedTrackingEnabledMethod = AdvertisingInfoClass.getMethod("isLimitAdTrackingEnabled");
362+
String playAdid = (String) getIdObject;
365363

366-
Object isLimitedTrackingEnabledObject = isLimitedTrackingEnabledMethod.invoke(AdvertisingInfoObject);
364+
return playAdid;
365+
}
366+
catch (Exception e) {
367+
}
368+
catch (NoClassDefFoundError ncdffe) {
369+
}
367370

368-
Boolean isLimitedTrackingEnabled = (Boolean) isLimitedTrackingEnabledObject;
371+
return null;
372+
}
369373

370-
if (isLimitedTrackingEnabled) {
371-
return null;
372-
}
374+
public static boolean isPlayTrackingEnabled(Context context) {
375+
try {
376+
Object AdvertisingInfoObject = getPlayAdvertisingInfoObject(context);
373377

374-
Method getIdMethod = AdvertisingInfoClass.getMethod("getId");
378+
Class AdvertisingInfoClass = AdvertisingInfoObject.getClass();
375379

376-
Object getIdObject = getIdMethod.invoke(AdvertisingInfoObject);
380+
Method isLimitedTrackingEnabledMethod = AdvertisingInfoClass.getMethod("isLimitAdTrackingEnabled");
377381

378-
String gpsAdid = (String) getIdObject;
382+
Object isLimitedTrackingEnabledObject = isLimitedTrackingEnabledMethod.invoke(AdvertisingInfoObject);
379383

380-
return gpsAdid;
384+
Boolean isLimitedTrackingEnabled = (Boolean) isLimitedTrackingEnabledObject;
385+
386+
return !isLimitedTrackingEnabled;
381387
}
382388
catch (Exception e) {
383389
}
384390
catch (NoClassDefFoundError ncdffe) {
385391
}
386392

387-
return null;
393+
return false;
394+
}
395+
396+
private static Object getPlayAdvertisingInfoObject(Context context) throws Exception {
397+
Class AdvertisingIdClientClass = Class.forName("com.google.android.gms.ads.identifier.AdvertisingIdClient");
398+
399+
Class[] cArg = new Class[1];
400+
cArg[0] = Context.class;
401+
Method getAdvertisingInfoMethod = AdvertisingIdClientClass.getMethod("getAdvertisingIdInfo", cArg);
402+
403+
Object AdvertisingInfoObject = getAdvertisingInfoMethod.invoke(null, context);
404+
405+
return AdvertisingInfoObject;
388406
}
389407
}

Adjust/test/src/com/adjust/sdk/test/TestActivityHandler.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void testFirstSession() {
9393

9494
// check the Sdk version is being tested
9595
assertEquals(activityPackage.getExtendedString(),
96-
"android3.3.4", activityPackage.getClientSdk());
96+
"android3.3.5", activityPackage.getClientSdk());
9797

9898
// check the server url
9999
assertEquals(Constants.BASE_URL, "https://app.adjust.io");
@@ -335,6 +335,11 @@ public void testEventsNotBuffered() {
335335
ActivityPackage activityPackage = mockPackageHandler.queue.get(1);
336336
Map<String, String> packageParameters = activityPackage.getParameters();
337337

338+
// check that it contains the information of the tracking being enabled
339+
assertNotNull(activityPackage.getExtendedString(),
340+
packageParameters.get("tracking_enabled"));
341+
342+
338343
// check the event count in the package parameters
339344
assertEquals(activityPackage.getExtendedString(),
340345
1, Integer.parseInt(packageParameters.get("event_count")));

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.4
1+
3.3.5

doc/migrate.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Migrate your adjust SDK for Android to 3.3.4 from v2.1.x
1+
## Migrate your adjust SDK for Android to 3.3.5 from v2.1.x
22

33
We renamed the main class `com.adeven.adjustio.AdjustIo` to
44
`com.adjust.sdk.Adjust`. Follow these steps to update all adjust SDK calls.
@@ -24,7 +24,7 @@ We renamed the main class `com.adeven.adjustio.AdjustIo` to
2424
4. In the same fashion, replace `adeven.adjustio` with `adjust.sdk` in all
2525
manifest files to update the package name of the `ReferrerReceiver`.
2626

27-
5. Download version v3.3.4 and create a new Android project from the `Adjust` folder.
27+
5. Download version v3.3.5 and create a new Android project from the `Adjust` folder.
2828

2929
![][import]
3030

@@ -36,7 +36,7 @@ We renamed the main class `com.adeven.adjustio.AdjustIo` to
3636

3737
8. Build your project to confirm that everything is properly connected again.
3838

39-
The adjust SDK v3.3.4 added delegate notifications. Check out the [README] for
39+
The adjust SDK v3.3.5 added delegate notifications. Check out the [README] for
4040
details.
4141

4242

0 commit comments

Comments
 (0)