2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
2014-10-18 19:02:23 +02:00
|
|
|
|
|
|
|
package org.musicpd;
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.util.Log;
|
|
|
|
|
2023-12-22 19:30:45 +01:00
|
|
|
import java.util.Set;
|
|
|
|
|
2014-10-18 19:02:23 +02:00
|
|
|
public class Receiver extends BroadcastReceiver {
|
2023-12-22 19:30:45 +01:00
|
|
|
|
|
|
|
private static final Set<String> BOOT_ACTIONS = Set.of(
|
|
|
|
"android.intent.action.BOOT_COMPLETED",
|
|
|
|
"android.intent.action.QUICKBOOT_POWERON"
|
|
|
|
);
|
|
|
|
|
2022-01-13 00:23:30 +01:00
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
Log.d("Receiver", "onReceive: " + intent);
|
2023-12-27 20:38:38 +01:00
|
|
|
if (BOOT_ACTIONS.contains(intent.getAction())) {
|
|
|
|
if (Preferences.getBoolean(context,
|
|
|
|
Preferences.KEY_RUN_ON_BOOT,
|
2022-01-13 00:23:30 +01:00
|
|
|
false)) {
|
|
|
|
final boolean wakelock =
|
2023-12-23 02:10:45 +01:00
|
|
|
Preferences.getBoolean(context,
|
|
|
|
Preferences.KEY_WAKELOCK, false);
|
2024-04-06 06:27:41 +02:00
|
|
|
Main.startService(context, wakelock);
|
2022-01-13 00:23:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-10-18 19:02:23 +02:00
|
|
|
}
|