| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.mtp; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
public class MtpEvent { |
| 24 |
|
| 25 |
public static final int EVENT_UNDEFINED = 0x4000; |
| 26 |
|
| 27 |
public static final int EVENT_CANCEL_TRANSACTION = 0x4001; |
| 28 |
|
| 29 |
public static final int EVENT_OBJECT_ADDED = 0x4002; |
| 30 |
|
| 31 |
public static final int EVENT_OBJECT_REMOVED = 0x4003; |
| 32 |
|
| 33 |
public static final int EVENT_STORE_ADDED = 0x4004; |
| 34 |
|
| 35 |
public static final int EVENT_STORE_REMOVED = 0x4005; |
| 36 |
|
| 37 |
public static final int EVENT_DEVICE_PROP_CHANGED = 0x4006; |
| 38 |
|
| 39 |
public static final int EVENT_OBJECT_INFO_CHANGED = 0x4007; |
| 40 |
|
| 41 |
public static final int EVENT_DEVICE_INFO_CHANGED = 0x4008; |
| 42 |
|
| 43 |
public static final int EVENT_REQUEST_OBJECT_TRANSFER = 0x4009; |
| 44 |
|
| 45 |
public static final int EVENT_STORE_FULL = 0x400A; |
| 46 |
|
| 47 |
public static final int EVENT_DEVICE_RESET = 0x400B; |
| 48 |
|
| 49 |
public static final int EVENT_STORAGE_INFO_CHANGED = 0x400C; |
| 50 |
|
| 51 |
public static final int EVENT_CAPTURE_COMPLETE = 0x400D; |
| 52 |
|
| 53 |
public static final int EVENT_UNREPORTED_STATUS = 0x400E; |
| 54 |
|
| 55 |
public static final int EVENT_OBJECT_PROP_CHANGED = 0xC801; |
| 56 |
|
| 57 |
public static final int EVENT_OBJECT_PROP_DESC_CHANGED = 0xC802; |
| 58 |
|
| 59 |
public static final int EVENT_OBJECT_REFERENCES_CHANGED = 0xC803; |
| 60 |
|
| 61 |
private int mEventCode = EVENT_UNDEFINED; |
| 62 |
|
| 63 |
|
| 64 |
private int mParameter1; |
| 65 |
private int mParameter2; |
| 66 |
private int mParameter3; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
private MtpEvent() {} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
public int getEventCode() { return mEventCode; } |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public int getParameter1() { return mParameter1; } |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
public int getParameter2() { return mParameter2; } |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
public int getParameter3() { return mParameter3; } |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
public int getObjectHandle() { |
| 106 |
switch (mEventCode) { |
| 107 |
case EVENT_OBJECT_ADDED: |
| 108 |
return mParameter1; |
| 109 |
case EVENT_OBJECT_REMOVED: |
| 110 |
return mParameter1; |
| 111 |
case EVENT_OBJECT_INFO_CHANGED: |
| 112 |
return mParameter1; |
| 113 |
case EVENT_REQUEST_OBJECT_TRANSFER: |
| 114 |
return mParameter1; |
| 115 |
case EVENT_OBJECT_PROP_CHANGED: |
| 116 |
return mParameter1; |
| 117 |
case EVENT_OBJECT_REFERENCES_CHANGED: |
| 118 |
return mParameter1; |
| 119 |
default: |
| 120 |
throw new IllegalParameterAccess("objectHandle", mEventCode); |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
public int getStorageId() { |
| 133 |
switch (mEventCode) { |
| 134 |
case EVENT_STORE_ADDED: |
| 135 |
return mParameter1; |
| 136 |
case EVENT_STORE_REMOVED: |
| 137 |
return mParameter1; |
| 138 |
case EVENT_STORE_FULL: |
| 139 |
return mParameter1; |
| 140 |
case EVENT_STORAGE_INFO_CHANGED: |
| 141 |
return mParameter1; |
| 142 |
default: |
| 143 |
throw new IllegalParameterAccess("storageID", mEventCode); |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
public int getDevicePropCode() { |
| 153 |
switch (mEventCode) { |
| 154 |
case EVENT_DEVICE_PROP_CHANGED: |
| 155 |
return mParameter1; |
| 156 |
default: |
| 157 |
throw new IllegalParameterAccess("devicePropCode", mEventCode); |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
public int getTransactionId() { |
| 167 |
switch (mEventCode) { |
| 168 |
case EVENT_CAPTURE_COMPLETE: |
| 169 |
return mParameter1; |
| 170 |
default: |
| 171 |
throw new IllegalParameterAccess("transactionID", mEventCode); |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
public int getObjectPropCode() { |
| 182 |
switch (mEventCode) { |
| 183 |
case EVENT_OBJECT_PROP_CHANGED: |
| 184 |
return mParameter2; |
| 185 |
case EVENT_OBJECT_PROP_DESC_CHANGED: |
| 186 |
return mParameter1; |
| 187 |
default: |
| 188 |
throw new IllegalParameterAccess("objectPropCode", mEventCode); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
public int getObjectFormatCode() { |
| 198 |
switch (mEventCode) { |
| 199 |
case EVENT_OBJECT_PROP_DESC_CHANGED: |
| 200 |
return mParameter2; |
| 201 |
default: |
| 202 |
throw new IllegalParameterAccess("objectFormatCode", mEventCode); |
| 203 |
} |
| 204 |
} |
| 205 |
|
| 206 |
private static class IllegalParameterAccess extends UnsupportedOperationException { |
| 207 |
public IllegalParameterAccess(String propertyName, int eventCode) { |
| 208 |
super("Cannot obtain " + propertyName + " for the event: " + eventCode + "."); |
| 209 |
} |
| 210 |
} |
| 211 |
} |