Fix crashes on network change.
This commit is contained in:
parent
fb8c453098
commit
afb615ac9d
5 changed files with 25 additions and 17 deletions
|
@ -106,7 +106,7 @@ public class LinphoneActivity extends TabActivity {
|
||||||
instance = this;
|
instance = this;
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
|
||||||
LinphonePreferenceManager.setContext(this);
|
LinphonePreferenceManager.getInstance(this);
|
||||||
useFirstLoginActivity = getResources().getBoolean(R.bool.useFirstLoginActivity);
|
useFirstLoginActivity = getResources().getBoolean(R.bool.useFirstLoginActivity);
|
||||||
useMenuSettings = getResources().getBoolean(R.bool.useMenuSettings);
|
useMenuSettings = getResources().getBoolean(R.bool.useMenuSettings);
|
||||||
useMenuAbout = getResources().getBoolean(R.bool.useMenuAbout);
|
useMenuAbout = getResources().getBoolean(R.bool.useMenuAbout);
|
||||||
|
|
|
@ -112,7 +112,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
private LinphoneCore mLc;
|
private LinphoneCore mLc;
|
||||||
private int mPhoneOrientation;
|
private int mPhoneOrientation;
|
||||||
private static Transports initialTransports;
|
private static Transports initialTransports;
|
||||||
private static LinphonePreferenceManager lpm = LinphonePreferenceManager.getInstance();
|
private static LinphonePreferenceManager lpm;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,6 +123,7 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
ringSoundFile = basePath + "/oldphone_mono.wav";
|
ringSoundFile = basePath + "/oldphone_mono.wav";
|
||||||
ringbackSoundFile = basePath + "/ringback.wav";
|
ringbackSoundFile = basePath + "/ringback.wav";
|
||||||
|
|
||||||
|
lpm = LinphonePreferenceManager.getInstance(c);
|
||||||
mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE));
|
mAudioManager = ((AudioManager) c.getSystemService(Context.AUDIO_SERVICE));
|
||||||
mVibrator = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE);
|
mVibrator = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
mPref = PreferenceManager.getDefaultSharedPreferences(c);
|
mPref = PreferenceManager.getDefaultSharedPreferences(c);
|
||||||
|
|
|
@ -15,7 +15,7 @@ GNU General Public License for more details.
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone;
|
package org.linphone;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -25,28 +25,26 @@ import android.preference.PreferenceManager;
|
||||||
public class LinphonePreferenceManager {
|
public class LinphonePreferenceManager {
|
||||||
|
|
||||||
private static LinphonePreferenceManager instance;
|
private static LinphonePreferenceManager instance;
|
||||||
private static Context c;
|
private Context c;
|
||||||
private static SharedPreferences p;
|
private SharedPreferences p;
|
||||||
|
|
||||||
public LinphonePreferenceManager() {
|
public LinphonePreferenceManager(Context context) {
|
||||||
|
c = context.getApplicationContext();
|
||||||
p = PreferenceManager.getDefaultSharedPreferences(c);
|
p = PreferenceManager.getDefaultSharedPreferences(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getString(int key) {
|
private String getString(int key) {
|
||||||
return c.getString(key);
|
return c.getString(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final synchronized LinphonePreferenceManager getInstance() {
|
public static final synchronized LinphonePreferenceManager getInstance() {
|
||||||
if (c == null) throw new RuntimeException("need a context");
|
if (instance == null) {
|
||||||
if (instance == null) instance = new LinphonePreferenceManager();
|
throw new RuntimeException("LinphonePreferenceManager not instanciated");
|
||||||
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void setContext(Context context) {
|
|
||||||
c = context.getApplicationContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean useSoftvolume() {
|
public boolean useSoftvolume() {
|
||||||
return p.getBoolean(
|
return p.getBoolean(
|
||||||
getString(R.string.pref_audio_soft_volume_key), false);
|
getString(R.string.pref_audio_soft_volume_key), false);
|
||||||
|
@ -65,4 +63,12 @@ public class LinphonePreferenceManager {
|
||||||
public int useSpecificAudioModeHack() {
|
public int useSpecificAudioModeHack() {
|
||||||
return Integer.parseInt(p.getString(getString(R.string.pref_audio_use_specific_mode_key), "0"));
|
return Integer.parseInt(p.getString(getString(R.string.pref_audio_use_specific_mode_key), "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final synchronized LinphonePreferenceManager getInstance(Context c) {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new LinphonePreferenceManager(c.getApplicationContext());
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
LinphonePreferenceManager.setContext(this); // In case restart after a crash . Main in LinphoneActivity
|
// In case restart after a crash. Main in LinphoneActivity
|
||||||
|
LinphonePreferenceManager.getInstance(this);
|
||||||
|
|
||||||
// Set default preferences
|
// Set default preferences
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
|
PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
|
||||||
|
|
|
@ -77,7 +77,7 @@ class AndroidCameraRecord5 extends AndroidCameraRecord implements PreviewCallbac
|
||||||
+ " whereas expected is " + expectedBuffLength + " don't calling putImage");
|
+ " whereas expected is " + expectedBuffLength + " don't calling putImage");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long curTime = System.currentTimeMillis();
|
long curTime = System.currentTimeMillis();
|
||||||
if (lastFrameTime == 0) {
|
if (lastFrameTime == 0) {
|
||||||
lastFrameTime = curTime;
|
lastFrameTime = curTime;
|
||||||
|
|
Loading…
Reference in a new issue