Disable background service if app is restricted

This commit is contained in:
Sylvain Berfini 2019-08-28 10:53:48 +02:00
parent 33caa7ce92
commit 8d914e1a6c
2 changed files with 7 additions and 0 deletions

View file

@ -32,6 +32,7 @@ import android.view.ViewGroup;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import org.linphone.LinphoneService; import org.linphone.LinphoneService;
import org.linphone.R; import org.linphone.R;
import org.linphone.compatibility.Compatibility;
import org.linphone.settings.widget.BasicSetting; import org.linphone.settings.widget.BasicSetting;
import org.linphone.settings.widget.SettingListenerBase; import org.linphone.settings.widget.SettingListenerBase;
import org.linphone.settings.widget.SwitchSetting; import org.linphone.settings.widget.SwitchSetting;
@ -205,6 +206,11 @@ public class AdvancedSettingsFragment extends SettingsFragment {
mLogUploadUrl.setValue(mPrefs.getLogCollectionUploadServerUrl()); mLogUploadUrl.setValue(mPrefs.getLogCollectionUploadServerUrl());
mBackgroundMode.setChecked(mPrefs.getServiceNotificationVisibility()); mBackgroundMode.setChecked(mPrefs.getServiceNotificationVisibility());
if (Compatibility.isAppUserRestricted(getActivity())) {
mBackgroundMode.setChecked(false);
mBackgroundMode.setEnabled(false);
mBackgroundMode.setSubtitle(getString(R.string.pref_background_mode_warning_desc));
}
mStartAtBoot.setChecked(mPrefs.isAutoStartEnabled()); mStartAtBoot.setChecked(mPrefs.isAutoStartEnabled());

View file

@ -499,6 +499,7 @@
<string name="pref_friendlist_subscribe">Friendlist subscribe</string> <string name="pref_friendlist_subscribe">Friendlist subscribe</string>
<string name="pref_background_mode">Background mode</string> <string name="pref_background_mode">Background mode</string>
<string name="pref_background_mode_desc">Show a notification to keep the app alive</string> <string name="pref_background_mode_desc">Show a notification to keep the app alive</string>
<string name="pref_background_mode_warning_desc">Linphone has been restricted for background usage, please authorize it first</string>
<string name="pref_animation_enable_title">Enable Animations</string> <string name="pref_animation_enable_title">Enable Animations</string>
<string name="pref_service_notification">Enable service notification</string> <string name="pref_service_notification">Enable service notification</string>
<string name="pref_autostart">Start at boot time</string> <string name="pref_autostart">Start at boot time</string>