blob: a05f343b923681e3918a5e61261c17faa851a962 [file] [log] [blame]
keunyounga3b28d82015-08-25 13:05:15 -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
Keun-young Parke54ac272016-02-16 19:02:18 -080018import android.car.CarInfoManager;
19import android.car.ICarInfo;
keunyounga3b28d82015-08-25 13:05:15 -070020import android.content.Context;
Keun-young Park064ddd82015-12-21 23:57:50 +000021import android.os.Bundle;
keunyounga3b28d82015-08-25 13:05:15 -070022import android.provider.Settings;
keunyounga3b28d82015-08-25 13:05:15 -070023
24import com.android.car.hal.InfoHalService;
Antonio Cortesc52d5f92017-02-06 08:47:38 -080025import com.android.car.internal.FeatureConfiguration;
26import com.android.car.internal.FeatureUtil;
keunyounga3b28d82015-08-25 13:05:15 -070027
28import java.io.PrintWriter;
keunyounga3b28d82015-08-25 13:05:15 -070029
30public class CarInfoService extends ICarInfo.Stub implements CarServiceBase {
31
keunyounga3b28d82015-08-25 13:05:15 -070032 private final InfoHalService mInfoHal;
keunyounga3b28d82015-08-25 13:05:15 -070033 private final Context mContext;
34
Pavel Maltsev0d07c762016-11-03 16:40:15 -070035 public CarInfoService(Context context, InfoHalService infoHal) {
36 mInfoHal = infoHal;
keunyounga3b28d82015-08-25 13:05:15 -070037 mContext = context;
38 }
39
40 @Override
Keun-young Park67456352016-10-03 13:45:19 -070041 public Bundle getBasicInfo() {
42 return mInfoHal.getBasicInfo();
Keun-young Park064ddd82015-12-21 23:57:50 +000043 }
44
45 @Override
Keun-young Park161f69e2017-01-27 16:13:00 -080046 public String getStringInfo(String key) {
47 switch (key) {
48 case CarInfoManager.INFO_KEY_PRODUCT_CONFIGURATION:
49 FeatureUtil.assertFeature(
50 FeatureConfiguration.ENABLE_PRODUCT_CONFIGURATION_INFO);
51 // still protect with if-feature code. code under if can be dropped by
52 // proguard if necessary.
53 if (FeatureConfiguration.ENABLE_PRODUCT_CONFIGURATION_INFO) {
54 //TODO get it from HAL layer
55 return null;
56 }
57 break;
58 default: // just throw exception
59 break;
60 }
61 throw new IllegalArgumentException("Unsupported key:" + key);
62 }
63
64 @Override
keunyounga3b28d82015-08-25 13:05:15 -070065 public void init() {
Keun-young Park67456352016-10-03 13:45:19 -070066 Bundle info = mInfoHal.getBasicInfo();
67 // do not update ID immediately even if user clears it.
68 info.putString(CarInfoManager.BASIC_INFO_KEY_VEHICLE_ID,
69 Settings.Secure.getString(mContext.getContentResolver(),
70 Settings.Secure.ANDROID_ID));
keunyounga3b28d82015-08-25 13:05:15 -070071 }
72
73 @Override
74 public synchronized void release() {
Keun-young Park67456352016-10-03 13:45:19 -070075 //nothing to do
keunyounga3b28d82015-08-25 13:05:15 -070076 }
77
78 @Override
79 public void dump(PrintWriter writer) {
80 writer.println("*CarInfoService*");
Keun-young Park67456352016-10-03 13:45:19 -070081 writer.println("**Check HAL dump");
keunyounga3b28d82015-08-25 13:05:15 -070082 }
83}
Keun-young Park67456352016-10-03 13:45:19 -070084