keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 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 | package com.android.car; |
| 17 | |
Keun-young Park | e54ac27 | 2016-02-16 19:02:18 -0800 | [diff] [blame] | 18 | import android.car.CarInfoManager; |
| 19 | import android.car.ICarInfo; |
| 20 | import android.car.annotation.ValueTypeDef; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 21 | import android.content.Context; |
Keun-young Park | 064ddd8 | 2015-12-21 23:57:50 +0000 | [diff] [blame] | 22 | import android.os.Bundle; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 23 | import android.provider.Settings; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 24 | |
| 25 | import com.android.car.hal.InfoHalService; |
| 26 | import com.android.car.hal.VehicleHal; |
| 27 | |
| 28 | import java.io.PrintWriter; |
| 29 | import java.lang.reflect.Field; |
| 30 | import java.util.HashMap; |
| 31 | import java.util.Map; |
| 32 | |
| 33 | public class CarInfoService extends ICarInfo.Stub implements CarServiceBase { |
| 34 | |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 35 | private final InfoHalService mInfoHal; |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 36 | private final Context mContext; |
| 37 | |
| 38 | public CarInfoService(Context context) { |
keunyoung | fe30ba0 | 2015-09-17 17:56:35 -0700 | [diff] [blame] | 39 | mInfoHal = VehicleHal.getInstance().getInfoHal(); |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 40 | mContext = context; |
| 41 | } |
| 42 | |
| 43 | @Override |
Keun-young Park | 6745635 | 2016-10-03 13:45:19 -0700 | [diff] [blame] | 44 | public Bundle getBasicInfo() { |
| 45 | return mInfoHal.getBasicInfo(); |
Keun-young Park | 064ddd8 | 2015-12-21 23:57:50 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | @Override |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 49 | public void init() { |
Keun-young Park | 6745635 | 2016-10-03 13:45:19 -0700 | [diff] [blame] | 50 | Bundle info = mInfoHal.getBasicInfo(); |
| 51 | // do not update ID immediately even if user clears it. |
| 52 | info.putString(CarInfoManager.BASIC_INFO_KEY_VEHICLE_ID, |
| 53 | Settings.Secure.getString(mContext.getContentResolver(), |
| 54 | Settings.Secure.ANDROID_ID)); |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public synchronized void release() { |
Keun-young Park | 6745635 | 2016-10-03 13:45:19 -0700 | [diff] [blame] | 59 | //nothing to do |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public void dump(PrintWriter writer) { |
| 64 | writer.println("*CarInfoService*"); |
Keun-young Park | 6745635 | 2016-10-03 13:45:19 -0700 | [diff] [blame] | 65 | writer.println("**Check HAL dump"); |
keunyoung | a3b28d8 | 2015-08-25 13:05:15 -0700 | [diff] [blame] | 66 | } |
| 67 | } |
Keun-young Park | 6745635 | 2016-10-03 13:45:19 -0700 | [diff] [blame] | 68 | |