Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74b048aa authored by Stanislav Zholnin's avatar Stanislav Zholnin
Browse files

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
parent f1ed02a5
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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<AppOpEntry> opsList =