1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 03:16:51 +01:00

Add MY_PACKAGE_REPLACED receiver to manifest, to re-connect after update, especially for users of Nightly releases. Fix #2855

This commit is contained in:
vanous 2022-10-13 20:51:08 +02:00
parent cc44ba4123
commit 6f01dd6514
2 changed files with 7 additions and 3 deletions

View File

@ -393,8 +393,8 @@
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>

View File

@ -30,8 +30,12 @@ public class AutoStartReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (GBApplication.getGBPrefs().getAutoStart() && Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Log.i(TAG, "Boot completed, starting Gadgetbridge");
if (GBApplication.getGBPrefs().getAutoStart() &&
(Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) ||
Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())
)) {
Log.i(TAG, "Boot or reinstall completed, starting Gadgetbridge");
if (GBApplication.getPrefs().getBoolean("general_autoconnectonbluetooth", false)) {
Log.i(TAG, "Autoconnect is enabled, attempting to connect");
GBApplication.deviceService().connect();