Merge "Hold a wakelock while retrieving reports" into mainline-prod
This commit is contained in:
committed by
Android (Google) Code Review
commit
802eb47994
@@ -27,6 +27,7 @@ import android.os.Binder;
|
|||||||
import android.os.IPullAtomCallback;
|
import android.os.IPullAtomCallback;
|
||||||
import android.os.IStatsManagerService;
|
import android.os.IStatsManagerService;
|
||||||
import android.os.IStatsd;
|
import android.os.IStatsd;
|
||||||
|
import android.os.PowerManager;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
@@ -412,8 +413,13 @@ public class StatsManagerService extends IStatsManagerService.Stub {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] getData(long key, String packageName) throws IllegalStateException {
|
public byte[] getData(long key, String packageName) throws IllegalStateException {
|
||||||
enforceDumpAndUsageStatsPermission(packageName);
|
enforceDumpAndUsageStatsPermission(packageName);
|
||||||
|
PowerManager powerManager = (PowerManager)
|
||||||
|
mContext.getSystemService(Context.POWER_SERVICE);
|
||||||
|
PowerManager.WakeLock wl = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
|
||||||
|
/*tag=*/ StatsManagerService.class.getCanonicalName());
|
||||||
int callingUid = Binder.getCallingUid();
|
int callingUid = Binder.getCallingUid();
|
||||||
final long token = Binder.clearCallingIdentity();
|
final long token = Binder.clearCallingIdentity();
|
||||||
|
wl.acquire();
|
||||||
try {
|
try {
|
||||||
IStatsd statsd = waitForStatsd();
|
IStatsd statsd = waitForStatsd();
|
||||||
if (statsd != null) {
|
if (statsd != null) {
|
||||||
@@ -423,6 +429,7 @@ public class StatsManagerService extends IStatsManagerService.Stub {
|
|||||||
Log.e(TAG, "Failed to getData with statsd");
|
Log.e(TAG, "Failed to getData with statsd");
|
||||||
throw new IllegalStateException(e.getMessage(), e);
|
throw new IllegalStateException(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
|
wl.release();
|
||||||
Binder.restoreCallingIdentity(token);
|
Binder.restoreCallingIdentity(token);
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Failed to connect to statsd to getData");
|
throw new IllegalStateException("Failed to connect to statsd to getData");
|
||||||
|
|||||||
Reference in New Issue
Block a user