Device and Battery

cordova-plugin-device and cordova-plugin-battery-status

cordova-plugin-device (3.0.0) fills a global device object before deviceready fires, and cordova-plugin-battery-status (2.0.3) fires batterystatus, batterylow and batterycritical events on window. With the emulator's battery set to 42% and unplugged (adb -s emulator-5558 emu power capacity 42 and emu power ac off), both plugins ran next to the browser's own Battery Status API:

Device details and battery level from two plugins and one web APIJavaScript
const battery = await new Promise((resolve) =>
  window.addEventListener('batterystatus', resolve, { once: true }));
const web = await navigator.getBattery();
({ device: `${device.manufacturer} ${device.model}, ${device.platform} ${device.version}`,
   isVirtual: device.isVirtual, plugged: battery.isPlugged,
   pluginLevel: battery.level, webLevel: web.level });
Output
{
  device: 'Google sdk_gphone64_x86_64, Android 16',
  isVirtual: true,
  plugged: false,
  pluginLevel: 42,
  webLevel: 0.42
}

The two battery sources agree apart from the scale. Because Android's WebView implements navigator.getBattery() itself, the battery plugin, last published in July 2019, adds nothing on Android. device has no web equivalent, which is why BookNest now installs it. Its device.uuid is the Android ID, which changes if the app's signing key changes.