summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaymond Hernandez <rayhdez@google.com>2023-03-27 16:02:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-03-27 16:02:11 +0000
commiteabcb6ff5e99b679e6231243f557f90a734ca67b (patch)
tree1ba248355ab43a0da4cd6463a33b63ca6781cffe
parent10574e7c1ed6e2c93588b37099081bf819d208e3 (diff)
parent1cf3019bd513286b97b9c10dc773e57984d4c6aa (diff)
downloadStatsD-eabcb6ff5e99b679e6231243f557f90a734ca67b.tar.gz
Merge "Hold reference to and close both ends of PFD"
-rw-r--r--service/java/com/android/server/stats/StatsCompanionService.java7
1 files changed, 3 insertions, 4 deletions
diff --git a/service/java/com/android/server/stats/StatsCompanionService.java b/service/java/com/android/server/stats/StatsCompanionService.java
index 76bd0dff..c3771df9 100644
--- a/service/java/com/android/server/stats/StatsCompanionService.java
+++ b/service/java/com/android/server/stats/StatsCompanionService.java
@@ -207,6 +207,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
backgroundThread.start();
Handler handler = new Handler(backgroundThread.getLooper());
handler.post(() -> {
+ if (DEBUG) Log.d(TAG, "Start thread for sending uid map data.");
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
PackageManager pm = context.getPackageManager();
final List<UserHandle> users = um.getUserHandles(true);
@@ -227,8 +228,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
} catch (IOException e) {
Log.e(TAG, "Failed to close the read side of the pipe.", e);
}
- final ParcelFileDescriptor writeFd = fds[1];
- FileOutputStream fout = new ParcelFileDescriptor.AutoCloseOutputStream(writeFd);
+ FileOutputStream fout = new ParcelFileDescriptor.AutoCloseOutputStream(fds[1]);
try {
ProtoOutputStream output = new ProtoOutputStream(fout);
int numRecords = 0;
@@ -283,9 +283,8 @@ public class StatsCompanionService extends IStatsCompanionService.Stub {
Log.d(TAG, "Sent data for " + numRecords + " apps");
}
} finally {
- FileUtils.closeQuietly(fout);
+ if (DEBUG) Log.d(TAG, "End thread for sending uid map data.");
backgroundThread.quit();
- backgroundThread.interrupt();
}
});
}