blob: 8986206194bfb54e44d09282d064d1d55ba34711 [file] [log] [blame]
keunyoungca515072015-07-10 12:21:47 -07001/*
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 */
16package com.android.car;
17
18import java.io.FileDescriptor;
19import java.io.PrintWriter;
20
keunyoungcc449f72015-08-12 10:46:27 -070021import com.android.car.hal.VehicleHal;
22
keunyoungca515072015-07-10 12:21:47 -070023import android.app.Service;
Keun-young Parke54ac272016-02-16 19:02:18 -080024import android.car.Car;
keunyoungca515072015-07-10 12:21:47 -070025import android.content.Intent;
26import android.os.IBinder;
Vitalii Tomkiv973d2a22016-04-13 17:05:38 -070027import android.os.SystemProperties;
keunyoungca515072015-07-10 12:21:47 -070028import android.util.Log;
29
30public class CarService extends Service {
31
32 // main thread only
33 private ICarImpl mICarImpl;
34
35 @Override
36 public void onCreate() {
37 Log.i(CarLog.TAG_SERVICE, "Service onCreate");
38 mICarImpl = ICarImpl.getInstance(this);
Vitalii Tomkiv973d2a22016-04-13 17:05:38 -070039 SystemProperties.set("boot.car_service_created", "1");
keunyoungca515072015-07-10 12:21:47 -070040 super.onCreate();
41 }
42
43 @Override
44 public void onDestroy() {
45 Log.i(CarLog.TAG_SERVICE, "Service onDestroy");
46 ICarImpl.releaseInstance();
47 super.onDestroy();
48 }
49
50 @Override
51 public int onStartCommand(Intent intent, int flags, int startId) {
52 // keep it alive.
53 return START_STICKY;
54 }
55
56 @Override
57 public IBinder onBind(Intent intent) {
58 return mICarImpl;
59 }
60
61 @Override
62 protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
63 writer.println("*dump car service*");
keunyoungcc449f72015-08-12 10:46:27 -070064 writer.println("*dump HAL*");
keunyoungfe30ba02015-09-17 17:56:35 -070065 VehicleHal.getInstance().dump(writer);
keunyoungcc449f72015-08-12 10:46:27 -070066 writer.println("*dump services*");
67 ICarImpl.getInstance(this).dump(writer);
keunyoungca515072015-07-10 12:21:47 -070068 }
69}