diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dcac501a..d4c34ecd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ Group changes to describe their impact on the project, as follows: - Using new AAudio & Camera2 frameworks for better performances (if available) - Android 10 compatibility - New plugin loader to be compatible with app bundle distribution mode +- Restart service if foreground service setting is on when app is updated ## Changed - Improved performances to reduce startup time diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ef5e73bb9..a1d880262 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -252,9 +252,8 @@ - - + diff --git a/app/src/main/java/org/linphone/call/CallManager.java b/app/src/main/java/org/linphone/call/CallManager.java index 3f5e68310..2c82893aa 100644 --- a/app/src/main/java/org/linphone/call/CallManager.java +++ b/app/src/main/java/org/linphone/call/CallManager.java @@ -91,7 +91,7 @@ public class CallManager { String currentDevice = core.getVideoDevice(); Log.i("[Call Manager] Current camera device is " + currentDevice); - + String[] devices = core.getVideoDevicesList(); for (String d : devices) { if (!d.equals(currentDevice) && !d.equals("StaticImage: Static picture")) { diff --git a/app/src/main/java/org/linphone/receivers/BootReceiver.java b/app/src/main/java/org/linphone/receivers/BootReceiver.java index 37a0966e6..b7a3e53be 100644 --- a/app/src/main/java/org/linphone/receivers/BootReceiver.java +++ b/app/src/main/java/org/linphone/receivers/BootReceiver.java @@ -36,17 +36,34 @@ public class BootReceiver extends BroadcastReceiver { "[Boot Receiver] Device is shutting down, destroying Core to unregister"); context.stopService( new Intent(Intent.ACTION_MAIN).setClass(context, LinphoneService.class)); - } else { + } else if (intent.getAction().equalsIgnoreCase(Intent.ACTION_BOOT_COMPLETED)) { LinphonePreferences.instance().setContext(context); boolean autostart = LinphonePreferences.instance().isAutoStartEnabled(); android.util.Log.i( "Linphone", "[Boot Receiver] Device is starting, auto_start is " + autostart); + if (autostart && !LinphoneService.isReady()) { - Intent serviceIntent = new Intent(Intent.ACTION_MAIN); - serviceIntent.setClass(context, LinphoneService.class); - serviceIntent.putExtra("ForceStartForeground", true); - Compatibility.startService(context, serviceIntent); + startService(context); + } + } else if (intent.getAction().equalsIgnoreCase(Intent.ACTION_MY_PACKAGE_REPLACED)) { + LinphonePreferences.instance().setContext(context); + boolean foregroundService = + LinphonePreferences.instance().getServiceNotificationVisibility(); + android.util.Log.i( + "Linphone", + "[Boot Receiver] App has been updated, foreground service is " + + foregroundService); + + if (foregroundService && !LinphoneService.isReady()) { + startService(context); } } } + + private void startService(Context context) { + Intent serviceIntent = new Intent(Intent.ACTION_MAIN); + serviceIntent.setClass(context, LinphoneService.class); + serviceIntent.putExtra("ForceStartForeground", true); + Compatibility.startService(context, serviceIntent); + } }