| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.mtp; |
| 18 |
|
| 19 |
import android.compat.annotation.UnsupportedAppUsage; |
| 20 |
|
| 21 |
import java.util.ArrayList; |
| 22 |
import java.util.List; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
class MtpPropertyList { |
| 30 |
|
| 31 |
|
| 32 |
private List<Integer> mObjectHandles; |
| 33 |
|
| 34 |
private List<Integer> mPropertyCodes; |
| 35 |
|
| 36 |
private List<Integer> mDataTypes; |
| 37 |
|
| 38 |
private List<Long> mLongValues; |
| 39 |
|
| 40 |
private List<String> mStringValues; |
| 41 |
|
| 42 |
|
| 43 |
private int mCode; |
| 44 |
|
| 45 |
public MtpPropertyList(int code) { |
| 46 |
mCode = code; |
| 47 |
mObjectHandles = new ArrayList<>(); |
| 48 |
mPropertyCodes = new ArrayList<>(); |
| 49 |
mDataTypes = new ArrayList<>(); |
| 50 |
mLongValues = new ArrayList<>(); |
| 51 |
mStringValues = new ArrayList<>(); |
| 52 |
} |
| 53 |
|
| 54 |
@UnsupportedAppUsage |
| 55 |
public void append(int handle, int property, int type, long value) { |
| 56 |
mObjectHandles.add(handle); |
| 57 |
mPropertyCodes.add(property); |
| 58 |
mDataTypes.add(type); |
| 59 |
mLongValues.add(value); |
| 60 |
mStringValues.add(null); |
| 61 |
} |
| 62 |
|
| 63 |
@UnsupportedAppUsage |
| 64 |
public void append(int handle, int property, String value) { |
| 65 |
mObjectHandles.add(handle); |
| 66 |
mPropertyCodes.add(property); |
| 67 |
mDataTypes.add(MtpConstants.TYPE_STR); |
| 68 |
mStringValues.add(value); |
| 69 |
mLongValues.add(0L); |
| 70 |
} |
| 71 |
|
| 72 |
public int getCode() { |
| 73 |
return mCode; |
| 74 |
} |
| 75 |
|
| 76 |
public int getCount() { |
| 77 |
return mObjectHandles.size(); |
| 78 |
} |
| 79 |
|
| 80 |
public int[] getObjectHandles() { |
| 81 |
return mObjectHandles.stream().mapToInt(Integer::intValue).toArray(); |
| 82 |
} |
| 83 |
|
| 84 |
public int[] getPropertyCodes() { |
| 85 |
return mPropertyCodes.stream().mapToInt(Integer::intValue).toArray(); |
| 86 |
} |
| 87 |
|
| 88 |
public int[] getDataTypes() { |
| 89 |
return mDataTypes.stream().mapToInt(Integer::intValue).toArray(); |
| 90 |
} |
| 91 |
|
| 92 |
public long[] getLongValues() { |
| 93 |
return mLongValues.stream().mapToLong(Long::longValue).toArray(); |
| 94 |
} |
| 95 |
|
| 96 |
public String[] getStringValues() { |
| 97 |
return mStringValues.toArray(new String[0]); |
| 98 |
} |
| 99 |
} |