Changes for assistant : fixed SHA-256, improved logs & use of xml default configs
This commit is contained in:
parent
aeb92f6b28
commit
2d3744fdbd
10 changed files with 125 additions and 30 deletions
|
@ -31,9 +31,11 @@ import android.widget.RelativeLayout;
|
|||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.AccountCreator;
|
||||
import org.linphone.core.AccountCreatorListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.DialPlan;
|
||||
import org.linphone.core.tools.Log;
|
||||
|
||||
|
@ -70,7 +72,6 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
|||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mAccountCreator.setDomain(getString(R.string.default_domain));
|
||||
mConnect.setEnabled(false);
|
||||
|
||||
if (mUsernameConnectionSwitch.isChecked()) {
|
||||
|
@ -83,7 +84,9 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
|||
|
||||
AccountCreator.Status status = mAccountCreator.recoverAccount();
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
Log.e("[Account Connection] recoverAccount returned " + status);
|
||||
Log.e(
|
||||
"[Account Connection Assistant] recoverAccount returned "
|
||||
+ status);
|
||||
mConnect.setEnabled(true);
|
||||
showGenericErrorDialog(status);
|
||||
}
|
||||
|
@ -202,7 +205,9 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
public void onRecoverAccount(
|
||||
AccountCreator creator, AccountCreator.Status status, String resp) {
|
||||
Log.i("[Account Connection] onRecoverAccount status is " + status);
|
||||
Log.i(
|
||||
"[Account Connection Assistant] onRecoverAccount status is "
|
||||
+ status);
|
||||
if (status.equals(AccountCreator.Status.RequestOk)) {
|
||||
Intent intent =
|
||||
new Intent(
|
||||
|
@ -216,6 +221,11 @@ public class AccountConnectionAssistantActivity extends AssistantActivity {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
reloadLinphoneAccountCreatorConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.linphone.R;
|
|||
import org.linphone.activities.DialerActivity;
|
||||
import org.linphone.activities.LinphoneGenericActivity;
|
||||
import org.linphone.core.AccountCreator;
|
||||
import org.linphone.core.Config;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.DialPlan;
|
||||
import org.linphone.core.Factory;
|
||||
|
@ -104,22 +105,52 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void reloadAccountCreatorConfig(String path) {
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
core.loadConfigFromXml(path);
|
||||
if (mAccountCreator != null) {
|
||||
// Below two settings are applied to account creator when it is built.
|
||||
// Reloading Core config after won't change the account creator configuration,
|
||||
// hence the manual reload
|
||||
Config config = LinphonePreferences.instance().getConfig();
|
||||
mAccountCreator.setDomain(config.getString("assistant", "domain", null));
|
||||
mAccountCreator.setAlgorithm(config.getString("assistant", "algorithm", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void reloadDefaultAccountCreatorConfig() {
|
||||
Log.i("[Assistant] Reloading configuration with default");
|
||||
reloadAccountCreatorConfig(LinphonePreferences.instance().getDefaultDynamicConfigFile());
|
||||
}
|
||||
|
||||
void reloadLinphoneAccountCreatorConfig() {
|
||||
Log.i("[Assistant] Reloading configuration with specifics");
|
||||
reloadAccountCreatorConfig(LinphonePreferences.instance().getLinphoneDynamicConfigFile());
|
||||
}
|
||||
|
||||
void createProxyConfigAndLeaveAssistant() {
|
||||
Core core = LinphoneManager.getCore();
|
||||
boolean useLinphoneDefaultValues =
|
||||
getString(R.string.default_domain).equals(mAccountCreator.getDomain());
|
||||
if (useLinphoneDefaultValues) {
|
||||
Log.i("[Assistant] Default domain found, reloading configuration");
|
||||
core.loadConfigFromXml(LinphonePreferences.instance().getLinphoneDynamicConfigFile());
|
||||
} else {
|
||||
Log.i("[Assistant] Third party domain found, keeping default values");
|
||||
}
|
||||
|
||||
ProxyConfig proxyConfig = mAccountCreator.createProxyConfig();
|
||||
|
||||
if (useLinphoneDefaultValues) {
|
||||
// Restore default values
|
||||
Log.i("[Assistant] Restoring default assistant configuration");
|
||||
core.loadConfigFromXml(LinphonePreferences.instance().getDefaultDynamicConfigFile());
|
||||
} else {
|
||||
// If this isn't a sip.linphone.org account, disable push notifications and enable
|
||||
// service notification, otherwise incoming calls won't work (most probably)
|
||||
Log.w("[Assistant] Unknown domain used, push probably won't work, enable service mode");
|
||||
LinphonePreferences.instance().setServiceNotificationVisibility(true);
|
||||
LinphoneContext.instance().getNotificationManager().startForeground();
|
||||
}
|
||||
|
|
|
@ -30,9 +30,11 @@ import android.view.View;
|
|||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.AccountCreator;
|
||||
import org.linphone.core.AccountCreatorListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.tools.Log;
|
||||
|
||||
public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
||||
|
@ -161,12 +163,13 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
public void onClick(View v) {
|
||||
enableButtonsAndFields(false);
|
||||
mAccountCreator.setDomain(getString(R.string.default_domain));
|
||||
|
||||
AccountCreator.Status status = mAccountCreator.isAccountExist();
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
enableButtonsAndFields(true);
|
||||
Log.e("[Email Account Creation] isAccountExists returned " + status);
|
||||
Log.e(
|
||||
"[Email Account Creation Assistant] isAccountExists returned "
|
||||
+ status);
|
||||
showGenericErrorDialog(status);
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +180,9 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
|||
new AccountCreatorListenerStub() {
|
||||
public void onIsAccountExist(
|
||||
AccountCreator creator, AccountCreator.Status status, String resp) {
|
||||
Log.i("[Email Account Creation] onIsAccountExist status is " + status);
|
||||
Log.i(
|
||||
"[Email Account Creation Assistant] onIsAccountExist status is "
|
||||
+ status);
|
||||
if (status.equals(AccountCreator.Status.AccountExist)
|
||||
|| status.equals(AccountCreator.Status.AccountExistWithAlias)) {
|
||||
showAccountAlreadyExistsDialog();
|
||||
|
@ -185,7 +190,9 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
|||
} else if (status.equals(AccountCreator.Status.AccountNotExist)) {
|
||||
status = mAccountCreator.createAccount();
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
Log.e("[Email Account Creation] createAccount returned " + status);
|
||||
Log.e(
|
||||
"[Email Account Creation Assistant] createAccount returned "
|
||||
+ status);
|
||||
enableButtonsAndFields(true);
|
||||
showGenericErrorDialog(status);
|
||||
}
|
||||
|
@ -198,7 +205,9 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
public void onCreateAccount(
|
||||
AccountCreator creator, AccountCreator.Status status, String resp) {
|
||||
Log.i("[Email Account Creation] onCreateAccount status is " + status);
|
||||
Log.i(
|
||||
"[Email Account Creation Assistant] onCreateAccount status is "
|
||||
+ status);
|
||||
if (status.equals(AccountCreator.Status.AccountCreated)) {
|
||||
startActivity(
|
||||
new Intent(
|
||||
|
@ -210,6 +219,11 @@ public class EmailAccountCreationAssistantActivity extends AssistantActivity {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
reloadLinphoneAccountCreatorConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void enableButtonsAndFields(boolean enable) {
|
||||
|
|
|
@ -52,7 +52,9 @@ public class EmailAccountValidationAssistantActivity extends AssistantActivity {
|
|||
|
||||
AccountCreator.Status status = mAccountCreator.isAccountActivated();
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
Log.e("[Email Account Validation] activateAccount returned " + status);
|
||||
Log.e(
|
||||
"[Email Account Validation Assistant] activateAccount returned "
|
||||
+ status);
|
||||
mFinishCreation.setEnabled(true);
|
||||
showGenericErrorDialog(status);
|
||||
}
|
||||
|
@ -65,7 +67,7 @@ public class EmailAccountValidationAssistantActivity extends AssistantActivity {
|
|||
public void onIsAccountActivated(
|
||||
AccountCreator creator, AccountCreator.Status status, String resp) {
|
||||
Log.i(
|
||||
"[Email Account Validation] onIsAccountActivated status is "
|
||||
"[Email Account Validation Assistant] onIsAccountActivated status is "
|
||||
+ status);
|
||||
if (status.equals(AccountCreator.Status.AccountActivated)) {
|
||||
createProxyConfigAndLeaveAssistant();
|
||||
|
|
|
@ -27,8 +27,11 @@ import android.widget.EditText;
|
|||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.TransportType;
|
||||
import org.linphone.core.tools.Log;
|
||||
|
||||
public class GenericConnectionAssistantActivity extends AssistantActivity implements TextWatcher {
|
||||
private TextView mLogin;
|
||||
|
@ -60,6 +63,12 @@ public class GenericConnectionAssistantActivity extends AssistantActivity implem
|
|||
mDomain = findViewById(R.id.assistant_domain);
|
||||
mDomain.addTextChangedListener(this);
|
||||
mTransport = findViewById(R.id.assistant_transports);
|
||||
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
Log.i("[Generic Connection Assistant] Reloading configuration with default");
|
||||
reloadDefaultAccountCreatorConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void configureAccount() {
|
||||
|
|
|
@ -58,7 +58,7 @@ public class OpenH264DownloadAssistantActivity extends AssistantActivity {
|
|||
public void onClick(View v) {
|
||||
mYes.setEnabled(false);
|
||||
mNo.setEnabled(false);
|
||||
Log.e("[OpenH264 Downloader] Start download");
|
||||
Log.e("[OpenH264 Downloader Assistant] Start download");
|
||||
mProgress.setVisibility(View.VISIBLE);
|
||||
mHelper.downloadCodec();
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class OpenH264DownloadAssistantActivity extends AssistantActivity {
|
|||
public void onClick(View v) {
|
||||
mYes.setEnabled(false);
|
||||
mNo.setEnabled(false);
|
||||
Log.e("[OpenH264 Downloader] Download refused");
|
||||
Log.e("[OpenH264 Downloader Assistant] Download refused");
|
||||
goToLinphoneActivity();
|
||||
}
|
||||
});
|
||||
|
@ -96,7 +96,7 @@ public class OpenH264DownloadAssistantActivity extends AssistantActivity {
|
|||
|
||||
@Override
|
||||
public void OnError(String s) {
|
||||
Log.e("[OpenH264 Downloader] " + s);
|
||||
Log.e("[OpenH264 Downloader Assistant] " + s);
|
||||
mYes.setEnabled(true);
|
||||
mNo.setEnabled(true);
|
||||
}
|
||||
|
|
|
@ -30,9 +30,11 @@ import android.widget.EditText;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import org.linphone.LinphoneManager;
|
||||
import org.linphone.R;
|
||||
import org.linphone.core.AccountCreator;
|
||||
import org.linphone.core.AccountCreatorListenerStub;
|
||||
import org.linphone.core.Core;
|
||||
import org.linphone.core.DialPlan;
|
||||
import org.linphone.core.tools.Log;
|
||||
|
||||
|
@ -74,11 +76,12 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
|||
} else {
|
||||
mAccountCreator.setUsername(mAccountCreator.getPhoneNumber());
|
||||
}
|
||||
mAccountCreator.setDomain(getString(R.string.default_domain));
|
||||
|
||||
AccountCreator.Status status = mAccountCreator.isAccountExist();
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
Log.e("[Phone Account Creation] isAccountExists returned " + status);
|
||||
Log.e(
|
||||
"[Phone Account Creation Assistant] isAccountExists returned "
|
||||
+ status);
|
||||
enableButtonsAndFields(true);
|
||||
showGenericErrorDialog(status);
|
||||
}
|
||||
|
@ -167,7 +170,9 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
|||
new AccountCreatorListenerStub() {
|
||||
public void onIsAccountExist(
|
||||
AccountCreator creator, AccountCreator.Status status, String resp) {
|
||||
Log.i("[Phone Account Creation] onIsAccountExist status is " + status);
|
||||
Log.i(
|
||||
"[Phone Account Creation Assistant] onIsAccountExist status is "
|
||||
+ status);
|
||||
if (status.equals(AccountCreator.Status.AccountExist)
|
||||
|| status.equals(AccountCreator.Status.AccountExistWithAlias)) {
|
||||
showAccountAlreadyExistsDialog();
|
||||
|
@ -175,7 +180,9 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
|||
} else if (status.equals(AccountCreator.Status.AccountNotExist)) {
|
||||
status = mAccountCreator.createAccount();
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
Log.e("[Phone Account Creation] createAccount returned " + status);
|
||||
Log.e(
|
||||
"[Phone Account Creation Assistant] createAccount returned "
|
||||
+ status);
|
||||
enableButtonsAndFields(true);
|
||||
showGenericErrorDialog(status);
|
||||
}
|
||||
|
@ -188,7 +195,9 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
public void onCreateAccount(
|
||||
AccountCreator creator, AccountCreator.Status status, String resp) {
|
||||
Log.i("[Phone Account Creation] onCreateAccount status is " + status);
|
||||
Log.i(
|
||||
"[Phone Account Creation Assistant] onCreateAccount status is "
|
||||
+ status);
|
||||
if (status.equals(AccountCreator.Status.AccountCreated)) {
|
||||
startActivity(
|
||||
new Intent(
|
||||
|
@ -200,6 +209,11 @@ public class PhoneAccountCreationAssistantActivity extends AssistantActivity {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
reloadLinphoneAccountCreatorConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -56,7 +56,7 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
int proxyConfigIndex = getIntent().getExtras().getInt("AccountNumber");
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core == null) {
|
||||
Log.e("[Account Linking] Core not available");
|
||||
Log.e("[Account Linking Assistant] Core not available");
|
||||
unexpectedError();
|
||||
}
|
||||
|
||||
|
@ -66,12 +66,12 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
|
||||
Address identity = mProxyConfig.getIdentityAddress();
|
||||
if (identity == null) {
|
||||
Log.e("[Account Linking] Proxy doesn't have an identity address");
|
||||
Log.e("[Account Linking Assistant] Proxy doesn't have an identity address");
|
||||
unexpectedError();
|
||||
}
|
||||
if (!mProxyConfig.getDomain().equals(getString(R.string.default_domain))) {
|
||||
Log.e(
|
||||
"[Account Linking] Can't link account on domain "
|
||||
"[Account Linking Assistant] Can't link account on domain "
|
||||
+ mProxyConfig.getDomain());
|
||||
unexpectedError();
|
||||
}
|
||||
|
@ -79,18 +79,18 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
|
||||
AuthInfo authInfo = mProxyConfig.findAuthInfo();
|
||||
if (authInfo == null) {
|
||||
Log.e("[Account Linking] Auth info not found");
|
||||
Log.e("[Account Linking Assistant] Auth info not found");
|
||||
unexpectedError();
|
||||
}
|
||||
mAccountCreator.setHa1(authInfo.getHa1());
|
||||
|
||||
mAccountCreator.setDomain(getString(R.string.default_domain));
|
||||
} else {
|
||||
Log.e("[Account Linking] Proxy config index out of bounds: " + proxyConfigIndex);
|
||||
Log.e(
|
||||
"[Account Linking Assistant] Proxy config index out of bounds: "
|
||||
+ proxyConfigIndex);
|
||||
unexpectedError();
|
||||
}
|
||||
} else {
|
||||
Log.e("[Account Linking] Proxy config index not found");
|
||||
Log.e("[Account Linking Assistant] Proxy config index not found");
|
||||
unexpectedError();
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,9 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
|
||||
AccountCreator.Status status = mAccountCreator.isAliasUsed();
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
Log.e("[Phone Account Linking] isAliasUsed returned " + status);
|
||||
Log.e(
|
||||
"[Phone Account Linking Assistant] isAliasUsed returned "
|
||||
+ status);
|
||||
enableButtonsAndFields(true);
|
||||
showGenericErrorDialog(status);
|
||||
}
|
||||
|
@ -178,11 +180,15 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
public void onIsAliasUsed(
|
||||
AccountCreator creator, AccountCreator.Status status, String resp) {
|
||||
Log.i("[Phone Account Linking] onIsAliasUsed status is " + status);
|
||||
Log.i(
|
||||
"[Phone Account Linking Assistant] onIsAliasUsed status is "
|
||||
+ status);
|
||||
if (status.equals(AccountCreator.Status.AliasNotExist)) {
|
||||
status = mAccountCreator.linkAccount();
|
||||
if (status != AccountCreator.Status.RequestOk) {
|
||||
Log.e("[Phone Account Linking] linkAccount returned " + status);
|
||||
Log.e(
|
||||
"[Phone Account Linking Assistant] linkAccount returned "
|
||||
+ status);
|
||||
enableButtonsAndFields(true);
|
||||
showGenericErrorDialog(status);
|
||||
}
|
||||
|
@ -200,7 +206,9 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
@Override
|
||||
public void onLinkAccount(
|
||||
AccountCreator creator, AccountCreator.Status status, String resp) {
|
||||
Log.i("[Phone Account Linking] onLinkAccount status is " + status);
|
||||
Log.i(
|
||||
"[Phone Account Linking Assistant] onLinkAccount status is "
|
||||
+ status);
|
||||
if (status.equals(AccountCreator.Status.RequestOk)) {
|
||||
Intent intent =
|
||||
new Intent(
|
||||
|
@ -214,6 +222,11 @@ public class PhoneAccountLinkingAssistantActivity extends AssistantActivity {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
Core core = LinphoneManager.getCore();
|
||||
if (core != null) {
|
||||
reloadLinphoneAccountCreatorConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<entry name="x3dh_server_url" overwrite="true"></entry>
|
||||
</section>
|
||||
<section name="assistant">
|
||||
<entry name="domain" overwrite="true"></entry>
|
||||
<entry name="algorithm" overwrite="true">MD5</entry>
|
||||
<entry name="password_max_length" overwrite="true">-1</entry>
|
||||
<entry name="password_min_length" overwrite="true">0</entry>
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
<entry name="x3dh_server_url" overwrite="true">https://lime.linphone.org/lime-server/lime-server.php</entry>
|
||||
</section>
|
||||
<section name="assistant">
|
||||
<entry name="domain" overwrite="true">sip.linphone.org</entry>
|
||||
<entry name="algorithm" overwrite="true">SHA-256</entry>
|
||||
<entry name="password_max_length" overwrite="true">-1</entry>
|
||||
<entry name="password_min_length" overwrite="true">1</entry>
|
||||
|
|
Loading…
Reference in a new issue