4bcbeae1e0
The service file was getting harder to read so lets pull the client code into it's own file
35 lines
897 B
Java
35 lines
897 B
Java
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
// Copyright The Music Player Daemon Project
|
|
|
|
package org.musicpd;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.util.Log;
|
|
|
|
import java.util.Set;
|
|
|
|
public class Receiver extends BroadcastReceiver {
|
|
|
|
private static final Set<String> BOOT_ACTIONS = Set.of(
|
|
"android.intent.action.BOOT_COMPLETED",
|
|
"android.intent.action.QUICKBOOT_POWERON"
|
|
);
|
|
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
Log.d("Receiver", "onReceive: " + intent);
|
|
if (BOOT_ACTIONS.contains(intent.getAction())) {
|
|
if (Preferences.getBoolean(context,
|
|
Preferences.KEY_RUN_ON_BOOT,
|
|
false)) {
|
|
final boolean wakelock =
|
|
Preferences.getBoolean(context,
|
|
Preferences.KEY_WAKELOCK, false);
|
|
Main.startService(context, wakelock);
|
|
}
|
|
}
|
|
}
|
|
}
|