add first start configuration checking
This commit is contained in:
parent
4749970d5c
commit
838be51880
9 changed files with 80 additions and 29 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.linphone"
|
package="org.linphone"
|
||||||
android:versionCode="104"
|
android:versionCode="106"
|
||||||
android:versionName="1.04">
|
android:versionName="1.06">
|
||||||
<uses-sdk android:minSdkVersion="3" />
|
<uses-sdk android:minSdkVersion="3" />
|
||||||
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
|
<application android:icon="@drawable/linphone2" android:label="@string/app_name" android:debuggable = "true">
|
||||||
|
|
||||||
|
|
BIN
libs/armeabi/liblinphone.so
Executable file
BIN
libs/armeabi/liblinphone.so
Executable file
Binary file not shown.
|
@ -5,4 +5,6 @@
|
||||||
<string name="pref_domain_key">pref_domain_key</string>
|
<string name="pref_domain_key">pref_domain_key</string>
|
||||||
<string name="pref_passwd_key">pref_passwd_key</string>
|
<string name="pref_passwd_key">pref_passwd_key</string>
|
||||||
<string name="pref_username_key">pref_username_key</string>
|
<string name="pref_username_key">pref_username_key</string>
|
||||||
|
<string name="pref_debug_key">pref_debug_key</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="pref_debug">Debug</string>
|
||||||
<string name="about_text">Linphone %s SIP (rfc 3261) Compatible Internet phone \n http://www.linphone.org</string>
|
<string name="about_text">Linphone %s SIP (rfc 3261) Compatible Internet phone \n http://www.linphone.org</string>
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
<string name="pref_audio">Audio</string>
|
<string name="pref_audio">Audio</string>
|
||||||
|
@ -23,7 +24,9 @@
|
||||||
<string name="call_error">Cannot call %s</string>
|
<string name="call_error">Cannot call %s</string>
|
||||||
<string name="yes">Yes</string>
|
<string name="yes">Yes</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
|
<string name="never_remind">Never remind me</string>
|
||||||
<string name="config_error">%s, do you want to return to the settings page ?</string>
|
<string name="config_error">%s, do you want to return to the settings page ?</string>
|
||||||
|
<string name="initial_config_error">No initial config found, do you want to return to the settings page ?</string>
|
||||||
<string name="warning_already_incall">Cannot initiate a new call because a call is already engaged</string>
|
<string name="warning_already_incall">Cannot initiate a new call because a call is already engaged</string>
|
||||||
<string name="tab_history">History</string>
|
<string name="tab_history">History</string>
|
||||||
<string name="warning_wrong_destination_address">Cannot build destination address from [%s]</string>
|
<string name="warning_wrong_destination_address">Cannot build destination address from [%s]</string>
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
<PreferenceCategory android:title="@string/pref_advanced">
|
<PreferenceCategory android:title="@string/pref_advanced">
|
||||||
<EditTextPreference android:title="@string/pref_prefix"
|
<EditTextPreference android:title="@string/pref_prefix"
|
||||||
android:key="@string/pref_prefix_key"></EditTextPreference>
|
android:key="@string/pref_prefix_key"></EditTextPreference>
|
||||||
|
|
||||||
|
<CheckBoxPreference android:key="@string/pref_debug_key" android:title="@string/pref_debug" android:enabled="true"></CheckBoxPreference>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
|
@ -25,11 +25,15 @@ import org.linphone.core.LinphoneCoreListener;
|
||||||
import org.linphone.core.LinphoneCore.GeneralState;
|
import org.linphone.core.LinphoneCore.GeneralState;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
@ -81,7 +85,9 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
private String mDisplayName;
|
private String mDisplayName;
|
||||||
private AudioManager mAudioManager;
|
private AudioManager mAudioManager;
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
|
private SharedPreferences mPref;
|
||||||
|
|
||||||
|
String PREF_CHECK_CONFIG = "pref_check_config";
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return null if not ready yet
|
* @return null if not ready yet
|
||||||
|
@ -103,7 +109,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
|
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
|
||||||
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"Linphone");
|
mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"Linphone");
|
||||||
|
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
@ -329,6 +335,34 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
|
||||||
case GSTATE_POWER_ON:
|
case GSTATE_POWER_ON:
|
||||||
mCall.setEnabled(!lc.isIncall());
|
mCall.setEnabled(!lc.isIncall());
|
||||||
mHangup.setEnabled(!mCall.isEnabled());
|
mHangup.setEnabled(!mCall.isEnabled());
|
||||||
|
try{
|
||||||
|
LinphoneService.instance().initFromConf();
|
||||||
|
} catch (LinphoneConfigException ec) {
|
||||||
|
Log.w(LinphoneService.TAG,"no valid settings found",ec);
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setMessage(getString(R.string.initial_config_error))
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
LinphoneActivity.instance().startprefActivity();
|
||||||
|
}
|
||||||
|
}).setNeutralButton(getString(R.string.no), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.cancel();
|
||||||
|
|
||||||
|
}
|
||||||
|
}).setNegativeButton(getString(R.string.never_remind), new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
mPref.edit().putBoolean(PREF_CHECK_CONFIG, true).commit();
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (mPref.getBoolean(PREF_CHECK_CONFIG, false) == false) {
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
} catch (Exception e ) {
|
||||||
|
Log.e(LinphoneService.TAG,"Cannot get initial config", e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case GSTATE_REG_OK: {
|
case GSTATE_REG_OK: {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class LinphoneActivity extends TabActivity implements SensorEventListener
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private void startprefActivity() {
|
protected void startprefActivity() {
|
||||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
intent.setClass(this, LinphonePreferencesActivity.class);
|
intent.setClass(this, LinphonePreferencesActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
|
@ -35,8 +35,10 @@ import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.LinphoneCore.GeneralState;
|
import org.linphone.core.LinphoneCore.GeneralState;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
|
@ -86,11 +88,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
, null);
|
, null);
|
||||||
|
|
||||||
mLinphoneCore.setSoftPlayLevel(3);
|
mLinphoneCore.setSoftPlayLevel(3);
|
||||||
try {
|
|
||||||
initFromConf();
|
|
||||||
} catch (LinphoneConfigException ec) {
|
|
||||||
Log.w(TAG,"no valid settings found",ec);
|
|
||||||
}
|
|
||||||
TimerTask lTask = new TimerTask() {
|
TimerTask lTask = new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -189,6 +187,10 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
|
||||||
public void initFromConf() throws LinphoneConfigException, LinphoneException {
|
public void initFromConf() throws LinphoneConfigException, LinphoneException {
|
||||||
|
//traces
|
||||||
|
boolean lIsDebug = mPref.getBoolean(getString(R.string.pref_debug_key), false);
|
||||||
|
LinphoneCoreFactory.instance().setDebugMode(lIsDebug);
|
||||||
|
|
||||||
//1 read proxy config from preferences
|
//1 read proxy config from preferences
|
||||||
String lUserName = mPref.getString(getString(R.string.pref_username_key), null);
|
String lUserName = mPref.getString(getString(R.string.pref_username_key), null);
|
||||||
if (lUserName == null || lUserName.length()==0) {
|
if (lUserName == null || lUserName.length()==0) {
|
||||||
|
@ -213,8 +215,10 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
|
||||||
//proxy
|
//proxy
|
||||||
String lProxy = mPref.getString(getString(R.string.pref_proxy_key), "sip:"+lDomain);
|
String lProxy = mPref.getString(getString(R.string.pref_proxy_key),null);
|
||||||
|
if (lProxy == null || lProxy.length() == 0) {
|
||||||
|
lProxy = "sip:"+lDomain;
|
||||||
|
}
|
||||||
//get Default proxy if any
|
//get Default proxy if any
|
||||||
LinphoneProxyConfig lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig();
|
LinphoneProxyConfig lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig();
|
||||||
String lIdentity = "sip:"+lUserName+"@"+lDomain;
|
String lIdentity = "sip:"+lUserName+"@"+lDomain;
|
||||||
|
@ -247,7 +251,7 @@ public class LinphoneService extends Service implements LinphoneCoreListener {
|
||||||
mLinphoneCore.setNetworkStateReachable(lConnectivityManager.getActiveNetworkInfo().getState() ==NetworkInfo.State.CONNECTED);
|
mLinphoneCore.setNetworkStateReachable(lConnectivityManager.getActiveNetworkInfo().getState() ==NetworkInfo.State.CONNECTED);
|
||||||
|
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
throw new LinphoneConfigException(getString(R.string.wrong_settings));
|
throw new LinphoneConfigException(getString(R.string.wrong_settings),e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class LinphoneCoreFactory {
|
public class LinphoneCoreFactory {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("linphone");
|
System.loadLibrary("linphone");
|
||||||
}
|
}
|
||||||
|
@ -43,5 +44,10 @@ public class LinphoneCoreFactory {
|
||||||
return new LinphoneAddressImpl(username,domain,displayName);
|
return new LinphoneAddressImpl(username,domain,displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable verbose traces
|
||||||
|
* @param enable
|
||||||
|
*/
|
||||||
|
public native void setDebugMode(boolean enable);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue