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

Commit 52e042af authored by Vova Sharaienko's avatar Vova Sharaienko
Browse files

StatsPerUidLogger: fixed StrictMode policy violation

- The caller of getBatteryUsageStats must call close() on the resulting BatteryUsageStats object

Flag: com.android.server.power.optimization.add_battery_usage_stats_slice_atom

Bug: 324602949
Test: adb shell cmd stats pull-source 10209; and review logcat for warnings
Change-Id: Ie4f81c7675b811c5b6b69fb33d5e926b05d0c02c
parent 04ccd1b4
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -1256,7 +1256,14 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                                    .setMinConsumedPowerThreshold(minConsumedPowerThreshold)
                                    .build();
                    bus = getBatteryUsageStats(List.of(query)).get(0);
                    return new StatsPerUidLogger(new FrameworkStatsLogger()).logStats(bus, data);
                    final int pullResult =
                            new StatsPerUidLogger(new FrameworkStatsLogger()).logStats(bus, data);
                    try {
                        bus.close();
                    } catch (IOException e) {
                        Slog.w(TAG, "Failure close BatteryUsageStats", e);
                    }
                    return pullResult;
                }
                default:
                    throw new UnsupportedOperationException("Unknown tagId=" + atomTag);