1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-28 19:45:50 +01:00

Rename GBDevice#hardwareVersion to model

(e.g. while DeviceType is "PEBBLE" in general, the model
might specify a Pebble Time or Time Steel.
This commit is contained in:
cpfeiffer 2016-08-26 20:57:59 +02:00
parent 4363f110fb
commit c59553c9c9
13 changed files with 39 additions and 25 deletions

View File

@ -211,8 +211,8 @@ public class ExternalPebbleJSActivity extends GBActivity {
JSONObject wi = new JSONObject();
try {
wi.put("firmware", mGBDevice.getFirmwareVersion());
wi.put("platform", PebbleUtils.getPlatformName(mGBDevice.getHardwareVersion()));
wi.put("model", PebbleUtils.getModel(mGBDevice.getHardwareVersion()));
wi.put("platform", PebbleUtils.getPlatformName(mGBDevice.getModel()));
wi.put("model", PebbleUtils.getModel(mGBDevice.getModel()));
//TODO: use real info
wi.put("language", "en");
} catch (JSONException e) {

View File

@ -112,7 +112,7 @@ public abstract class AbstractAppManagerFragment extends Fragment {
systemApps.add(new GBDeviceApp(UUID.fromString("67a32d95-ef69-46d4-a0b9-854cc62f97f9"), "Alarms (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
systemApps.add(new GBDeviceApp(UUID.fromString("18e443ce-38fd-47c8-84d5-6d0c775fbe55"), "Watchfaces (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
if (mGBDevice != null && !"aplite".equals(PebbleUtils.getPlatformName(mGBDevice.getHardwareVersion()))) {
if (mGBDevice != null && !"aplite".equals(PebbleUtils.getPlatformName(mGBDevice.getModel()))) {
systemApps.add(new GBDeviceApp(UUID.fromString("0863fc6a-66c5-4f62-ab8a-82ed00a98b5d"), "Send Text (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_PEBBLE_HEALTH, "Health (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
}
@ -188,7 +188,7 @@ public abstract class AbstractAppManagerFragment extends Fragment {
cachedAppList.add(new GBDeviceApp(UUID.fromString("cf1e816a-9db0-4511-bbb8-f60c48ca8fac"), "Golf (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
}
*/
if (mGBDevice != null && !"aplite".equals(PebbleUtils.getPlatformName(mGBDevice.getHardwareVersion()))) {
if (mGBDevice != null && !"aplite".equals(PebbleUtils.getPlatformName(mGBDevice.getModel()))) {
if (baseName.equals(PebbleProtocol.UUID_PEBBLE_HEALTH.toString())) {
cachedAppList.add(new GBDeviceApp(PebbleProtocol.UUID_PEBBLE_HEALTH, "Health (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
continue;

View File

@ -161,8 +161,8 @@ public class GBDeviceAdapter extends ArrayAdapter<GBDevice> {
private String getUniqueDeviceName(GBDevice device) {
String deviceName = device.getName();
if (!isUniqueDeviceName(device, deviceName)) {
if (device.getHardwareVersion() != null) {
deviceName = deviceName + " " + device.getHardwareVersion();
if (device.getModel() != null) {
deviceName = deviceName + " " + device.getModel();
if (!isUniqueDeviceName(device, deviceName)) {
deviceName = deviceName + " " + device.getShortAddress();
}

View File

@ -180,7 +180,7 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator {
@Override
public boolean supportsHeartRateMeasurement(GBDevice device) {
String hwVersion = device.getHardwareVersion();
String hwVersion = device.getModel();
return isMi1S(hwVersion) || isMiPro(hwVersion);
}

View File

@ -52,7 +52,7 @@ public class PBWInstallHandler implements InstallHandler {
return;
}
String platformName = PebbleUtils.getPlatformName(device.getHardwareVersion());
String platformName = PebbleUtils.getPlatformName(device.getModel());
try {
mPBWReader = new PBWReader(mUri, mContext, platformName);
@ -75,7 +75,7 @@ public class PBWInstallHandler implements InstallHandler {
installItem.setIcon(R.drawable.ic_firmware);
String hwRevision = mPBWReader.getHWRevision();
if (hwRevision != null && hwRevision.equals(device.getHardwareVersion())) {
if (hwRevision != null && hwRevision.equals(device.getModel())) {
installItem.setName(mContext.getString(R.string.pbw_installhandler_pebble_firmware, ""));
installItem.setDetails(mContext.getString(R.string.pbwinstallhandler_correct_hw_revision));

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import org.slf4j.Logger;
@ -48,7 +49,7 @@ public class GBDevice implements Parcelable {
private final DeviceType mDeviceType;
private String mFirmwareVersion;
private String mFirmwareVersion2;
private String mHardwareVersion;
private String mModel;
private State mState = State.NOT_CONNECTED;
private short mBatteryLevel = BATTERY_UNKNOWN;
private short mBatteryThresholdPercent = BATTERY_THRESHOLD_PERCENT;
@ -70,7 +71,7 @@ public class GBDevice implements Parcelable {
mDeviceType = DeviceType.values()[in.readInt()];
mFirmwareVersion = in.readString();
mFirmwareVersion2 = in.readString();
mHardwareVersion = in.readString();
mModel = in.readString();
mState = State.values()[in.readInt()];
mBatteryLevel = (short) in.readInt();
mBatteryThresholdPercent = (short) in.readInt();
@ -89,7 +90,7 @@ public class GBDevice implements Parcelable {
dest.writeInt(mDeviceType.ordinal());
dest.writeString(mFirmwareVersion);
dest.writeString(mFirmwareVersion2);
dest.writeString(mHardwareVersion);
dest.writeString(mModel);
dest.writeInt(mState.ordinal());
dest.writeInt(mBatteryLevel);
dest.writeInt(mBatteryThresholdPercent);
@ -136,12 +137,19 @@ public class GBDevice implements Parcelable {
mFirmwareVersion2 = firmwareVersion2;
}
public String getHardwareVersion() {
return mHardwareVersion;
/**
* Returns the specific model/hardware revision of this device.
* This information is not always available, typically only when the device is initialized
* @return the model/hardware revision of this device
* @see #getType()
*/
@Nullable
public String getModel() {
return mModel;
}
public void setHardwareVersion(String hardwareVersion) {
mHardwareVersion = hardwareVersion;
public void setModel(String model) {
mModel = model;
}
public boolean isConnected() {
@ -261,6 +269,12 @@ public class GBDevice implements Parcelable {
return GBApplication.getContext().getString(R.string.unknown_state);
}
/**
* Returns the general type of this device. For more detailed information,
* soo #getModel()
* @return the general type of this device
*/
@NonNull
public DeviceType getType() {
return mDeviceType;
}
@ -384,8 +398,8 @@ public class GBDevice implements Parcelable {
if (mDeviceInfos != null) {
result.addAll(mDeviceInfos);
}
if (mHardwareVersion != null) {
result.add(new GenericItem(DEVINFO_HW_VER, mHardwareVersion));
if (mModel != null) {
result.add(new GenericItem(DEVINFO_HW_VER, mModel));
}
if (mFirmwareVersion != null) {
result.add(new GenericItem(DEVINFO_FW_VER, mFirmwareVersion));

View File

@ -152,7 +152,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
return;
}
gbDevice.setFirmwareVersion(infoEvent.fwVersion);
gbDevice.setHardwareVersion(infoEvent.hwVersion);
gbDevice.setModel(infoEvent.hwVersion);
gbDevice.sendDeviceUpdateIntent(context);
}

View File

@ -13,7 +13,7 @@ public abstract class AbstractMi1SFirmwareInfo extends AbstractMiFirmwareInfo {
@Override
public boolean isGenerallyCompatibleWith(GBDevice device) {
return MiBandConst.MI_1S.equals(device.getHardwareVersion());
return MiBandConst.MI_1S.equals(device.getModel());
}
@Override

View File

@ -31,7 +31,7 @@ public class Mi1AFirmwareInfo extends AbstractMi1FirmwareInfo {
@Override
public boolean isGenerallyCompatibleWith(GBDevice device) {
String hwVersion = device.getHardwareVersion();
String hwVersion = device.getModel();
return MiBandConst.MI_1A.equals(hwVersion);
}
}

View File

@ -31,7 +31,7 @@ public class Mi1FirmwareInfo extends AbstractMi1FirmwareInfo {
@Override
public boolean isGenerallyCompatibleWith(GBDevice device) {
String hwVersion = device.getHardwareVersion();
String hwVersion = device.getModel();
return MiBandConst.MI_1.equals(hwVersion);
}
}

View File

@ -30,7 +30,7 @@ public class Mi1SFirmwareInfo extends CompositeMiFirmwareInfo {
@Override
public boolean isGenerallyCompatibleWith(GBDevice device) {
return MiBandConst.MI_1S.equals(device.getHardwareVersion());
return MiBandConst.MI_1S.equals(device.getModel());
}
@Override

View File

@ -591,7 +591,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
return;
}
String platformName = PebbleUtils.getPlatformName(gbDevice.getHardwareVersion());
String platformName = PebbleUtils.getPlatformName(gbDevice.getModel());
try {
mPBWReader = new PBWReader(uri, getContext(), platformName);

View File

@ -100,7 +100,7 @@ public class EntitiesTest {
// DBHelper dbHelper = new DBHelper(RuntimeEnvironment.application);
GBDevice dummyGBDevice = new GBDevice("00:00:00:00:00", "Testie", DeviceType.TEST);
dummyGBDevice.setFirmwareVersion("1.2.3");
dummyGBDevice.setHardwareVersion("4.0");
dummyGBDevice.setModel("4.0");
Device device = DBHelper.getDevice(dummyGBDevice, daoSession);
assertNotNull(device);
assertEquals("00:00:00:00:00", device.getIdentifier());