Skip to content

Commit 5a30089

Browse files
authored
Merge pull request #474 from Countly/set_id_mode
Remove Secure.ANDROID_ID usage
2 parents ac11ac0 + d533b82 commit 5a30089

File tree

8 files changed

+23
-41
lines changed

8 files changed

+23
-41
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
## XX.XX.XX
2+
* ! Minor breaking change ! Removed Secure.ANDROID_ID usage in device id generation. The SDK now exclusively uses random UUIDs for device id generation.
3+
24
* Added a Content feature method "refreshContentZone" that does a manual refresh.
35
* Added a new interface "CountlyNotificationButtonURLHandler" to allow custom handling of URLs when notification buttons are clicked. Could be set by "CountlyConfigPush.setNotificationButtonURLHandler"
46

5-
* Deprecated the experimental configuration function enableServerConfiguration. It is now enabled by default and can be controlled directly from the server.
6-
77
* Mitigated an issue that caused PN message data collision if two message with same ID was received.
88

9+
* Removed the deprecated function "CountlyConfig.setIdMode(idMode)"
10+
11+
* Deprecated the experimental configuration function enableServerConfiguration. It is now enabled by default and can be controlled directly from the server.
12+
913
## 25.1.1
1014
* Mitigated an issue where after closing a content, they were not being fetched again.
1115

sdk/src/androidTest/java/ly/count/android/sdk/CountlyConfigTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public boolean filterCrash(String crash) {
110110
config.setCountlyStore(cs);
111111
config.checkForNativeCrashDumps(false);
112112
config.setDeviceId(s[2]);
113-
config.setIdMode(DeviceIdType.DEVELOPER_SUPPLIED);
114113
config.setStarRatingSessionLimit(1335);
115114
config.setStarRatingCallback(rc);
116115
config.setStarRatingTextDismiss(s[3]);

sdk/src/androidTest/java/ly/count/android/sdk/DeviceIdTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void setUp() {
3030
Countly.sharedInstance().setLoggingEnabled(true);
3131

3232
openUDIDProvider = new OpenUDIDProvider() {
33-
@Override public String getOpenUDID() {
33+
@Override public String getUUID() {
3434
return currentOpenUDIDValue;
3535
}
3636
};
@@ -106,7 +106,7 @@ public void getType() {
106106
store.clear();
107107

108108
assertEquals(DeviceIdType.OPEN_UDID, new DeviceId(null, store, mock(ModuleLog.class), new OpenUDIDProvider() {
109-
@Override public String getOpenUDID() {
109+
@Override public String getUUID() {
110110
return "abc";
111111
}
112112
}).getType());

sdk/src/main/java/ly/count/android/sdk/ConnectionProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ public void run() {
339339
}
340340

341341
if (deviceIdProvider_.getDeviceId() == null) {
342-
// When device ID is supplied by OpenUDID or by Google Advertising ID.
343-
// In some cases it might take time for them to initialize. So, just wait for it.
342+
// This might not be the case anymore, check it out TODO
344343
L.i("[ConnectionProcessor] No Device ID available yet, skipping request " + storedRequests[0]);
345344
break;
346345
}

sdk/src/main/java/ly/count/android/sdk/CountlyConfig.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class CountlyConfig {
7979
protected String appKey = null;
8080

8181
/**
82-
* unique ID for the device the app is running on; note that null in deviceID means that Countly will fall back to OpenUDID, then, if it's not available, to Google Advertising ID.
82+
* unique ID for the device the app is running on; note that null in deviceID means that Countly will fall back to UUID.
8383
*/
8484
protected String deviceID = null;
8585

@@ -289,7 +289,7 @@ public synchronized CountlyConfig setAppKey(String appKey) {
289289
}
290290

291291
/**
292-
* unique ID for the device the app is running on; note that null in deviceID means that Countly will fall back to OpenUDID, then, if it's not available, to Google Advertising ID.
292+
* unique ID for the device the app is running on; note that null in deviceID means that Countly will fall back to UUID.
293293
*
294294
* @return Returns the same config object for convenient linking
295295
*/
@@ -298,16 +298,6 @@ public synchronized CountlyConfig setDeviceId(String deviceID) {
298298
return this;
299299
}
300300

301-
/**
302-
* enum value specifying which device ID generation strategy Countly should use: OpenUDID or Google Advertising ID.
303-
*
304-
* @return Returns the same config object for convenient linking
305-
* @deprecated this call should not be used anymore as it does not have any purpose anymore
306-
*/
307-
public synchronized CountlyConfig setIdMode(DeviceIdType idMode) {
308-
return this;
309-
}
310-
311301
/**
312302
* sets the limit after how many sessions, for each apps version, the automatic star rating dialog is shown.
313303
*
@@ -992,7 +982,6 @@ public synchronized CountlyConfig enableExplicitStorageMode() {
992982
return this;
993983
}
994984

995-
996985
/**
997986
* This is an experimental feature and it can have breaking changes
998987
*
@@ -1005,7 +994,7 @@ public synchronized CountlyConfig enableExplicitStorageMode() {
1005994
public synchronized CountlyConfig enableServerConfiguration() {
1006995
return this;
1007996
}
1008-
997+
1009998
protected synchronized CountlyConfig disableHealthCheck() {
1010999
healthCheckEnabled = false;
10111000
return this;

sdk/src/main/java/ly/count/android/sdk/DeviceId.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ protected DeviceId(@Nullable String providedId, @NonNull StorageProvider givenSt
6262

6363
if (providedId == null) {
6464
//if the provided ID is 'null' then that means that a new ID must be generated
65-
L.i("[DeviceId-int] Using OpenUDID");
66-
setAndStoreId(DeviceIdType.OPEN_UDID, openUDIDProvider.getOpenUDID());
65+
L.i("[DeviceId-int] Using UUID");
66+
setAndStoreId(DeviceIdType.OPEN_UDID, openUDIDProvider.getUUID());
6767
} else if (providedId.equals(temporaryCountlyDeviceId)) {
6868
L.i("[DeviceId-int] Entering temp ID mode");
6969

@@ -106,8 +106,8 @@ protected String getCurrentId() {
106106
assert type != null;
107107

108108
if (id == null && type == DeviceIdType.OPEN_UDID) {
109-
//using openUDID as a fallback
110-
id = openUDIDProvider.getOpenUDID();
109+
//using UUID as a fallback
110+
id = openUDIDProvider.getUUID();
111111
}
112112
return id;
113113
}

sdk/src/main/java/ly/count/android/sdk/ModuleDeviceId.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package ly.count.android.sdk;
22

3-
import android.annotation.SuppressLint;
43
import android.content.Context;
54
import android.content.SharedPreferences;
6-
import android.provider.Settings;
75
import androidx.annotation.NonNull;
86
import androidx.annotation.Nullable;
97
import java.util.UUID;
@@ -252,33 +250,26 @@ void halt() {
252250

253251
}
254252

255-
public final static String PREF_KEY = "openudid";
253+
public final static String PREF_KEY = "openudid"; // key of old impl, keeping because needs migration
256254
public final static String PREFS_NAME = "openudid_prefs";
257255

258-
@SuppressLint("HardwareIds")
259-
@Override @NonNull public String getOpenUDID() {
256+
@Override @NonNull public String getUUID() {
260257
String retrievedID;
261258

262259
SharedPreferences mPreferences = _cly.context_.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
263-
//Try to get the openudid from local preferences
260+
//Try to get the stored UUID from local preferences
264261
retrievedID = mPreferences.getString(PREF_KEY, null);
265262
if (retrievedID == null) //Not found if temp storage
266263
{
267-
Countly.sharedInstance().L.d("[OpenUDID] Generating openUDID");
268-
//Try to get the ANDROID_ID
269-
retrievedID = Settings.Secure.getString(_cly.context_.getContentResolver(), Settings.Secure.ANDROID_ID);
270-
if (retrievedID == null || retrievedID.equals("9774d56d682e549c") || retrievedID.length() < 15) {
271-
//if ANDROID_ID is null, or it's equals to the GalaxyTab generic ANDROID_ID or is too short bad, generates a new one
272-
//the new one would be random
273-
retrievedID = UUID.randomUUID().toString();
274-
}
264+
Countly.sharedInstance().L.d("[ModuleDeviceId] getUUID, Generating UUID");
265+
retrievedID = UUID.randomUUID().toString();
275266

276267
final SharedPreferences.Editor e = mPreferences.edit();
277268
e.putString(PREF_KEY, retrievedID);
278269
e.apply();
279270
}
280271

281-
Countly.sharedInstance().L.d("[OpenUDID] ID: " + retrievedID);
272+
Countly.sharedInstance().L.d("[ModuleDeviceId] getUUID, retrievedID:[" + retrievedID + "]");
282273

283274
return retrievedID;
284275
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package ly.count.android.sdk;
22

33
interface OpenUDIDProvider {
4-
String getOpenUDID();
4+
String getUUID();
55
}

0 commit comments

Comments
 (0)