Fixed crashes reported on play store

This commit is contained in:
Sylvain Berfini 2020-02-28 14:43:59 +01:00
parent 4ba26a6775
commit a42d7a47ae
5 changed files with 52 additions and 23 deletions

View file

@ -90,6 +90,9 @@ public class LinphoneContext {
}
public static LinphoneContext instance() {
if (sInstance == null) {
throw new RuntimeException("[Context] Linphone Context not available!");
}
return sInstance;
}

View file

@ -23,6 +23,7 @@ import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.util.Log;
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.assistant.MenuAssistantActivity;
@ -57,9 +58,14 @@ public class LinphoneLauncherActivity extends Activity implements ServiceWaitThr
if (LinphoneService.isReady()) {
onServiceReady();
} else {
try {
startService(
new Intent().setClass(LinphoneLauncherActivity.this, LinphoneService.class));
new Intent()
.setClass(LinphoneLauncherActivity.this, LinphoneService.class));
new ServiceWaitThread(this).start();
} catch (IllegalStateException ise) {
Log.e("Linphone", "Exception raised while starting service: " + ise);
}
}
}

View file

@ -49,6 +49,7 @@ import androidx.core.content.ContextCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import org.linphone.LinphoneContext;
import org.linphone.LinphoneManager;
import org.linphone.R;
import org.linphone.activities.LinphoneGenericActivity;
@ -94,6 +95,8 @@ public class CallActivity extends LinphoneGenericActivity
@Override
public void run() {
// Make sure that at the time this is executed this is still required
if (!LinphoneContext.isReady()) return;
Call call = LinphoneManager.getCore().getCurrentCall();
if (call != null && call.getCurrentParams().videoEnabled()) {
CallActivity activity = mWeakCallActivity.get();

View file

@ -36,6 +36,7 @@ import org.linphone.core.Core;
import org.linphone.core.CoreListenerStub;
import org.linphone.core.EcCalibratorStatus;
import org.linphone.core.PayloadType;
import org.linphone.core.tools.Log;
import org.linphone.settings.widget.BasicSetting;
import org.linphone.settings.widget.ListSetting;
import org.linphone.settings.widget.SettingListenerBase;
@ -113,7 +114,11 @@ public class AudioSettingsFragment extends SettingsFragment {
new SettingListenerBase() {
@Override
public void onTextValueChanged(String newValue) {
try {
mPrefs.setMicGainDb(Float.valueOf(newValue));
} catch (NumberFormatException nfe) {
Log.e("Can't set mic gain, number format exception: " + nfe);
}
}
});
@ -121,7 +126,11 @@ public class AudioSettingsFragment extends SettingsFragment {
new SettingListenerBase() {
@Override
public void onTextValueChanged(String newValue) {
try {
mPrefs.setPlaybackGainDb(Float.valueOf(newValue));
} catch (NumberFormatException nfe) {
Log.e("Can't set speaker gain, number format exception: " + nfe);
}
}
});
@ -129,6 +138,7 @@ public class AudioSettingsFragment extends SettingsFragment {
new SettingListenerBase() {
@Override
public void onListValueChanged(int position, String newLabel, String newValue) {
try {
int bitrate = Integer.valueOf(newValue);
mPrefs.setCodecBitrateLimit(bitrate);
@ -138,6 +148,9 @@ public class AudioSettingsFragment extends SettingsFragment {
pt.setNormalBitrate(bitrate);
}
}
} catch (NumberFormatException nfe) {
Log.e("Can't set codec bitrate limit, number format exception: " + nfe);
}
}
});

View file

@ -245,21 +245,25 @@ public final class LinphoneUtils {
}
if (username.contains("@")) {
String domain = username.split("@")[1];
String[] split = username.split("@");
if (split.length > 1) {
String domain = split[1];
ProxyConfig lpc = core.getDefaultProxyConfig();
if (lpc != null) {
if (domain.equals(lpc.getDomain())) {
return username.split("@")[0];
return split[0];
}
} else {
if (domain.equals(
LinphoneContext.instance()
.getApplicationContext()
.getString(R.string.default_domain))) {
return username.split("@")[0];
return split[0];
}
}
}
return split[0];
}
return username;
}