Fixed various crashes reported on play store

This commit is contained in:
Sylvain Berfini 2019-12-05 10:43:57 +01:00
parent 5bf110afb9
commit 30168a6fdb
10 changed files with 145 additions and 33 deletions

View file

@ -825,7 +825,7 @@ public class LinphoneManager implements SensorEventListener {
public void setCallGsmON(boolean on) { public void setCallGsmON(boolean on) {
mCallGsmON = on; mCallGsmON = on;
if (on) { if (on && mCore != null) {
mCore.pauseAllCalls(); mCore.pauseAllCalls();
} }
} }

View file

@ -84,7 +84,11 @@ public abstract class LinphoneGenericActivity extends ThemeableActivity {
} }
Log.i("[Generic Activity] Starting Service"); Log.i("[Generic Activity] Starting Service");
try {
startService(new Intent().setClass(this, LinphoneService.class)); startService(new Intent().setClass(this, LinphoneService.class));
} catch (IllegalStateException ise) {
Log.e("[Generic Activity] Couldn't start service, exception: ", ise);
}
} }
} }
} }

View file

@ -424,8 +424,8 @@ public abstract class MainActivity extends LinphoneGenericActivity
} }
private void quit() { private void quit() {
goHomeAndClearStack();
stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class)); stopService(new Intent(Intent.ACTION_MAIN).setClass(this, LinphoneService.class));
goHomeAndClearStack();
/*ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); /*ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
am.killBackgroundProcesses(getString(R.string.sync_account_type)); am.killBackgroundProcesses(getString(R.string.sync_account_type));
android.os.Process.killProcess(android.os.Process.myPid());*/ android.os.Process.killProcess(android.os.Process.myPid());*/

View file

@ -154,7 +154,9 @@ public abstract class AssistantActivity extends LinphoneGenericActivity
} else { } else {
// If this isn't a sip.linphone.org account, disable push notifications and enable // If this isn't a sip.linphone.org account, disable push notifications and enable
// service notification, otherwise incoming calls won't work (most probably) // service notification, otherwise incoming calls won't work (most probably)
if (proxyConfig != null) {
proxyConfig.setPushNotificationAllowed(false); proxyConfig.setPushNotificationAllowed(false);
}
Log.w( Log.w(
"[Assistant] Unknown domain used, push probably won't work, enable service mode"); "[Assistant] Unknown domain used, push probably won't work, enable service mode");
LinphonePreferences.instance().setServiceNotificationVisibility(true); LinphonePreferences.instance().setServiceNotificationVisibility(true);

View file

@ -280,6 +280,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
permissionsList.add(Manifest.permission.READ_PHONE_STATE); permissionsList.add(Manifest.permission.READ_PHONE_STATE);
} }
if (LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests() if (LinphonePreferences.instance().shouldAutomaticallyAcceptVideoRequests()
&& mCall != null
&& mCall.getRemoteParams().videoEnabled()) { && mCall.getRemoteParams().videoEnabled()) {
if (camera != PackageManager.PERMISSION_GRANTED) { if (camera != PackageManager.PERMISSION_GRANTED) {
Log.i("[Permission] Asking for camera"); Log.i("[Permission] Asking for camera");

View file

@ -144,6 +144,7 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
return data; return data;
} }
try {
String id = c.getString(c.getColumnIndex(ContactsContract.Data.CONTACT_ID)); String id = c.getString(c.getColumnIndex(ContactsContract.Data.CONTACT_ID));
boolean starred = boolean starred =
c.getInt(c.getColumnIndex(ContactsContract.Contacts.STARRED)) == 1; c.getInt(c.getColumnIndex(ContactsContract.Contacts.STARRED)) == 1;
@ -163,6 +164,11 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
} }
contact.syncValuesFromAndroidCusor(c); contact.syncValuesFromAndroidCusor(c);
} catch (IllegalStateException ise) {
Log.e(
"[Contacts Manager] Couldn't get values from cursor, exception: ",
ise);
}
} }
c.close(); c.close();
} }

View file

@ -225,6 +225,7 @@ public class ContactsManager extends ContentObserver
if (mContext == null) { if (mContext == null) {
return false; return false;
} }
boolean contactsR = boolean contactsR =
(PackageManager.PERMISSION_GRANTED (PackageManager.PERMISSION_GRANTED
== mContext.getPackageManager() == mContext.getPackageManager()
@ -239,6 +240,7 @@ public class ContactsManager extends ContentObserver
if (mContext == null) { if (mContext == null) {
return false; return false;
} }
return (PackageManager.PERMISSION_GRANTED return (PackageManager.PERMISSION_GRANTED
== mContext.getPackageManager() == mContext.getPackageManager()
.checkPermission( .checkPermission(
@ -249,6 +251,7 @@ public class ContactsManager extends ContentObserver
if (mContext == null) { if (mContext == null) {
return false; return false;
} }
return (PackageManager.PERMISSION_GRANTED return (PackageManager.PERMISSION_GRANTED
== mContext.getPackageManager() == mContext.getPackageManager()
.checkPermission( .checkPermission(
@ -435,6 +438,8 @@ public class ContactsManager extends ContentObserver
} }
public String getAddressOrNumberForAndroidContact(ContentResolver resolver, Uri contactUri) { public String getAddressOrNumberForAndroidContact(ContentResolver resolver, Uri contactUri) {
if (resolver == null || contactUri == null) return null;
// Phone Numbers // Phone Numbers
String[] projection = new String[] {ContactsContract.CommonDataKinds.Phone.NUMBER}; String[] projection = new String[] {ContactsContract.CommonDataKinds.Phone.NUMBER};
Cursor c = resolver.query(contactUri, projection, null, null, null); Cursor c = resolver.query(contactUri, projection, null, null, null);
@ -445,8 +450,8 @@ public class ContactsManager extends ContentObserver
c.close(); c.close();
return number; return number;
} }
}
c.close(); c.close();
}
projection = new String[] {ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS}; projection = new String[] {ContactsContract.CommonDataKinds.SipAddress.SIP_ADDRESS};
c = resolver.query(contactUri, projection, null, null, null); c = resolver.query(contactUri, projection, null, null, null);
@ -458,12 +463,14 @@ public class ContactsManager extends ContentObserver
c.close(); c.close();
return address; return address;
} }
}
c.close(); c.close();
}
return null; return null;
} }
private synchronized boolean refreshSipContact(Friend lf) { private synchronized boolean refreshSipContact(Friend lf) {
if (lf == null) return false;
LinphoneContact contact = (LinphoneContact) lf.getUserData(); LinphoneContact contact = (LinphoneContact) lf.getUserData();
if (contact != null) { if (contact != null) {

View file

@ -456,22 +456,25 @@ public class LinphoneContact extends AndroidContact
} }
public boolean hasPresenceModelForUriOrTelCapability(String uri, FriendCapability capability) { public boolean hasPresenceModelForUriOrTelCapability(String uri, FriendCapability capability) {
if (mFriend == null) return false; if (mFriend == null || uri == null) return false;
PresenceModel presence = mFriend.getPresenceModelForUriOrTel(uri); PresenceModel presence = mFriend.getPresenceModelForUriOrTel(uri);
if (presence != null) { if (presence != null) {
return presence.hasCapability(capability); return presence.hasCapability(capability);
} else { } else {
for (LinphoneNumberOrAddress noa : getNumbersOrAddresses()) { for (LinphoneNumberOrAddress noa : getNumbersOrAddresses()) {
String contact = getContactFromPresenceModelForUriOrTel(noa.getValue()); String value = noa.getValue();
if (value != null) {
String contact = getContactFromPresenceModelForUriOrTel(value);
if (contact != null && contact.equals(uri)) { if (contact != null && contact.equals(uri)) {
presence = mFriend.getPresenceModelForUriOrTel(noa.getValue()); presence = mFriend.getPresenceModelForUriOrTel(value);
if (presence != null) { if (presence != null) {
return presence.hasCapability(capability); return presence.hasCapability(capability);
} }
} }
} }
} }
}
return false; return false;
} }

View file

@ -320,10 +320,12 @@ public class LinphonePreferences {
// Video settings // Video settings
public boolean useFrontCam() { public boolean useFrontCam() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "front_camera_default", true); return getConfig().getBool("app", "front_camera_default", true);
} }
public void setFrontCamAsDefault(boolean frontcam) { public void setFrontCamAsDefault(boolean frontcam) {
if (getConfig() == null) return;
getConfig().setBool("app", "front_camera_default", frontcam); getConfig().setBool("app", "front_camera_default", frontcam);
} }
@ -425,6 +427,7 @@ public class LinphonePreferences {
// Contact settings // Contact settings
public boolean isFriendlistsubscriptionEnabled() { public boolean isFriendlistsubscriptionEnabled() {
if (getConfig() == null) return false;
if (getConfig().getBool("app", "friendlist_subscription_enabled", false)) { if (getConfig().getBool("app", "friendlist_subscription_enabled", false)) {
// Old setting, do migration // Old setting, do migration
getConfig().setBool("app", "friendlist_subscription_enabled", false); getConfig().setBool("app", "friendlist_subscription_enabled", false);
@ -434,18 +437,22 @@ public class LinphonePreferences {
} }
public void enabledFriendlistSubscription(boolean enabled) { public void enabledFriendlistSubscription(boolean enabled) {
if (getLc() == null) return;
getLc().enableFriendListSubscription(enabled); getLc().enableFriendListSubscription(enabled);
} }
public boolean isPresenceStorageInNativeAndroidContactEnabled() { public boolean isPresenceStorageInNativeAndroidContactEnabled() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "store_presence_in_native_contact", false); return getConfig().getBool("app", "store_presence_in_native_contact", false);
} }
public void enabledPresenceStorageInNativeAndroidContact(boolean enabled) { public void enabledPresenceStorageInNativeAndroidContact(boolean enabled) {
if (getConfig() == null) return;
getConfig().setBool("app", "store_presence_in_native_contact", enabled); getConfig().setBool("app", "store_presence_in_native_contact", enabled);
} }
public boolean isDisplayContactOrganization() { public boolean isDisplayContactOrganization() {
if (getConfig() == null) return false;
return getConfig() return getConfig()
.getBool( .getBool(
"app", "app",
@ -454,24 +461,29 @@ public class LinphonePreferences {
} }
public void enabledDisplayContactOrganization(boolean enabled) { public void enabledDisplayContactOrganization(boolean enabled) {
if (getConfig() == null) return;
getConfig().setBool("app", "display_contact_organization", enabled); getConfig().setBool("app", "display_contact_organization", enabled);
} }
// End of contact settings // End of contact settings
// Call settings // Call settings
public boolean isMediaEncryptionMandatory() { public boolean isMediaEncryptionMandatory() {
if (getLc() == null) return false;
return getLc().isMediaEncryptionMandatory(); return getLc().isMediaEncryptionMandatory();
} }
public void setMediaEncryptionMandatory(boolean accept) { public void setMediaEncryptionMandatory(boolean accept) {
if (getLc() == null) return;
getLc().setMediaEncryptionMandatory(accept); getLc().setMediaEncryptionMandatory(accept);
} }
public boolean acceptIncomingEarlyMedia() { public boolean acceptIncomingEarlyMedia() {
if (getConfig() == null) return false;
return getConfig().getBool("sip", "incoming_calls_early_media", false); return getConfig().getBool("sip", "incoming_calls_early_media", false);
} }
public void setAcceptIncomingEarlyMedia(boolean accept) { public void setAcceptIncomingEarlyMedia(boolean accept) {
if (getConfig() == null) return;
getConfig().setBool("sip", "incoming_calls_early_media", accept); getConfig().setBool("sip", "incoming_calls_early_media", accept);
} }
@ -506,28 +518,34 @@ public class LinphonePreferences {
} }
public String getVoiceMailUri() { public String getVoiceMailUri() {
if (getConfig() == null) return null;
return getConfig().getString("app", "voice_mail", null); return getConfig().getString("app", "voice_mail", null);
} }
public void setVoiceMailUri(String uri) { public void setVoiceMailUri(String uri) {
if (getConfig() == null) return;
getConfig().setString("app", "voice_mail", uri); getConfig().setString("app", "voice_mail", uri);
} }
public boolean getNativeDialerCall() { public boolean getNativeDialerCall() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "native_dialer_call", false); return getConfig().getBool("app", "native_dialer_call", false);
} }
public void setNativeDialerCall(boolean use) { public void setNativeDialerCall(boolean use) {
if (getConfig() == null) return;
getConfig().setBool("app", "native_dialer_call", use); getConfig().setBool("app", "native_dialer_call", use);
} }
// End of call settings // End of call settings
public boolean isWifiOnlyEnabled() { public boolean isWifiOnlyEnabled() {
if (getLc() == null) return false;
return getLc().wifiOnlyEnabled(); return getLc().wifiOnlyEnabled();
} }
// Network settings // Network settings
public void setWifiOnlyEnabled(Boolean enable) { public void setWifiOnlyEnabled(Boolean enable) {
if (getLc() == null) return;
getLc().enableWifiOnly(enable); getLc().enableWifiOnly(enable);
} }
@ -536,6 +554,7 @@ public class LinphonePreferences {
} }
private void useRandomPort(boolean enabled, boolean apply) { private void useRandomPort(boolean enabled, boolean apply) {
if (getConfig() == null) return;
getConfig().setBool("app", "random_port", enabled); getConfig().setBool("app", "random_port", enabled);
if (apply) { if (apply) {
if (enabled) { if (enabled) {
@ -547,6 +566,7 @@ public class LinphonePreferences {
} }
public boolean isUsingRandomPort() { public boolean isUsingRandomPort() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "random_port", true); return getConfig().getBool("app", "random_port", true);
} }
@ -677,10 +697,12 @@ public class LinphonePreferences {
} }
public boolean isPushNotificationEnabled() { public boolean isPushNotificationEnabled() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "push_notification", true); return getConfig().getBool("app", "push_notification", true);
} }
public void setPushNotificationEnabled(boolean enable) { public void setPushNotificationEnabled(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "push_notification", enable); getConfig().setBool("app", "push_notification", enable);
Core core = getLc(); Core core = getLc();
@ -748,6 +770,7 @@ public class LinphonePreferences {
} }
private String getPushNotificationRegistrationID() { private String getPushNotificationRegistrationID() {
if (getConfig() == null) return null;
return getConfig().getString("app", "push_notification_regid", null); return getConfig().getString("app", "push_notification_regid", null);
} }
@ -770,30 +793,36 @@ public class LinphonePreferences {
// End of network settings // End of network settings
public boolean isDebugEnabled() { public boolean isDebugEnabled() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "debug", false); return getConfig().getBool("app", "debug", false);
} }
// Advanced settings // Advanced settings
public void setDebugEnabled(boolean enabled) { public void setDebugEnabled(boolean enabled) {
if (getConfig() == null) return;
getConfig().setBool("app", "debug", enabled); getConfig().setBool("app", "debug", enabled);
LinphoneUtils.configureLoggingService(enabled, mContext.getString(R.string.app_name)); LinphoneUtils.configureLoggingService(enabled, mContext.getString(R.string.app_name));
} }
public void setJavaLogger(boolean enabled) { public void setJavaLogger(boolean enabled) {
if (getConfig() == null) return;
getConfig().setBool("app", "java_logger", enabled); getConfig().setBool("app", "java_logger", enabled);
LinphoneUtils.configureLoggingService( LinphoneUtils.configureLoggingService(
isDebugEnabled(), mContext.getString(R.string.app_name)); isDebugEnabled(), mContext.getString(R.string.app_name));
} }
public boolean useJavaLogger() { public boolean useJavaLogger() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "java_logger", false); return getConfig().getBool("app", "java_logger", false);
} }
public boolean isAutoStartEnabled() { public boolean isAutoStartEnabled() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "auto_start", false); return getConfig().getBool("app", "auto_start", false);
} }
public void setAutoStart(boolean autoStartEnabled) { public void setAutoStart(boolean autoStartEnabled) {
if (getConfig() == null) return;
getConfig().setBool("app", "auto_start", autoStartEnabled); getConfig().setBool("app", "auto_start", autoStartEnabled);
} }
@ -975,80 +1004,99 @@ public class LinphonePreferences {
} }
public int getCodecBitrateLimit() { public int getCodecBitrateLimit() {
if (getConfig() == null) return 36;
return getConfig().getInt("audio", "codec_bitrate_limit", 36); return getConfig().getInt("audio", "codec_bitrate_limit", 36);
} }
public void setCodecBitrateLimit(int bitrate) { public void setCodecBitrateLimit(int bitrate) {
if (getConfig() == null) return;
getConfig().setInt("audio", "codec_bitrate_limit", bitrate); getConfig().setInt("audio", "codec_bitrate_limit", bitrate);
} }
public String getXmlrpcUrl() { public String getXmlrpcUrl() {
if (getConfig() == null) return null;
return getConfig().getString("assistant", "xmlrpc_url", null); return getConfig().getString("assistant", "xmlrpc_url", null);
} }
public String getLinkPopupTime() { public String getLinkPopupTime() {
if (getConfig() == null) return null;
return getConfig().getString("app", "link_popup_time", null); return getConfig().getString("app", "link_popup_time", null);
} }
public void setLinkPopupTime(String date) { public void setLinkPopupTime(String date) {
if (getConfig() == null) return;
getConfig().setString("app", "link_popup_time", date); getConfig().setString("app", "link_popup_time", date);
} }
public boolean isLinkPopupEnabled() { public boolean isLinkPopupEnabled() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "link_popup_enabled", true); return getConfig().getBool("app", "link_popup_enabled", true);
} }
public void enableLinkPopup(boolean enable) { public void enableLinkPopup(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "link_popup_enabled", enable); getConfig().setBool("app", "link_popup_enabled", enable);
} }
public boolean isDNDSettingsPopupEnabled() { public boolean isDNDSettingsPopupEnabled() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "dnd_settings_popup_enabled", true); return getConfig().getBool("app", "dnd_settings_popup_enabled", true);
} }
public void enableDNDSettingsPopup(boolean enable) { public void enableDNDSettingsPopup(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "dnd_settings_popup_enabled", enable); getConfig().setBool("app", "dnd_settings_popup_enabled", enable);
} }
public boolean isLimeSecurityPopupEnabled() { public boolean isLimeSecurityPopupEnabled() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "lime_security_popup_enabled", true); return getConfig().getBool("app", "lime_security_popup_enabled", true);
} }
public void enableLimeSecurityPopup(boolean enable) { public void enableLimeSecurityPopup(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "lime_security_popup_enabled", enable); getConfig().setBool("app", "lime_security_popup_enabled", enable);
} }
public String getDebugPopupAddress() { public String getDebugPopupAddress() {
if (getConfig() == null) return null;
return getConfig().getString("app", "debug_popup_magic", null); return getConfig().getString("app", "debug_popup_magic", null);
} }
public String getActivityToLaunchOnIncomingReceived() { public String getActivityToLaunchOnIncomingReceived() {
if (getConfig() == null) return "org.linphone.call.CallIncomingActivity";
return getConfig() return getConfig()
.getString( .getString(
"app", "incoming_call_activity", "org.linphone.call.CallIncomingActivity"); "app", "incoming_call_activity", "org.linphone.call.CallIncomingActivity");
} }
public void setActivityToLaunchOnIncomingReceived(String name) { public void setActivityToLaunchOnIncomingReceived(String name) {
if (getConfig() == null) return;
getConfig().setString("app", "incoming_call_activity", name); getConfig().setString("app", "incoming_call_activity", name);
} }
public boolean getServiceNotificationVisibility() { public boolean getServiceNotificationVisibility() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "show_service_notification", false); return getConfig().getBool("app", "show_service_notification", false);
} }
public void setServiceNotificationVisibility(boolean enable) { public void setServiceNotificationVisibility(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "show_service_notification", enable); getConfig().setBool("app", "show_service_notification", enable);
} }
public String getCheckReleaseUrl() { public String getCheckReleaseUrl() {
if (getConfig() == null) return null;
return getConfig().getString("misc", "version_check_url_root", null); return getConfig().getString("misc", "version_check_url_root", null);
} }
public int getLastCheckReleaseTimestamp() { public int getLastCheckReleaseTimestamp() {
if (getConfig() == null) return 0;
return getConfig().getInt("app", "version_check_url_last_timestamp", 0); return getConfig().getInt("app", "version_check_url_last_timestamp", 0);
} }
public void setLastCheckReleaseTimestamp(int timestamp) { public void setLastCheckReleaseTimestamp(int timestamp) {
if (getConfig() == null) return;
getConfig().setInt("app", "version_check_url_last_timestamp", timestamp); getConfig().setInt("app", "version_check_url_last_timestamp", timestamp);
} }
@ -1058,10 +1106,12 @@ public class LinphonePreferences {
// Disable overlay and use PIP feature // Disable overlay and use PIP feature
return false; return false;
} }
if (getConfig() == null) return false;
return getConfig().getBool("app", "display_overlay", false); return getConfig().getBool("app", "display_overlay", false);
} }
public void enableOverlay(boolean enable) { public void enableOverlay(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "display_overlay", enable); getConfig().setBool("app", "display_overlay", enable);
} }
@ -1071,66 +1121,81 @@ public class LinphonePreferences {
.checkPermission( .checkPermission(
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,
mContext.getPackageName()); mContext.getPackageName());
if (getConfig() == null) return readExternalStorage == PackageManager.PERMISSION_GRANTED;
return getConfig().getBool("app", "device_ringtone", true) return getConfig().getBool("app", "device_ringtone", true)
&& readExternalStorage == PackageManager.PERMISSION_GRANTED; && readExternalStorage == PackageManager.PERMISSION_GRANTED;
} }
public void enableDeviceRingtone(boolean enable) { public void enableDeviceRingtone(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "device_ringtone", enable); getConfig().setBool("app", "device_ringtone", enable);
LinphoneManager.getInstance().enableDeviceRingtone(enable); LinphoneManager.getInstance().enableDeviceRingtone(enable);
} }
public boolean isIncomingCallVibrationEnabled() { public boolean isIncomingCallVibrationEnabled() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "incoming_call_vibration", true); return getConfig().getBool("app", "incoming_call_vibration", true);
} }
public void enableIncomingCallVibration(boolean enable) { public void enableIncomingCallVibration(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "incoming_call_vibration", enable); getConfig().setBool("app", "incoming_call_vibration", enable);
} }
public boolean isBisFeatureEnabled() { public boolean isBisFeatureEnabled() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "bis_feature", true); return getConfig().getBool("app", "bis_feature", true);
} }
public boolean isAutoAnswerEnabled() { public boolean isAutoAnswerEnabled() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "auto_answer", false); return getConfig().getBool("app", "auto_answer", false);
} }
public void enableAutoAnswer(boolean enable) { public void enableAutoAnswer(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "auto_answer", enable); getConfig().setBool("app", "auto_answer", enable);
} }
public int getAutoAnswerTime() { public int getAutoAnswerTime() {
if (getConfig() == null) return 0;
return getConfig().getInt("app", "auto_answer_delay", 0); return getConfig().getInt("app", "auto_answer_delay", 0);
} }
public void setAutoAnswerTime(int time) { public void setAutoAnswerTime(int time) {
if (getConfig() == null) return;
getConfig().setInt("app", "auto_answer_delay", time); getConfig().setInt("app", "auto_answer_delay", time);
} }
public void disableFriendsStorage() { public void disableFriendsStorage() {
if (getConfig() == null) return;
getConfig().setBool("misc", "store_friends", false); getConfig().setBool("misc", "store_friends", false);
} }
public boolean useBasicChatRoomFor1To1() { public boolean useBasicChatRoomFor1To1() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "prefer_basic_chat_room", false); return getConfig().getBool("app", "prefer_basic_chat_room", false);
} }
// 0 is download all, -1 is disable feature, else size is bytes // 0 is download all, -1 is disable feature, else size is bytes
public int getAutoDownloadFileMaxSize() { public int getAutoDownloadFileMaxSize() {
if (getLc() == null) return -1;
return getLc().getMaxSizeForAutoDownloadIncomingFiles(); return getLc().getMaxSizeForAutoDownloadIncomingFiles();
} }
// 0 is download all, -1 is disable feature, else size is bytes // 0 is download all, -1 is disable feature, else size is bytes
public void setAutoDownloadFileMaxSize(int size) { public void setAutoDownloadFileMaxSize(int size) {
if (getLc() == null) return;
getLc().setMaxSizeForAutoDownloadIncomingFiles(size); getLc().setMaxSizeForAutoDownloadIncomingFiles(size);
} }
public boolean hasPowerSaverDialogBeenPrompted() { public boolean hasPowerSaverDialogBeenPrompted() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "android_power_saver_dialog", false); return getConfig().getBool("app", "android_power_saver_dialog", false);
} }
public void powerSaverDialogPrompted(boolean b) { public void powerSaverDialogPrompted(boolean b) {
if (getConfig() == null) return;
getConfig().setBool("app", "android_power_saver_dialog", b); getConfig().setBool("app", "android_power_saver_dialog", b);
} }
@ -1153,63 +1218,78 @@ public class LinphonePreferences {
} }
public void enableDarkMode(boolean enable) { public void enableDarkMode(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "dark_mode", enable); getConfig().setBool("app", "dark_mode", enable);
} }
public String getDeviceName(Context context) { public String getDeviceName(Context context) {
String defaultValue = Compatibility.getDeviceName(context); String defaultValue = Compatibility.getDeviceName(context);
if (getConfig() == null) return defaultValue;
return getConfig().getString("app", "device_name", defaultValue); return getConfig().getString("app", "device_name", defaultValue);
} }
public void setDeviceName(String name) { public void setDeviceName(String name) {
if (getConfig() == null) return;
getConfig().setString("app", "device_name", name); getConfig().setString("app", "device_name", name);
} }
public boolean isEchoCancellationCalibrationDone() { public boolean isEchoCancellationCalibrationDone() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "echo_cancellation_calibration_done", false); return getConfig().getBool("app", "echo_cancellation_calibration_done", false);
} }
public void setEchoCancellationCalibrationDone(boolean done) { public void setEchoCancellationCalibrationDone(boolean done) {
if (getConfig() == null) return;
getConfig().setBool("app", "echo_cancellation_calibration_done", done); getConfig().setBool("app", "echo_cancellation_calibration_done", done);
} }
public boolean isOpenH264CodecDownloadEnabled() { public boolean isOpenH264CodecDownloadEnabled() {
if (getConfig() == null) return true;
return getConfig().getBool("app", "open_h264_download_enabled", true); return getConfig().getBool("app", "open_h264_download_enabled", true);
} }
public void setOpenH264CodecDownloadEnabled(boolean enable) { public void setOpenH264CodecDownloadEnabled(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "open_h264_download_enabled", enable); getConfig().setBool("app", "open_h264_download_enabled", enable);
} }
public boolean isVideoPreviewEnabled() { public boolean isVideoPreviewEnabled() {
if (getConfig() == null) return false;
return isVideoEnabled() && getConfig().getBool("app", "video_preview", false); return isVideoEnabled() && getConfig().getBool("app", "video_preview", false);
} }
public void setVideoPreviewEnabled(boolean enabled) { public void setVideoPreviewEnabled(boolean enabled) {
if (getConfig() == null) return;
getConfig().setBool("app", "video_preview", enabled); getConfig().setBool("app", "video_preview", enabled);
} }
public boolean shortcutsCreationEnabled() { public boolean shortcutsCreationEnabled() {
if (getConfig() == null) return false;
return getConfig().getBool("app", "shortcuts", false); return getConfig().getBool("app", "shortcuts", false);
} }
public void enableChatRoomsShortcuts(boolean enable) { public void enableChatRoomsShortcuts(boolean enable) {
if (getConfig() == null) return;
getConfig().setBool("app", "shortcuts", enable); getConfig().setBool("app", "shortcuts", enable);
} }
public boolean hideEmptyChatRooms() { public boolean hideEmptyChatRooms() {
if (getConfig() == null) return true;
return getConfig().getBool("misc", "hide_empty_chat_rooms", true); return getConfig().getBool("misc", "hide_empty_chat_rooms", true);
} }
public void setHideEmptyChatRooms(boolean hide) { public void setHideEmptyChatRooms(boolean hide) {
if (getConfig() == null) return;
getConfig().setBool("misc", "hide_empty_chat_rooms", hide); getConfig().setBool("misc", "hide_empty_chat_rooms", hide);
} }
public boolean hideRemovedProxiesChatRooms() { public boolean hideRemovedProxiesChatRooms() {
if (getConfig() == null) return true;
return getConfig().getBool("misc", "hide_chat_rooms_from_removed_proxies", true); return getConfig().getBool("misc", "hide_chat_rooms_from_removed_proxies", true);
} }
public void setHideRemovedProxiesChatRooms(boolean hide) { public void setHideRemovedProxiesChatRooms(boolean hide) {
if (getConfig() == null) return;
getConfig().setBool("misc", "hide_chat_rooms_from_removed_proxies", hide); getConfig().setBool("misc", "hide_chat_rooms_from_removed_proxies", hide);
} }
} }

View file

@ -151,9 +151,10 @@ public class DeviceUtils {
for (final Intent intent : POWERMANAGER_INTENTS) { for (final Intent intent : POWERMANAGER_INTENTS) {
if (DeviceUtils.isIntentCallable(context, intent)) { if (DeviceUtils.isIntentCallable(context, intent)) {
Log.w( Log.w(
"[Hacks] " "[Hacks] ",
+ android.os.Build.MANUFACTURER android.os.Build.MANUFACTURER,
+ " device with power saver detected !"); " device with power saver detected: ",
intent.getComponent().getClassName());
if (!LinphonePreferences.instance().hasPowerSaverDialogBeenPrompted()) { if (!LinphonePreferences.instance().hasPowerSaverDialogBeenPrompted()) {
Log.w("[Hacks] Asking power saver for whitelist !"); Log.w("[Hacks] Asking power saver for whitelist !");
@ -201,7 +202,15 @@ public class DeviceUtils {
// assume it will make the change so don't prompt again // assume it will make the change so don't prompt again
LinphonePreferences.instance().powerSaverDialogPrompted(true); LinphonePreferences.instance().powerSaverDialogPrompted(true);
try {
context.startActivity(intent); context.startActivity(intent);
} catch (SecurityException se) {
Log.e(
"[Hacks] Couldn't start intent [",
intent.getComponent().getClassName(),
"], security exception was thrown: ",
se);
}
dialog.dismiss(); dialog.dismiss();
} }
}); });