From d4459ea3a3de5688884f53a70030c97978c0d7a9 Mon Sep 17 00:00:00 2001 From: adolfintel Date: Sat, 23 Mar 2019 10:17:07 +0100 Subject: [PATCH] Improvements to BLE scanner, event detections, decoding --- .../java/com/dosse/airpods/PodsService.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java b/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java index fc356f4..0a54b6a 100644 --- a/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java +++ b/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java @@ -1,5 +1,6 @@ package com.dosse.airpods; +import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.Service; @@ -52,6 +53,7 @@ public class PodsService extends Service { * What we did to workaround this issue is this: * - When a beacon arrives that looks like a pair of AirPods, look at the other beacons received in the last 10 seconds and get the strongest one * - If the strongest beacon's fake address is the same as this, use this beacon; otherwise use the strongest beacon + * - Filter for signals stronger than -70db * - Decode... * * Decoding the beacon: @@ -91,6 +93,7 @@ public class PodsService extends Service { } if(strongestBeacon!=null&&strongestBeacon.getDevice().getAddress().equals(result.getDevice().getAddress())) strongestBeacon=result; result=strongestBeacon; + if(result.getRssi()<-70) return; String a=decodeHex(result.getScanRecord().getManufacturerSpecificData(76)); String str = ""; //left airpod (0-10 batt; 15=disconnected) String str2 = ""; //right airpod (0-10 batt; 15=disconnected) @@ -179,13 +182,14 @@ public class PodsService extends Service { channel.enableVibration(false); channel.enableLights(false); channel.setShowBadge(true); + channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); mNotifyManager.createNotificationChannel(channel); } mBuilder.setShowWhen(false); mBuilder.setOngoing(true); mBuilder.setSmallIcon(R.drawable.left_pod); for(;;){ - if(maybeConnected &&!(leftStatus==15&&rightStatus==15&&caseStatus==15)){ + if(maybeConnected &&!(leftStatus==15&&rightStatus==15&&caseStatus==15)/*&&System.currentTimeMillis()-lastSeenConnected