1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-29 05:16:51 +01:00

Sony WH-1000XM3: Initial Support

This commit is contained in:
José Rebelo 2021-10-31 15:01:50 +00:00
parent b0f22815b0
commit bf5eebd411
24 changed files with 1725 additions and 2 deletions

View File

@ -109,6 +109,35 @@ public class DeviceSettingsPreferenceConst {
public static final String PREF_GALAXY_BUDS_TOUCH_LEFT = "pref_galaxy_buds_touch_left";
public static final String PREF_GALAXY_BUDS_TOUCH_RIGHT = "pref_galaxy_buds_touch_right";
public static final String PREF_SONY_WH1000XM3_AMBIENT_SOUND_CONTROL = "pref_sony_wh1000xm3_ambient_sound_control";
public static final String PREF_SONY_WH1000XM3_FOCUS_VOICE = "pref_sony_wh1000xm3_focus_voice";
public static final String PREF_SONY_WH1000XM3_AMBIENT_SOUND_LEVEL = "pref_sony_wh1000xm3_ambient_sound_level";
public static final String PREF_SONY_WH1000XM3_SOUND_POSITION = "pref_sony_wh1000xm3_sound_position";
public static final String PREF_SONY_WH1000XM3_SURROUND_MODE = "pref_sony_wh1000xm3_surround_mode";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_MODE = "pref_sony_wh1000xm3_equalizer_mode";
public static final String PREF_SONY_WH1000XM3_DSEE_HX = "pref_sony_wh1000xm3_dsee_hx";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_400 = "pref_sony_wh1000xm3_equalizer_manual_band_400";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_1000 = "pref_sony_wh1000xm3_equalizer_manual_band_1000";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_2500 = "pref_sony_wh1000xm3_equalizer_manual_band_2500";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_6300 = "pref_sony_wh1000xm3_equalizer_manual_band_6300";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_16000 = "pref_sony_wh1000xm3_equalizer_manual_band_16000";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_CLEAR_BASS = "pref_sony_wh1000xm3_equalizer_manual_clear_bass";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_400 = "pref_sony_wh1000xm3_equalizer_custom_1_band_400";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_1000 = "pref_sony_wh1000xm3_equalizer_custom_1_band_1000";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_2500 = "pref_sony_wh1000xm3_equalizer_custom_1_band_2500";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_6300 = "pref_sony_wh1000xm3_equalizer_custom_1_band_6300";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_16000 = "pref_sony_wh1000xm3_equalizer_custom_1_band_16000";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_CLEAR_BASS = "pref_sony_wh1000xm3_equalizer_custom_1_clear_bass";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_400 = "pref_sony_wh1000xm3_equalizer_custom_2_band_400";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_1000 = "pref_sony_wh1000xm3_equalizer_custom_2_band_1000";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_2500 = "pref_sony_wh1000xm3_equalizer_custom_2_band_2500";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_6300 = "pref_sony_wh1000xm3_equalizer_custom_2_band_6300";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_16000 = "pref_sony_wh1000xm3_equalizer_custom_2_band_16000";
public static final String PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_CLEAR_BASS = "pref_sony_wh1000xm3_equalizer_custom_2_clear_bass";
public static final String PREF_SONY_WH1000XM3_TOUCH_SENSOR = "pref_sony_wh1000xm3_touch_sensor";
public static final String PREF_SONY_WH1000XM3_AUTOMATIC_POWER_OFF = "pref_sony_wh1000xm3_automatic_power_off";
public static final String PREF_SONY_WH1000XM3_NOTIFICATION_VOICE_GUIDE = "pref_sony_wh1000xm3_notification_voice_guide";
public static final String PREF_SOUNDS = "sounds";
public static final String PREF_AUTH_KEY = "authkey";
}

View File

@ -119,6 +119,34 @@ import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.Dev
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_VIBRATION_ENABLE;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_NOTHING_EAR1_AUDIOMODE;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_NOTHING_EAR1_INEAR;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AMBIENT_SOUND_CONTROL;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_FOCUS_VOICE;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AMBIENT_SOUND_LEVEL;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_SOUND_POSITION;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_SURROUND_MODE;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MODE;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_400;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_1000;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_2500;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_6300;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_16000;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_CLEAR_BASS;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_400;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_1000;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_2500;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_6300;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_16000;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_CLEAR_BASS;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_400;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_1000;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_2500;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_6300;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_16000;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_CLEAR_BASS;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_DSEE_HX;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_TOUCH_SENSOR;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AUTOMATIC_POWER_OFF;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_NOTIFICATION_VOICE_GUIDE;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_FELL_SLEEP_BROADCAST;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DEVICE_ACTION_FELL_SLEEP_SELECTION;
@ -485,6 +513,35 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
addPreferenceHandlerFor(PREF_GALAXY_BUDS_TOUCH_LEFT);
addPreferenceHandlerFor(PREF_GALAXY_BUDS_TOUCH_RIGHT);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_AMBIENT_SOUND_CONTROL);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_FOCUS_VOICE);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_AMBIENT_SOUND_LEVEL);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_SOUND_POSITION);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_SURROUND_MODE);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_MODE);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_400);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_1000);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_2500);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_6300);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_16000);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_CLEAR_BASS);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_400);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_1000);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_2500);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_6300);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_16000);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_CLEAR_BASS);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_400);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_1000);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_2500);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_6300);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_16000);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_CLEAR_BASS);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_DSEE_HX);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_TOUCH_SENSOR);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_AUTOMATIC_POWER_OFF);
addPreferenceHandlerFor(PREF_SONY_WH1000XM3_NOTIFICATION_VOICE_GUIDE);
String sleepTimeState = prefs.getString(PREF_SLEEP_TIME, PREF_DO_NOT_DISTURB_OFF);
boolean sleepTimeScheduled = sleepTimeState.equals(PREF_DO_NOT_DISTURB_SCHEDULED);

View File

@ -0,0 +1,24 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3;
public enum AmbientSoundControl {
OFF,
NOISE_CANCELLING,
WIND_NOISE_REDUCTION,
AMBIENT_SOUND
}

View File

@ -0,0 +1,25 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3;
public enum AutomaticPowerOff {
OFF,
AFTER_5_MIN,
AFTER_30_MIN,
AFTER_1_HOUR,
AFTER_3_HOUR
}

View File

@ -0,0 +1,51 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3;
import java.util.List;
public class EqualizerCustomBands {
private List<Integer> bands;
private int clearBass;
public EqualizerCustomBands(List<Integer> bands, int clearBass) {
if (bands.size() != 5) {
throw new IllegalArgumentException("Equalizer needs exactly 5 bands");
}
for (Integer band : bands) {
if (band < -10 || band > 10) {
throw new IllegalArgumentException(String.format("Bands should be between -10 and 10, got %d", band));
}
}
if (clearBass < -10 || clearBass > 10) {
throw new IllegalArgumentException(String.format("Clear Bass value shoulud be between -10 and 10, got %d", clearBass));
}
this.bands = bands;
this.clearBass = clearBass;
}
public List<Integer> getBands() {
return bands;
}
public int getClearBass() {
return clearBass;
}
}

View File

@ -0,0 +1,32 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3;
public enum EqualizerPreset {
OFF,
BRIGHT,
EXCITED,
MELLOW,
RELAXED,
VOCAL,
TREBLE_BOOST,
BASS_BOOST,
SPEECH,
MANUAL,
CUSTOM_1,
CUSTOM_2
}

View File

@ -0,0 +1,149 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class SonyWh1000Xm3Coordinator extends AbstractDeviceCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(SonyWh1000Xm3Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
if (candidate.getName().contains("WH-1000XM3")) {
return DeviceType.SONY_WH_1000XM3;
}
return DeviceType.UNKNOWN;
}
@Override
public DeviceType getDeviceType() {
return DeviceType.SONY_WH_1000XM3;
}
@Override
public String getManufacturer() {
return "Sony";
}
@Override
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
}
@Nullable
@Override
public Class<? extends Activity> getPairingActivity() {
return null;
}
@Override
public boolean supportsActivityDataFetching() {
return false;
}
@Override
public boolean supportsActivityTracking() {
return false;
}
@Override
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
return null;
}
@Override
public boolean supportsScreenshots() {
return false;
}
@Override
public int getAlarmSlotCount() {
return 0;
}
@Override
public boolean supportsSmartWakeup(GBDevice device) {
return false;
}
@Override
public boolean supportsHeartRateMeasurement(GBDevice device) {
return false;
}
@Override
public boolean supportsAppsManagement() {
return false;
}
@Override
public Class<? extends Activity> getAppsManagementActivity() {
return null;
}
@Override
public boolean supportsCalendarEvents() {
return false;
}
@Override
public boolean supportsRealtimeData() {
return false;
}
@Override
public boolean supportsWeather() {
return false;
}
@Override
public boolean supportsFindDevice() {
return false;
}
@Override
public int[] getSupportedDeviceSpecificSettings(final GBDevice device) {
return new int[]{
R.xml.devicesettings_sony_1000xm3
};
}
}

View File

@ -0,0 +1,26 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3;
public enum SoundPosition {
OFF,
FRONT,
FRONT_LEFT,
FRONT_RIGHT,
REAR_LEFT,
REAR_RIGHT
}

View File

@ -0,0 +1,25 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3;
public enum SurroundMode {
OFF,
ARENA,
CLUB,
OUTDOOR_STAGE,
CONCERT_HALL
}

View File

@ -102,6 +102,7 @@ public enum DeviceType {
DOMYOS_T540(400, R.drawable.ic_device_lovetoy, R.drawable.ic_device_lovetoy_disabled, R.string.devicetype_domyos_t540),
NOTHING_EAR1(410, R.drawable.ic_device_nothingear, R.drawable.ic_device_nothingear_disabled, R.string.devicetype_nothingear1),
GALAXY_BUDS(420, R.drawable.ic_device_galaxy_buds, R.drawable.ic_device_galaxy_buds_disabled, R.string.devicetype_galaxybuds),
SONY_WH_1000XM3(430, R.drawable.ic_device_headphones, R.drawable.ic_device_headphones_disabled, R.string.devicetype_sony_wh_1000xm3),
TEST(1000, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_test);
private final int key;

View File

@ -94,6 +94,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.um25.Support.UM25Sup
import nodomain.freeyourgadget.gadgetbridge.service.devices.vibratissimo.VibratissimoSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.waspos.WaspOSDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.watch9.Watch9DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.wh1000xm3.SonyWh1000Xm3Support;
import nodomain.freeyourgadget.gadgetbridge.service.devices.xwatch.XWatchSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.zetime.ZeTimeDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
@ -366,7 +367,9 @@ public class DeviceSupportFactory {
case GALAXY_BUDS:
deviceSupport = new ServiceDeviceSupport(new GalaxyBudsDeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
break;
case SONY_WH_1000XM3:
deviceSupport = new ServiceDeviceSupport(new SonyWh1000Xm3Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
break;
}
if (deviceSupport != null) {
deviceSupport.setContext(gbDevice, mBtAdapter, mContext);

View File

@ -161,7 +161,7 @@ public abstract class BtClassicIoThread extends GBDeviceIoThread {
mOutStream = mBtSocket.getOutputStream();
setUpdateState(GBDevice.State.CONNECTED);
} catch (IOException e) {
LOG.error("Server socket cannot be started.");
LOG.error("Server socket cannot be started.", e);
//LOG.error(e.getMessage());
setUpdateState(originalState);
mInStream = null;

View File

@ -0,0 +1,74 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.wh1000xm3;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.btclassic.BtClassicIoThread;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class SonyWh1000Xm3IoThread extends BtClassicIoThread {
private static final Logger LOG = LoggerFactory.getLogger(SonyWh1000Xm3IoThread.class);
public SonyWh1000Xm3IoThread(GBDevice gbDevice, Context context, SonyWh1000Xm3Protocol xm3protocol, SonyWh1000Xm3Support xm3support, BluetoothAdapter roidmiBtAdapter) {
super(gbDevice, context, xm3protocol, xm3support, roidmiBtAdapter);
}
@Override
protected byte[] parseIncoming(InputStream inputStream) throws IOException {
ByteArrayOutputStream msgStream = new ByteArrayOutputStream();
byte[] incoming = new byte[1];
while (true) {
inputStream.read(incoming);
if (incoming[0] == SonyWh1000Xm3Protocol.PACKET_HEADER) {
msgStream.reset();
continue;
}
if (incoming[0] == SonyWh1000Xm3Protocol.PACKET_TRAILER) {
break;
}
msgStream.write(incoming);
}
byte[] msgArray = msgStream.toByteArray();
LOG.debug("Received: " + GB.hexdump(msgArray, 0, msgArray.length));
return msgArray;
}
@NonNull
@Override
protected UUID getUuidToConnect(@NonNull ParcelUuid[] uuids) {
return UUID.fromString("96CC203E-5068-46ad-B32D-E316F5E069BA");
}
}

View File

@ -0,0 +1,585 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.wh1000xm3;
import android.content.SharedPreferences;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3.AmbientSoundControl;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3.AutomaticPowerOff;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3.EqualizerCustomBands;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3.EqualizerPreset;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3.SoundPosition;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3.SurroundMode;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class SonyWh1000Xm3Protocol extends GBDeviceProtocol {
private static final Logger LOG = LoggerFactory.getLogger(SonyWh1000Xm3Protocol.class);
/**
* Packet format:
*
* - PACKET_HEADER
* - Command type? - almost always 0x0c?
* - Sequence Number - needs to be updated with the one sent in the responses
* - 4-byte big endian int with number of bytes that will follow
* - N bytes of data
* - Checksum (1-byte sum, excluding header)
* - PACKET_TRAILER
*
* Data between PACKET_HEADER and PACKET_TRAILER is escaped with PACKET_ESCAPE, and the
* following byte masked with PACKET_ESCAPE_MASK.
*/
public static final byte PACKET_HEADER = 0x3e;
public static final byte PACKET_TRAILER = 0x3c;
public static final byte PACKET_ESCAPE = 0x3d;
public static final byte PACKET_ESCAPE_MASK = (byte) 0b11101111;
private static final byte MSG_TYPE_ACK = 0x01;
private static final byte CMD_SOUND_SURROUND = 0x01;
private static final byte CMD_SOUND_POSITION = 0x02;
private int sequenceNumber = 0;
public SonyWh1000Xm3Protocol(GBDevice device) {
super(device);
}
@Override
public GBDeviceEvent[] decodeResponse(byte[] res) {
byte[] message = unescape(res);
String hexdump = GB.hexdump(message, 0, message.length);
LOG.debug("Received {}", hexdump);
byte messageChecksum = message[message.length - 1];
byte expectedChecksum = calcChecksum(message, true);
if (messageChecksum != expectedChecksum) {
LOG.error("Invalid checksum for {}", hexdump);
return null;
}
int payloadLength = ((message[2] << 24) & 0xFF000000) | ((message[3] << 16) & 0xFF0000) | ((message[4] << 8) & 0xFF00) | ((message[5] << 24) & 0xFF000000);
if (payloadLength != message.length - 7) {
LOG.error("Unexpected payload length {}, expected {}", message.length - 6, payloadLength);
return null;
}
sequenceNumber = message[1];
if (message[0] == MSG_TYPE_ACK) {
LOG.info("Received ACK: {}", hexdump);
return new GBDeviceEvent[]{};
}
LOG.warn("Unknown message: {}", hexdump);
return null;
}
@Override
public byte[] encodeSendConfiguration(String config) {
final SharedPreferences prefs = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
EqualizerPreset equalizerPreset = EqualizerPreset.valueOf(prefs.getString(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MODE, "off").toUpperCase());
switch (config) {
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AMBIENT_SOUND_CONTROL:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_FOCUS_VOICE:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AMBIENT_SOUND_LEVEL:
String soundControl = prefs.getString(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AMBIENT_SOUND_CONTROL, "noise_cancelling");
boolean focusVoice = prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_FOCUS_VOICE, false);
int level = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AMBIENT_SOUND_LEVEL, 0);
return encodeSoundControl(AmbientSoundControl.valueOf(soundControl.toUpperCase()), focusVoice, level);
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_SOUND_POSITION:
return encodeSoundPosition(
SoundPosition.valueOf(prefs.getString(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_SOUND_POSITION, "off").toUpperCase())
);
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_SURROUND_MODE:
return encodeSurroundMode(
SurroundMode.valueOf(prefs.getString(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_SURROUND_MODE, "off").toUpperCase())
);
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MODE:
return encodeEqualizerPreset(equalizerPreset);
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_400:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_1000:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_2500:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_6300:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_16000:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_CLEAR_BASS:
int m_band1 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_400, 10) - 10;
int m_band2 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_1000, 10) - 10;
int m_band3 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_2500, 10) - 10;
int m_band4 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_6300, 10) - 10;
int m_band5 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_BAND_16000, 10) - 10;
int m_bass = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MANUAL_CLEAR_BASS, 10) - 10;
// Set the equalizer preset, since changing the bands will switch it
// TODO: This is not updating the UI once the user returns to the previous screen
prefs.edit().putString(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MODE, EqualizerPreset.MANUAL.toString().toLowerCase()).apply();
return encodeEqualizerCustomBands(EqualizerPreset.MANUAL, equalizerPreset, new EqualizerCustomBands(Arrays.asList(m_band1, m_band2, m_band3, m_band4, m_band5), m_bass));
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_400:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_1000:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_2500:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_6300:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_16000:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_CLEAR_BASS:
int c1_band1 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_400, 10) - 10;
int c1_band2 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_1000, 10) - 10;
int c1_band3 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_2500, 10) - 10;
int c1_band4 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_6300, 10) - 10;
int c1_band5 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_BAND_16000, 10) - 10;
int c1_bass = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_1_CLEAR_BASS, 10) - 10;
// Set the equalizer preset, since changing the bands will switch it
// TODO: This is not updating the UI once the user returns to the previous screen
prefs.edit().putString(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MODE, EqualizerPreset.CUSTOM_1.toString().toLowerCase()).apply();
return encodeEqualizerCustomBands(EqualizerPreset.CUSTOM_1, equalizerPreset, new EqualizerCustomBands(Arrays.asList(c1_band1, c1_band2, c1_band3, c1_band4, c1_band5), c1_bass));
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_400:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_1000:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_2500:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_6300:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_16000:
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_CLEAR_BASS:
int c2_band1 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_400, 10) - 10;
int c2_band2 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_1000, 10) - 10;
int c2_band3 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_2500, 10) - 10;
int c2_band4 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_6300, 10) - 10;
int c2_band5 = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_BAND_16000, 10) - 10;
int c2_bass = prefs.getInt(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_CUSTOM_2_CLEAR_BASS, 10) - 10;
// Set the equalizer preset, since changing the bands will switch it
// TODO: This is not updating the UI once the user returns to the previous screen
prefs.edit().putString(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_EQUALIZER_MODE, EqualizerPreset.CUSTOM_2.toString().toLowerCase()).apply();
return encodeEqualizerCustomBands(EqualizerPreset.CUSTOM_2, equalizerPreset, new EqualizerCustomBands(Arrays.asList(c2_band1, c2_band2, c2_band3, c2_band4, c2_band5), c2_bass));
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_DSEE_HX:
return encodeDSEEHX(prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_DSEE_HX, false));
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_TOUCH_SENSOR:
return encodeTouchSensor(prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_TOUCH_SENSOR, true));
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AUTOMATIC_POWER_OFF:
return encodeAutomaticPowerOff(
AutomaticPowerOff.valueOf(prefs.getString(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_AUTOMATIC_POWER_OFF, "off").toUpperCase())
);
case DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_NOTIFICATION_VOICE_GUIDE:
return encodeVoiceNotifications(prefs.getBoolean(DeviceSettingsPreferenceConst.PREF_SONY_WH1000XM3_NOTIFICATION_VOICE_GUIDE, true));
default:
LOG.warn("Unknown config '{}'", config);
}
return super.encodeSendConfiguration(config);
}
public byte[] encodeTriggerNoiseCancellingOptimizer() {
// This successfully triggers the noise cancelling optimizer. However, we don't get the
// optimization progress messages.
ByteBuffer buf = ByteBuffer.allocate(10);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(4);
buf.put((byte) 0x84);
buf.put((byte) 0x01);
buf.put((byte) 0x00);
buf.put((byte) 0x01);
return encodeMessage(buf.array());
}
private byte[] encodeSoundControl(AmbientSoundControl ambientSoundControl, boolean focusOnVoice, int ambientSound) {
if (ambientSound < 0 || ambientSound > 19) {
throw new IllegalArgumentException("Level must be between 0 and 19");
}
ByteBuffer buf = ByteBuffer.allocate(14);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(8);
buf.put((byte) 0x68);
buf.put((byte) 0x02);
if (AmbientSoundControl.OFF.equals(ambientSoundControl)) {
buf.put((byte) 0x00);
} else {
buf.put((byte) 0x11);
}
buf.put((byte) 0x01);
switch (ambientSoundControl) {
case NOISE_CANCELLING:
buf.put((byte) 2);
break;
case WIND_NOISE_REDUCTION:
buf.put((byte) 1);
break;
case OFF:
case AMBIENT_SOUND:
default:
buf.put((byte) 0);
break;
}
buf.put((byte) 0x01);
buf.put((byte) (focusOnVoice ? 0x01 : 0x00));
buf.put((byte) (ambientSound + 1));
return encodeMessage(buf.array());
}
private byte[] encodeSoundPosition(SoundPosition position) {
final ByteBuffer buf = ByteBuffer.allocate(9);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(3);
buf.put((byte) 0x48);
buf.put(CMD_SOUND_POSITION);
switch (position) {
case OFF:
buf.put((byte) 0x00);
break;
case FRONT:
buf.put((byte) 0x03);
break;
case FRONT_LEFT:
buf.put((byte) 0x01);
break;
case FRONT_RIGHT:
buf.put((byte) 0x02);
break;
case REAR_LEFT:
buf.put((byte) 0x11);
break;
case REAR_RIGHT:
buf.put((byte) 0x12);
break;
}
return encodeMessage(buf.array());
}
private byte[] encodeSurroundMode(SurroundMode mode) {
final ByteBuffer buf = ByteBuffer.allocate(9);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(3);
buf.put((byte) 0x48);
buf.put(CMD_SOUND_SURROUND);
switch (mode) {
case OFF:
buf.put((byte) 0x00);
break;
case ARENA:
buf.put((byte) 0x02);
break;
case CLUB:
buf.put((byte) 0x04);
break;
case OUTDOOR_STAGE:
buf.put((byte) 0x01);
break;
case CONCERT_HALL:
buf.put((byte) 0x03);
break;
}
return encodeMessage(buf.array());
}
private byte[] encodeEqualizerPreset(EqualizerPreset preset) {
final ByteBuffer buf = ByteBuffer.allocate(10);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(4);
buf.put((byte) 0x58);
buf.put((byte) 0x01);
switch (preset) {
case OFF:
buf.put((byte) 0x00).put((byte) 0x00);
break;
case BRIGHT:
buf.put((byte) 0x10).put((byte) 0x00);
break;
case EXCITED:
buf.put((byte) 0x11).put((byte) 0x00);
break;
case MELLOW:
buf.put((byte) 0x12).put((byte) 0x00);
break;
case RELAXED:
buf.put((byte) 0x13).put((byte) 0x00);
break;
case VOCAL:
buf.put((byte) 0x14).put((byte) 0x00);
break;
case TREBLE_BOOST:
buf.put((byte) 0x15).put((byte) 0x00);
break;
case BASS_BOOST:
buf.put((byte) 0x16).put((byte) 0x00);
break;
case SPEECH:
buf.put((byte) 0x17).put((byte) 0x00);
break;
case MANUAL:
buf.put((byte) 0xa0).put((byte) 0x00);
break;
case CUSTOM_1:
buf.put((byte) 0xa1).put((byte) 0x00);
break;
case CUSTOM_2:
buf.put((byte) 0xa2).put((byte) 0x00);
break;
}
return encodeMessage(buf.array());
}
private byte[] encodeEqualizerCustomBands(EqualizerPreset preset, EqualizerPreset previousPreset, EqualizerCustomBands equalizer) {
ByteArrayOutputStream cmdStream = new ByteArrayOutputStream(16);
try {
if (preset != previousPreset) {
// If we're not on the preset that is being changed, we need to swap to it
cmdStream.write(encodeEqualizerPreset(preset));
}
cmdStream.write(encodeEqualizerCustomBands(equalizer));
if (preset != previousPreset) {
// And then we swap back to the previous preset
// FIXME: this is not working, the new preset stays
//cmdStream.write(encodeEqualizerPreset(previousPreset));
}
} catch (IOException e) {
LOG.error("This should never happen", e);
}
return cmdStream.toByteArray();
}
private byte[] encodeEqualizerCustomBands(EqualizerCustomBands equalizer) {
final ByteBuffer buf = ByteBuffer.allocate(16);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(10);
buf.put((byte) 0x58);
buf.put((byte) 0x01);
buf.put((byte) 0xff);
buf.put((byte) 0x06);
buf.put((byte) (equalizer.getClearBass() + 10));
for (final Integer band : equalizer.getBands()) {
buf.put((byte) (band + 10));
}
return encodeMessage(buf.array());
}
private byte[] encodeDSEEHX(boolean enabled) {
ByteBuffer buf = ByteBuffer.allocate(10);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(4);
buf.put((byte) 0xe8);
buf.put((byte) 0x02);
buf.put((byte) 0x00);
buf.put((byte) (enabled ? 0x01 : 0x00));
return encodeMessage(buf.array());
}
private byte[] encodeTouchSensor(boolean enabled) {
ByteBuffer buf = ByteBuffer.allocate(10);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(4);
buf.put((byte) 0xd8);
buf.put((byte) 0xd2);
buf.put((byte) 0x01);
buf.put((byte) (enabled ? 0x01 : 0x00));
return encodeMessage(buf.array());
}
private byte[] encodeAutomaticPowerOff(AutomaticPowerOff automaticPowerOff) {
ByteBuffer buf = ByteBuffer.allocate(11);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0c);
buf.put((byte) sequenceNumber++);
buf.putInt(5);
buf.put((byte) 0xf8);
buf.put((byte) 0x04);
buf.put((byte) 0x01);
switch (automaticPowerOff) {
case OFF:
buf.put((byte) 0x11).put((byte) 0x00);
break;
case AFTER_5_MIN:
buf.put((byte) 0x00).put((byte) 0x00);
break;
case AFTER_30_MIN:
buf.put((byte) 0x01).put((byte) 0x01);
break;
case AFTER_1_HOUR:
buf.put((byte) 0x02).put((byte) 0x02);
break;
case AFTER_3_HOUR:
buf.put((byte) 0x03).put((byte) 0x03);
break;
}
return encodeMessage(buf.array());
}
private byte[] encodeVoiceNotifications(boolean enabled) {
ByteBuffer buf = ByteBuffer.allocate(10);
buf.order(ByteOrder.BIG_ENDIAN);
buf.put((byte) 0x0e);
buf.put((byte) sequenceNumber++);
buf.putInt(4);
buf.put((byte) 0x48);
buf.put((byte) 0x01);
buf.put((byte) 0x01);
buf.put((byte) (enabled ? 0x01 : 0x00));
return encodeMessage(buf.array());
}
private byte[] encodeMessage(byte[] message) {
ByteArrayOutputStream cmdStream = new ByteArrayOutputStream(message.length + 2);
cmdStream.write(PACKET_HEADER);
byte checksum = calcChecksum(message, false);
try {
cmdStream.write(escape(message));
cmdStream.write(escape(new byte[]{checksum}));
} catch (IOException e) {
LOG.error("This should never happen", e);
}
cmdStream.write(PACKET_TRAILER);
return cmdStream.toByteArray();
}
private byte[] escape(byte[] bytes) {
ByteArrayOutputStream escapedStream = new ByteArrayOutputStream(bytes.length);
for (byte b : bytes) {
switch (b) {
case PACKET_HEADER:
case PACKET_TRAILER:
case PACKET_ESCAPE:
escapedStream.write(PACKET_ESCAPE);
escapedStream.write(b & PACKET_ESCAPE_MASK);
break;
default:
escapedStream.write(b);
break;
}
}
return escapedStream.toByteArray();
}
private byte[] unescape(byte[] bytes) {
ByteArrayOutputStream unescapedStream = new ByteArrayOutputStream(bytes.length);
for (int i = 0; i < bytes.length; i++) {
byte b = bytes[i];
if (b == PACKET_ESCAPE) {
if (++i >= bytes.length) {
throw new IllegalArgumentException("Invalid escape character at end of array");
}
unescapedStream.write(b & ~PACKET_ESCAPE_MASK);
} else {
unescapedStream.write(b);
}
}
return unescapedStream.toByteArray();
}
public byte calcChecksum(byte[] message, boolean ignoreLastByte) {
int chk = 0;
for (int i = 0; i < message.length - (ignoreLastByte ? 1 : 0); i++) {
chk += message[i] & 255;
}
return (byte) chk;
}
}

View File

@ -0,0 +1,96 @@
/* Copyright (C) 2021 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.sony.wh1000xm3;
import android.net.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
import nodomain.freeyourgadget.gadgetbridge.service.serial.AbstractSerialDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceIoThread;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
public class SonyWh1000Xm3Support extends AbstractSerialDeviceSupport {
private static final Logger LOG = LoggerFactory.getLogger(SonyWh1000Xm3Support.class);
@Override
public boolean connect() {
getDeviceIOThread().start();
return true;
}
@Override
protected GBDeviceProtocol createDeviceProtocol() {
return new SonyWh1000Xm3Protocol(getDevice());
}
@Override
protected GBDeviceIoThread createDeviceIOThread() {
return new SonyWh1000Xm3IoThread(getDevice(), getContext(), (SonyWh1000Xm3Protocol) getDeviceProtocol(), SonyWh1000Xm3Support.this, getBluetoothAdapter());
}
@Override
public synchronized SonyWh1000Xm3IoThread getDeviceIOThread() {
return (SonyWh1000Xm3IoThread) super.getDeviceIOThread();
}
@Override
public boolean useAutoConnect() {
return false;
}
@Override
public void onInstallApp(Uri uri) {
// Nothing to do
}
@Override
public void onAppConfiguration(UUID uuid, String config, Integer id) {
// Nothing to do
}
@Override
public void onHeartRateTest() {
// Nothing to do
}
@Override
public void onSetConstantVibration(int intensity) {
// Nothing to do
}
@Override
public void onSetHeartRateMeasurementInterval(int seconds) {
// Nothing to do
}
@Override
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
// Nothing to do
}
@Override
public void onReadConfiguration(String config) {
// Nothing to do
}
}

View File

@ -112,6 +112,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.um25.Coordinator.UM25Coordin
import nodomain.freeyourgadget.gadgetbridge.devices.vibratissimo.VibratissimoCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.waspos.WaspOSCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.watch9.Watch9DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.wh1000xm3.SonyWh1000Xm3Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xwatch.XWatchCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimeCoordinator;
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
@ -311,6 +312,8 @@ public class DeviceHelper {
result.add(new FitProDeviceCoordinator());
result.add(new Ear1Coordinator());
result.add(new GalaxyBudsDeviceCoordinator());
result.add(new SonyWh1000Xm3Coordinator());
return result;
}

View File

@ -0,0 +1,28 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:name="path_1"
android:pathData="M 3.871 3.877 L 24.796 3.877 C 25.047 3.877 25.289 3.977 25.466 4.154 C 25.644 4.332 25.744 4.573 25.744 4.824 L 25.744 24.834 C 25.744 25.085 25.644 25.327 25.466 25.504 C 25.289 25.682 25.047 25.782 24.796 25.782 L 3.871 25.782 C 3.62 25.782 3.379 25.682 3.201 25.504 C 3.024 25.327 2.924 25.085 2.924 24.834 L 2.924 4.824 C 2.924 4.573 3.024 4.332 3.201 4.154 C 3.379 3.977 3.62 3.877 3.871 3.877"
android:fillColor="#1f7fdb"
android:strokeWidth="1"/>
<path
android:name="path_5"
android:pathData="M 3.879 3.035 L 24.804 3.035 C 25.055 3.035 25.296 3.135 25.474 3.312 C 25.651 3.49 25.751 3.731 25.751 3.982 L 25.751 23.992 C 25.751 24.243 25.651 24.485 25.474 24.662 C 25.296 24.84 25.055 24.94 24.804 24.94 L 3.879 24.94 C 3.628 24.94 3.387 24.84 3.209 24.662 C 3.032 24.485 2.932 24.243 2.932 23.992 L 2.932 3.982 C 2.932 3.731 3.032 3.49 3.209 3.312 C 3.387 3.135 3.628 3.035 3.879 3.035"
android:fillColor="#4dabf5"
android:strokeWidth="1"/>
<path
android:name="path_6"
android:pathData="M 3.879 3.035 L 24.804 3.035 C 25.055 3.035 25.296 3.135 25.474 3.313 C 25.652 3.49 25.751 3.731 25.751 3.982 L 25.751 23.992 C 25.751 24.244 25.652 24.485 25.474 24.662 C 25.296 24.84 25.055 24.94 24.804 24.94 L 3.879 24.94 C 3.628 24.94 3.387 24.84 3.209 24.662 C 3.032 24.485 2.932 24.244 2.932 23.992 L 2.932 3.982 C 2.932 3.731 3.032 3.49 3.209 3.313 C 3.387 3.135 3.628 3.035 3.879 3.035"
android:fillColor="#2196f3"
android:strokeWidth="1"/>
<path
android:name="path_7"
android:pathData="M 14.362 8.693 C 11.231 8.693 8.693 11.231 8.693 14.362 L 8.693 18.772 C 8.693 19.465 9.26 20.031 9.953 20.031 L 12.472 20.031 L 12.472 14.992 L 9.953 14.992 L 9.953 14.362 C 9.953 11.924 11.924 9.953 14.362 9.953 C 16.8 9.953 18.772 11.924 18.772 14.362 L 18.772 14.992 L 16.252 14.992 L 16.252 20.031 L 18.772 20.031 C 19.465 20.031 20.031 19.465 20.031 18.772 L 20.031 14.362 C 20.031 11.231 17.493 8.693 14.362 8.693 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
</vector>

View File

@ -0,0 +1,28 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="vector"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:name="path_1"
android:pathData="M 3.871 3.877 L 24.796 3.877 C 25.047 3.877 25.289 3.977 25.466 4.154 C 25.644 4.332 25.744 4.573 25.744 4.824 L 25.744 24.834 C 25.744 25.085 25.644 25.327 25.466 25.504 C 25.289 25.682 25.047 25.782 24.796 25.782 L 3.871 25.782 C 3.62 25.782 3.379 25.682 3.201 25.504 C 3.024 25.327 2.924 25.085 2.924 24.834 L 2.924 4.824 C 2.924 4.573 3.024 4.332 3.201 4.154 C 3.379 3.977 3.62 3.877 3.871 3.877"
android:fillColor="#7a7a7a"
android:strokeWidth="1"/>
<path
android:name="path_5"
android:pathData="M 3.879 3.035 L 24.804 3.035 C 25.055 3.035 25.296 3.135 25.474 3.312 C 25.651 3.49 25.751 3.731 25.751 3.982 L 25.751 23.992 C 25.751 24.243 25.651 24.485 25.474 24.662 C 25.296 24.84 25.055 24.94 24.804 24.94 L 3.879 24.94 C 3.628 24.94 3.387 24.84 3.209 24.662 C 3.032 24.485 2.932 24.243 2.932 23.992 L 2.932 3.982 C 2.932 3.731 3.032 3.49 3.209 3.312 C 3.387 3.135 3.628 3.035 3.879 3.035"
android:fillColor="#9f9f9f"
android:strokeWidth="1"/>
<path
android:name="path_6"
android:pathData="M 3.879 3.035 L 24.804 3.035 C 25.055 3.035 25.296 3.135 25.474 3.313 C 25.652 3.49 25.751 3.731 25.751 3.982 L 25.751 23.992 C 25.751 24.244 25.652 24.485 25.474 24.662 C 25.296 24.84 25.055 24.94 24.804 24.94 L 3.879 24.94 C 3.628 24.94 3.387 24.84 3.209 24.662 C 3.032 24.485 2.932 24.244 2.932 23.992 L 2.932 3.982 C 2.932 3.731 3.032 3.49 3.209 3.313 C 3.387 3.135 3.628 3.035 3.879 3.035"
android:fillColor="#8a8a8a"
android:strokeWidth="1"/>
<path
android:name="path_7"
android:pathData="M 14.362 8.693 C 11.231 8.693 8.693 11.231 8.693 14.362 L 8.693 18.772 C 8.693 19.465 9.26 20.031 9.953 20.031 L 12.472 20.031 L 12.472 14.992 L 9.953 14.992 L 9.953 14.362 C 9.953 11.924 11.924 9.953 14.362 9.953 C 16.8 9.953 18.772 11.924 18.772 14.362 L 18.772 14.992 L 16.252 14.992 L 16.252 20.031 L 18.772 20.031 C 19.465 20.031 20.031 19.465 20.031 18.772 L 20.031 14.362 C 20.031 11.231 17.493 8.693 14.362 8.693 Z"
android:fillColor="#ffffff"
android:strokeWidth="1"/>
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#7E7E7E"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M17,2L7,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,1.99 2,1.99L17,22c1.1,0 2,-0.9 2,-2L19,4c0,-1.1 -0.9,-2 -2,-2zM12,4c1.1,0 2,0.9 2,2s-0.9,2 -2,2c-1.11,0 -2,-0.9 -2,-2s0.89,-2 2,-2zM12,20c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,12c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z" />
</vector>

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#7E7E7E"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M20,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM7.76,16.24l-1.41,1.41C4.78,16.1 4,14.05 4,12c0,-2.05 0.78,-4.1 2.34,-5.66l1.41,1.41C6.59,8.93 6,10.46 6,12s0.59,3.07 1.76,4.24zM12,16c-2.21,0 -4,-1.79 -4,-4s1.79,-4 4,-4 4,1.79 4,4 -1.79,4 -4,4zM17.66,17.66l-1.41,-1.41C17.41,15.07 18,13.54 18,12s-0.59,-3.07 -1.76,-4.24l1.41,-1.41C19.22,7.9 20,9.95 20,12c0,2.05 -0.78,4.1 -2.34,5.66zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z" />
</vector>

View File

@ -1166,4 +1166,58 @@
\nNota: não precisa instalar .res e .gps se esses forem exatamente os mesmos que os instalados anteriormente.
\n
\nPROSSIGA AO SEU PRÓPRIO RISCO!</string>
<string name="pref_header_sony_ambient_sound_control">Controlo Som Ambiente</string>
<string name="sony_ambient_sound">Modo</string>
<string name="sony_ambient_sound_off">Desligado</string>
<string name="sony_ambient_sound_noise_cancelling">Cancelamento de ruído</string>
<string name="sony_ambient_sound_wind_noise_reduction">Redução de ruído do vento</string>
<string name="sony_ambient_sound_ambient_sound">Som ambiente</string>
<string name="sony_ambient_sound_focus_voice">Foco na voz</string>
<string name="sony_ambient_sound_level">Nível de som ambiente</string>
<string name="sony_sound_position">Posição do som</string>
<string name="sony_sound_position_off">Desligado</string>
<string name="sony_sound_position_front">Frente</string>
<string name="sony_sound_position_front_left">Frente Esquerda</string>
<string name="sony_sound_position_front_right">Frente Direita</string>
<string name="sony_sound_position_rear_left">Traseira Esquerda</string>
<string name="sony_sound_position_rear_right">Traseira Direita</string>
<string name="sony_surround_mode">Modo Surround</string>
<string name="sony_surround_mode_off">Desligado</string>
<string name="sony_surround_mode_arena">Arena</string>
<string name="sony_surround_mode_club">Discoteca</string>
<string name="sony_surround_mode_outdoor_stage">Palco exterior</string>
<string name="sony_surround_mode_concert_hall">Sala de concertos</string>
<string name="sony_surround_position_mutually_exclusive">Aviso: As preferencias de posição de som / modo surround são mutuamente exclusivas.</string>
<string name="sony_warn_sbc_codec">Aviso: Estas preferencias só funcionam com o codec de audio SBC.</string>
<string name="sony_equalizer">Equalizador</string>
<string name="sony_equalizer_preset_off">Desligado</string>
<string name="sony_equalizer_preset_bright">Brilhante</string>
<string name="sony_equalizer_preset_excited">Excitado</string>
<string name="sony_equalizer_preset_mellow">Suave</string>
<string name="sony_equalizer_preset_relaxed">Relaxado</string>
<string name="sony_equalizer_preset_vocal">Vocal</string>
<string name="sony_equalizer_preset_treble_boost">Amplificação de agudos</string>
<string name="sony_equalizer_preset_bass_boost">Amplificação de graves</string>
<string name="sony_equalizer_preset_speech">Discurso</string>
<string name="sony_equalizer_preset_manual">Manual</string>
<string name="sony_equalizer_preset_custom_1">Pessoal 1</string>
<string name="sony_equalizer_preset_custom_2">Pessoal 2</string>
<string name="pref_header_sony_equalizer_preset_manual">Predefinição Manual</string>
<string name="pref_header_sony_equalizer_preset_custom_1">Predefinição Pessoal 1</string>
<string name="pref_header_sony_equalizer_preset_custom_2">Predefinição Pessoal 2</string>
<string name="sony_equalizer_band_400">400</string>
<string name="sony_equalizer_band_1000">1k</string>
<string name="sony_equalizer_band_2500">2.5k</string>
<string name="sony_equalizer_band_6300">6.3k</string>
<string name="sony_equalizer_band_16000">16k</string>
<string name="sony_equalizer_clear_bass">Clear Bass</string>
<string name="sony_dsee_hx">DSEE HX</string>
<string name="sony_touch_sensor">Controlo com sensor tátil</string>
<string name="sony_notification_voice_guide">Notificações &amp; Guia de voz</string>
<string name="sony_automatic_power_off">Desligar automaticamente</string>
<string name="sony_automatic_power_off_off">Não desligar</string>
<string name="sony_automatic_power_off_5_min">5 minutos</string>
<string name="sony_automatic_power_off_30_min">30 minutos</string>
<string name="sony_automatic_power_off_1_hour">1 hora</string>
<string name="sony_automatic_power_off_3_hour">3 horas</string>
</resources>

View File

@ -1833,5 +1833,98 @@
<item>3</item>
</string-array>
<string-array name="sony_wh1000xm3_ambient_sound_control_names">
<item>@string/sony_ambient_sound_off</item>
<item>@string/sony_ambient_sound_noise_cancelling</item>
<item>@string/sony_ambient_sound_wind_noise_reduction</item>
<item>@string/sony_ambient_sound_ambient_sound</item>
</string-array>
<string-array name="sony_wh1000xm3_ambient_sound_control_values">
<item>off</item>
<item>noise_cancelling</item>
<item>wind_noise_reduction</item>
<item>ambient_sound</item>
</string-array>
<string-array name="sony_wh1000xm3_sound_position_names">
<item>@string/sony_sound_position_off</item>
<item>@string/sony_sound_position_front</item>
<item>@string/sony_sound_position_front_left</item>
<item>@string/sony_sound_position_front_right</item>
<item>@string/sony_sound_position_rear_left</item>
<item>@string/sony_sound_position_rear_right</item>
</string-array>
<string-array name="sony_wh1000xm3_sound_position_values">
<item>off</item>
<item>front</item>
<item>front_left</item>
<item>front_right</item>
<item>rear_left</item>
<item>rear_right</item>
</string-array>
<string-array name="sony_wh1000xm3_surround_mode_names">
<item>@string/sony_surround_mode_off</item>
<item>@string/sony_surround_mode_arena</item>
<item>@string/sony_surround_mode_club</item>
<item>@string/sony_surround_mode_outdoor_stage</item>
<item>@string/sony_surround_mode_concert_hall</item>
</string-array>
<string-array name="sony_wh1000xm3_surround_mode_values">
<item>off</item>
<item>arena</item>
<item>club</item>
<item>outdoor_stage</item>
<item>concert_hall</item>
</string-array>
<string-array name="sony_wh1000xm3_equalizer_mode_names">
<item>@string/sony_equalizer_preset_off</item>
<item>@string/sony_equalizer_preset_bright</item>
<item>@string/sony_equalizer_preset_excited</item>
<item>@string/sony_equalizer_preset_mellow</item>
<item>@string/sony_equalizer_preset_relaxed</item>
<item>@string/sony_equalizer_preset_vocal</item>
<item>@string/sony_equalizer_preset_treble_boost</item>
<item>@string/sony_equalizer_preset_bass_boost</item>
<item>@string/sony_equalizer_preset_speech</item>
<item>@string/sony_equalizer_preset_manual</item>
<item>@string/sony_equalizer_preset_custom_1</item>
<item>@string/sony_equalizer_preset_custom_2</item>
</string-array>
<string-array name="sony_wh1000xm3_equalizer_mode_values">
<item>off</item>
<item>bright</item>
<item>excited</item>
<item>mellow</item>
<item>relaxed</item>
<item>vocal</item>
<item>treble_boost</item>
<item>bass_boost</item>
<item>speech</item>
<item>manual</item>
<item>custom_1</item>
<item>custom_2</item>
</string-array>
<string-array name="sony_wh1000xm3_automatic_power_off_names">
<item>@string/sony_automatic_power_off_off</item>
<item>@string/sony_automatic_power_off_5_min</item>
<item>@string/sony_automatic_power_off_30_min</item>
<item>@string/sony_automatic_power_off_1_hour</item>
<item>@string/sony_automatic_power_off_3_hour</item>
</string-array>
<string-array name="sony_wh1000xm3_automatic_power_off_values">
<item>off</item>
<item>after_5_min</item>
<item>after_30_min</item>
<item>after_1_hour</item>
<item>after_3_hour</item>
</string-array>
</resources>

View File

@ -101,6 +101,9 @@
<!-- Strings related to Settings -->
<string name="title_activity_settings">Settings</string>
<string name="pref_header_general">General settings</string>
<string name="pref_header_other">Other</string>
<string name="pref_header_system">System</string>
<string name="pref_header_equalizer">Equalizer</string>
<string name="pref_title_general_autoconnectonbluetooth">Connect to Gadgetbridge device when Bluetooth is turned on</string>
<string name="pref_title_general_autostartonboot">Start automatically</string>
<string name="pref_title_general_autoreconnect">Reconnect automatically</string>
@ -888,6 +891,7 @@
<string name="devicetype_smaq2oss">SMA-Q2 OSS</string>
<string name="devicetype_fitpro">FitPro</string>
<string name="devicetype_domyos_t540"/>
<string name="devicetype_sony_wh_1000xm3">Sony WH-1000XM3</string>
<string name="choose_auto_export_location">Choose export location</string>
<string name="notification_channel_name">General</string>
<string name="notification_channel_high_priority_name">High-priority</string>
@ -1312,4 +1316,59 @@
<string name="battery_case">Battery case</string>
<string name="left_earbud">Left earbud</string>
<string name="right_earbud">Right earbud</string>
<string name="pref_header_sony_ambient_sound_control">Ambient Sound Control</string>
<string name="sony_ambient_sound">Mode</string>
<string name="sony_ambient_sound_off">Off</string>
<string name="sony_ambient_sound_noise_cancelling">Noise Cancelling</string>
<string name="sony_ambient_sound_wind_noise_reduction">Wind Noise Reduction</string>
<string name="sony_ambient_sound_ambient_sound">Ambient Sound</string>
<string name="sony_ambient_sound_focus_voice">Focus on Voice</string>
<string name="sony_ambient_sound_level">Ambient Sound Level</string>
<string name="sony_sound_position">Sound Position</string>
<string name="sony_sound_position_off">Off</string>
<string name="sony_sound_position_front">Front</string>
<string name="sony_sound_position_front_left">Front Left</string>
<string name="sony_sound_position_front_right">Front Right</string>
<string name="sony_sound_position_rear_left">Rear Left</string>
<string name="sony_sound_position_rear_right">Rear Right</string>
<string name="sony_surround_mode">Surround Mode</string>
<string name="sony_surround_mode_off">Off</string>
<string name="sony_surround_mode_arena">Arena</string>
<string name="sony_surround_mode_club">Club</string>
<string name="sony_surround_mode_outdoor_stage">Outdoor Stage</string>
<string name="sony_surround_mode_concert_hall">Concert Hall</string>
<string name="sony_surround_position_mutually_exclusive">Warning: The sound position / surround mode settings are mutually exclusive.</string>
<string name="sony_warn_sbc_codec">Warning: These settings only work for the SBC audio codec.</string>
<string name="sony_equalizer">Equalizer</string>
<string name="sony_equalizer_preset_off">Off</string>
<string name="sony_equalizer_preset_bright">Bright</string>
<string name="sony_equalizer_preset_excited">Excited</string>
<string name="sony_equalizer_preset_mellow">Mellow</string>
<string name="sony_equalizer_preset_relaxed">Relaxed</string>
<string name="sony_equalizer_preset_vocal">Vocal</string>
<string name="sony_equalizer_preset_treble_boost">Treble Boost</string>
<string name="sony_equalizer_preset_bass_boost">Bass Boost</string>
<string name="sony_equalizer_preset_speech">Speech</string>
<string name="sony_equalizer_preset_manual">Manual</string>
<string name="sony_equalizer_preset_custom_1">Custom 1</string>
<string name="sony_equalizer_preset_custom_2">Custom 2</string>
<string name="pref_header_sony_equalizer_preset_manual">Manual Preset</string>
<string name="pref_header_sony_equalizer_preset_custom_1">Custom Preset 1</string>
<string name="pref_header_sony_equalizer_preset_custom_2">Custom Preset 2</string>
<string name="sony_equalizer_band_400">400</string>
<string name="sony_equalizer_band_1000">1k</string>
<string name="sony_equalizer_band_2500">2.5k</string>
<string name="sony_equalizer_band_6300">6.3k</string>
<string name="sony_equalizer_band_16000">16k</string>
<string name="sony_equalizer_clear_bass">Clear Bass</string>
<string name="sony_dsee_hx">DSEE HX</string>
<string name="sony_touch_sensor">Touch sensor control</string>
<string name="sony_notification_voice_guide">Notifications &amp; Voice Guide</string>
<string name="sony_automatic_power_off">Automatic Power Off</string>
<string name="sony_automatic_power_off_off">Do not turn off</string>
<string name="sony_automatic_power_off_5_min">5 minutes</string>
<string name="sony_automatic_power_off_30_min">30 minutes</string>
<string name="sony_automatic_power_off_1_hour">1 hour</string>
<string name="sony_automatic_power_off_3_hour">3 hours</string>
</resources>

View File

@ -0,0 +1,261 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:key="pref_key_header_sony_ambient_sound_control"
android:title="@string/pref_header_sony_ambient_sound_control">
<ListPreference
android:defaultValue="noise_cancelling"
android:entries="@array/sony_wh1000xm3_ambient_sound_control_names"
android:entryValues="@array/sony_wh1000xm3_ambient_sound_control_values"
android:icon="@drawable/ic_hearing"
android:key="pref_sony_wh1000xm3_ambient_sound_control"
android:summary="%s"
android:title="@string/sony_ambient_sound" />
<SeekBarPreference
android:defaultValue="0"
android:icon="@drawable/ic_volume_up"
android:key="pref_sony_wh1000xm3_ambient_sound_level"
android:max="19"
android:title="@string/sony_ambient_sound_level" />
<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_voice"
android:key="pref_sony_wh1000xm3_focus_voice"
android:title="@string/sony_ambient_sound_focus_voice" />
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_equalizer"
android:title="@string/pref_header_equalizer">
<Preference
android:icon="@drawable/ic_warning"
android:key="pref_sony_wh1000xm3_warning_sbc_codec_1"
android:summary="@string/sony_warn_sbc_codec" />
<ListPreference
android:defaultValue="off"
android:entries="@array/sony_wh1000xm3_equalizer_mode_names"
android:entryValues="@array/sony_wh1000xm3_equalizer_mode_values"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_mode"
android:summary="%s"
android:title="@string/sony_equalizer" />
<PreferenceScreen
android:icon="@drawable/ic_extension"
android:key="pref_sony_equalizer_preset_manual"
android:persistent="false"
android:title="@string/pref_header_sony_equalizer_preset_manual">
<PreferenceCategory
android:key="pref_key_equalizer"
android:title="@string/pref_header_sony_equalizer_preset_manual">
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_manual_band_400"
android:max="20"
android:title="@string/sony_equalizer_band_400" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_manual_band_1000"
android:max="20"
android:title="@string/sony_equalizer_band_1000" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_manual_band_2500"
android:max="20"
android:title="@string/sony_equalizer_band_2500" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_manual_band_6300"
android:max="20"
android:title="@string/sony_equalizer_band_6300" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_manual_band_16000"
android:max="20"
android:title="@string/sony_equalizer_band_16000" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_speaker"
android:key="pref_sony_wh1000xm3_equalizer_manual_clear_bass"
android:max="20"
android:title="@string/sony_equalizer_clear_bass" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen
android:icon="@drawable/ic_extension"
android:key="pref_sony_equalizer_preset_custom_1"
android:persistent="false"
android:title="@string/pref_header_sony_equalizer_preset_custom_1">
<PreferenceCategory
android:key="pref_key_equalizer"
android:title="@string/pref_header_sony_equalizer_preset_custom_1">
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_1_band_400"
android:max="20"
android:title="@string/sony_equalizer_band_400" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_1_band_1000"
android:max="20"
android:title="@string/sony_equalizer_band_1000" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_1_band_2500"
android:max="20"
android:title="@string/sony_equalizer_band_2500" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_1_band_6300"
android:max="20"
android:title="@string/sony_equalizer_band_6300" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_1_band_16000"
android:max="20"
android:title="@string/sony_equalizer_band_16000" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_speaker"
android:key="pref_sony_wh1000xm3_equalizer_custom_1_clear_bass"
android:max="20"
android:title="@string/sony_equalizer_clear_bass" />
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen
android:icon="@drawable/ic_extension"
android:key="pref_sony_equalizer_preset_custom_2"
android:persistent="false"
android:title="@string/pref_header_sony_equalizer_preset_custom_2">
<PreferenceCategory
android:key="pref_key_equalizer"
android:title="@string/pref_header_sony_equalizer_preset_custom_2">
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_2_band_400"
android:max="20"
android:title="@string/sony_equalizer_band_400" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_2_band_1000"
android:max="20"
android:title="@string/sony_equalizer_band_1000" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_2_band_2500"
android:max="20"
android:title="@string/sony_equalizer_band_2500" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_2_band_6300"
android:max="20"
android:title="@string/sony_equalizer_band_6300" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_graphic_eq"
android:key="pref_sony_wh1000xm3_equalizer_custom_2_band_16000"
android:max="20"
android:title="@string/sony_equalizer_band_16000" />
<SeekBarPreference
android:defaultValue="10"
android:icon="@drawable/ic_speaker"
android:key="pref_sony_wh1000xm3_equalizer_custom_2_clear_bass"
android:max="20"
android:title="@string/sony_equalizer_clear_bass" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_other"
android:title="@string/pref_header_other">
<Preference
android:icon="@drawable/ic_warning"
android:key="pref_sony_wh1000xm3_warning_position_surround"
android:summary="@string/sony_surround_position_mutually_exclusive" />
<Preference
android:icon="@drawable/ic_warning"
android:key="pref_sony_wh1000xm3_warning_sbc_codec_2"
android:summary="@string/sony_warn_sbc_codec" />
<ListPreference
android:defaultValue="off"
android:entries="@array/sony_wh1000xm3_sound_position_names"
android:entryValues="@array/sony_wh1000xm3_sound_position_values"
android:icon="@drawable/ic_switch_left"
android:key="pref_sony_wh1000xm3_sound_position"
android:summary="%s"
android:title="@string/sony_sound_position" />
<ListPreference
android:defaultValue="off"
android:entries="@array/sony_wh1000xm3_surround_mode_names"
android:entryValues="@array/sony_wh1000xm3_surround_mode_values"
android:icon="@drawable/ic_surround"
android:key="pref_sony_wh1000xm3_surround_mode"
android:summary="%s"
android:title="@string/sony_surround_mode" />
<SwitchPreference
android:defaultValue="false"
android:icon="@drawable/ic_extension"
android:key="pref_sony_wh1000xm3_dsee_hx"
android:title="@string/sony_dsee_hx" />
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_other"
android:title="@string/pref_header_system">
<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_touch"
android:key="pref_sony_wh1000xm3_touch_sensor"
android:title="@string/sony_touch_sensor" />
<ListPreference
android:defaultValue="off"
android:entries="@array/sony_wh1000xm3_automatic_power_off_names"
android:entryValues="@array/sony_wh1000xm3_automatic_power_off_values"
android:icon="@drawable/ic_power_settings_new"
android:key="pref_sony_wh1000xm3_automatic_power_off"
android:summary="%s"
android:title="@string/sony_automatic_power_off" />
<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_notifications"
android:key="pref_sony_wh1000xm3_notification_voice_guide"
android:title="@string/sony_notification_voice_guide" />
</PreferenceCategory>
</androidx.preference.PreferenceScreen>