Add comments
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index a9fac0c..32bbcdc 100644 (file)
@@ -43,7 +43,6 @@ import android.support.v4.app.FragmentTransaction;
 import android.text.Editable;\r
 import android.text.InputType;\r
 import android.text.TextWatcher;\r
-import android.util.Log;\r
 import android.view.KeyEvent;\r
 import android.view.MotionEvent;\r
 import android.view.View;\r
@@ -114,12 +113,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private static final String KEY_PASSWORD_EXPOSED = "PASSWORD_VISIBLE";\r
     private static final String KEY_AUTH_STATUS_TEXT = "AUTH_STATUS_TEXT";\r
     private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON";\r
-    private static final String KEY_REFRESH_BUTTON_ENABLED = "REFRESH_BUTTON_ENABLED";\r
     private static final String KEY_SERVER_AUTH_METHOD = "SERVER_AUTH_METHOD";\r
-    private static final String KEY_GET_SERVER_INFO_OP_ID = "DETECT_AUTH_OP_ID";\r
-    private static final String KEY_EXISTENCE_CHECK_OP_ID = "EXISTENCE_CHECK_OP_ID";\r
-    private static final String KEY_OAUTH2_GET_ACCESS_TOKEN_OP_ID = "OAUTH2_GET_ACCESS_TOKEN";\r
-    private static final String KEY_GET_USER_NAME_OP_ID = "GET_USER_NAME";\r
+    private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID";\r
     private static final String KEY_AUTH_TOKEN = "AUTH_TOKEN";\r
 \r
     private static final String AUTH_ON = "on";\r
@@ -158,6 +153,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     \r
     private boolean mServerIsChecked = false;\r
     private boolean mServerIsValid = false;\r
+    private boolean mPendingAutoCheck = false;\r
 \r
     private GetServerInfoOperation.ServerInfo mServerInfo = \r
             new GetServerInfoOperation.ServerInfo();\r
@@ -177,12 +173,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private String mAuthToken = "";\r
 \r
     \r
-    /// Operation-in-progress identifiers - TODO improve pull-interface with OperationsService \r
-    private int mGetServerInfoOpId = -1;\r
-    private int mOauth2GetAccessTokenOpId = -1;\r
-    private int mExistenceCheckOpId = -1;\r
-    private int mGetUserNameOpId = -1;\r
-    \r
+    /// Identifier of operation in progress which result shouldn't be lost \r
+    private long mWaitingForOpId = Long.MAX_VALUE;\r
+\r
     \r
     /**\r
      * {@inheritDoc}\r
@@ -191,7 +184,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      */\r
     @Override\r
     protected void onCreate(Bundle savedInstanceState) {\r
-        Log_OC.wtf(TAG,  "onCreate init");\r
+        //Log_OC.wtf(TAG,  "onCreate init");\r
         super.onCreate(savedInstanceState);\r
         getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
 \r
@@ -218,6 +211,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             initAuthTokenType();\r
         } else {\r
             mAuthTokenType = savedInstanceState.getString(KEY_AUTH_TOKEN_TYPE);\r
+            mWaitingForOpId = savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID);\r
         }\r
         \r
         /// load user interface\r
@@ -226,13 +220,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         /// initialize general UI elements\r
         initOverallUi(savedInstanceState);\r
         \r
+        mOkButton = findViewById(R.id.buttonOK);\r
+\r
         /// initialize block to be moved to single Fragment to check server and get info about it \r
         initServerPreFragment(savedInstanceState);\r
         \r
         /// initialize block to be moved to single Fragment to retrieve and validate credentials \r
         initAuthorizationPreFragment(savedInstanceState);\r
 \r
-        Log_OC.wtf(TAG,  "onCreate end");\r
+        //Log_OC.wtf(TAG,  "onCreate end");\r
     }\r
 \r
     private void initAuthTokenType() {\r
@@ -314,7 +310,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 \r
         /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)\r
         boolean isUrlInputAllowed = getResources().getBoolean(R.bool.show_server_url_input); \r
-        //boolean refreshButtonEnabled = false;\r
         if (savedInstanceState == null) {\r
             if (mAccount != null) {\r
                 mServerInfo.mBaseUrl = mAccountMgr.getUserData(mAccount, Constants.KEY_OC_BASE_URL);\r
@@ -328,7 +323,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 mServerInfo.mIsSslConn = mServerInfo.mBaseUrl.startsWith("https://");\r
             }\r
         } else {\r
-            //refreshButtonEnabled = savedInstanceState.getBoolean(KEY_REFRESH_BUTTON_ENABLED);\r
             mServerStatusText = savedInstanceState.getInt(KEY_SERVER_STATUS_TEXT);\r
             mServerStatusIcon = savedInstanceState.getInt(KEY_SERVER_STATUS_ICON);\r
             \r
@@ -345,9 +339,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             mServerInfo.mAuthMethod = AuthenticationMethod.valueOf(\r
                     savedInstanceState.getString(KEY_SERVER_AUTH_METHOD));\r
             \r
-            // TODO save and recover any operation in progress, in a reasonable way\r
-            mGetServerInfoOpId = savedInstanceState.getInt(KEY_GET_SERVER_INFO_OP_ID);\r
-            \r
         }\r
         \r
         /// step 2 - set properties of UI elements (text, visibility, enabled...)\r
@@ -364,7 +355,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             findViewById(R.id.hostUrlFrame).setVisibility(View.GONE);\r
             mRefreshButton = findViewById(R.id.centeredRefreshButton);\r
         }\r
-        showRefreshButton(mServerIsChecked && !mServerIsValid && mGetServerInfoOpId == -1);\r
+        showRefreshButton(mServerIsChecked && !mServerIsValid && \r
+                mWaitingForOpId > Integer.MAX_VALUE);\r
         mServerStatusView = (TextView) findViewById(R.id.server_status_text);\r
         showServerStatus();\r
         \r
@@ -415,12 +407,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         });\r
      \r
         \r
-        /// step 4 - automatic actions to start\r
-        if (savedInstanceState == null) {\r
-            if (mAction != ACTION_CREATE || !isUrlInputAllowed) {\r
-                checkOcServer(); \r
-            }\r
-        }\r
+        /// step 4 - mark automatic check to be started when OperationsService is ready\r
+        mPendingAutoCheck = (savedInstanceState == null && \r
+                (mAction != ACTION_CREATE || !isUrlInputAllowed));\r
     }\r
     \r
     \r
@@ -437,7 +426,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         mUsernameInput = (EditText) findViewById(R.id.account_username);\r
         mPasswordInput = (EditText) findViewById(R.id.account_password);\r
         mAuthStatusView = (TextView) findViewById(R.id.auth_status_text); \r
-        mOkButton = findViewById(R.id.buttonOK);\r
         \r
         /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState)\r
         String presetUserName = null;\r
@@ -452,9 +440,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             mAuthStatusText = savedInstanceState.getInt(KEY_AUTH_STATUS_TEXT);\r
             mAuthStatusIcon = savedInstanceState.getInt(KEY_AUTH_STATUS_ICON);\r
             mAuthToken = savedInstanceState.getString(KEY_AUTH_TOKEN);\r
-            mExistenceCheckOpId = savedInstanceState.getInt(KEY_EXISTENCE_CHECK_OP_ID);\r
-            mOauth2GetAccessTokenOpId = savedInstanceState.getInt(KEY_OAUTH2_GET_ACCESS_TOKEN_OP_ID);\r
-            mGetUserNameOpId = savedInstanceState.getInt(KEY_GET_USER_NAME_OP_ID);\r
         }\r
         \r
         /// step 2 - set properties of UI elements (text, visibility, enabled...)\r
@@ -548,19 +533,17 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      */\r
     @Override\r
     protected void onSaveInstanceState(Bundle outState) {\r
-        Log.wtf(TAG, "onSaveInstanceState init" );\r
+        //Log_OC.wtf(TAG, "onSaveInstanceState init" );\r
         super.onSaveInstanceState(outState);\r
 \r
         /// global state\r
         outState.putString(KEY_AUTH_TOKEN_TYPE, mAuthTokenType);\r
+        outState.putLong(KEY_WAITING_FOR_OP_ID, mWaitingForOpId);\r
 \r
         /// Server PRE-fragment state\r
-        //outState.putBoolean(KEY_REFRESH_BUTTON_ENABLED, (mRefreshButton.getVisibility() == View.VISIBLE));\r
         outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText);\r
         outState.putInt(KEY_SERVER_STATUS_ICON, mServerStatusIcon);\r
         outState.putBoolean(KEY_SERVER_CHECKED, mServerIsChecked);\r
-        //outState.putBoolean(KEY_SERVER_CHECK_IN_PROGRESS, (!mServerIsValid && mServerInfoOperation != null));\r
-        outState.putInt(KEY_GET_SERVER_INFO_OP_ID, mGetServerInfoOpId);\r
         outState.putBoolean(KEY_SERVER_VALID, mServerIsValid);\r
         outState.putBoolean(KEY_IS_SSL_CONN, mServerInfo.mIsSslConn);\r
         outState.putString(KEY_HOST_URL_TEXT, mServerInfo.mBaseUrl);\r
@@ -574,11 +557,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         outState.putInt(KEY_AUTH_STATUS_ICON, mAuthStatusIcon);\r
         outState.putInt(KEY_AUTH_STATUS_TEXT, mAuthStatusText);\r
         outState.putString(KEY_AUTH_TOKEN, mAuthToken);\r
-        outState.putInt(KEY_EXISTENCE_CHECK_OP_ID, mExistenceCheckOpId);\r
-        outState.putInt(KEY_OAUTH2_GET_ACCESS_TOKEN_OP_ID, mOauth2GetAccessTokenOpId);\r
-        outState.putInt(KEY_GET_USER_NAME_OP_ID, mGetUserNameOpId);\r
 \r
-        Log.wtf(TAG, "onSaveInstanceState end" );\r
+        //Log_OC.wtf(TAG, "onSaveInstanceState end" );\r
     }\r
 \r
 \r
@@ -605,7 +585,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      */\r
     @Override\r
     protected void onResume() {\r
-        Log_OC.wtf(TAG, "onResume init" );\r
+        //Log_OC.wtf(TAG, "onResume init" );\r
         super.onResume();\r
         \r
         // bound here to avoid spurious changes triggered by Android on device rotations\r
@@ -620,15 +600,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             doOnResumeAndBound();\r
         }\r
         \r
-        Log_OC.wtf(TAG, "onResume end" );\r
+        //Log_OC.wtf(TAG, "onResume end" );\r
     }\r
 \r
     \r
     @Override\r
     protected void onPause() {\r
-        Log.wtf(TAG, "onPause init" );\r
+        //Log_OC.wtf(TAG, "onPause init" );\r
         if (mOperationsServiceBinder != null) {\r
-            Log.wtf(TAG, "unregistering to listen for operation callbacks" );\r
+            //Log_OC.wtf(TAG, "unregistering to listen for operation callbacks" );\r
             mOperationsServiceBinder.removeOperationListener(this);\r
         }\r
         \r
@@ -636,7 +616,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         mHostUrlInput.setOnFocusChangeListener(null);\r
         \r
         super.onPause();\r
-        Log.wtf(TAG, "onPause end" );\r
+        //Log_OC.wtf(TAG, "onPause end" );\r
     }\r
     \r
     @Override\r
@@ -679,8 +659,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
                 queryParameters);\r
         \r
         if (mOperationsServiceBinder != null) {\r
-            Log.wtf(TAG, "getting access token..." );\r
-            mOauth2GetAccessTokenOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent);\r
+            //Log_OC.wtf(TAG, "getting access token..." );\r
+            mWaitingForOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent);\r
         }\r
     }\r
 \r
@@ -745,8 +725,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             getServerInfoIntent.putExtra(OperationsService.EXTRA_SERVER_URL, uri);\r
             getServerInfoIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN_TYPE, mAuthTokenType);\r
             if (mOperationsServiceBinder != null) {\r
-                Log.wtf(TAG, "checking server..." );\r
-                mGetServerInfoOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent);\r
+                //Log_OC.wtf(TAG, "checking server..." );\r
+                mWaitingForOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent);\r
+            } else {\r
+              Log_OC.wtf(TAG, "Server check tried with OperationService unbound!" );\r
             }\r
             \r
         } else {\r
@@ -778,10 +760,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 \r
 \r
     private void showViewPasswordButton() {\r
-        //int drawable = android.R.drawable.ic_menu_view;\r
         int drawable = R.drawable.ic_view;\r
         if (isPasswordVisible()) {\r
-            //drawable = android.R.drawable.ic_secure;\r
             drawable = R.drawable.ic_hide;\r
         }\r
         mPasswordInput.setCompoundDrawablesWithIntrinsicBounds(0, 0, drawable, 0);\r
@@ -829,7 +809,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             mServerStatusText = R.string.auth_wtf_reenter_URL;\r
             showServerStatus();\r
             mOkButton.setEnabled(false);\r
-            Log_OC.wtf(TAG,  "The user was allowed to click 'connect' to an unchecked server!!");\r
+            //Log_OC.wtf(TAG,  "The user was allowed to click 'connect' to an unchecked server!!");\r
             return;\r
         }\r
 \r
@@ -882,8 +862,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         existenceCheckIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects);\r
         \r
         if (mOperationsServiceBinder != null) {\r
-            Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." );\r
-            mExistenceCheckOpId = mOperationsServiceBinder.newOperation(existenceCheckIntent);\r
+            //Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." );\r
+            mWaitingForOpId = mOperationsServiceBinder.newOperation(existenceCheckIntent);\r
         }\r
     }\r
 \r
@@ -898,14 +878,12 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         showAuthStatus();\r
 \r
         // GET AUTHORIZATION request\r
-        //Uri uri = Uri.parse(getString(R.string.oauth2_url_endpoint_auth));\r
         Uri uri = Uri.parse(mOAuthAuthEndpointText.getText().toString().trim());\r
         Uri.Builder uriBuilder = uri.buildUpon();\r
         uriBuilder.appendQueryParameter(OAuth2Constants.KEY_RESPONSE_TYPE, getString(R.string.oauth2_response_type));\r
         uriBuilder.appendQueryParameter(OAuth2Constants.KEY_REDIRECT_URI, getString(R.string.oauth2_redirect_uri));   \r
         uriBuilder.appendQueryParameter(OAuth2Constants.KEY_CLIENT_ID, getString(R.string.oauth2_client_id));\r
         uriBuilder.appendQueryParameter(OAuth2Constants.KEY_SCOPE, getString(R.string.oauth2_scope));\r
-        //uriBuilder.appendQueryParameter(OAuth2Constants.KEY_STATE, whateverwewant);\r
         uri = uriBuilder.build();\r
         Log_OC.d(TAG, "Starting browser to view " + uri.toString());\r
         Intent i = new Intent(Intent.ACTION_VIEW, uri);\r
@@ -946,7 +924,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {\r
 \r
         if (operation instanceof GetServerInfoOperation) {\r
-            if (operation.hashCode() == mGetServerInfoOpId) {\r
+            if (operation.hashCode() == mWaitingForOpId) {\r
                 onGetServerInfoFinish(result);\r
             }   // else nothing ; only the last check operation is considered; \r
                 // multiple can be started if the user amends a URL quickly\r
@@ -955,7 +933,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             onGetOAuthAccessTokenFinish(result);\r
 \r
         } else if (operation instanceof ExistenceCheckRemoteOperation)  {\r
-            Log_OC.wtf(TAG, "received detection response through callback" );\r
+            //Log_OC.wtf(TAG, "received detection response through callback" );\r
             if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {\r
                 onSamlBasedFederatedSingleSignOnAuthorizationStart(result);\r
 \r
@@ -969,7 +947,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     }\r
 \r
     private void onGetUserNameFinish(RemoteOperationResult result) {\r
-        mGetUserNameOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         if (result.isSuccess()) {\r
             boolean success = false;\r
             String username = (String) result.getData().get(0);\r
@@ -1002,10 +980,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     }\r
 \r
     private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) {\r
-        mExistenceCheckOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 
-        //if (result.isTemporalRedirection() && result.isIdPRedirection()) {\r
         if (result.isIdPRedirection()) {
             String url = result.getRedirectedLocation();\r
             String targetUrl = mServerInfo.mBaseUrl \r
@@ -1037,7 +1014,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private void onGetServerInfoFinish(RemoteOperationResult result) {\r
         /// update activity state\r
         mServerIsChecked = true;\r
-        mGetServerInfoOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         \r
         // update server status, but don't show it yet\r
         updateServerStatusIconAndText(result);\r
@@ -1304,7 +1281,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * @param result        Result of the operation.\r
      */\r
     private void onGetOAuthAccessTokenFinish(RemoteOperationResult result) {\r
-        mOauth2GetAccessTokenOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 \r
         String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);\r
@@ -1343,7 +1320,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * @param result        Result of the operation.\r
      */\r
     private void onAuthorizationCheckFinish(RemoteOperationResult result) {\r
-        mExistenceCheckOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 \r
         if (result.isSuccess()) {\r
@@ -1367,12 +1344,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             /// the server\r
             mServerIsChecked = true;\r
             mServerIsValid = false;\r
-            /*\r
-            mServerInfo.mIsSslConn = false;\r
-            mServerInfo.mVersion = null;\r
-            mServerInfo.mBaseUrl = \r
-                    normalizeUrl(mHostUrlInput.getText().toString(), mServerInfo.mIsSslConn);    // TODO remove?\r
-                    */\r
             mServerInfo = new GetServerInfoOperation.ServerInfo();  \r
 \r
             // update status icon and text\r
@@ -1674,8 +1645,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         getUserNameIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects);\r
         \r
         if (mOperationsServiceBinder != null) {\r
-            Log_OC.wtf(TAG, "starting getRemoteUserNameOperation..." );\r
-            mGetUserNameOpId = mOperationsServiceBinder.newOperation(getUserNameIntent);\r
+            //Log_OC.wtf(TAG, "starting getRemoteUserNameOperation..." );\r
+            mWaitingForOpId = mOperationsServiceBinder.newOperation(getUserNameIntent);\r
         }\r
     }\r
 \r
@@ -1769,51 +1740,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 \r
 \r
     private void doOnResumeAndBound() {\r
-        Log.wtf(TAG, "registering to listen for operation callbacks" );\r
+        //Log_OC.wtf(TAG, "registering to listen for operation callbacks" );\r
         mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler);\r
+        if (mWaitingForOpId <= Integer.MAX_VALUE) {\r
+            mOperationsServiceBinder.dispatchResultIfFinished((int)mWaitingForOpId, this);\r
+        }\r
         \r
-        \r
-        \r
-        if (mGetServerInfoOpId != -1) {\r
-            RemoteOperationResult result = \r
-                    mOperationsServiceBinder.getOperationResultIfFinished(mGetServerInfoOpId);\r
-            if (result != null) {\r
-                Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
-                onGetServerInfoFinish(result);\r
-            }\r
-            \r
-        } else if (mOauth2GetAccessTokenOpId != -1) {\r
-            RemoteOperationResult result = \r
-                    mOperationsServiceBinder.getOperationResultIfFinished(\r
-                            mOauth2GetAccessTokenOpId);\r
-            if (result != null) {\r
-                Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
-                onGetOAuthAccessTokenFinish(result);\r
-            }\r
-            \r
-        } else if (mExistenceCheckOpId != -1) {\r
-            RemoteOperationResult result = \r
-                    mOperationsServiceBinder.getOperationResultIfFinished(mExistenceCheckOpId);\r
-            if (result != null) {\r
-                Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
-                if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(\r
-                        MainApp.getAccountType()).equals(mAuthTokenType)) {\r
-                    onSamlBasedFederatedSingleSignOnAuthorizationStart(result);\r
-\r
-                } else {\r
-                    onAuthorizationCheckFinish(result);\r
-                }\r
-            }\r
-        }if (mGetUserNameOpId != -1) {\r
-            RemoteOperationResult result = \r
-                    mOperationsServiceBinder.getOperationResultIfFinished(mGetUserNameOpId);\r
-            if (result != null) {\r
-                Log_OC.wtf(TAG, "found result of operation finished while rotating");\r
-                onGetUserNameFinish(result);\r
-            }\r
-            \r
-        } \r
-        \r
+        if (mPendingAutoCheck) {\r
+            checkOcServer();\r
+        }\r
     }\r
 \r
     \r
@@ -1834,7 +1769,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
         @Override\r
         public void onServiceConnected(ComponentName component, IBinder service) {\r
             if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) {\r
-                Log_OC.wtf(TAG, "Operations service connected");\r
+                //Log_OC.wtf(TAG, "Operations service connected");\r
                 mOperationsServiceBinder = (OperationsServiceBinder) service;\r
                 \r
                 doOnResumeAndBound();\r