mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-02-04 13:04:08 +01:00
Huami: Change default find band vibration pattern
The previous one was too long, now that we loop it. This one should be a sane default, even for devices that do not support it (eg. Bip), as the total time is 1.5s.
This commit is contained in:
parent
2df6ce2aed
commit
43b43ab742
@ -114,7 +114,7 @@ public class GBApplication extends Application {
|
|||||||
private static SharedPreferences sharedPrefs;
|
private static SharedPreferences sharedPrefs;
|
||||||
private static final String PREFS_VERSION = "shared_preferences_version";
|
private static final String PREFS_VERSION = "shared_preferences_version";
|
||||||
//if preferences have to be migrated, increment the following and add the migration logic in migratePrefs below; see http://stackoverflow.com/questions/16397848/how-can-i-migrate-android-preferences-with-a-new-version
|
//if preferences have to be migrated, increment the following and add the migration logic in migratePrefs below; see http://stackoverflow.com/questions/16397848/how-can-i-migrate-android-preferences-with-a-new-version
|
||||||
private static final int CURRENT_PREFS_VERSION = 17;
|
private static final int CURRENT_PREFS_VERSION = 18;
|
||||||
|
|
||||||
private static LimitedQueue mIDSenderLookup = new LimitedQueue(16);
|
private static LimitedQueue mIDSenderLookup = new LimitedQueue(16);
|
||||||
private static Prefs prefs;
|
private static Prefs prefs;
|
||||||
@ -1156,6 +1156,30 @@ public class GBApplication extends Application {
|
|||||||
editor.remove(GBPrefs.CALENDAR_BLACKLIST);
|
editor.remove(GBPrefs.CALENDAR_BLACKLIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldVersion < 18) {
|
||||||
|
// Migrate the default value for Huami find band vibration pattern
|
||||||
|
try (DBHandler db = acquireDB()) {
|
||||||
|
final DaoSession daoSession = db.getDaoSession();
|
||||||
|
final List<Device> activeDevices = DBHelper.getActiveDevices(daoSession);
|
||||||
|
|
||||||
|
for (Device dbDevice : activeDevices) {
|
||||||
|
if (!dbDevice.getManufacturer().equals("Huami")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final SharedPreferences deviceSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
|
||||||
|
final SharedPreferences.Editor deviceSharedPrefsEdit = deviceSharedPrefs.edit();
|
||||||
|
|
||||||
|
deviceSharedPrefsEdit.putString("huami_vibration_profile_find_band", "long");
|
||||||
|
deviceSharedPrefsEdit.putString("huami_vibration_count_find_band", "1");
|
||||||
|
|
||||||
|
deviceSharedPrefsEdit.apply();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.w(TAG, "error acquiring DB lock");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
|
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ public abstract class Huami2021Support extends HuamiSupport {
|
|||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
try {
|
try {
|
||||||
final TransactionBuilder builder = performInitialized("test");
|
final TransactionBuilder builder = performInitialized("test");
|
||||||
findBandOneShot(builder);
|
|
||||||
builder.queue(getQueue());
|
builder.queue(getQueue());
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
LOG.error("Failed to test new function", e);
|
LOG.error("Failed to test new function", e);
|
||||||
@ -213,19 +213,21 @@ public abstract class Huami2021Support extends HuamiSupport {
|
|||||||
writeToChunked2021("ack find phone", CHUNKED2021_ENDPOINT_FIND_DEVICE, cmd, true);
|
writeToChunked2021("ack find phone", CHUNKED2021_ENDPOINT_FIND_DEVICE, cmd, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void findBandOneShot(final TransactionBuilder builder) {
|
@Override
|
||||||
LOG.info("Sending one-shot find band");
|
protected void sendFindDeviceCommand(boolean start) {
|
||||||
|
if (!start) {
|
||||||
writeToChunked2021(builder, CHUNKED2021_ENDPOINT_FIND_DEVICE, new byte[]{FIND_BAND_ONESHOT}, true);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
LOG.info("Sending one-shot find band");
|
||||||
public void onFindDevice(final boolean start) {
|
|
||||||
// FIXME: This does not work while band is in DND (#752)
|
try {
|
||||||
final CallSpec callSpec = new CallSpec();
|
final TransactionBuilder builder = performInitialized("find huami 2021");
|
||||||
callSpec.command = start ? CallSpec.CALL_INCOMING : CallSpec.CALL_END;
|
writeToChunked2021(builder, CHUNKED2021_ENDPOINT_FIND_DEVICE, new byte[]{FIND_BAND_ONESHOT}, true);
|
||||||
callSpec.name = "Gadgetbridge";
|
builder.queue(getQueue());
|
||||||
onSetCallState(callSpec);
|
} catch (IOException e) {
|
||||||
|
LOG.error("error while sending find Huami 2021 device command", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1598,7 +1598,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
|||||||
return findDeviceInterval;
|
return findDeviceInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendFindDeviceCommand(boolean start) {
|
protected void sendFindDeviceCommand(boolean start) {
|
||||||
BluetoothGattCharacteristic characteristic = getCharacteristic(UUID_CHARACTERISTIC_ALERT_LEVEL);
|
BluetoothGattCharacteristic characteristic = getCharacteristic(UUID_CHARACTERISTIC_ALERT_LEVEL);
|
||||||
try {
|
try {
|
||||||
TransactionBuilder builder = performInitialized("find huami");
|
TransactionBuilder builder = performInitialized("find huami");
|
||||||
|
@ -229,7 +229,7 @@
|
|||||||
<PreferenceCategory android:title="@string/pref_screen_notification_profile_find_device" />
|
<PreferenceCategory android:title="@string/pref_screen_notification_profile_find_device" />
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="@string/p_ring"
|
android:defaultValue="@string/p_long"
|
||||||
android:entries="@array/vibration_profile"
|
android:entries="@array/vibration_profile"
|
||||||
android:entryValues="@array/vibration_profile_values"
|
android:entryValues="@array/vibration_profile_values"
|
||||||
android:key="huami_vibration_profile_find_band"
|
android:key="huami_vibration_profile_find_band"
|
||||||
@ -237,7 +237,7 @@
|
|||||||
android:summary="%s" />
|
android:summary="%s" />
|
||||||
|
|
||||||
<EditTextPreference
|
<EditTextPreference
|
||||||
android:defaultValue="3"
|
android:defaultValue="1"
|
||||||
android:inputType="number"
|
android:inputType="number"
|
||||||
android:key="huami_vibration_count_find_band"
|
android:key="huami_vibration_count_find_band"
|
||||||
android:maxLength="1"
|
android:maxLength="1"
|
||||||
|
Loading…
Reference in New Issue
Block a user