1 /* 2 * Copyright (C) 2022 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.systemui.unfold 18 19 import android.annotation.IntDef 20 import com.android.systemui.statusbar.policy.CallbackController 21 import com.android.systemui.unfold.FoldStateLoggingProvider.FoldStateLoggingListener 22 import com.android.systemui.unfold.FoldStateLoggingProvider.LoggedFoldedStates 23 24 /** Reports device fold states for logging purposes. */ 25 // TODO(b/198305865): Log state changes. 26 interface FoldStateLoggingProvider : CallbackController<FoldStateLoggingListener> { 27 initnull28 fun init() 29 fun uninit() 30 31 interface FoldStateLoggingListener { 32 fun onFoldUpdate(foldStateUpdate: FoldStateChange) 33 } 34 35 @IntDef(prefix = ["LOGGED_FOLD_STATE_"], value = [FULLY_OPENED, FULLY_CLOSED, HALF_OPENED]) 36 @Retention(AnnotationRetention.SOURCE) 37 annotation class LoggedFoldedStates 38 } 39 40 data class FoldStateChange( 41 @LoggedFoldedStates val previous: Int, 42 @LoggedFoldedStates val current: Int, 43 val dtMillis: Long 44 ) 45 46 const val FULLY_OPENED = 1 47 const val FULLY_CLOSED = 2 48 const val HALF_OPENED = 3 49