@@ -30,18 +30,25 @@ Context getContext() {
3030
3131 public synchronized LocalDevice getLocalDevice () {
3232 if (localDevice == null ) {
33+ Log .v (TAG , "getLocalDevice(): creating new instance and returning that" );
3334 localDevice = new LocalDevice (this );
35+ } else {
36+ Log .v (TAG , "getLocalDevice(): returning existing instance" );
3437 }
3538 return localDevice ;
3639 }
3740
3841 public synchronized void setActivationStateMachine (ActivationStateMachine activationStateMachine ) {
42+ Log .v (TAG , "setActivationStateMachine(): activationStateMachine=" + activationStateMachine );
3943 this .activationStateMachine = activationStateMachine ;
4044 }
4145
4246 public synchronized ActivationStateMachine getActivationStateMachine () {
4347 if (activationStateMachine == null ) {
48+ Log .v (TAG , "getActivationStateMachine(): creating new instance and returning that" );
4449 activationStateMachine = new ActivationStateMachine (this );
50+ } else {
51+ Log .v (TAG , "getActivationStateMachine(): returning existing instance" );
4552 }
4653 return activationStateMachine ;
4754 }
@@ -55,6 +62,8 @@ AblyRest getAbly() throws AblyException {
5562 if (ably != null ) {
5663 Log .v (TAG , "getAbly(): returning existing Ably instance" );
5764 return ably ;
65+ } else {
66+ Log .v (TAG , "getAbly(): creating new Ably instance" );
5867 }
5968
6069 String deviceIdentityToken = getLocalDevice ().deviceIdentityToken ;
@@ -67,22 +76,27 @@ AblyRest getAbly() throws AblyException {
6776 }
6877
6978 public boolean setClientId (String clientId , boolean propagateGotPushDeviceDetails ) {
79+ Log .v (TAG , "setClientId(): clientId=" + clientId + ", propagateGotPushDeviceDetails=" + propagateGotPushDeviceDetails );
7080 boolean updated = !clientId .equals (this .clientId );
7181 if (updated ) {
7282 this .clientId = clientId ;
7383 if (localDevice != null ) {
84+ Log .v (TAG , "setClientId(): local device exists" );
7485 /* Spec: RSH8d */
7586 localDevice .setClientId (clientId );
7687 if (localDevice .isRegistered () && activationStateMachine != null && propagateGotPushDeviceDetails ) {
7788 /* Spec: RSH8e */
7889 activationStateMachine .handleEvent (new ActivationStateMachine .GotPushDeviceDetails ());
7990 }
91+ } else {
92+ Log .v (TAG , "setClientId(): local device doest not exist" );
8093 }
8194 }
8295 return updated ;
8396 }
8497
8598 public void onNewRegistrationToken (RegistrationToken .Type type , String token ) {
99+ Log .v (TAG , "onNewRegistrationToken(): type=" + type + ", token=" + token );
86100 LocalDevice localDevice = getLocalDevice ();
87101 RegistrationToken previous = localDevice .getRegistrationToken ();
88102 if (previous != null ) {
@@ -100,6 +114,8 @@ public void onNewRegistrationToken(RegistrationToken.Type type, String token) {
100114 }
101115
102116 public void reset () {
117+ Log .v (TAG , "reset()" );
118+
103119 ably = null ;
104120
105121 getActivationStateMachine ().reset ();
@@ -120,19 +136,26 @@ public static ActivationContext getActivationContext(Context applicationContext,
120136 if (activationContext == null ) {
121137 Log .v (TAG , "getActivationContext(): creating new ActivationContext for this application" );
122138 activationContexts .put (applicationContext , (activationContext = new ActivationContext (applicationContext )));
139+ } else {
140+ Log .v (TAG , "getActivationContext(): returning existing ActivationContext for this application" );
123141 }
124142 if (ably != null ) {
143+ Log .v (TAG , "Setting Ably instance on the activation context" );
125144 activationContext .setAbly (ably );
145+ } else {
146+ Log .v (TAG , "Not setting Ably instance on the activation context" );
126147 }
127148 }
128149 return activationContext ;
129150 }
130151
131152 protected void getRegistrationToken (final Callback <String > callback ) {
153+ Log .v (TAG , "getRegistrationToken(): callback=" + callback );
132154 FirebaseInstanceId .getInstance ().getInstanceId ()
133155 .addOnCompleteListener (new OnCompleteListener <InstanceIdResult >() {
134156 @ Override
135157 public void onComplete (Task <InstanceIdResult > task ) {
158+ Log .v (TAG , "getRegistrationToken(): firebase called onComplete(): task=" + task );
136159 if (task .isSuccessful ()) {
137160 /* Get new Instance ID token */
138161 String token = task .getResult ().getToken ();
@@ -145,6 +168,7 @@ public void onComplete(Task<InstanceIdResult> task) {
145168 }
146169
147170 public static void setActivationContext (Context applicationContext , ActivationContext activationContext ) {
171+ Log .v (TAG , "setActivationContext(): applicationContext=" + applicationContext + ", activationContext=" + activationContext );
148172 activationContexts .put (applicationContext , activationContext );
149173 }
150174
0 commit comments