mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Fix tests and linter
This commit is contained in:
parent
1c2c1f710e
commit
18e08d13da
@ -178,10 +178,6 @@
|
|||||||
android:name=".devices.pebble.PebbleSettingsActivity"
|
android:name=".devices.pebble.PebbleSettingsActivity"
|
||||||
android:label="@string/pref_title_pebble_settings"
|
android:label="@string/pref_title_pebble_settings"
|
||||||
android:parentActivityName=".activities.SettingsActivity" />
|
android:parentActivityName=".activities.SettingsActivity" />
|
||||||
<activity
|
|
||||||
android:name=".devices.hplus.HPlusSettingsActivity"
|
|
||||||
android:label="@string/preferences_hplus_settings"
|
|
||||||
android:parentActivityName=".activities.SettingsActivity" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".devices.zetime.ZeTimePreferenceActivity"
|
android:name=".devices.zetime.ZeTimePreferenceActivity"
|
||||||
android:label="@string/zetime_title_settings"
|
android:label="@string/zetime_title_settings"
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.btle;
|
package nodomain.freeyourgadget.gadgetbridge.service.btle;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
@ -326,8 +327,8 @@ public class BLEScanService extends Service {
|
|||||||
unregisterReceiver(bluetoothStateChangedReceiver);
|
unregisterReceiver(bluetoothStateChangedReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasBluetoothPermission(){
|
private boolean hasBluetoothPermission() {
|
||||||
if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.R){
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
|
||||||
// workaround. Cannot give bluetooth permission on Android O
|
// workaround. Cannot give bluetooth permission on Android O
|
||||||
LOG.warn("Running on android 11, skipping bluetooth permission check");
|
LOG.warn("Running on android 11, skipping bluetooth permission check");
|
||||||
return ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
return ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
||||||
@ -335,6 +336,7 @@ public class BLEScanService extends Service {
|
|||||||
return ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED;
|
return ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.BLUETOOTH_SCAN) == PackageManager.PERMISSION_GRANTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("MissingPermission") // linter does not recognize the usage of hasBluetoothPermission
|
||||||
private void restartScan(boolean applyFilters) {
|
private void restartScan(boolean applyFilters) {
|
||||||
if (!hasBluetoothPermission()) {
|
if (!hasBluetoothPermission()) {
|
||||||
// this should never happen
|
// this should never happen
|
||||||
@ -357,8 +359,10 @@ public class BLEScanService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentState.isDoingAnyScan()) {
|
if (currentState.isDoingAnyScan()) {
|
||||||
|
if (hasBluetoothPermission()) {
|
||||||
scanner.stopScan(scanCallback);
|
scanner.stopScan(scanCallback);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ArrayList<ScanFilter> scanFilters = null;
|
ArrayList<ScanFilter> scanFilters = null;
|
||||||
|
|
||||||
if (applyFilters) {
|
if (applyFilters) {
|
||||||
@ -375,7 +379,7 @@ public class BLEScanService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanFilters.size() == 0) {
|
if (scanFilters.isEmpty()) {
|
||||||
// no need to start scanning
|
// no need to start scanning
|
||||||
LOG.debug("restartScan: stopping BLE scan, no devices");
|
LOG.debug("restartScan: stopping BLE scan, no devices");
|
||||||
currentState = ScanningState.NOT_SCANNING;
|
currentState = ScanningState.NOT_SCANNING;
|
||||||
|
@ -53,7 +53,7 @@ public class LanguageUtilsTest extends TestBase {
|
|||||||
final Map<String, String> tests = new LinkedHashMap<String, String>() {{
|
final Map<String, String> tests = new LinkedHashMap<String, String>() {{
|
||||||
put("Тхе qицк брон фоx јумпед овер тхе лаз* дог", "The qick bron fox jumped over the laz* dog");
|
put("Тхе qицк брон фоx јумпед овер тхе лаз* дог", "The qick bron fox jumped over the laz* dog");
|
||||||
put("Српска ћирилица", "Srpska cirilica");
|
put("Српска ћирилица", "Srpska cirilica");
|
||||||
put("Novak Đoković", "Novak Dokovic");
|
put("Novak Đoković", "Novak Djokovic");
|
||||||
put("Џ, Њ and Љ", "Dz, Nj and Lj");
|
put("Џ, Њ and Љ", "Dz, Nj and Lj");
|
||||||
put("Љуљачка", "Ljuljacka");
|
put("Љуљачка", "Ljuljacka");
|
||||||
put("Наковањ", "Nakovanj");
|
put("Наковањ", "Nakovanj");
|
||||||
@ -63,7 +63,7 @@ public class LanguageUtilsTest extends TestBase {
|
|||||||
put("Ћ, ћ", "C, c");
|
put("Ћ, ћ", "C, c");
|
||||||
put("Ж, ж", "Z, z");
|
put("Ж, ж", "Z, z");
|
||||||
put("Ш, ш", "S, s");
|
put("Ш, ш", "S, s");
|
||||||
put("Ђ, ђ", "D, d");
|
put("Ђ, ђ", "Dj, dj");
|
||||||
put("Џ, џ", "Dz, dz");
|
put("Џ, џ", "Dz, dz");
|
||||||
put("Њ, њ", "Nj, nj");
|
put("Њ, њ", "Nj, nj");
|
||||||
put("Љ, љ", "Lj, lj");
|
put("Љ, љ", "Lj, lj");
|
||||||
|
Loading…
Reference in New Issue
Block a user