wangzhibo
4 天以前 ae6f40460dcd56af6c5f60ba52c883854c3bac55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*  Copyright (C) 2020-2024 Daniel Dakhno
 
    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 <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file;
 
public enum FileHandle {
    OTA_FILE(0x00, 0x00),
    ACTIVITY_FILE(0x01, 0x00),
    HARDWARE_LOG_FILE(0x02, 0x00),
    FONT_FILE(0x03, 0x00),
    MUSIC_INFO(0x04, 0x00),
    UI_CONTROL(0x05, 0x00),
    HAND_ACTIONS(0x06, 0x00),
    SETTINGS_BUTTONS(0x06, 0x00),
    ASSET_BACKGROUND_IMAGES(0x07, 0x00),
    ASSET_NOTIFICATION_IMAGES(0x07, 0x01),
    ASSET_TRANSLATIONS(0x07, 0x02),
    ASSET_REPLY_IMAGES(0x07, 0x03),
    CONFIGURATION(0x08, 0x00),
    NOTIFICATION_PLAY(0x09, 0x00),
    ALARMS(0x0A, 0x00),
    DEVICE_INFO(0x0b, 0x00),
    NOTIFICATION_FILTER(0x0C, 0x00),
    WATCH_PARAMETERS(0x0E, 0x00),
    LOOK_UP_TABLE(0x0f, 0x00),
    RATE(0x10, 0x00),
    REPLY_MESSAGES(0x13, 0x00),
    APP_CODE(0x15, 0xFE),
    ;
 
    private int handle, subHandle;
 
    FileHandle(int handle, int subHandle) {
        this.handle = handle;
        this.subHandle = subHandle;
    }
 
    public static FileHandle fromName(String name){
        for(FileHandle handle : FileHandle.values()){
            if(handle.toString().equals(name)){
                return handle;
            }
        }
        return null;
    }
 
    public static FileHandle fromHandle(short handleBytes){
        for(FileHandle handle : FileHandle.values()){
            if(handle.getHandle() == handleBytes){
                return handle;
            }
        }
        return null;
    }
 
    public short getHandle(){
        return (short)((handle << 8) | (subHandle));
    }
 
    public byte getMinorHandle(){
        return (byte) subHandle;
    }
 
    public byte getMajorHandle() {
        return (byte) handle;
    }
}