Skip to content
Snippets Groups Projects
Commit 39cc66f9 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov Committed by Automerger Merge Worker
Browse files

Merge "Enforce declared permissions on getCellularBatteryStats(),...

Merge "Enforce declared permissions on getCellularBatteryStats(), getWifiBatteryStats() and getGpsBatteryStats()" into sc-dev am: 940921d0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14985497

Change-Id: I91047a7a56cbb952f4df7da7fea0e168ccaf5b3c
parents aec66bd4 940921d0
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@
package com.android.server.am;
import static android.content.pm.PackageManager.PERMISSION_DENIED;
import static android.net.NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED;
import static android.os.BatteryStats.POWER_DATA_UNAVAILABLE;
......@@ -2524,6 +2525,12 @@ public final class BatteryStatsService extends IBatteryStats.Stub
* @hide
*/
public CellularBatteryStats getCellularBatteryStats() {
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.UPDATE_DEVICE_STATS) == PERMISSION_DENIED) {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.BATTERY_STATS, null);
}
// Wait for the completion of pending works if there is any
awaitCompletion();
synchronized (mStats) {
......@@ -2536,6 +2543,12 @@ public final class BatteryStatsService extends IBatteryStats.Stub
* @hide
*/
public WifiBatteryStats getWifiBatteryStats() {
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.UPDATE_DEVICE_STATS) == PERMISSION_DENIED) {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.BATTERY_STATS, null);
}
// Wait for the completion of pending works if there is any
awaitCompletion();
synchronized (mStats) {
......@@ -2548,6 +2561,8 @@ public final class BatteryStatsService extends IBatteryStats.Stub
* @hide
*/
public GpsBatteryStats getGpsBatteryStats() {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.BATTERY_STATS, null);
// Wait for the completion of pending works if there is any
awaitCompletion();
synchronized (mStats) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment