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.car.drivemode; 18 19 import androidx.annotation.NonNull; 20 21 import java.util.List; 22 23 /** 24 * The state manager for the Drive Mode feature. 25 */ 26 public interface DriveModeManager { 27 28 /** 29 * Gets the active drive mode name. 30 * 31 * @return Drive Mode name 32 */ getDriveMode()33 @NonNull String getDriveMode(); 34 35 /** 36 * Sets the new active drive mode. 37 * 38 * @param driveMode new active drive mode name 39 */ setDriveMode(@onNull String driveMode)40 void setDriveMode(@NonNull String driveMode); 41 42 /** 43 * Returns all the available drive modes. 44 * 45 * @return List of drive mode names 46 */ getAvailableDriveModes()47 @NonNull List<String> getAvailableDriveModes(); 48 49 50 /** 51 * Adds a drive mode listener. Adding a listener immediately triggers 52 * [Callback.onDriveModeChanged] call on it. 53 * 54 * @param callback The callback to add 55 */ addCallback(@onNull Callback callback)56 void addCallback(@NonNull Callback callback); 57 58 /** 59 * Removes the given listener from the list. 60 * 61 * @param callback The callback to remove 62 */ removeCallback(@onNull Callback callback)63 void removeCallback(@NonNull Callback callback); 64 65 /** 66 * Callback interface for listening to Drive Mode state changes. 67 */ 68 interface Callback { 69 /** 70 * Triggered on all the listeners when a new drive mode is activated. 71 * 72 * @param newDriveMode the new active drive mode 73 */ onDriveModeChanged(@onNull String newDriveMode)74 void onDriveModeChanged(@NonNull String newDriveMode); 75 } 76 } 77