Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.getpebble.android.framework.protocol.outbound;
- import com.getpebble.android.framework.protocol.EndpointId;
- import com.getpebble.android.framework.util.ByteUtils;
- public class PblOutboundRegistryMessage extends PblOutboundMessage
- {
- private final byte[] mByteValue;
- private final RegistryCommand mCommand;
- private final RegistryKey mKey;
- private final RegistryType mType;
- public PblOutboundRegistryMessage(RegistryKey paramRegistryKey, int paramInt, RegistryType paramRegistryType, RegistryCommand paramRegistryCommand)
- {
- super(paramRegistryType.getEndpointId());
- this.mKey = paramRegistryKey;
- this.mByteValue = ByteUtils.int2bytes(paramInt);
- this.mType = paramRegistryType;
- this.mCommand = paramRegistryCommand;
- }
- public byte[] getBytes()
- {
- try
- {
- if (!areBytesCached())
- {
- Byte[] arrayOfByte1 = new Byte[1];
- arrayOfByte1[0] = Byte.valueOf((byte)this.mCommand.getId());
- addBytes(arrayOfByte1);
- Byte[] arrayOfByte2 = new Byte[1];
- arrayOfByte2[0] = Byte.valueOf((byte)(0xFF & this.mKey.getString().length()));
- addBytes(arrayOfByte2);
- if (this.mCommand == RegistryCommand.WRITE)
- {
- Byte[] arrayOfByte3 = new Byte[1];
- arrayOfByte3[0] = Byte.valueOf((byte)(0xFF & this.mByteValue.length));
- addBytes(arrayOfByte3);
- }
- ByteUtils.writeFixedLengthString(this, this.mKey.getString(), this.mKey.getString().length());
- if (this.mCommand == RegistryCommand.WRITE)
- addBytes(this.mByteValue);
- }
- byte[] arrayOfByte = super.getBytes();
- return arrayOfByte;
- }
- finally
- {
- }
- }
- public static enum RegistryCommand
- {
- private final int id;
- static
- {
- REMOVE = new RegistryCommand("REMOVE", 2, 4);
- RegistryCommand[] arrayOfRegistryCommand = new RegistryCommand[3];
- arrayOfRegistryCommand[0] = READ;
- arrayOfRegistryCommand[1] = WRITE;
- arrayOfRegistryCommand[2] = REMOVE;
- }
- private RegistryCommand(int paramInt)
- {
- this.id = paramInt;
- }
- public int getId()
- {
- return this.id;
- }
- }
- public static enum RegistryKey
- {
- private final String mKeyCode;
- static
- {
- MISC = new RegistryKey("MISC", 3, "mfg_misc");
- FUNC_TEST = new RegistryKey("FUNC_TEST", 4, "mfg_functest");
- COLOR = new RegistryKey("COLOR", 5, "mfg_color");
- FAC_MODE = new RegistryKey("FAC_MODE", 6, "mfg_facmode");
- RegistryKey[] arrayOfRegistryKey = new RegistryKey[7];
- arrayOfRegistryKey[0] = PCB_TEST_DATE;
- arrayOfRegistryKey[1] = RTC_FREQ;
- arrayOfRegistryKey[2] = TEST_RESULT;
- arrayOfRegistryKey[3] = MISC;
- arrayOfRegistryKey[4] = FUNC_TEST;
- arrayOfRegistryKey[5] = COLOR;
- arrayOfRegistryKey[6] = FAC_MODE;
- }
- private RegistryKey(String paramString)
- {
- this.mKeyCode = paramString;
- }
- public String getString()
- {
- return this.mKeyCode;
- }
- }
- public static enum RegistryType
- {
- private final EndpointId mEndpointId;
- static
- {
- FACTORY = new RegistryType("FACTORY", 1, EndpointId.FCT_REG);
- RegistryType[] arrayOfRegistryType = new RegistryType[2];
- arrayOfRegistryType[0] = SYSTEM;
- arrayOfRegistryType[1] = FACTORY;
- }
- private RegistryType(EndpointId paramEndpointId)
- {
- this.mEndpointId = paramEndpointId;
- }
- public EndpointId getEndpointId()
- {
- return this.mEndpointId;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement