Merge pull request #12587 from nextcloud/fixAuthNPE

On branded clients NPE can occur
This commit is contained in:
Tobias Kaminsky 2024-02-23 14:49:52 +01:00 committed by GitHub
commit 639a7b9f53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,7 +60,6 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AndroidRuntimeException; import android.util.AndroidRuntimeException;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -215,7 +214,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
private AccountManager mAccountMgr; private AccountManager mAccountMgr;
/// Server PRE-Fragment elements /// Server PRE-Fragment elements
private AccountSetupBinding accountSetupBinding; private AccountSetupBinding accountSetupBinding = null;
private AccountSetupWebviewBinding accountSetupWebviewBinding; private AccountSetupWebviewBinding accountSetupWebviewBinding;
private String mServerStatusText = EMPTY_STRING; private String mServerStatusText = EMPTY_STRING;
@ -768,13 +767,14 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
} }
@SuppressFBWarnings("NP")
private void checkOcServer() { private void checkOcServer() {
String uri; String uri;
Editable hostUrlInput = accountSetupBinding.hostUrlInput.getText();
if (accountSetupBinding != null && hostUrlInput != null && if (accountSetupBinding != null &&
!hostUrlInput.toString().isEmpty()) { accountSetupBinding.hostUrlInput.getText() != null &&
uri = hostUrlInput.toString().trim(); !accountSetupBinding.hostUrlInput.getText().toString().isEmpty()) {
uri = accountSetupBinding.hostUrlInput.getText().toString().trim();
} else { } else {
uri = mServerInfo.mBaseUrl; uri = mServerInfo.mBaseUrl;
} }