/* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.privatespace.logging /** * A class to hold aggregated details about file operations for logging purposes. It tracks the * total size of successful and failed operations, along with MIME types and error details. */ class FilesLoggingDetails { var totalSuccessFilesSize: Long = 0L private set var totalFailedFilesSize: Long = 0L private set val successFileMimeTypes: List get() = _successFilesMimeTypes private val _successFilesMimeTypes = mutableListOf() val failedFileDetails: List get() = _failedFileDetails private val _failedFileDetails = mutableListOf() fun addSuccessFileDetails(sizeBytes: Long, mimeType: String) { totalSuccessFilesSize += sizeBytes _successFilesMimeTypes.add(mimeType) } fun addFailedFileDetails(errorCode: Int, sizeBytes: Long, mimeType: String? = null) { totalFailedFilesSize += sizeBytes _failedFileDetails.add(FailedFileDetails(errorCode, mimeType)) } /** * A data class to hold specific details for a file that failed to transfer. * * @param errorCode The error code associated with the failure. * @param mimeType The MIME type of the file that failed. If null, the MIME type is unknown. */ data class FailedFileDetails(val errorCode: Int, val mimeType: String?) }