• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.car.evs;
17 
18 import android.annotation.SystemApi;
19 import android.car.evs.CarEvsManager;
20 import android.car.evs.CarEvsManager.CarEvsStreamEvent;
21 import android.util.Slog;
22 
23 /**
24  * Utility class for CarEvsService
25  *
26  * @hide
27  */
28 @SystemApi
29 public final class CarEvsServiceUtils {
30     private static final String TAG = CarEvsServiceUtils.class.getSimpleName();
CarEvsServiceUtils()31     private CarEvsServiceUtils() {}
32 
33     /**
34      * Converts EvsEvent to CarEvsManager.CarEvsStreamEvent.
35      *
36      * See the definition of EvsEventType in hardware/interfaces/automotive/evs/1.1/types.hal
37      */
convertToStreamEvent(int inputEvent)38     static @CarEvsStreamEvent int convertToStreamEvent(int inputEvent) {
39         @CarEvsStreamEvent int outputStatus = CarEvsManager.STREAM_EVENT_NONE;
40 
41         switch (inputEvent) {
42             case 0: // EvsEventType.STREAM_STARTED
43                 outputStatus = CarEvsManager.STREAM_EVENT_STREAM_STARTED;
44                 break;
45             case 1: // EvsEventType.STREAM_STOPPED
46                 outputStatus = CarEvsManager.STREAM_EVENT_STREAM_STOPPED;
47                 break;
48             case 2: // EvsEventType.FRAME_DROPPED
49                 outputStatus = CarEvsManager.STREAM_EVENT_FRAME_DROPPED;
50                 break;
51             case 3: // EvsEventType.TIMEOUT
52                 outputStatus = CarEvsManager.STREAM_EVENT_TIMEOUT;
53                 break;
54             case 4: // EvsEventType.PARAMETER_CHANGED
55                 outputStatus = CarEvsManager.STREAM_EVENT_PARAMETER_CHANGED;
56                 break;
57             case 5: // EvsEventType.MASTER_RELEASED
58                 outputStatus = CarEvsManager.STREAM_EVENT_PRIMARY_OWNER_CHANGED;
59                 break;
60             case 6: // EvsEventType.STREAM_ERROR
61                 outputStatus = CarEvsManager.STREAM_EVENT_OTHER_ERRORS;
62                 break;
63             default:
64                 Slog.w(TAG, "Invalid event type: " + inputEvent);
65                 break;
66         }
67 
68         return outputStatus;
69     }
70 }
71