@@ -77,18 +77,18 @@ public void initFinished(final InternalConfig config) {
7777
7878 if (Utils .isNotEmpty (config .getCustomDeviceId ())) {
7979 // developer specified id on SDK init
80- Config .DID did = new Config .DID (Config .DID .REALM_DID , Config . DID . STRATEGY_CUSTOM , config .getCustomDeviceId ());
80+ Config .DID did = new Config .DID (Config .DID .STRATEGY_CUSTOM , config .getCustomDeviceId ());
8181 L .d ("[ModuleDeviceIdCore] initFinished, Got developer id [" + did + "]" );
8282 SDKCore .instance .onDeviceId (config , did , null );
8383 } else {
8484 // regular flow - acquire id using specified strategy
85- Config .DID did = new Config .DID (Config . DID . REALM_DID , config .getDeviceIdStrategy (), null );
85+ Config .DID did = new Config .DID (config .getDeviceIdStrategy (), null );
8686 acquireId (config , did );
8787 }
8888 } else {
8989 // second or next app launch, notify id is available
9090 Config .DID loadedDid = config .getDeviceId ();
91- L .d ("[ModuleDeviceIdCore] initFinished, Loading previously saved device id:[" + loadedDid .id + "] realm:[" + loadedDid . realm + "] strategy:[" + loadedDid .strategy + "]" );
91+ L .d ("[ModuleDeviceIdCore] initFinished, Loading previously saved device id:[" + loadedDid .id + "] strategy:[" + loadedDid .strategy + "]" );
9292 SDKCore .instance .onDeviceId (config , loadedDid , loadedDid );
9393 }
9494 }
@@ -99,7 +99,7 @@ public void deviceIdChanged(Config.DID oldDeviceId, boolean withMerge) {
9999 Config .DID deviceId = internalConfig .getDeviceId ();
100100 SessionImpl session = SDKCore .instance .getSession ();
101101
102- if (deviceId != null && oldDeviceId != null && deviceId . realm == Config . DID . REALM_DID && !deviceId .equals (oldDeviceId )) {
102+ if (deviceId != null && oldDeviceId != null && !deviceId .equals (oldDeviceId )) {
103103 // device id changed
104104 if (session != null && session .isActive ()) {
105105 // end previous session
@@ -129,15 +129,15 @@ public void onDeviceId(InternalConfig config, final Config.DID deviceId, final C
129129
130130 SessionImpl session = SDKCore .instance .getSession ();
131131
132- if (deviceId == null && oldDeviceId != null && oldDeviceId . realm == Config . DID . REALM_DID ) {
132+ if (deviceId == null && oldDeviceId != null ) {
133133 // device id is unset
134134 if (session != null ) {
135135 L .d ("[ModuleDeviceIdCore] Ending session because device id was unset from [" + oldDeviceId .id + "]" );
136136 session .end (null , null , oldDeviceId .id );
137137 }
138138
139139 sendDIDSignal (config , null , oldDeviceId );
140- } else if (deviceId != null && oldDeviceId == null && deviceId . realm == Config . DID . REALM_DID ) {
140+ } else if (deviceId != null && oldDeviceId == null ) {
141141 // device id just acquired
142142 if (this .tasks == null ) {
143143 this .tasks = new Tasks ("deviceId" , L );
@@ -211,7 +211,7 @@ public void login(InternalConfig config, String id) {
211211 L .e ("[ModuleDeviceIdCore] Empty id passed to login method" );
212212 } else {
213213 final Config .DID old = config .getDeviceId ();
214- config .setDeviceId (new Config .DID (Config .DID .REALM_DID , Config . DID . STRATEGY_CUSTOM , id ));
214+ config .setDeviceId (new Config .DID (Config .DID .STRATEGY_CUSTOM , id ));
215215 config .storageProvider .setDeviceIdType (DeviceIdType .DEVELOPER_SUPPLIED .name ());
216216 config .storageProvider .setDeviceID (id );
217217
@@ -234,7 +234,7 @@ public void logout(final InternalConfig config) {
234234 config .storageProvider .setDeviceIdType ("" );
235235
236236 SDKCore .instance .onDeviceId (config , null , old );
237- acquireId (config , new Config .DID (Config . DID . REALM_DID , config .getDeviceIdStrategy (), null ));
237+ acquireId (config , new Config .DID (config .getDeviceIdStrategy (), null ));
238238 }
239239
240240 /**
@@ -254,8 +254,14 @@ protected void changeDeviceIdInternal(InternalConfig config, String id, boolean
254254 }
255255
256256 final Config .DID old = config .getDeviceId ();
257- config .setDeviceId (new Config .DID (Config .DID .REALM_DID , Config .DID .STRATEGY_CUSTOM , id ));
258- Storage .push (config , config );
257+ if (old .id .equals (id )) {
258+ L .w ("[ModuleDeviceIdCore] changeDeviceId, Same id passed to changeDeviceId method, ignoring" );
259+ return ;
260+ }
261+
262+ internalConfig .setDeviceId (new Config .DID (Config .DID .STRATEGY_CUSTOM , id ));
263+ internalConfig .storageProvider .setDeviceIdType (DeviceIdType .DEVELOPER_SUPPLIED .name ());
264+ internalConfig .storageProvider .setDeviceID (id );
259265 SDKCore .instance .notifyModulesDeviceIdChanged (old , withMerge );
260266 }
261267
@@ -267,7 +273,7 @@ protected void changeDeviceIdInternal(InternalConfig config, String id, boolean
267273 * @param holder DID object which holds strategy and possibly other info for id generation
268274 */
269275 protected void acquireId (final InternalConfig config , final Config .DID holder ) {
270- L .i ("[ModuleDeviceIdCore] acquireId, Acquiring device id of strategy [" + holder .strategy + " / " + holder . realm + " ]" );
276+ L .i ("[ModuleDeviceIdCore] acquireId, Acquiring device id of strategy [" + holder .strategy + "]" );
271277 Config .DID did = null ;
272278
273279 int index = holder .strategy ;
@@ -280,7 +286,7 @@ protected void acquireId(final InternalConfig config, final Config.DID holder) {
280286 } else {
281287 String id = generator .generate (config );
282288 if (Utils .isNotEmpty (id )) {
283- did = new Config .DID (holder . realm , index , id );
289+ did = new Config .DID (index , id );
284290 break ;
285291 } else {
286292 L .w ("[ModuleDeviceIdCore] Device id strategy [" + index + "] didn't return. Falling back to next one." );
0 commit comments