1 /*
2  * Copyright (C) 2024 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.settingslib.bluetooth.devicesettings
18 
19 import android.os.Bundle
20 import android.os.Parcel
21 import android.os.Parcelable
22 
23 /**
24  * A data class representing a device settings provider service status.
25  *
26  * @property enabled Whether the service is enabled.
27  * @property extras Extra bundle
28  */
29 data class DeviceSettingsProviderServiceStatus(
30     val enabled: Boolean,
31     val extras: Bundle = Bundle.EMPTY,
32 ) : Parcelable {
33 
describeContentsnull34     override fun describeContents(): Int = 0
35 
36     override fun writeToParcel(parcel: Parcel, flags: Int) {
37         parcel.run {
38             writeBoolean(enabled)
39             writeBundle(extras)
40         }
41     }
42 
43     companion object {
44         @JvmField
45         val CREATOR: Parcelable.Creator<DeviceSettingsProviderServiceStatus> =
46             object : Parcelable.Creator<DeviceSettingsProviderServiceStatus> {
createFromParcelnull47                 override fun createFromParcel(parcel: Parcel) =
48                     parcel.run {
49                         DeviceSettingsProviderServiceStatus(
50                             enabled = readBoolean(),
51                             extras = readBundle((Bundle::class.java.classLoader)) ?: Bundle.EMPTY,
52                         )
53                     }
54 
newArraynull55                 override fun newArray(size: Int): Array<DeviceSettingsProviderServiceStatus?> {
56                     return arrayOfNulls(size)
57                 }
58             }
59     }
60 }
61