1 /* 2 * Copyright (C) 2021 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 package com.android.systemui.unfold.updates 17 18 import androidx.annotation.FloatRange 19 import androidx.annotation.IntDef 20 import com.android.systemui.unfold.updates.FoldStateProvider.FoldUpdatesListener 21 import com.android.systemui.unfold.util.CallbackController 22 23 /** 24 * Allows to subscribe to main events related to fold/unfold process such as hinge angle update, 25 * start folding/unfolding, screen availability 26 */ 27 interface FoldStateProvider : CallbackController<FoldUpdatesListener> { startnull28 fun start() 29 fun stop() 30 31 val isFinishedOpening: Boolean 32 33 interface FoldUpdatesListener { 34 fun onHingeAngleUpdate(@FloatRange(from = 0.0, to = 180.0) angle: Float) {} 35 fun onFoldUpdate(@FoldUpdate update: Int) {} 36 fun onUnfoldedScreenAvailable() {} 37 } 38 39 @IntDef( 40 value = 41 [ 42 FOLD_UPDATE_START_OPENING, 43 FOLD_UPDATE_START_CLOSING, 44 FOLD_UPDATE_FINISH_HALF_OPEN, 45 FOLD_UPDATE_FINISH_FULL_OPEN, 46 FOLD_UPDATE_FINISH_CLOSED]) 47 @Retention(AnnotationRetention.SOURCE) 48 annotation class FoldUpdate 49 } 50 51 const val FOLD_UPDATE_START_OPENING = 0 52 const val FOLD_UPDATE_START_CLOSING = 1 53 const val FOLD_UPDATE_FINISH_HALF_OPEN = 2 54 const val FOLD_UPDATE_FINISH_FULL_OPEN = 3 55 const val FOLD_UPDATE_FINISH_CLOSED = 4 56