1 /*
2  * Copyright (C) 2023 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 distributed under the
11  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12  * KIND, either express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 package com.android.systemui.unfold.progress
16 
17 import android.os.RemoteException
18 import android.util.Log
19 import com.android.systemui.unfold.UnfoldTransitionProgressProvider.TransitionProgressListener
20 import javax.inject.Inject
21 
22 /** Forwards received unfold events to [remoteListener], when present. */
23 class UnfoldTransitionProgressForwarder @Inject constructor() :
24     TransitionProgressListener, IUnfoldAnimation.Stub() {
25 
26     private var remoteListener: IUnfoldTransitionListener? = null
27 
onTransitionStartednull28     override fun onTransitionStarted() {
29         try {
30             Log.d(TAG, "onTransitionStarted")
31             remoteListener?.onTransitionStarted()
32         } catch (e: RemoteException) {
33             Log.e(TAG, "Failed call onTransitionStarted", e)
34         }
35     }
36 
onTransitionFinishednull37     override fun onTransitionFinished() {
38         try {
39             Log.d(TAG, "onTransitionFinished")
40             remoteListener?.onTransitionFinished()
41         } catch (e: RemoteException) {
42             Log.e(TAG, "Failed call onTransitionFinished", e)
43         }
44     }
45 
onTransitionProgressnull46     override fun onTransitionProgress(progress: Float) {
47         try {
48             remoteListener?.onTransitionProgress(progress)
49         } catch (e: RemoteException) {
50             Log.e(TAG, "Failed call onTransitionProgress", e)
51         }
52     }
53 
setListenernull54     override fun setListener(listener: IUnfoldTransitionListener?) {
55         remoteListener = listener
56     }
57 
58     companion object {
59         private val TAG = UnfoldTransitionProgressForwarder::class.java.simpleName
60     }
61 }
62