X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/f24e56d19dd384e7afa90a5b0f6326072d189cce..c39e851f5eada08c93d3a57d41054ea112b4bfcf:/src/com/owncloud/android/authentication/AuthenticatorActivity.java diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 60111930..32bbcdcc 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -114,7 +114,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private static final String KEY_AUTH_STATUS_TEXT = "AUTH_STATUS_TEXT"; private static final String KEY_AUTH_STATUS_ICON = "AUTH_STATUS_ICON"; private static final String KEY_SERVER_AUTH_METHOD = "SERVER_AUTH_METHOD"; - private static final String KEY_WAITING_FOR_OP_ID = "DETECT_AUTH_OP_ID"; + private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID"; private static final String KEY_AUTH_TOKEN = "AUTH_TOKEN"; private static final String AUTH_ON = "on"; @@ -153,6 +153,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private boolean mServerIsChecked = false; private boolean mServerIsValid = false; + private boolean mPendingAutoCheck = false; private GetServerInfoOperation.ServerInfo mServerInfo = new GetServerInfoOperation.ServerInfo(); @@ -174,7 +175,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// Identifier of operation in progress which result shouldn't be lost private long mWaitingForOpId = Long.MAX_VALUE; - + /** * {@inheritDoc} @@ -183,7 +184,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { */ @Override protected void onCreate(Bundle savedInstanceState) { - Log_OC.wtf(TAG, "onCreate init"); + //Log_OC.wtf(TAG, "onCreate init"); super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); @@ -219,13 +220,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { /// initialize general UI elements initOverallUi(savedInstanceState); + mOkButton = findViewById(R.id.buttonOK); + /// initialize block to be moved to single Fragment to check server and get info about it initServerPreFragment(savedInstanceState); /// initialize block to be moved to single Fragment to retrieve and validate credentials initAuthorizationPreFragment(savedInstanceState); - Log_OC.wtf(TAG, "onCreate end"); + //Log_OC.wtf(TAG, "onCreate end"); } private void initAuthTokenType() { @@ -404,12 +407,9 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { }); - /// step 4 - automatic actions to start - if (savedInstanceState == null) { - if (mAction != ACTION_CREATE || !isUrlInputAllowed) { - checkOcServer(); - } - } + /// step 4 - mark automatic check to be started when OperationsService is ready + mPendingAutoCheck = (savedInstanceState == null && + (mAction != ACTION_CREATE || !isUrlInputAllowed)); } @@ -426,7 +426,6 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mUsernameInput = (EditText) findViewById(R.id.account_username); mPasswordInput = (EditText) findViewById(R.id.account_password); mAuthStatusView = (TextView) findViewById(R.id.auth_status_text); - mOkButton = findViewById(R.id.buttonOK); /// step 1 - load and process relevant inputs (resources, intent, savedInstanceState) String presetUserName = null; @@ -534,7 +533,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { */ @Override protected void onSaveInstanceState(Bundle outState) { - Log_OC.wtf(TAG, "onSaveInstanceState init" ); + //Log_OC.wtf(TAG, "onSaveInstanceState init" ); super.onSaveInstanceState(outState); /// global state @@ -559,7 +558,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { outState.putInt(KEY_AUTH_STATUS_TEXT, mAuthStatusText); outState.putString(KEY_AUTH_TOKEN, mAuthToken); - Log_OC.wtf(TAG, "onSaveInstanceState end" ); + //Log_OC.wtf(TAG, "onSaveInstanceState end" ); } @@ -586,7 +585,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { */ @Override protected void onResume() { - Log_OC.wtf(TAG, "onResume init" ); + //Log_OC.wtf(TAG, "onResume init" ); super.onResume(); // bound here to avoid spurious changes triggered by Android on device rotations @@ -601,15 +600,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { doOnResumeAndBound(); } - Log_OC.wtf(TAG, "onResume end" ); + //Log_OC.wtf(TAG, "onResume end" ); } @Override protected void onPause() { - Log_OC.wtf(TAG, "onPause init" ); + //Log_OC.wtf(TAG, "onPause init" ); if (mOperationsServiceBinder != null) { - Log_OC.wtf(TAG, "unregistering to listen for operation callbacks" ); + //Log_OC.wtf(TAG, "unregistering to listen for operation callbacks" ); mOperationsServiceBinder.removeOperationListener(this); } @@ -617,7 +616,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mHostUrlInput.setOnFocusChangeListener(null); super.onPause(); - Log_OC.wtf(TAG, "onPause end" ); + //Log_OC.wtf(TAG, "onPause end" ); } @Override @@ -660,7 +659,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { queryParameters); if (mOperationsServiceBinder != null) { - Log_OC.wtf(TAG, "getting access token..." ); + //Log_OC.wtf(TAG, "getting access token..." ); mWaitingForOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent); } } @@ -726,8 +725,10 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { getServerInfoIntent.putExtra(OperationsService.EXTRA_SERVER_URL, uri); getServerInfoIntent.putExtra(OperationsService.EXTRA_AUTH_TOKEN_TYPE, mAuthTokenType); if (mOperationsServiceBinder != null) { - Log_OC.wtf(TAG, "checking server..." ); + //Log_OC.wtf(TAG, "checking server..." ); mWaitingForOpId = mOperationsServiceBinder.newOperation(getServerInfoIntent); + } else { + Log_OC.wtf(TAG, "Server check tried with OperationService unbound!" ); } } else { @@ -808,7 +809,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { mServerStatusText = R.string.auth_wtf_reenter_URL; showServerStatus(); mOkButton.setEnabled(false); - Log_OC.wtf(TAG, "The user was allowed to click 'connect' to an unchecked server!!"); + //Log_OC.wtf(TAG, "The user was allowed to click 'connect' to an unchecked server!!"); return; } @@ -861,7 +862,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { existenceCheckIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects); if (mOperationsServiceBinder != null) { - Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." ); + //Log_OC.wtf(TAG, "starting existenceCheckRemoteOperation..." ); mWaitingForOpId = mOperationsServiceBinder.newOperation(existenceCheckIntent); } } @@ -932,7 +933,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { onGetOAuthAccessTokenFinish(result); } else if (operation instanceof ExistenceCheckRemoteOperation) { - Log_OC.wtf(TAG, "received detection response through callback" ); + //Log_OC.wtf(TAG, "received detection response through callback" ); if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) { onSamlBasedFederatedSingleSignOnAuthorizationStart(result); @@ -1644,7 +1645,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { getUserNameIntent.putExtra(OperationsService.EXTRA_FOLLOW_REDIRECTS, followRedirects); if (mOperationsServiceBinder != null) { - Log_OC.wtf(TAG, "starting getRemoteUserNameOperation..." ); + //Log_OC.wtf(TAG, "starting getRemoteUserNameOperation..." ); mWaitingForOpId = mOperationsServiceBinder.newOperation(getUserNameIntent); } } @@ -1739,11 +1740,15 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { private void doOnResumeAndBound() { - Log_OC.wtf(TAG, "registering to listen for operation callbacks" ); + //Log_OC.wtf(TAG, "registering to listen for operation callbacks" ); mOperationsServiceBinder.addOperationListener(AuthenticatorActivity.this, mHandler); if (mWaitingForOpId <= Integer.MAX_VALUE) { mOperationsServiceBinder.dispatchResultIfFinished((int)mWaitingForOpId, this); } + + if (mPendingAutoCheck) { + checkOcServer(); + } } @@ -1764,7 +1769,7 @@ SsoWebViewClientListener, OnSslUntrustedCertListener { @Override public void onServiceConnected(ComponentName component, IBinder service) { if (component.equals(new ComponentName(AuthenticatorActivity.this, OperationsService.class))) { - Log_OC.wtf(TAG, "Operations service connected"); + //Log_OC.wtf(TAG, "Operations service connected"); mOperationsServiceBinder = (OperationsServiceBinder) service; doOnResumeAndBound();