mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-09-01 03:55:47 +02:00
Huawei: Use proper file type for sleep files
This commit is contained in:
parent
88c8629ec0
commit
9321e470d7
@ -31,13 +31,16 @@ public class FileDownloadService2C {
|
||||
public static final int id = 0x2c;
|
||||
|
||||
public enum FileType {
|
||||
SLEEP,
|
||||
SLEEP_STATE,
|
||||
SLEEP_DATA,
|
||||
UNKNOWN; // Never use this as input
|
||||
|
||||
static byte fileTypeToByte(FileType fileType) {
|
||||
switch (fileType) {
|
||||
case SLEEP:
|
||||
case SLEEP_STATE:
|
||||
return (byte) 0x0e;
|
||||
case SLEEP_DATA:
|
||||
return (byte) 0x0f;
|
||||
default:
|
||||
throw new RuntimeException();
|
||||
}
|
||||
@ -46,7 +49,9 @@ public class FileDownloadService2C {
|
||||
static FileType byteToFileType(byte b) {
|
||||
switch (b) {
|
||||
case 0x0e:
|
||||
return FileType.SLEEP;
|
||||
return FileType.SLEEP_STATE;
|
||||
case 0x0f:
|
||||
return FileType.SLEEP_DATA;
|
||||
default:
|
||||
return FileType.UNKNOWN;
|
||||
}
|
||||
|
@ -107,7 +107,8 @@ public class HuaweiFileDownloadManager {
|
||||
*/
|
||||
public enum FileType {
|
||||
DEBUG,
|
||||
SLEEP,
|
||||
SLEEP_STATE,
|
||||
SLEEP_DATA,
|
||||
UNKNOWN // Never for input!
|
||||
}
|
||||
|
||||
@ -243,7 +244,7 @@ public class HuaweiFileDownloadManager {
|
||||
public void downloadSleep(boolean supportsTruSleepNewSync, String filename, int startTime, int endTime) {
|
||||
FileRequest request = new FileRequest();
|
||||
request.filename = filename;
|
||||
request.fileType = FileType.SLEEP;
|
||||
request.fileType = (filename.equals("sleep_state.bin"))?FileType.SLEEP_STATE: FileType.SLEEP_DATA;
|
||||
request.newSync = supportsTruSleepNewSync;
|
||||
request.startTime = startTime;
|
||||
request.endTime = endTime;
|
||||
|
@ -53,8 +53,10 @@ public class GetFileDownloadInitRequest extends Request {
|
||||
|
||||
private FileDownloadService2C.FileType convertFileTypeTo2C(HuaweiFileDownloadManager.FileType type) {
|
||||
switch (type) {
|
||||
case SLEEP:
|
||||
return FileDownloadService2C.FileType.SLEEP;
|
||||
case SLEEP_STATE:
|
||||
return FileDownloadService2C.FileType.SLEEP_STATE;
|
||||
case SLEEP_DATA:
|
||||
return FileDownloadService2C.FileType.SLEEP_DATA;
|
||||
default:
|
||||
return FileDownloadService2C.FileType.UNKNOWN;
|
||||
}
|
||||
@ -62,8 +64,10 @@ public class GetFileDownloadInitRequest extends Request {
|
||||
|
||||
private HuaweiFileDownloadManager.FileType convertFileTypeFrom2C(FileDownloadService2C.FileType type) {
|
||||
switch (type) {
|
||||
case SLEEP:
|
||||
return HuaweiFileDownloadManager.FileType.SLEEP;
|
||||
case SLEEP_STATE:
|
||||
return HuaweiFileDownloadManager.FileType.SLEEP_STATE;
|
||||
case SLEEP_DATA:
|
||||
return HuaweiFileDownloadManager.FileType.SLEEP_DATA;
|
||||
default:
|
||||
return HuaweiFileDownloadManager.FileType.UNKNOWN;
|
||||
}
|
||||
@ -80,7 +84,7 @@ public class GetFileDownloadInitRequest extends Request {
|
||||
} else {
|
||||
if (this.request.fileType == HuaweiFileDownloadManager.FileType.DEBUG)
|
||||
return new FileDownloadService0A.FileDownloadInit.DebugFilesRequest(paramsProvider).serialize();
|
||||
else if (this.request.fileType == HuaweiFileDownloadManager.FileType.SLEEP)
|
||||
else if (this.request.fileType == HuaweiFileDownloadManager.FileType.SLEEP_STATE)
|
||||
return new FileDownloadService0A.FileDownloadInit.SleepFilesRequest(paramsProvider, request.startTime, request.endTime).serialize();
|
||||
else
|
||||
throw new RequestCreationException("Unknown file type");
|
||||
|
Loading…
Reference in New Issue
Block a user