|
41 | 41 | import com.sun.jna.platform.mac.CoreFoundation.CFArrayRef;
|
42 | 42 | import com.sun.jna.platform.mac.CoreFoundation.CFBooleanRef;
|
43 | 43 | import com.sun.jna.platform.mac.CoreFoundation.CFDictionaryRef;
|
44 |
| -import com.sun.jna.platform.mac.CoreFoundation.CFIndex; |
45 | 44 | import com.sun.jna.platform.mac.CoreFoundation.CFMutableDictionaryRef;
|
46 | 45 | import com.sun.jna.platform.mac.CoreFoundation.CFNumberRef;
|
47 | 46 | import com.sun.jna.platform.mac.CoreFoundation.CFStringRef;
|
@@ -108,8 +107,7 @@ public void testMatching() {
|
108 | 107 | // Get all the keys
|
109 | 108 | PointerByReference properties = new PointerByReference();
|
110 | 109 | assertEquals(0, platformExpert.createCFProperties(properties));
|
111 |
| - dict = new CFMutableDictionaryRef(); |
112 |
| - dict.setPointer(properties.getValue()); |
| 110 | + dict = new CFMutableDictionaryRef(properties.getValue()); |
113 | 111 | assertNotEquals(0, dict.getValueIfPresent(serialKey, null));
|
114 | 112 | result = dict.getValue(serialKey);
|
115 | 113 | cfSerial = new CFStringRef(result);
|
@@ -243,27 +241,26 @@ public void testPowerSources() {
|
243 | 241 | CFStringRef isPresentKey = CFStringRef.createCFString("Is Present");
|
244 | 242 | CFStringRef currentCapacityKey = CFStringRef.createCFString("Current Capacity");
|
245 | 243 | CFStringRef maxCapacityKey = CFStringRef.createCFString("Max Capacity");
|
246 |
| - int powerSourcesCount = powerSourcesList.getCount().intValue(); |
| 244 | + int powerSourcesCount = powerSourcesList.getCount(); |
247 | 245 | for (int ps = 0; ps < powerSourcesCount; ps++) {
|
248 | 246 | // Get the dictionary for that Power Source
|
249 |
| - Pointer pwrSrcPtr = powerSourcesList.getValueAtIndex(new CFIndex(ps)); |
250 |
| - CFTypeRef powerSource = new CFTypeRef(); |
251 |
| - powerSource.setPointer(pwrSrcPtr); |
| 247 | + Pointer pwrSrcPtr = powerSourcesList.getValueAtIndex(ps); |
| 248 | + CFTypeRef powerSource = new CFTypeRef(pwrSrcPtr); |
252 | 249 | CFDictionaryRef dictionary = IOKit.INSTANCE.IOPSGetPowerSourceDescription(powerSourcesInfo, powerSource);
|
253 | 250 |
|
254 | 251 | // Get values from dictionary (See IOPSKeys.h)
|
255 | 252 | // Skip if not present
|
256 | 253 | PointerByReference result = new PointerByReference();
|
257 |
| - if (0 != dictionary.getValueIfPresent(isPresentKey, result)) { |
| 254 | + if (dictionary.getValueIfPresent(isPresentKey, result)) { |
258 | 255 | CFBooleanRef isPresentRef = new CFBooleanRef(result.getValue());
|
259 | 256 | if (isPresentRef.booleanValue()) {
|
260 | 257 | int currentCapacity = 0;
|
261 |
| - if (0 != dictionary.getValueIfPresent(currentCapacityKey, result)) { |
| 258 | + if (dictionary.getValueIfPresent(currentCapacityKey, result)) { |
262 | 259 | CFNumberRef cap = new CFNumberRef(result.getValue());
|
263 | 260 | currentCapacity = cap.intValue();
|
264 | 261 | }
|
265 | 262 | int maxCapacity = 100;
|
266 |
| - if (0 != dictionary.getValueIfPresent(maxCapacityKey, result)) { |
| 263 | + if (dictionary.getValueIfPresent(maxCapacityKey, result)) { |
267 | 264 | CFNumberRef cap = new CFNumberRef(result.getValue());
|
268 | 265 | maxCapacity = cap.intValue();
|
269 | 266 | }
|
|
0 commit comments