Fix crash with sms configuration
This commit is contained in:
parent
d36697ee33
commit
5a32346d2c
2 changed files with 21 additions and 5 deletions
|
@ -54,8 +54,12 @@ public class LinphonePreferences {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setContext(Context c) {
|
||||||
|
mContext = c;
|
||||||
|
}
|
||||||
|
|
||||||
private String getString(int key) {
|
private String getString(int key) {
|
||||||
if (mContext == null) {
|
if (mContext == null && LinphoneManager.isInstanciated()) {
|
||||||
mContext = LinphoneManager.getInstance().getContext();
|
mContext = LinphoneManager.getInstance().getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,8 +75,14 @@ public class LinphonePreferences {
|
||||||
|
|
||||||
public LpConfig getConfig() {
|
public LpConfig getConfig() {
|
||||||
LinphoneCore lc = getLc();
|
LinphoneCore lc = getLc();
|
||||||
if (lc != null)
|
if (lc != null) {
|
||||||
return lc.getConfig();
|
return lc.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!LinphoneManager.isInstanciated()) {
|
||||||
|
Log.w("LinphoneManager not instanciated yet...");
|
||||||
|
return LinphoneCoreFactory.instance().createLpConfig(mContext.getFilesDir().getAbsolutePath() + "/.linphonerc");
|
||||||
|
}
|
||||||
|
|
||||||
return LinphoneCoreFactory.instance().createLpConfig(LinphoneManager.getInstance().mLinphoneConfigFile);
|
return LinphoneCoreFactory.instance().createLpConfig(LinphoneManager.getInstance().mLinphoneConfigFile);
|
||||||
}
|
}
|
||||||
|
@ -986,9 +996,13 @@ public class LinphonePreferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRemoteProvisioningUrl(String url) {
|
public void setRemoteProvisioningUrl(String url) {
|
||||||
if (url != null && url.length() == 0)
|
if (url != null && url.length() == 0) {
|
||||||
url = null;
|
url = null;
|
||||||
getConfig().setString("misc", "config-uri", url);
|
}
|
||||||
|
|
||||||
|
LpConfig config = getConfig();
|
||||||
|
config.setString("misc", "config-uri", url);
|
||||||
|
config.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRemoteProvisioningUrl() {
|
public String getRemoteProvisioningUrl() {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import static android.content.Intent.ACTION_MAIN;
|
||||||
|
|
||||||
import org.linphone.LinphoneActivity;
|
import org.linphone.LinphoneActivity;
|
||||||
import org.linphone.LinphoneLauncherActivity;
|
import org.linphone.LinphoneLauncherActivity;
|
||||||
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphonePreferences;
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRemoteProvisioningListener;
|
import org.linphone.LinphoneSimpleListener.LinphoneOnRemoteProvisioningListener;
|
||||||
|
@ -157,13 +158,14 @@ public class RemoteProvisioningActivity extends Activity implements LinphoneOnRe
|
||||||
private void setRemoteProvisioningAddressAndRestart(String configUri) {
|
private void setRemoteProvisioningAddressAndRestart(String configUri) {
|
||||||
if (spinner != null) spinner.setVisibility(View.VISIBLE);
|
if (spinner != null) spinner.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
LinphonePreferences.instance().setContext(this); // Needed, else the next call will crash
|
||||||
LinphonePreferences.instance().setRemoteProvisioningUrl(configUri);
|
LinphonePreferences.instance().setRemoteProvisioningUrl(configUri);
|
||||||
LinphonePreferences.instance().firstRemoteProvisioningSuccessful();
|
LinphonePreferences.instance().firstRemoteProvisioningSuccessful();
|
||||||
|
|
||||||
mHandler.postDelayed(new Runnable() {
|
mHandler.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Restart Linphone
|
LinphoneManager.destroy();
|
||||||
stopService(new Intent(ACTION_MAIN).setClass(RemoteProvisioningActivity.this, LinphoneService.class));
|
stopService(new Intent(ACTION_MAIN).setClass(RemoteProvisioningActivity.this, LinphoneService.class));
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setClass(RemoteProvisioningActivity.this, LinphoneLauncherActivity.class);
|
intent.setClass(RemoteProvisioningActivity.this, LinphoneLauncherActivity.class);
|
||||||
|
|
Loading…
Reference in a new issue