1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
|
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.os;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.content.Context;
import android.net.NetworkStack;
import android.os.connectivity.CellularBatteryStats;
import android.os.connectivity.WifiBatteryStats;
import android.telephony.DataConnectionRealTimeInfo;
import com.android.internal.app.IBatteryStats;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
/**
* This class provides an API surface for internal system components to report events that are
* needed for battery usage/estimation and battery blaming for apps.
*
* Note: This internally uses the same {@link IBatteryStats} binder service as the public
* {@link BatteryManager}.
* @hide
*/
@SystemApi
@SystemService(Context.BATTERY_STATS_SERVICE)
public final class BatteryStatsManager {
/**
* Wifi states.
*
* @see #noteWifiState(int, String)
*/
/**
* Wifi fully off.
*/
public static final int WIFI_STATE_OFF = 0;
/**
* Wifi connectivity off, but scanning enabled.
*/
public static final int WIFI_STATE_OFF_SCANNING = 1;
/**
* Wifi on, but no saved infrastructure networks to connect to.
*/
public static final int WIFI_STATE_ON_NO_NETWORKS = 2;
/**
* Wifi on, but not connected to any infrastructure networks.
*/
public static final int WIFI_STATE_ON_DISCONNECTED = 3;
/**
* Wifi on and connected to a infrastructure network.
*/
public static final int WIFI_STATE_ON_CONNECTED_STA = 4;
/**
* Wifi on and connected to a P2P device, but no infrastructure connection to a network.
*/
public static final int WIFI_STATE_ON_CONNECTED_P2P = 5;
/**
* Wifi on and connected to both a P2P device and infrastructure connection to a network.
*/
public static final int WIFI_STATE_ON_CONNECTED_STA_P2P = 6;
/**
* SoftAp/Hotspot turned on.
*/
public static final int WIFI_STATE_SOFT_AP = 7;
/** @hide */
public static final int NUM_WIFI_STATES = WIFI_STATE_SOFT_AP + 1;
/** @hide */
@IntDef(prefix = { "WIFI_STATE_" }, value = {
WIFI_STATE_OFF,
WIFI_STATE_OFF_SCANNING,
WIFI_STATE_ON_NO_NETWORKS,
WIFI_STATE_ON_DISCONNECTED,
WIFI_STATE_ON_CONNECTED_STA,
WIFI_STATE_ON_CONNECTED_P2P,
WIFI_STATE_ON_CONNECTED_STA_P2P,
WIFI_STATE_SOFT_AP
})
@Retention(RetentionPolicy.SOURCE)
public @interface WifiState {}
/**
* Wifi supplicant daemon states.
*
* @see android.net.wifi.SupplicantState for detailed description of states.
* @see #noteWifiSupplicantStateChanged(int)
*/
/** @see android.net.wifi.SupplicantState#INVALID */
public static final int WIFI_SUPPL_STATE_INVALID = 0;
/** @see android.net.wifi.SupplicantState#DISCONNECTED*/
public static final int WIFI_SUPPL_STATE_DISCONNECTED = 1;
/** @see android.net.wifi.SupplicantState#INTERFACE_DISABLED */
public static final int WIFI_SUPPL_STATE_INTERFACE_DISABLED = 2;
/** @see android.net.wifi.SupplicantState#INACTIVE*/
public static final int WIFI_SUPPL_STATE_INACTIVE = 3;
/** @see android.net.wifi.SupplicantState#SCANNING*/
public static final int WIFI_SUPPL_STATE_SCANNING = 4;
/** @see android.net.wifi.SupplicantState#AUTHENTICATING */
public static final int WIFI_SUPPL_STATE_AUTHENTICATING = 5;
/** @see android.net.wifi.SupplicantState#ASSOCIATING */
public static final int WIFI_SUPPL_STATE_ASSOCIATING = 6;
/** @see android.net.wifi.SupplicantState#ASSOCIATED */
public static final int WIFI_SUPPL_STATE_ASSOCIATED = 7;
/** @see android.net.wifi.SupplicantState#FOUR_WAY_HANDSHAKE */
public static final int WIFI_SUPPL_STATE_FOUR_WAY_HANDSHAKE = 8;
/** @see android.net.wifi.SupplicantState#GROUP_HANDSHAKE */
public static final int WIFI_SUPPL_STATE_GROUP_HANDSHAKE = 9;
/** @see android.net.wifi.SupplicantState#COMPLETED */
public static final int WIFI_SUPPL_STATE_COMPLETED = 10;
/** @see android.net.wifi.SupplicantState#DORMANT */
public static final int WIFI_SUPPL_STATE_DORMANT = 11;
/** @see android.net.wifi.SupplicantState#UNINITIALIZED */
public static final int WIFI_SUPPL_STATE_UNINITIALIZED = 12;
/** @hide */
public static final int NUM_WIFI_SUPPL_STATES = WIFI_SUPPL_STATE_UNINITIALIZED + 1;
/** @hide */
@IntDef(prefix = { "WIFI_SUPPL_STATE_" }, value = {
WIFI_SUPPL_STATE_INVALID,
WIFI_SUPPL_STATE_DISCONNECTED,
WIFI_SUPPL_STATE_INTERFACE_DISABLED,
WIFI_SUPPL_STATE_INACTIVE,
WIFI_SUPPL_STATE_SCANNING,
WIFI_SUPPL_STATE_AUTHENTICATING,
WIFI_SUPPL_STATE_ASSOCIATING,
WIFI_SUPPL_STATE_ASSOCIATED,
WIFI_SUPPL_STATE_FOUR_WAY_HANDSHAKE,
WIFI_SUPPL_STATE_GROUP_HANDSHAKE,
WIFI_SUPPL_STATE_COMPLETED,
WIFI_SUPPL_STATE_DORMANT,
WIFI_SUPPL_STATE_UNINITIALIZED,
})
@Retention(RetentionPolicy.SOURCE)
public @interface WifiSupplState {}
private final IBatteryStats mBatteryStats;
/** @hide */
public BatteryStatsManager(IBatteryStats batteryStats) {
mBatteryStats = batteryStats;
}
/**
* Returns BatteryUsageStats, which contains power attribution data on a per-subsystem
* and per-UID basis.
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.BATTERY_STATS)
@NonNull
public BatteryUsageStats getBatteryUsageStats() {
return getBatteryUsageStats(BatteryUsageStatsQuery.DEFAULT);
}
/**
* Returns BatteryUsageStats, which contains power attribution data on a per-subsystem
* and per-UID basis.
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.BATTERY_STATS)
@NonNull
public BatteryUsageStats getBatteryUsageStats(BatteryUsageStatsQuery query) {
return getBatteryUsageStats(List.of(query)).get(0);
}
/**
* Returns BatteryUsageStats, which contains power attribution data on a per-subsystem
* and per-UID basis.
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.BATTERY_STATS)
@NonNull
public List<BatteryUsageStats> getBatteryUsageStats(List<BatteryUsageStatsQuery> queries) {
try {
return mBatteryStats.getBatteryUsageStats(queries);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Indicates that the wifi connection RSSI has changed.
*
* @param newRssi The new RSSI value.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiRssiChanged(@IntRange(from = -127, to = 0) int newRssi) {
try {
mBatteryStats.noteWifiRssiChanged(newRssi);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that wifi was toggled on.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiOn() {
try {
mBatteryStats.noteWifiOn();
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that wifi was toggled off.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiOff() {
try {
mBatteryStats.noteWifiOff();
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that wifi state has changed.
*
* @param newWifiState The new wifi State.
* @param accessPoint SSID of the network if wifi is connected to STA, else null.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiState(@WifiState int newWifiState,
@Nullable String accessPoint) {
try {
mBatteryStats.noteWifiState(newWifiState, accessPoint);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that a new wifi scan has started.
*
* @param ws worksource (to be used for battery blaming).
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiScanStartedFromSource(@NonNull WorkSource ws) {
try {
mBatteryStats.noteWifiScanStartedFromSource(ws);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that an ongoing wifi scan has stopped.
*
* @param ws worksource (to be used for battery blaming).
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiScanStoppedFromSource(@NonNull WorkSource ws) {
try {
mBatteryStats.noteWifiScanStoppedFromSource(ws);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that a new wifi batched scan has started.
*
* @param ws worksource (to be used for battery blaming).
* @param csph Channels scanned per hour.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiBatchedScanStartedFromSource(@NonNull WorkSource ws,
@IntRange(from = 0) int csph) {
try {
mBatteryStats.noteWifiBatchedScanStartedFromSource(ws, csph);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that an ongoing wifi batched scan has stopped.
*
* @param ws worksource (to be used for battery blaming).
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiBatchedScanStoppedFromSource(@NonNull WorkSource ws) {
try {
mBatteryStats.noteWifiBatchedScanStoppedFromSource(ws);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Retrieves all the cellular related battery stats.
*
* @return Instance of {@link CellularBatteryStats}.
*/
@RequiresPermission(anyOf = {
android.Manifest.permission.BATTERY_STATS,
android.Manifest.permission.UPDATE_DEVICE_STATS})
public @NonNull CellularBatteryStats getCellularBatteryStats() {
try {
return mBatteryStats.getCellularBatteryStats();
} catch (RemoteException e) {
e.rethrowFromSystemServer();
return null;
}
}
/**
* Retrieves all the wifi related battery stats.
*
* @return Instance of {@link WifiBatteryStats}.
*/
@RequiresPermission(anyOf = {
android.Manifest.permission.BATTERY_STATS,
android.Manifest.permission.UPDATE_DEVICE_STATS})
public @NonNull WifiBatteryStats getWifiBatteryStats() {
try {
return mBatteryStats.getWifiBatteryStats();
} catch (RemoteException e) {
e.rethrowFromSystemServer();
return null;
}
}
/**
* Retrieves accumulate wake lock stats.
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.BATTERY_STATS)
@NonNull
public WakeLockStats getWakeLockStats() {
try {
return mBatteryStats.getWakeLockStats();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Retrieves accumulated bluetooth stats.
*
* @hide
*/
@RequiresPermission(android.Manifest.permission.BATTERY_STATS)
@NonNull
public BluetoothBatteryStats getBluetoothBatteryStats() {
try {
return mBatteryStats.getBluetoothBatteryStats();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
/**
* Indicates an app acquiring full wifi lock.
*
* @param ws worksource (to be used for battery blaming).
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportFullWifiLockAcquiredFromSource(@NonNull WorkSource ws) {
try {
mBatteryStats.noteFullWifiLockAcquiredFromSource(ws);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates an app releasing full wifi lock.
*
* @param ws worksource (to be used for battery blaming).
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportFullWifiLockReleasedFromSource(@NonNull WorkSource ws) {
try {
mBatteryStats.noteFullWifiLockReleasedFromSource(ws);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that supplicant state has changed.
*
* @param newSupplState The new Supplicant state.
* @param failedAuth Boolean indicating whether there was a connection failure due to
* authentication failure.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiSupplicantStateChanged(@WifiSupplState int newSupplState,
boolean failedAuth) {
try {
mBatteryStats.noteWifiSupplicantStateChanged(newSupplState, failedAuth);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that an app has acquired the wifi multicast lock.
*
* @param ws Worksource with the uid of the app that acquired the wifi lock (to be used for
* battery blaming).
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiMulticastEnabled(@NonNull WorkSource ws) {
try {
mBatteryStats.noteWifiMulticastEnabled(ws.getAttributionUid());
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that an app has released the wifi multicast lock.
*
* @param ws Worksource with the uid of the app that released the wifi lock (to be used for
* battery blaming).
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiMulticastDisabled(@NonNull WorkSource ws) {
try {
mBatteryStats.noteWifiMulticastDisabled(ws.getAttributionUid());
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that the radio power state has changed.
*
* @param isActive indicates if the mobile radio is powered.
* @param uid Uid of this event. For the active state it represents the uid that was responsible
* for waking the radio, or -1 if the system was responsible for waking the radio.
* For inactive state, the UID should always be -1.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportMobileRadioPowerState(boolean isActive, int uid) {
try {
mBatteryStats.noteMobileRadioPowerState(getDataConnectionPowerState(isActive),
SystemClock.elapsedRealtimeNanos(), uid);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that the wifi power state has changed.
*
* @param isActive indicates if the wifi radio is powered.
* @param uid Uid of this event. For the active state it represents the uid that was responsible
* for waking the radio, or -1 if the system was responsible for waking the radio.
* For inactive state, the UID should always be -1.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportWifiRadioPowerState(boolean isActive, int uid) {
try {
mBatteryStats.noteWifiRadioPowerState(getDataConnectionPowerState(isActive),
SystemClock.elapsedRealtimeNanos(), uid);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Notifies the battery stats of a new interface, and the transport types of the network that
* includes that interface.
*
* @param iface The interface of the network.
* @param transportTypes The transport type of the network {@link Transport}.
* @hide
*/
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@RequiresPermission(anyOf = {
NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK,
android.Manifest.permission.NETWORK_STACK})
public void reportNetworkInterfaceForTransports(@NonNull String iface,
@NonNull int[] transportTypes) throws RuntimeException {
try {
mBatteryStats.noteNetworkInterfaceForTransports(iface, transportTypes);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that Bluetooth was toggled on.
*
* @param uid calling package uid
* @param reason why Bluetooth has been turned on
* @param packageName package responsible for this change
*/
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
public void reportBluetoothOn(int uid, int reason, @NonNull String packageName) {
try {
mBatteryStats.noteBluetoothOn(uid, reason, packageName);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that Bluetooth was toggled off.
*
* @param uid calling package uid
* @param reason why Bluetooth has been turned on
* @param packageName package responsible for this change
*/
@RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
public void reportBluetoothOff(int uid, int reason, @NonNull String packageName) {
try {
mBatteryStats.noteBluetoothOff(uid, reason, packageName);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that a new Bluetooth LE scan has started.
*
* @param ws worksource (to be used for battery blaming).
* @param isUnoptimized whether or not the scan has a filter.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportBleScanStarted(@NonNull WorkSource ws, boolean isUnoptimized) {
try {
mBatteryStats.noteBleScanStarted(ws, isUnoptimized);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that an ongoing Bluetooth LE scan has stopped.
*
* @param ws worksource (to be used for battery blaming).
* @param isUnoptimized whether or not the scan has a filter.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportBleScanStopped(@NonNull WorkSource ws, boolean isUnoptimized) {
try {
mBatteryStats.noteBleScanStopped(ws, isUnoptimized);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that Bluetooth LE has been reset.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportBleScanReset() {
try {
mBatteryStats.noteBleScanReset();
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Indicates that Bluetooth LE scan has received new results.
*
* @param ws worksource (to be used for battery blaming).
* @param numNewResults number of results received since last update.
*/
@RequiresPermission(android.Manifest.permission.UPDATE_DEVICE_STATS)
public void reportBleScanResults(@NonNull WorkSource ws, int numNewResults) {
try {
mBatteryStats.noteBleScanResults(ws, numNewResults);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
private static int getDataConnectionPowerState(boolean isActive) {
// TODO: DataConnectionRealTimeInfo is under telephony package but the constants are used
// for both Wifi and mobile. It would make more sense to separate the constants to a
// generic class or move it to generic package.
return isActive ? DataConnectionRealTimeInfo.DC_POWER_STATE_HIGH
: DataConnectionRealTimeInfo.DC_POWER_STATE_LOW;
}
/**
* Sets battery AC charger to enabled/disabled, and freezes the battery state.
* @hide
*/
@TestApi
@RequiresPermission(android.Manifest.permission.DEVICE_POWER)
public void setChargerAcOnline(boolean online, boolean forceUpdate) {
try {
mBatteryStats.setChargerAcOnline(online, forceUpdate);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Sets battery level, and freezes the battery state.
* @hide
*/
@TestApi
@RequiresPermission(android.Manifest.permission.DEVICE_POWER)
public void setBatteryLevel(int level, boolean forceUpdate) {
try {
mBatteryStats.setBatteryLevel(level, forceUpdate);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Unplugs battery, and freezes the battery state.
* @hide
*/
@TestApi
@RequiresPermission(android.Manifest.permission.DEVICE_POWER)
public void unplugBattery(boolean forceUpdate) {
try {
mBatteryStats.unplugBattery(forceUpdate);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Unfreezes battery state, returning to current hardware values.
* @hide
*/
@TestApi
@RequiresPermission(android.Manifest.permission.DEVICE_POWER)
public void resetBattery(boolean forceUpdate) {
try {
mBatteryStats.resetBattery(forceUpdate);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
/**
* Suspend charging even if plugged in.
* @hide
*/
@TestApi
@RequiresPermission(android.Manifest.permission.DEVICE_POWER)
public void suspendBatteryInput() {
try {
mBatteryStats.suspendBatteryInput();
} catch (RemoteException e) {
e.rethrowFromSystemServer();
}
}
}
|