Redmi Buds: Make packages and support classes generic

This commit is contained in:
José Rebelo 2025-01-02 17:19:48 +00:00
parent af10677157
commit efd1e3d597
16 changed files with 49 additions and 52 deletions

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro;
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds;
import androidx.annotation.NonNull;
@ -26,7 +26,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.Device;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.RedmiBuds5ProDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.RedmiBudsDeviceSupport;
public abstract class AbstractRedmiBudsCoordinator extends AbstractDeviceCoordinator {
@Override
@ -42,7 +42,7 @@ public abstract class AbstractRedmiBudsCoordinator extends AbstractDeviceCoordin
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return RedmiBuds5ProDeviceSupport.class;
return RedmiBudsDeviceSupport.class;
}
@Override

View File

@ -14,14 +14,11 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro;
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettings;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class RedmiBuds4ActiveCoordinator extends AbstractRedmiBudsCoordinator {
@Override

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro;
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds;
import java.util.regex.Pattern;
@ -45,6 +45,6 @@ public class RedmiBuds5ProCoordinator extends AbstractRedmiBudsCoordinator {
@Override
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(final GBDevice device) {
return new RedmiBuds5ProSettingsCustomizer(device);
return new RedmiBudsSettingsCustomizer(device);
}
}

View File

@ -1,4 +1,4 @@
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro;
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds;
import java.util.regex.Pattern;

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro;
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds;
import android.os.Parcel;
@ -33,11 +33,11 @@ import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpec
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class RedmiBuds5ProSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
public class RedmiBudsSettingsCustomizer implements DeviceSpecificSettingsCustomizer {
final GBDevice device;
public RedmiBuds5ProSettingsCustomizer(final GBDevice device) {
public RedmiBudsSettingsCustomizer(final GBDevice device) {
this.device = device;
}
@ -146,16 +146,16 @@ public class RedmiBuds5ProSettingsCustomizer implements DeviceSpecificSettingsCu
parcel.writeParcelable(device, 0);
}
public static final Creator<RedmiBuds5ProSettingsCustomizer> CREATOR = new Creator<RedmiBuds5ProSettingsCustomizer>() {
public static final Creator<RedmiBudsSettingsCustomizer> CREATOR = new Creator<RedmiBudsSettingsCustomizer>() {
@Override
public RedmiBuds5ProSettingsCustomizer createFromParcel(final Parcel in) {
final GBDevice device = in.readParcelable(RedmiBuds5ProSettingsCustomizer.class.getClassLoader());
return new RedmiBuds5ProSettingsCustomizer(device);
public RedmiBudsSettingsCustomizer createFromParcel(final Parcel in) {
final GBDevice device = in.readParcelable(RedmiBudsSettingsCustomizer.class.getClassLoader());
return new RedmiBudsSettingsCustomizer(device);
}
@Override
public RedmiBuds5ProSettingsCustomizer[] newArray(final int size) {
return new RedmiBuds5ProSettingsCustomizer[size];
public RedmiBudsSettingsCustomizer[] newArray(final int size) {
return new RedmiBudsSettingsCustomizer[size];
}
};
}

View File

@ -1,4 +1,4 @@
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.prefs;
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.prefs;
public class Configuration {

View File

@ -1,4 +1,4 @@
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.prefs;
package nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.prefs;
public class Gestures {

View File

@ -283,9 +283,9 @@ import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband9.MiBand9Coordi
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miband9pro.MiBand9ProCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miwatch.MiWatchLiteCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.miwatchcolorsport.MiWatchColorSportCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.RedmiBuds4ActiveCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.RedmiBuds5ProCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.RedmiBuds6ActiveCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.RedmiBuds4ActiveCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.RedmiBuds5ProCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.RedmiBuds6ActiveCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmismartband2.RedmiSmartBand2Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmismartbandpro.RedmiSmartBandProCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmiwatch2.RedmiWatch2Coordinator;

View File

@ -14,23 +14,23 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro;
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds;
import nodomain.freeyourgadget.gadgetbridge.service.serial.AbstractSerialDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceIoThread;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
public class RedmiBuds5ProDeviceSupport extends AbstractSerialDeviceSupport {
public class RedmiBudsDeviceSupport extends AbstractSerialDeviceSupport {
@Override
protected GBDeviceProtocol createDeviceProtocol() {
return new RedmiBuds5ProProtocol(getDevice());
return new RedmiBudsProtocol(getDevice());
}
@Override
protected GBDeviceIoThread createDeviceIOThread() {
return new RedmiBuds5ProIOThread(getDevice(), getContext(),
(RedmiBuds5ProProtocol) getDeviceProtocol(),
RedmiBuds5ProDeviceSupport.this, getBluetoothAdapter());
return new RedmiBudsIOThread(getDevice(), getContext(),
(RedmiBudsProtocol) getDeviceProtocol(),
RedmiBudsDeviceSupport.this, getBluetoothAdapter());
}
@Override

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro;
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds;
import static nodomain.freeyourgadget.gadgetbridge.util.GB.hexdump;
@ -35,11 +35,11 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.btclassic.BtClassicIoThread;
public class RedmiBuds5ProIOThread extends BtClassicIoThread {
private static final Logger LOG = LoggerFactory.getLogger(RedmiBuds5ProIOThread.class);
private final RedmiBuds5ProProtocol redmiProtocol;
public class RedmiBudsIOThread extends BtClassicIoThread {
private static final Logger LOG = LoggerFactory.getLogger(RedmiBudsIOThread.class);
private final RedmiBudsProtocol redmiProtocol;
public RedmiBuds5ProIOThread(GBDevice gbDevice, Context context, RedmiBuds5ProProtocol redmiProtocol, RedmiBuds5ProDeviceSupport deviceSupport, BluetoothAdapter btAdapter) {
public RedmiBudsIOThread(GBDevice gbDevice, Context context, RedmiBudsProtocol redmiProtocol, RedmiBudsDeviceSupport deviceSupport, BluetoothAdapter btAdapter) {
super(gbDevice, context, redmiProtocol, deviceSupport, btAdapter);
this.redmiProtocol = redmiProtocol;
}

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro;
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.*;
import static nodomain.freeyourgadget.gadgetbridge.util.GB.hexdump;
@ -37,28 +37,28 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInf
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdateDeviceState;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.prefs.Configuration.Config;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.prefs.Configuration.StrengthTarget;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.prefs.Gestures.InteractionType;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds5pro.prefs.Gestures.Position;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.prefs.Configuration.Config;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.prefs.Configuration.StrengthTarget;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.prefs.Gestures.InteractionType;
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.redmibuds.prefs.Gestures.Position;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice.State;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol.Authentication;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol.Message;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol.MessageType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol.Opcode;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol.Authentication;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol.Message;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol.MessageType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol.Opcode;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class RedmiBuds5ProProtocol extends GBDeviceProtocol {
public class RedmiBudsProtocol extends GBDeviceProtocol {
private static final Logger LOG = LoggerFactory.getLogger(RedmiBuds5ProProtocol.class);
private static final Logger LOG = LoggerFactory.getLogger(RedmiBudsProtocol.class);
final UUID UUID_DEVICE_CTRL = UUID.fromString("0000fd2d-0000-1000-8000-00805f9b34fb");
private byte sequenceNumber = 0;
protected RedmiBuds5ProProtocol(GBDevice device) {
protected RedmiBudsProtocol(GBDevice device) {
super(device);
}

View File

@ -1,4 +1,4 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol;
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol;
class AuthData {

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol;
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol;
import java.math.BigInteger;
import java.security.SecureRandom;
import java.util.ArrayList;

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol;
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol;
import static nodomain.freeyourgadget.gadgetbridge.util.GB.hexdump;

View File

@ -1,4 +1,4 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol;
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol;
public enum MessageType {
PHONE_REQUEST(0xC4),

View File

@ -1,4 +1,4 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds5pro.protocol;
package nodomain.freeyourgadget.gadgetbridge.service.devices.redmibuds.protocol;
public enum Opcode {
GET_DEVICE_INFO(0x02),