Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
fixup! Bluetooth auto turn off
Browse files Browse the repository at this point in the history
Adjust to DelayedConditionalAction changes.
  • Loading branch information
muhomorr authored and thestinger committed Apr 2, 2024
1 parent 364b11f commit f21b443
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.ext.settings.ExtSettings;
import android.util.Slog;

Expand All @@ -21,12 +22,18 @@ class BluetoothAutoOff extends DelayedConditionalAction {
@Nullable
private final BluetoothAdapter adapter;

BluetoothAutoOff(SystemServerExt sse) {
private BluetoothAutoOff(SystemServerExt sse) {
super(sse, ExtSettings.BLUETOOTH_AUTO_OFF, sse.bgHandler);
manager = sse.context.getSystemService(BluetoothManager.class);
adapter = manager.getAdapter();
}

static void maybeInit(SystemServerExt sse) {
if (sse.packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH, 0)) {
new BluetoothAutoOff(sse).init();
}
}

@Override
protected boolean shouldScheduleAlarm() {
return isAdapterOnAndDisconnected();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public static void init(Context systemContext, PackageManagerService pm) {

void initBgThread() {
WifiAutoOff.maybeInit(this);

if (packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH, 0)) {
new BluetoothAutoOff(this);
}
BluetoothAutoOff.maybeInit(this);
}
}

0 comments on commit f21b443

Please sign in to comment.