1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-09 06:38:01 +02:00

Allow discovering unsupported devices for debug purposes

This commit is contained in:
vanous 2021-12-23 18:28:02 +01:00
parent e889796671
commit 71138192f0
9 changed files with 437 additions and 4 deletions

View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
version="1.1"
id="svg2"
width="28.740126"
height="28.740126"
viewBox="0 0 28.740126 28.740126"
sodipodi:docname="ic_device_unknown.svg"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<metadata
id="metadata8">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs6">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 14.370063 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="28.740126 : 14.370063 : 1"
inkscape:persp3d-origin="14.370063 : 9.580042 : 1"
id="perspective903" />
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1035"
id="namedview4"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
inkscape:zoom="11.313709"
inkscape:cx="-17.89864"
inkscape:cy="11.269514"
inkscape:window-x="0"
inkscape:window-y="45"
inkscape:window-maximized="1"
inkscape:current-layer="layer2"
inkscape:pagecheckerboard="0">
<inkscape:grid
type="xygrid"
id="grid972" />
</sodipodi:namedview>
<g
inkscape:groupmode="layer"
id="layer1"
inkscape:label="Background"
style="display:inline"
sodipodi:insensitive="true">
<g
inkscape:groupmode="layer"
id="layer4"
inkscape:label="Bottom"
style="display:inline"
sodipodi:insensitive="true">
<rect
style="display:inline;fill:#1f7fdb;fill-opacity:1;stroke:none;stroke-width:3.57115;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect817-5"
width="22.819572"
height="21.904638"
x="2.9239759"
y="3.8768768"
ry="0.9472276" />
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="Middle"
style="display:inline"
sodipodi:insensitive="true">
<rect
style="display:inline;fill:#4dabf5;fill-opacity:1;stroke:none;stroke-width:3.57115;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect817-7"
width="22.819572"
height="21.904638"
x="2.9317887"
y="3.0349438"
ry="0.9472276" />
</g>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Top"
style="display:inline"
sodipodi:insensitive="true">
<rect
style="fill:#2196f3;fill-opacity:1;stroke:none;stroke-width:3.57115;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect817"
width="22.819572"
height="21.904638"
x="2.9238882"
y="3.4130721"
ry="0.9472276" />
</g>
<g
aria-label="?"
id="text2312"
style="font-style:italic;font-size:24px;line-height:124%;font-family:Sans;-inkscape-font-specification:'Sans Italic';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px">
<path
d="m 15.634456,17.365391 h -4.230469 v -0.574219 q 0,-0.960937 0.386719,-1.699219 0.386718,-0.75 1.628906,-1.898437 l 0.75,-0.679688 q 0.667969,-0.609375 0.972656,-1.148437 0.316406,-0.539063 0.316406,-1.078125 0,-0.8203127 -0.5625,-1.277344 -0.5625,-0.46875 -1.570312,-0.46875 -0.949219,0 -2.050781,0.3984375 -1.101563,0.3867188 -2.2968753,1.1601565 V 6.4200783 q 1.4179683,-0.4921875 2.5898433,-0.7265625 1.171875,-0.234375 2.261719,-0.234375 2.859375,0 4.359375,1.171875 1.5,1.1601562 1.5,3.3984372 0,1.148438 -0.457031,2.0625 -0.457031,0.902344 -1.558594,1.945313 l -0.75,0.667969 q -0.796875,0.726562 -1.042969,1.171875 -0.246093,0.433593 -0.246093,0.960937 z m -4.230469,1.734375 h 4.230469 v 4.171875 h -4.230469 z"
style="font-style:normal;font-weight:bold;-inkscape-font-specification:'Sans Bold';fill:#ffffff;fill-opacity:1;stroke:none"
id="path14366" />
</g>
</g>
<g
inkscape:groupmode="layer"
id="layer5"
inkscape:label="Original"
style="display:none">
<image
y="0.0079936879"
x="0.010951031"
id="image4124"
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAAA3NCSVQICAjb4U/gAAAACXBIWXMA ADFOAAAxTgGacD5yAAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAABF0RVh0 VGl0bGUAUGViYmxlIEljb26KvwD9AAAADHRFWHRBdXRob3IAeHBobnh/4OzMAAAAY3RFWHRDb3B5 cmlnaHQAQ0MgQXR0cmlidXRpb24tTm9uQ29tbWVyY2lhbC1TaGFyZUFsaWtlIGh0dHA6Ly9jcmVh dGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzMuMC/eBBrlAAABy1BMVEUAAAAAAAAA AP8AAIAAAFUAAKoAVaoAAIAAQIAAM2YAM5kzM2YzM5krK4AkJG0kJJIgIIAcHHEcHI4aGoAXF3QX F4sXLnQXLosVK4AUJ3YUJ4kSJIAkJIARInciInciIogQIIAgIIAeHngeHoccHIAcK4AbKHkbKIYa GoAaJoAYJHkXI4AXI4sWIXoWIYUVIIAfH3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UUewIBh/m8c4qOBbfu58dQRLCmYnJmZLKphKJicdwR8X vJsymSmhIM37FSv4OJlhxnlUOAJHAC8Ye5PHmPNe9PsEJX/5dT5AigvmPtkw53wnr3xB34809uWc zDp9OWflV7xgBaBlzY79MWORALhuui+vbhoArfwe3rUp5MtWfl2Il1QDUtAaj+rKakv1XdEhBfGm Wo1kq+/pM1Ih+wdRI6iIq3IFvEAewgke6QHFg1mU26PjhbtwghsKEbG1X8ew3PmnUPGfXRAwv7hr yqAD13t6nwPQ23PnBMeivG4gg85c7XwCQOeVU+avZ5bslcrrNm7dfehIInGSguOJo+0Hd27ZoOam j3ULvOjTI02x+PYddLTEY42GJpfnpo/L0g50k8pqI1IfbWikoSFaXxfSFKnMrqFsZpKbKKoWDFbT EdQCqlfCdhtIG7AoESLTQogk4EJd/VRTn8fLgecKTg3MjyUsA4SKDD7MT1bQ8++NmvwCRmydh2Fg UvEAAAAASUVORK5CYII= "
style="opacity:0.490741;image-rendering:optimizeQuality"
preserveAspectRatio="none"
height="28.710279"
width="28.710279" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.2 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -32,6 +32,8 @@ import android.bluetooth.le.ScanRecord;
import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@ -45,6 +47,7 @@ import android.os.Message;
import android.os.ParcelUuid;
import android.os.Parcelable;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
@ -94,6 +97,7 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
* If already bonded devices are to be ignored when scanning
*/
private boolean ignoreBonded = true;
private boolean discoverUnsupported = false;
private ProgressBar bluetoothProgress;
private ProgressBar bluetoothLEProgress;
private DeviceCandidateAdapter deviceCandidateAdapter;
@ -248,6 +252,7 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
Prefs prefs = GBApplication.getPrefs();
ignoreBonded = prefs.getBoolean("ignore_bonded_devices", true);
discoverUnsupported = prefs.getBoolean("discover_unsupported_devices", false);
oldBleScanning = prefs.getBoolean("disable_new_ble_scanning", false);
if (oldBleScanning) {
@ -392,9 +397,9 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
GBDeviceCandidate candidate = new GBDeviceCandidate(device, rssi, uuids);
DeviceType deviceType = DeviceHelper.getInstance().getSupportedType(candidate);
if (deviceType.isSupported()) {
if (deviceType.isSupported() || discoverUnsupported) {
candidate.setDeviceType(deviceType);
LOG.info("Recognized supported device: " + candidate);
LOG.info("Recognized device: " + candidate);
int index = deviceCandidates.indexOf(candidate);
if (index >= 0) {
deviceCandidates.set(index, candidate); // replace
@ -713,6 +718,25 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
LOG.error("Device candidate clicked, but item not found");
return;
}
if (!deviceCandidate.getDeviceType().isSupported()){
LOG.error("Unsupported device candidate");
ArrayList deviceDetails = new ArrayList<>();
deviceDetails.add(deviceCandidate.getName());
deviceDetails.add(deviceCandidate.getMacAddress());
try {
for (ParcelUuid uuid : deviceCandidate.getServiceUuids()) {
deviceDetails.add(uuid.getUuid().toString());
}
} catch (Exception e) {
LOG.error("Error collecting device uuids: " + e);
}
String clipboardData = TextUtils.join(", ", deviceDetails);
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(deviceCandidate.getName(), clipboardData);
clipboard.setPrimaryClip(clip);
toast(this, "Device details copied to clipboard", Toast.LENGTH_SHORT, GB.INFO);
return;
}
stopDiscovery();
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(deviceCandidate);
@ -760,6 +784,14 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView
LOG.error("Device candidate clicked, but item not found");
return true;
}
if (!deviceCandidate.getDeviceType().isSupported()) {
LOG.error("Unsupported device candidate");
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(deviceCandidate.getName(), deviceCandidate.getMacAddress());
clipboard.setPrimaryClip(clip);
toast(this, "Bluetooth address copied to clipboard", Toast.LENGTH_SHORT, GB.INFO);
return true;
}
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(deviceCandidate);
GBDevice device = DeviceHelper.getInstance().toSupportedDevice(deviceCandidate);

View File

@ -73,6 +73,10 @@ public class DeviceCandidateAdapter extends ArrayAdapter<GBDeviceCandidate> {
}
}
if (!device.getDeviceType().isSupported()) {
status += " UNSUPPORTED";
}
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(device);
if (coordinator.getBondingStyle() == DeviceCoordinator.BONDING_STYLE_REQUIRE_KEY) {
if (device.getDevice().getBondState() == BluetoothDevice.BOND_BONDED) {

View File

@ -32,7 +32,7 @@ import nodomain.freeyourgadget.gadgetbridge.R;
* and may not be changed.
*/
public enum DeviceType {
UNKNOWN(-1, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_unknown),
UNKNOWN(-1, R.drawable.ic_device_unknown, R.drawable.ic_device_unknown_disabled, R.string.devicetype_unknown),
PEBBLE(1, R.drawable.ic_device_pebble, R.drawable.ic_device_pebble_disabled, R.string.devicetype_pebble),
MIBAND(10, R.drawable.ic_device_miband, R.drawable.ic_device_miband_disabled, R.string.devicetype_miband),
MIBAND2(11, R.drawable.ic_device_miband2, R.drawable.ic_device_miband2_disabled, R.string.devicetype_miband2),

View File

@ -0,0 +1,22 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="45sp"
android:height="45sp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:fillColor="#1f7fdb"
android:pathData="M3.871 3.877h20.925a0.947 0.947 0 0 1 0.948 0.947v20.01a0.947 0.947 0 0 1-0.948 0.948H3.871a0.947 0.947 0 0 1-0.947-0.948V4.824a0.947 0.947 0 0 1 0.947-0.947z"
android:strokeWidth="3.5" />
<path
android:fillColor="#4dabf5"
android:pathData="M3.879 3.035h20.925a0.947 0.947 0 0 1 0.947 0.947v20.01a0.947 0.947 0 0 1-0.947 0.948H3.88a0.947 0.947 0 0 1-0.947-0.948V3.982A0.947 0.947 0 0 1 3.88 3.035z"
android:strokeWidth="3.5" />
<path
android:fillColor="#2196f3"
android:pathData="M3.871 3.413h20.925a0.947 0.947 0 0 1 0.948 0.947v20.01a0.947 0.947 0 0 1-0.948 0.948H3.871a0.947 0.947 0 0 1-0.947-0.948V4.36A0.947 0.947 0 0 1 3.87 3.413z"
android:strokeWidth="3.5" />
<path
android:fillColor="#ffffff"
android:pathData="M15.634 17.365h-4.23v-0.574q0-0.96 0.387-1.699 0.386-0.75 1.629-1.898l0.75-0.68q0.668-0.61 0.972-1.148 0.317-0.54 0.317-1.079 0-0.82-0.563-1.277-0.562-0.469-1.57-0.469-0.95 0-2.05 0.399-1.103 0.386-2.298 1.16V6.42q1.418-0.492 2.59-0.727Q12.74 5.46 13.83 5.46q2.86 0 4.36 1.172 1.5 1.16 1.5 3.398 0 1.149-0.458 2.063-0.457 0.902-1.559 1.945l-0.75 0.668q-0.796 0.727-1.042 1.172-0.247 0.434-0.247 0.961zm-4.23 1.735h4.23v4.172h-4.23z"
android:strokeWidth="1" />
</vector>

View File

@ -0,0 +1,27 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="45sp"
android:height="45sp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:fillColor="#7a7a7a"
android:pathData="M3.871 3.877h20.925a0.947 0.947 0 0 1 0.948 0.947v20.01a0.947 0.947 0 0 1-0.948 0.948H3.871a0.947 0.947 0 0 1-0.947-0.948V4.824a0.947 0.947 0 0 1 0.947-0.947z"
android:strokeWidth="3.5" />
<path
android:fillAlpha="0.941176"
android:fillColor="#9f9f9f"
android:pathData="M3.879 3.035h20.925a0.947 0.947 0 0 1 0.947 0.947v20.01a0.947 0.947 0 0 1-0.947 0.948H3.88a0.947 0.947 0 0 1-0.947-0.948V3.982A0.947 0.947 0 0 1 3.88 3.035z"
android:strokeWidth="3.5" />
<path
android:fillColor="#8a8a8a"
android:pathData="M3.871 3.413h20.925a0.947 0.947 0 0 1 0.948 0.947v20.01a0.947 0.947 0 0 1-0.948 0.948H3.871a0.947 0.947 0 0 1-0.947-0.948V4.36A0.947 0.947 0 0 1 3.87 3.413z"
android:strokeWidth="3.5" />
<path
android:fillAlpha="0.9411765"
android:fillColor="#8a8a8a"
android:pathData="M12.483 10.865h3.907v6.978h-3.907z" />
<path
android:fillColor="#ffffff"
android:pathData="M15.634 17.365h-4.23v-0.574q0-0.96 0.387-1.699 0.386-0.75 1.629-1.898l0.75-0.68q0.668-0.61 0.972-1.148 0.317-0.54 0.317-1.079 0-0.82-0.563-1.277-0.562-0.469-1.57-0.469-0.95 0-2.05 0.399-1.103 0.386-2.298 1.16V6.42q1.418-0.492 2.59-0.727Q12.74 5.46 13.83 5.46q2.86 0 4.36 1.172 1.5 1.16 1.5 3.398 0 1.149-0.458 2.063-0.457 0.902-1.559 1.945l-0.75 0.668q-0.796 0.727-1.042 1.172-0.247 0.434-0.247 0.961zm-4.23 1.735h4.23v4.172h-4.23z"
android:strokeWidth="1" />
</vector>

View File

@ -1100,6 +1100,8 @@
<string name="error_retrieving_devices_database">Error retrieving devices from database</string>
<string name="ignore_bonded_devices">Ignore bonded devices</string>
<string name="ignore_bonded_devices_description">Enabling this option will ignore devices that have been bonded/paired already when scanning</string>
<string name="discover_unsupported_devices">Discover unsupported devices</string>
<string name="discover_unsupported_devices_description">Enabling this option will display all discovered bluetooth devices when scanning. They cannot be used in Gadgetbridge.</string>
<string name="error_location_enabled_mandatory">Location must be turned on to scan for devices</string>
<string name="sonyswr12_settings_title">Sony SWR12 Settings</string>
<string name="sonyswr12_settings_low_vibration">Low vibration enabled</string>

View File

@ -394,6 +394,11 @@
android:layout="@layout/preference_checkbox"
android:summary="@string/companiondevice_pairing_details"
android:title="@string/companiondevice_pairing" />
<CheckBoxPreference
android:defaultValue="false"
android:key="discover_unsupported_devices"
android:layout="@layout/preference_checkbox"
android:summary="@string/discover_unsupported_devices_description"
android:title="@string/discover_unsupported_devices" />
</PreferenceCategory>
</PreferenceScreen>