From 74b048aac8c9adf4306fce4e93a4e3f246a426f2 Mon Sep 17 00:00:00 2001 From: Stanislav Zholnin Date: Sun, 31 May 2020 13:17:16 +0100 Subject: [PATCH] Fix AppOps estimation call time out. AppOps estimation call times out with likely reason being that when Pooled excutor runs this task when StatsPulAtomService is not active, mContext.getMainExecutor() provides executor which is not active. Test: atest testAppOps Bug: 143519689 Change-Id: Ie2d61b3304b8cc0beb7d4e0ad06ba58aeed1bb19 --- .../com/android/server/stats/pull/StatsPullAtomService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java index 22455ad39960c..25c2e406f43cb 100644 --- a/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java +++ b/services/core/java/com/android/server/stats/pull/StatsPullAtomService.java @@ -3322,8 +3322,8 @@ public class StatsPullAtomService extends SystemService { public void run() { try { estimateAppOpsSamplingRate(); - } catch (Exception e) { - Slog.e(TAG, "AppOps sampling ratio estimation failed"); + } catch (Throwable e) { + Slog.e(TAG, "AppOps sampling ratio estimation failed: ", e); synchronized (mAppOpsSamplingRateLock) { mAppOpsSamplingRate = min(mAppOpsSamplingRate, 10); } @@ -3364,7 +3364,7 @@ public class StatsPullAtomService extends SystemService { Instant.now().minus(1, ChronoUnit.DAYS).toEpochMilli(), Long.MAX_VALUE).setFlags( OP_FLAGS_PULLED).build(); - appOps.getHistoricalOps(histOpsRequest, mContext.getMainExecutor(), ops::complete); + appOps.getHistoricalOps(histOpsRequest, AsyncTask.THREAD_POOL_EXECUTOR, ops::complete); HistoricalOps histOps = ops.get(EXTERNAL_STATS_SYNC_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); List opsList =