Skip to content

Commit

Permalink
JNA 5.5.0 (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwiddis committed Nov 5, 2019
1 parent 926f6f6 commit 0ff6fc1
Show file tree
Hide file tree
Showing 19 changed files with 86 additions and 2,313 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
4.2.0 (in progress)
================
* [#1038](https://github.com/oshi/oshi/pull/1038): More Battery Statistics. - [@dbwiddis](https://github.com/dbwiddis).
* [#1039](https://github.com/oshi/oshi/pull/1039): JNA 5.5.0. - [@dbwiddis](https://github.com/dbwiddis).
* Your contribution here.

4.1.0 (10/16/2019), 4.1.1 (10/24/2019)
Expand Down
16 changes: 15 additions & 1 deletion README.md
Expand Up @@ -19,7 +19,8 @@
[![first-timers-only](https://img.shields.io/badge/first--timers--only-friendly-blue.svg?style=flat-square)](https://www.firsttimersonly.com/)
[![Join the chat at https://gitter.im/oshi/oshi](https://badges.gitter.im/oshi/oshi.svg)](https://gitter.im/oshi/oshi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java.
OSHI is a free [JNA](https://github.com/java-native-access/jna)-based (native)
Operating System and Hardware Information library for Java.
It does not require the installation of any additional native libraries and aims to provide a
cross-platform implementation to retrieve system information, such as OS version, processes,
memory & CPU usage, disks & partitions, devices, sensors, etc.
Expand Down Expand Up @@ -114,6 +115,18 @@ Memory and swapfile information is available.
Memory: 11.6 GiB/32 GiB
Swap used: 3.6 GiB/5 GiB
```
Statistics for the system battery are provided.
```
Power Sources:
Name: InternalBattery-0, Device Name: bq20z451,
RemainingCapacityPercent: 100.0%, Time Remaining: 5:42, Time Remaining Instant: 5:42,
Power Usage Rate: -16045.216mW, Voltage: 12.694V, Amperage: -1264.0mA,
Power OnLine: false, Charging: false, Discharging: true,
Capacity Units: MAH, Current Capacity: 7213, Max Capacity: 7315, Design Capacity: 7336,
Cycle Count: 6, Chemistry: LIon, Manufacture Date: 2019-06-11, Manufacturer: SMP,
SerialNumber: D869243A2U3J65JAB, Temperature: 30.46°C
```

The EDID for each Display is provided. This can be parsed with various utilities for detailed information. OSHI provides a summary of selected data.
```
Displays:
Expand Down Expand Up @@ -143,6 +156,7 @@ Disks:
|-- disk1s2: Dropbox (disk image) Maj:Min=1:5, size: 959.7 GB @ /Volumes/Dropbox
```

Sensor readings are available for some hardware (see notes in the [FAQ](https://github.com/oshi/oshi/blob/master/FAQ.md)).
```
Sensors:
Expand Down
Expand Up @@ -28,9 +28,10 @@
import java.nio.charset.StandardCharsets;
import java.util.function.Supplier;

import com.sun.jna.platform.mac.IOKit.IORegistryEntry; // NOSONAR squid:S1191
import com.sun.jna.platform.mac.IOKitUtil;

import oshi.hardware.common.AbstractBaseboard;
import oshi.jna.platform.mac.IOKit.IORegistryEntry;
import oshi.jna.platform.mac.IOKitUtil;
import oshi.util.Constants;
import oshi.util.Util;

Expand Down
Expand Up @@ -28,11 +28,12 @@
import java.nio.charset.StandardCharsets;
import java.util.function.Supplier;

import com.sun.jna.platform.mac.IOKit.IORegistryEntry; // NOSONAR squid:S1191
import com.sun.jna.platform.mac.IOKitUtil;

import oshi.hardware.Baseboard;
import oshi.hardware.Firmware;
import oshi.hardware.common.AbstractComputerSystem;
import oshi.jna.platform.mac.IOKit.IORegistryEntry;
import oshi.jna.platform.mac.IOKitUtil;
import oshi.util.Constants;
import oshi.util.Util;

Expand Down
30 changes: 15 additions & 15 deletions oshi-core/src/main/java/oshi/hardware/platform/mac/MacDisks.java
Expand Up @@ -37,27 +37,27 @@
import org.slf4j.LoggerFactory;

import com.sun.jna.Pointer; // NOSONAR squid:S1191
import com.sun.jna.platform.mac.CoreFoundation;
import com.sun.jna.platform.mac.CoreFoundation.CFBooleanRef;
import com.sun.jna.platform.mac.CoreFoundation.CFDictionaryRef;
import com.sun.jna.platform.mac.CoreFoundation.CFIndex;
import com.sun.jna.platform.mac.CoreFoundation.CFMutableDictionaryRef;
import com.sun.jna.platform.mac.CoreFoundation.CFNumberRef;
import com.sun.jna.platform.mac.CoreFoundation.CFStringRef;
import com.sun.jna.platform.mac.CoreFoundation.CFTypeRef;
import com.sun.jna.platform.mac.DiskArbitration;
import com.sun.jna.platform.mac.DiskArbitration.DADiskRef;
import com.sun.jna.platform.mac.DiskArbitration.DASessionRef;
import com.sun.jna.platform.mac.IOKit;
import com.sun.jna.platform.mac.IOKit.IOIterator;
import com.sun.jna.platform.mac.IOKit.IORegistryEntry;
import com.sun.jna.platform.mac.IOKitUtil;
import com.sun.jna.platform.mac.SystemB;
import com.sun.jna.platform.mac.SystemB.Statfs;

import oshi.hardware.Disks;
import oshi.hardware.HWDiskStore;
import oshi.hardware.HWPartition;
import oshi.jna.platform.mac.CoreFoundation;
import oshi.jna.platform.mac.CoreFoundation.CFBooleanRef;
import oshi.jna.platform.mac.CoreFoundation.CFDictionaryRef;
import oshi.jna.platform.mac.CoreFoundation.CFIndex;
import oshi.jna.platform.mac.CoreFoundation.CFMutableDictionaryRef;
import oshi.jna.platform.mac.CoreFoundation.CFNumberRef;
import oshi.jna.platform.mac.CoreFoundation.CFStringRef;
import oshi.jna.platform.mac.CoreFoundation.CFTypeRef;
import oshi.jna.platform.mac.DiskArbitration;
import oshi.jna.platform.mac.DiskArbitration.DADiskRef;
import oshi.jna.platform.mac.DiskArbitration.DASessionRef;
import oshi.jna.platform.mac.IOKit;
import oshi.jna.platform.mac.IOKit.IOIterator;
import oshi.jna.platform.mac.IOKit.IORegistryEntry;
import oshi.jna.platform.mac.IOKitUtil;
import oshi.util.Constants;
import oshi.util.ExecutingCommand;
import oshi.util.ParseUtil;
Expand Down
Expand Up @@ -29,16 +29,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.jna.Pointer;
import com.sun.jna.Pointer; // NOSONAR squid:S1191
import com.sun.jna.platform.mac.CoreFoundation.CFDataRef;
import com.sun.jna.platform.mac.CoreFoundation.CFStringRef;
import com.sun.jna.platform.mac.CoreFoundation.CFTypeRef;
import com.sun.jna.platform.mac.IOKit.IOIterator;
import com.sun.jna.platform.mac.IOKit.IORegistryEntry;
import com.sun.jna.platform.mac.IOKitUtil;

import oshi.hardware.Display;
import oshi.hardware.common.AbstractDisplay;
import oshi.jna.platform.mac.CoreFoundation.CFDataRef;
import oshi.jna.platform.mac.CoreFoundation.CFStringRef;
import oshi.jna.platform.mac.CoreFoundation.CFTypeRef;
import oshi.jna.platform.mac.IOKit.IOIterator;
import oshi.jna.platform.mac.IOKit.IORegistryEntry;
import oshi.jna.platform.mac.IOKitUtil;

/**
* A Display
Expand Down
Expand Up @@ -28,10 +28,11 @@
import java.nio.charset.StandardCharsets;
import java.util.function.Supplier;

import com.sun.jna.platform.mac.IOKit.IOIterator; // NOSONAR squid:S1191
import com.sun.jna.platform.mac.IOKit.IORegistryEntry;
import com.sun.jna.platform.mac.IOKitUtil;

import oshi.hardware.common.AbstractFirmware;
import oshi.jna.platform.mac.IOKit.IOIterator;
import oshi.jna.platform.mac.IOKit.IORegistryEntry;
import oshi.jna.platform.mac.IOKitUtil;
import oshi.util.Constants;
import oshi.util.Util;

Expand Down
Expand Up @@ -28,19 +28,19 @@
import java.util.List;

import com.sun.jna.Pointer; // NOSONAR squid:S1191
import com.sun.jna.platform.mac.CoreFoundation;
import com.sun.jna.platform.mac.CoreFoundation.CFArrayRef;
import com.sun.jna.platform.mac.CoreFoundation.CFBooleanRef;
import com.sun.jna.platform.mac.CoreFoundation.CFDictionaryRef;
import com.sun.jna.platform.mac.CoreFoundation.CFNumberRef;
import com.sun.jna.platform.mac.CoreFoundation.CFStringRef;
import com.sun.jna.platform.mac.CoreFoundation.CFTypeRef;
import com.sun.jna.platform.mac.IOKit;
import com.sun.jna.platform.mac.IOKit.IORegistryEntry;
import com.sun.jna.platform.mac.IOKitUtil;

import oshi.hardware.PowerSource;
import oshi.hardware.common.AbstractPowerSource;
import oshi.jna.platform.mac.CoreFoundation;
import oshi.jna.platform.mac.CoreFoundation.CFArrayRef;
import oshi.jna.platform.mac.CoreFoundation.CFBooleanRef;
import oshi.jna.platform.mac.CoreFoundation.CFDictionaryRef;
import oshi.jna.platform.mac.CoreFoundation.CFNumberRef;
import oshi.jna.platform.mac.CoreFoundation.CFStringRef;
import oshi.jna.platform.mac.CoreFoundation.CFTypeRef;
import oshi.jna.platform.mac.IOKit;
import oshi.jna.platform.mac.IOKit.IORegistryEntry;
import oshi.jna.platform.mac.IOKitUtil;
import oshi.util.Constants;

/**
Expand Down
Expand Up @@ -23,8 +23,9 @@
*/
package oshi.hardware.platform.mac;

import com.sun.jna.platform.mac.IOKit.IOConnect; // NOSONAR squid:S1191

import oshi.hardware.common.AbstractSensors;
import oshi.jna.platform.mac.IOKit.IOConnect;
import oshi.util.platform.mac.SmcUtil;

/**
Expand Down
Expand Up @@ -29,16 +29,17 @@
import java.util.List;
import java.util.Map;

import com.sun.jna.platform.mac.CoreFoundation; // NOSONAR squid:S1191
import com.sun.jna.platform.mac.CoreFoundation.CFIndex;
import com.sun.jna.platform.mac.CoreFoundation.CFMutableDictionaryRef;
import com.sun.jna.platform.mac.CoreFoundation.CFStringRef;
import com.sun.jna.platform.mac.CoreFoundation.CFTypeRef;
import com.sun.jna.platform.mac.IOKit.IOIterator;
import com.sun.jna.platform.mac.IOKit.IORegistryEntry;
import com.sun.jna.platform.mac.IOKitUtil;

import oshi.hardware.UsbDevice;
import oshi.hardware.common.AbstractUsbDevice;
import oshi.jna.platform.mac.CoreFoundation;
import oshi.jna.platform.mac.CoreFoundation.CFIndex;
import oshi.jna.platform.mac.CoreFoundation.CFMutableDictionaryRef;
import oshi.jna.platform.mac.CoreFoundation.CFStringRef;
import oshi.jna.platform.mac.CoreFoundation.CFTypeRef;
import oshi.jna.platform.mac.IOKit.IOIterator;
import oshi.jna.platform.mac.IOKit.IORegistryEntry;
import oshi.jna.platform.mac.IOKitUtil;

/**
* <p>
Expand Down
Expand Up @@ -253,11 +253,6 @@ protected ProcessorIdentifier queryProcessorId() {
SYSTEM_INFO sysinfo = new SYSTEM_INFO();
Kernel32.INSTANCE.GetNativeSystemInfo(sysinfo);
int processorArchitecture = sysinfo.processorArchitecture.pi.wProcessorArchitecture.intValue();
// JNA reads wrong union member. Temporarily override.
// See https://github.com/java-native-access/jna/pull/1134
if (sysinfo.processorArchitecture.dwOemID.intValue() > 0) {
processorArchitecture = sysinfo.processorArchitecture.dwOemID.intValue() & 0xffff;
}
if (processorArchitecture == 9 // PROCESSOR_ARCHITECTURE_AMD64
|| processorArchitecture == 12 // PROCESSOR_ARCHITECTURE_ARM64
|| processorArchitecture == 6) { // PROCESSOR_ARCHITECTURE_IA64
Expand Down

0 comments on commit 0ff6fc1

Please sign in to comment.