Эх сурвалжийг харах

Merge pull request #13219 from nextcloud/bugfix/create-plain-client-on-background-thread

Bug-Fix Create PlainClient On Background Thread
Tobias Kaminsky 1 жил өмнө
parent
commit
c5d4e13589

+ 9 - 5
app/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -364,7 +364,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     private final LifecycleEventObserver lifecycleEventObserver = ((lifecycleOwner, event) -> {
         if (event == Lifecycle.Event.ON_START && token != null) {
             Log_OC.d(TAG, "Start poolLogin");
-            poolLogin(clientFactory.createPlainClient());
+            poolLogin();
         }
     });
 
@@ -398,7 +398,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
             try {
                 JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
                 String loginUrl = getLoginUrl(jsonObject);
-                runOnUiThread(() -> launchDefaultWebBrowser(loginUrl));
+                runOnUiThread(() -> {
+                    initLoginInfoView();
+                    launchDefaultWebBrowser(loginUrl);
+                });
                 token = jsonObject.getAsJsonObject("poll").get("token").getAsString();
             } catch (Throwable t) {
                 Log_OC.d(TAG, "Error caught at anonymouslyPostLoginRequest: " + t);
@@ -1653,21 +1656,22 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
     private boolean isLoginProcessCompleted = false;
     private boolean isRedirectedToTheDefaultBrowser = false;
 
-    private void poolLogin(PlainClient client) {
+    private void poolLogin() {
         loginFlowExecutorService.scheduleWithFixedDelay(() -> {
             if (!isLoginProcessCompleted) {
-                performLoginFlowV2(client);
+                performLoginFlowV2();
             }
         }, 0, 30, TimeUnit.SECONDS);
     }
 
-    private void performLoginFlowV2(PlainClient client) {
+    private void performLoginFlowV2() {
         String postRequestUrl = baseUrl + "/poll";
 
         RequestBody requestBody = new FormBody.Builder()
             .add("token", token)
             .build();
 
+        PlainClient client = clientFactory.createPlainClient();
         PostMethod post = new PostMethod(postRequestUrl, false, requestBody);
         int status = post.execute(client);
         String response = post.getResponseBodyAsString();