Preventing hash colisions in identifier of operations
[pub/Android/ownCloud.git] / src / com / owncloud / android / authentication / AuthenticatorActivity.java
index ee9d9bc..fd0849e 100644 (file)
@@ -174,7 +174,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 \r
     \r
     /// Identifier of operation in progress which result shouldn't be lost \r
 \r
     \r
     /// Identifier of operation in progress which result shouldn't be lost \r
-    private int mWaitingForOpId = -1;\r
+    private long mWaitingForOpId = Long.MAX_VALUE;\r
     \r
     \r
     /**\r
     \r
     \r
     /**\r
@@ -211,7 +211,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             initAuthTokenType();\r
         } else {\r
             mAuthTokenType = savedInstanceState.getString(KEY_AUTH_TOKEN_TYPE);\r
             initAuthTokenType();\r
         } else {\r
             mAuthTokenType = savedInstanceState.getString(KEY_AUTH_TOKEN_TYPE);\r
-            mWaitingForOpId = savedInstanceState.getInt(KEY_WAITING_FOR_OP_ID);\r
+            mWaitingForOpId = savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID);\r
         }\r
         \r
         /// load user interface\r
         }\r
         \r
         /// load user interface\r
@@ -355,7 +355,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
             findViewById(R.id.hostUrlFrame).setVisibility(View.GONE);\r
             mRefreshButton = findViewById(R.id.centeredRefreshButton);\r
         }\r
             findViewById(R.id.hostUrlFrame).setVisibility(View.GONE);\r
             mRefreshButton = findViewById(R.id.centeredRefreshButton);\r
         }\r
-        showRefreshButton(mServerIsChecked && !mServerIsValid && mWaitingForOpId == -1);\r
+        showRefreshButton(mServerIsChecked && !mServerIsValid && \r
+                mWaitingForOpId > Integer.MAX_VALUE);\r
         mServerStatusView = (TextView) findViewById(R.id.server_status_text);\r
         showServerStatus();\r
         \r
         mServerStatusView = (TextView) findViewById(R.id.server_status_text);\r
         showServerStatus();\r
         \r
@@ -541,7 +542,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
 \r
         /// global state\r
         outState.putString(KEY_AUTH_TOKEN_TYPE, mAuthTokenType);\r
 \r
         /// global state\r
         outState.putString(KEY_AUTH_TOKEN_TYPE, mAuthTokenType);\r
-        outState.putInt(KEY_WAITING_FOR_OP_ID, mWaitingForOpId);\r
+        outState.putLong(KEY_WAITING_FOR_OP_ID, mWaitingForOpId);\r
 \r
         /// Server PRE-fragment state\r
         outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText);\r
 \r
         /// Server PRE-fragment state\r
         outState.putInt(KEY_SERVER_STATUS_TEXT, mServerStatusText);\r
@@ -952,7 +953,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     }\r
 \r
     private void onGetUserNameFinish(RemoteOperationResult result) {\r
     }\r
 \r
     private void onGetUserNameFinish(RemoteOperationResult result) {\r
-        mWaitingForOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         if (result.isSuccess()) {\r
             boolean success = false;\r
             String username = (String) result.getData().get(0);\r
         if (result.isSuccess()) {\r
             boolean success = false;\r
             String username = (String) result.getData().get(0);\r
@@ -985,7 +986,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     }\r
 \r
     private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) {\r
     }\r
 \r
     private void onSamlBasedFederatedSingleSignOnAuthorizationStart(RemoteOperationResult result) {\r
-        mWaitingForOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 
         //if (result.isTemporalRedirection() && result.isIdPRedirection()) {\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 
         //if (result.isTemporalRedirection() && result.isIdPRedirection()) {\r
@@ -1020,7 +1021,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private void onGetServerInfoFinish(RemoteOperationResult result) {\r
         /// update activity state\r
         mServerIsChecked = true;\r
     private void onGetServerInfoFinish(RemoteOperationResult result) {\r
         /// update activity state\r
         mServerIsChecked = true;\r
-        mWaitingForOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         \r
         // update server status, but don't show it yet\r
         updateServerStatusIconAndText(result);\r
         \r
         // update server status, but don't show it yet\r
         updateServerStatusIconAndText(result);\r
@@ -1287,7 +1288,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * @param result        Result of the operation.\r
      */\r
     private void onGetOAuthAccessTokenFinish(RemoteOperationResult result) {\r
      * @param result        Result of the operation.\r
      */\r
     private void onGetOAuthAccessTokenFinish(RemoteOperationResult result) {\r
-        mWaitingForOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 \r
         String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 \r
         String webdav_path = AccountUtils.getWebdavPath(mServerInfo.mVersion, mAuthTokenType);\r
@@ -1326,7 +1327,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
      * @param result        Result of the operation.\r
      */\r
     private void onAuthorizationCheckFinish(RemoteOperationResult result) {\r
      * @param result        Result of the operation.\r
      */\r
     private void onAuthorizationCheckFinish(RemoteOperationResult result) {\r
-        mWaitingForOpId = -1;\r
+        mWaitingForOpId = Long.MAX_VALUE;\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 \r
         result = new RemoteOperationResult(new RuntimeException("FAKE"));\r
         dismissDialog(WAIT_DIALOG_TAG);\r
 \r
         result = new RemoteOperationResult(new RuntimeException("FAKE"));\r
@@ -1755,8 +1756,8 @@ SsoWebViewClientListener, OnSslUntrustedCertListener {
     private void doOnResumeAndBound() {\r
         Log.wtf(TAG, "registering to listen for operation callbacks" );\r
         mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler);\r
     private void doOnResumeAndBound() {\r
         Log.wtf(TAG, "registering to listen for operation callbacks" );\r
         mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler);\r
-        if (mWaitingForOpId != -1) {\r
-            mOperationsServiceBinder.dispatchResultIfFinished(mWaitingForOpId, this);\r
+        if (mWaitingForOpId <= Integer.MAX_VALUE) {\r
+            mOperationsServiceBinder.dispatchResultIfFinished((int)mWaitingForOpId, this);\r
         }\r
     }\r
 \r
         }\r
     }\r
 \r