1 /*
2  * Copyright (C) 2019 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 android.car.experimental;
18 
19 import android.car.Car;
20 import android.car.CarManagerBase;
21 import android.car.annotation.RequiredFeature;
22 import android.os.IBinder;
23 import android.os.RemoteException;
24 
25 /**
26  * Demo CarManager API for demonstrating experimental feature / API usage. This will never go to
27  * production.
28  *
29  * @hide
30  */
31 @RequiredFeature(ExperimentalCar.TEST_EXPERIMENTAL_FEATURE_SERVICE)
32 public final class CarTestDemoExperimentalFeatureManager extends CarManagerBase {
33 
34     private final ITestDemoExperimental mService;
35 
36     /**
37      * Constructor parameters should remain this way for Car library to construct this.
38      */
CarTestDemoExperimentalFeatureManager(Car car, IBinder service)39     public CarTestDemoExperimentalFeatureManager(Car car, IBinder service) {
40         super(car);
41         mService = ITestDemoExperimental.Stub.asInterface(service);
42     }
43 
44     /**
45      * Send ping msg service. It will replay back with the same message.
46      */
ping(String msg)47     public String ping(String msg) {
48         try {
49             return mService.ping(msg);
50         } catch (RemoteException e) {
51             // For experimental API, we just crash client.
52             throw e.rethrowFromSystemServer();
53         }
54     }
55 
onCarDisconnected()56     protected void onCarDisconnected() {
57         // Nothing to do
58     }
59 }
60