As per discussed on this topic, xDrip is detecting Full Android Smartwaches as Android Wear (wearOS) Smartwaches and Bluetooth Service stops after smartwatches are wrongly detected.
I have compiled a version with @tolot27 code suggestion and shared on xDrip Facebook group and this is the list of watches tested and confirmed the fix:
LEMFO LEMP
Rogbid Brave Pro
Kospet Optimus 2
Rogbid AIR
The patch applied on app/src/main/java/com/eveningoutpost/dexdrip/Services/Ob1G5CollectionService.java:
Line 972Before:android_wear = (getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_WATCH;After:android_wear = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH); Adding at the top of the file:import android.content.pm.PackageManager;
The patch applied on app/src/main/java/com/eveningoutpost/dexdrip/Services/DexCollectionService.java:
Lines 821 - 829Before:
@SuppressLint("ObsoleteSdkInt")
private static boolean shouldServiceRun() {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false;
final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel())
&& ((!Home.get_forced_wear() && (((UiModeManager) xdrip.getAppContext().getSystemService(UI_MODE_SERVICE)).getCurrentModeType() != Configuration.UI_MODE_TYPE_WATCH))
|| PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector));
if (d) Log.d(TAG, "shouldServiceRun() returning: " + result);
return result;
}
After:
@SuppressLint("ObsoleteSdkInt")
private boolean shouldServiceRun() {
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) return false;
final boolean result = (DexCollectionType.hasXbridgeWixel() || DexCollectionType.hasBtWixel())
&& ((!Home.get_forced_wear() && !getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH))
|| PersistentStore.getBoolean(CollectionServiceStarter.pref_run_wear_collector));
if (d) Log.d(TAG, "shouldServiceRun() returning: " + result);
return result;
}
Adding at the top of the file:import android.content.pm.PackageManager;
As per discussed on this topic, xDrip is detecting Full Android Smartwaches as Android Wear (wearOS) Smartwaches and Bluetooth Service stops after smartwatches are wrongly detected.
I have compiled a version with @tolot27 code suggestion and shared on xDrip Facebook group and this is the list of watches tested and confirmed the fix:
The patch applied on
app/src/main/java/com/eveningoutpost/dexdrip/Services/Ob1G5CollectionService.java
: Line 972 Before:android_wear = (getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_WATCH;
After:android_wear = getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
Adding at the top of the file:import android.content.pm.PackageManager;
The patch applied on
app/src/main/java/com/eveningoutpost/dexdrip/Services/DexCollectionService.java
: Lines 821 - 829 Before:After:
Adding at the top of the file:
import android.content.pm.PackageManager;
Files changed:
Files where
Configuration.UI_MODE_TYPE_WATCH
is present: https://github.com/NightscoutFoundation/xDrip/search?q=Configuration.UI_MODE_TYPE_WATCH