• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2025 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.documentsui.services
18 
19 import android.os.Parcel
20 import android.os.Parcelable
21 
22 /**
23  * Represents the current progress on an individual job owned by the FileOperationService.
24  * JobProgress objects are broadcast from the service to activities in order to update the UI.
25  */
26 data class JobProgress @JvmOverloads constructor(
27     @JvmField val id: String,
28     @JvmField @Job.State val state: Int,
29     @JvmField val msg: String?,
30     @JvmField val hasFailures: Boolean,
31     @JvmField val currentBytes: Long = -1,
32     @JvmField val requiredBytes: Long = -1,
33     @JvmField val msRemaining: Long = -1,
34 ) : Parcelable {
35 
describeContentsnull36     override fun describeContents(): Int {
37         return 0
38     }
39 
writeToParcelnull40     override fun writeToParcel(dest: Parcel, flags: Int) {
41         dest.apply {
42             writeString(id)
43             writeInt(state)
44             writeString(msg)
45             writeBoolean(hasFailures)
46             writeLong(currentBytes)
47             writeLong(requiredBytes)
48             writeLong(msRemaining)
49         }
50     }
51 
52     companion object CREATOR : Parcelable.Creator<JobProgress?> {
createFromParcelnull53         override fun createFromParcel(parcel: Parcel): JobProgress? {
54             return JobProgress(
55                 parcel.readString()!!,
56                 parcel.readInt(),
57                 parcel.readString(),
58                 parcel.readBoolean(),
59                 parcel.readLong(),
60                 parcel.readLong(),
61                 parcel.readLong(),
62             )
63         }
64 
newArraynull65         override fun newArray(size: Int): Array<JobProgress?> {
66             return arrayOfNulls(size)
67         }
68     }
69 }
70