キー修正, 否定追加, ログ追加 #30

Merged
asura146 merged 1 commits from fix/fix_service into main 2024-07-30 06:09:24 +00:00
Showing only changes of commit 751d47aee7 - Show all commits

View File

@ -27,6 +27,8 @@ import androidx.core.app.NotificationManagerCompat;
import com.google.firebase.firestore.DocumentReference; import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.FirebaseFirestore; import com.google.firebase.firestore.FirebaseFirestore;
import org.checkerframework.checker.index.qual.LengthOf;
public class TestService extends Service { public class TestService extends Service {
private final Handler handler = new Handler(); private final Handler handler = new Handler();
@ -73,7 +75,7 @@ public class TestService extends Service {
private static final NotificationContent REPORTED_NOTIFICATION = private static final NotificationContent REPORTED_NOTIFICATION =
new NotificationContent("子供の置き去りをしていませんか?", "第三者からの通報が行われました。", REPORTED_CHANNEL_ID, 2); new NotificationContent("子供の置き去りをしていませんか?", "第三者からの通報が行われました。", REPORTED_CHANNEL_ID, 2);
private static final NotificationContent BLUETOOTH_NOTIFICATION = private static final NotificationContent BLUETOOTH_NOTIFICATION =
new NotificationContent("子供の置き去りをしていませんか?", "Bluetoothと車の切断から5分が経過しました", BT_ALERT_CHANNEL_ID, 3); new NotificationContent("子供の置き去りをしていませんか?🐈", "Bluetoothと車の切断から5分が経過しました", BT_ALERT_CHANNEL_ID, 3);
private String userId = null; private String userId = null;
@ -315,13 +317,18 @@ public class TestService extends Service {
Log.d("BT_Judge", "Not registered device"); Log.d("BT_Judge", "Not registered device");
return; return;
} }
boolean isInCar = getSharedPreferences("Bluetooth_situation", MODE_PRIVATE).getBoolean("isInCarPref", false); boolean isInCar = !getSharedPreferences("app_situation", MODE_PRIVATE).getBoolean("change", false);
if (!isInCar) { if (!isInCar) {
Log.d("BT_Judge", "Not in car"); Log.d("BT_Judge", "Not in car");
return; return;
} }
// ----------------------------------------------------- // -----------------------------------------------------
// debug log
Log.d("BT", "Bluetooth device found: " + deviceHardwareAddress);
Log.d("BT", "Registered device: " + registeredId);
Log.d("BT", "Is in car: " + isInCar);
String action = intent.getAction(); // may need to chain this to a recognizing function String action = intent.getAction(); // may need to chain this to a recognizing function
if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) { if (BluetoothDevice.ACTION_ACL_DISCONNECTED.equals(action)) {
// bluetoothが切断されたときに乗車状態のとき // bluetoothが切断されたときに乗車状態のとき