@@ -38,23 +38,45 @@ public class AuthFlowIn extends AppCompatActivity {
3838 private static final String PREF_TIDEPOOL_USER_NAME = "tidepool_username" ;
3939 private static final String PREF_TIDEPOOL_SUB_NAME = "tidepool_subname" ;
4040
41+ private static final boolean DEBUG = false ;
42+
4143 final AtomicReference <JSONObject > userInfo = new AtomicReference <>();
4244
4345 public void onCreate (final Bundle savedInstanceBundle ) {
4446 super .onCreate (savedInstanceBundle );
47+ val intent = getIntent ();
4548 Log .d (TAG , "Got response" );
46- Inevitable .task ("tidepool-process-auth" , 10 , () -> processIntent (getIntent ()));
49+ if (DEBUG ) {
50+ val extras = intent .getExtras ();
51+ if (extras != null ) {
52+ for (String key : extras .keySet ()) {
53+ Object value = extras .get (key );
54+ Log .d (TAG , key + " = " + value + " (" + (value != null ? value .getClass ().getName () : "null" ) + ")" );
55+ }
56+ } else {
57+ Log .d (TAG , "No extras found in intent." );
58+ }
59+ }
60+ Inevitable .task ("tidepool-process-auth" , 10 , () -> processIntent (intent ));
4761 this .finish ();
4862 }
4963
5064 private void processIntent (final Intent intent ) {
65+ if (intent == null ) {
66+ Log .wtf (TAG , "Intent is null when trying to process intent" );
67+ return ;
68+ }
5169 val authorizationResponse = AuthorizationResponse .fromIntent (intent );
5270 val authorizationException = AuthorizationException .fromIntent (intent );
5371 val state = AuthFlowOut .getAuthState ();
5472 if (state == null ) {
5573 Log .wtf (TAG , "Could not get auth state" );
5674 return ;
5775 }
76+ if (authorizationResponse == null && authorizationException == null ) {
77+ Log .wtf (TAG , "Both response and exception are null when processing intent?" );
78+ return ;
79+ }
5880 state .update (authorizationResponse , authorizationException );
5981 if (authorizationException != null ) {
6082 Log .d (TAG , "Got authorization error - resetting state: " + authorizationException );
0 commit comments