-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
31 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,4 +26,4 @@ public Identity getInstance() { | |
return identityToSet; | ||
} | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/amplitude/identitymanager/IdentityUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.amplitude.identitymanager; | ||
|
||
import android.util.Log; | ||
|
||
public class IdentityUtils { | ||
static private final int device_id_length = 25; | ||
static private final String base_36_char_set = "abcdefghijklmnopqrstuvwxyz0123456789"; | ||
static private final int base_36_radix = 36; | ||
|
||
static void logIdentityWarning(String message) { | ||
Log.w(Identity.class.getName(), message); | ||
} | ||
|
||
static String generateBase36Id() { | ||
String stringBuilder = ""; | ||
for (int idx = 0; idx < device_id_length; idx++) { | ||
double randomIdx = Math.floor(Math.random() * base_36_radix); | ||
char nextChar = base_36_char_set.charAt((int)randomIdx); | ||
stringBuilder += nextChar; | ||
} | ||
|
||
return stringBuilder; | ||
} | ||
} |