1 /*
2  * Copyright (C) 2015 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.support.car;
18 
19 import android.content.Context;
20 import android.os.Looper;
21 
22 /**
23  * CarServiceLoader is the abstraction for loading different types of car service.
24  * @hide
25  */
26 public abstract class CarServiceLoader {
27 
28     private final Context mContext;
29     private final ServiceConnectionListener mListener;
30     private final Looper mLooper;
31 
CarServiceLoader(Context context, ServiceConnectionListener listener, Looper looper)32     public CarServiceLoader(Context context, ServiceConnectionListener listener, Looper looper) {
33         mContext = context;
34         mListener = listener;
35         mLooper = looper;
36     }
37 
connect()38     public abstract void connect() throws IllegalStateException;
disconnect()39     public abstract void disconnect();
isConnectedToCar()40     public abstract boolean isConnectedToCar();
41     @Car.ConnectionType
getCarConnectionType()42     public abstract int getCarConnectionType() throws CarNotConnectedException;
registerCarConnectionListener(CarConnectionListener listener)43     public abstract void registerCarConnectionListener(CarConnectionListener listener)
44             throws CarNotConnectedException;
unregisterCarConnectionListener(CarConnectionListener listener)45     public abstract void unregisterCarConnectionListener(CarConnectionListener listener);
getCarManager(String serviceName)46     public abstract Object getCarManager(String serviceName)
47             throws CarNotSupportedException, CarNotConnectedException;
48 
getContext()49     protected Context getContext() {
50         return mContext;
51     }
52 
getConnectionListener()53     protected ServiceConnectionListener getConnectionListener() {
54         return mListener;
55     }
56 
getLooper()57     protected Looper getLooper() {
58         return mLooper;
59     }
60 }
61