diff options
author | android-build-team Robot | 2018-05-13 02:25:45 -0500 |
---|---|---|
committer | android-build-team Robot | 2018-05-13 02:25:45 -0500 |
commit | 56edfe013427b8432b3ed8ef919a9088fa170c87 (patch) | |
tree | 0ea0417a0e5d5bc0ea31581fdfe17b788fa20632 | |
parent | 842bade7c1ba55dc343bfb2e2e0ba051ef22e2a5 (diff) | |
parent | fda603e310e55d5e7b8abb80e6ee1b2cb9e1e85e (diff) | |
download | platform-packages-services-car-56edfe013427b8432b3ed8ef919a9088fa170c87.tar.gz platform-packages-services-car-56edfe013427b8432b3ed8ef919a9088fa170c87.tar.xz platform-packages-services-car-56edfe013427b8432b3ed8ef919a9088fa170c87.zip |
Snap for 4778776 from fda603e310e55d5e7b8abb80e6ee1b2cb9e1e85e to pi-release
Change-Id: I4289a0188a4ef1a2cc6b78c917072c1c9255c73d
11 files changed, 314 insertions, 24 deletions
diff --git a/car-lib/src/android/car/user/CarUserManagerHelper.java b/car-lib/src/android/car/user/CarUserManagerHelper.java index cad477c4..49ec5afb 100644 --- a/car-lib/src/android/car/user/CarUserManagerHelper.java +++ b/car-lib/src/android/car/user/CarUserManagerHelper.java | |||
@@ -58,8 +58,8 @@ public class CarUserManagerHelper { | |||
58 | } | 58 | } |
59 | }; | 59 | }; |
60 | 60 | ||
61 | public CarUserManagerHelper(Context applicationContext) { | 61 | public CarUserManagerHelper(Context context) { |
62 | mContext = applicationContext; | 62 | mContext = context.getApplicationContext(); |
63 | mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); | 63 | mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); |
64 | mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); | 64 | mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); |
65 | } | 65 | } |
diff --git a/car_product/overlay/frameworks/base/packages/SystemUI/res/layout/car_navigation_bar.xml b/car_product/overlay/frameworks/base/packages/SystemUI/res/layout/car_navigation_bar.xml new file mode 100644 index 00000000..a4902cdf --- /dev/null +++ b/car_product/overlay/frameworks/base/packages/SystemUI/res/layout/car_navigation_bar.xml | |||
@@ -0,0 +1,165 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | ||
2 | <!-- | ||
3 | ** | ||
4 | ** Copyright 2018, The Android Open Source Project | ||
5 | ** | ||
6 | ** Licensed under the Apache License, Version 2.0 (the "License"); | ||
7 | ** you may not use this file except in compliance with the License. | ||
8 | ** You may obtain a copy of the License at | ||
9 | ** | ||
10 | ** http://www.apache.org/licenses/LICENSE-2.0 | ||
11 | ** | ||
12 | ** Unless required by applicable law or agreed to in writing, software | ||
13 | ** distributed under the License is distributed on an "AS IS" BASIS, | ||
14 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
15 | ** See the License for the specific language governing permissions and | ||
16 | ** limitations under the License. | ||
17 | */ | ||
18 | --> | ||
19 | |||
20 | <com.android.systemui.statusbar.car.CarNavigationBarView | ||
21 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
22 | xmlns:systemui="http://schemas.android.com/apk/res-auto" | ||
23 | android:layout_height="match_parent" | ||
24 | android:layout_width="match_parent" | ||
25 | android:background="@drawable/system_bar_background"> | ||
26 | |||
27 | <LinearLayout | ||
28 | android:layout_height="match_parent" | ||
29 | android:layout_width="wrap_content" | ||
30 | android:paddingStart="@dimen/car_keyline_1" | ||
31 | android:paddingEnd="@dimen/car_keyline_1" | ||
32 | android:orientation="horizontal" | ||
33 | android:id="@+id/nav_buttons" | ||
34 | android:gravity="center" | ||
35 | android:layout_weight="1" | ||
36 | android:animateLayoutChanges="true"> | ||
37 | |||
38 | <com.android.systemui.statusbar.car.CarNavigationButton | ||
39 | android:id="@+id/home" | ||
40 | style="@style/NavigationBarButton" | ||
41 | systemui:intent="intent:#Intent;action=android.intent.action.MAIN;category=android.intent.category.HOME;launchFlags=0x14000000;end" | ||
42 | android:src="@drawable/car_ic_overview" | ||
43 | android:background="?android:attr/selectableItemBackground" | ||
44 | /> | ||
45 | |||
46 | <com.android.systemui.statusbar.car.CarFacetButton | ||
47 | android:id="@+id/maps_nav" | ||
48 | style="@style/NavigationBarButton" | ||
49 | systemui:icon="@drawable/car_ic_navigation" | ||
50 | systemui:intent="intent:#Intent;component=com.android.car.mapsplaceholder/.MapsPlaceholderActivity;launchFlags=0x24000000;end" | ||
51 | systemui:componentNames="com.android.car.mapsplaceholder/.MapsPlaceholderActivity" | ||
52 | /> | ||
53 | |||
54 | <com.android.systemui.statusbar.car.CarFacetButton | ||
55 | android:id="@+id/music_nav" | ||
56 | style="@style/NavigationBarButton" | ||
57 | systemui:icon="@drawable/car_ic_music" | ||
58 | systemui:intent="intent:#Intent;component=com.android.car.media/.MediaActivity;launchFlags=0x14000000;end" | ||
59 | systemui:packages="com.android.car.media" | ||
60 | /> | ||
61 | |||
62 | <com.android.systemui.statusbar.car.CarFacetButton | ||
63 | android:id="@+id/phone_nav" | ||
64 | style="@style/NavigationBarButton" | ||
65 | systemui:icon="@drawable/car_ic_phone" | ||
66 | systemui:intent="intent:#Intent;component=com.android.car.dialer/.TelecomActivity;launchFlags=0x14000000;end" | ||
67 | systemui:componentNames="com.android.car.dialer/.TelecomActivity" | ||
68 | /> | ||
69 | |||
70 | <com.android.systemui.statusbar.car.CarFacetButton | ||
71 | android:id="@+id/grid_nav" | ||
72 | style="@style/NavigationBarButton" | ||
73 | systemui:icon="@drawable/car_ic_apps" | ||
74 | systemui:intent="intent:#Intent;component=com.android.car.carlauncher/.AppGridActivity;launchFlags=0x24000000;end" | ||
75 | systemui:componentNames="com.android.car.carlauncher/.AppGridActivity" | ||
76 | /> | ||
77 | |||
78 | <Space | ||
79 | android:layout_height="match_parent" | ||
80 | android:layout_width="0dp" | ||
81 | android:layout_weight="1"/> | ||
82 | |||
83 | <com.android.systemui.statusbar.car.CarNavigationButton | ||
84 | android:id="@+id/hvac" | ||
85 | style="@style/NavigationBarButton" | ||
86 | systemui:intent="intent:#Intent;action=android.car.intent.action.TOGGLE_HVAC_CONTROLS;end" | ||
87 | systemui:broadcast="true" | ||
88 | android:src="@drawable/car_ic_hvac" | ||
89 | android:background="?android:attr/selectableItemBackground" | ||
90 | /> | ||
91 | |||
92 | <com.android.keyguard.AlphaOptimizedImageButton | ||
93 | android:id="@+id/notifications" | ||
94 | style="@style/NavigationBarButton" | ||
95 | android:src="@drawable/car_ic_notification" | ||
96 | android:background="?android:attr/selectableItemBackground" | ||
97 | /> | ||
98 | |||
99 | <FrameLayout | ||
100 | android:id="@+id/clock_container" | ||
101 | android:layout_width="wrap_content" | ||
102 | android:layout_height="match_parent" | ||
103 | android:layout_centerInParent="true" | ||
104 | > | ||
105 | <com.android.systemui.statusbar.car.CarNavigationButton | ||
106 | android:id="@+id/qs" | ||
107 | android:layout_height="match_parent" | ||
108 | android:layout_width="match_parent" | ||
109 | android:background="@null" | ||
110 | systemui:intent="intent:#Intent;component=com.android.car.settings/.common.CarSettingActivity;launchFlags=0x14008000;end" | ||
111 | /> | ||
112 | <com.android.systemui.statusbar.policy.Clock | ||
113 | android:id="@+id/clock" | ||
114 | android:textAppearance="@style/TextAppearance.StatusBar.Clock" | ||
115 | android:layout_width="wrap_content" | ||
116 | android:layout_height="match_parent" | ||
117 | android:singleLine="true" | ||
118 | android:paddingStart="@dimen/status_bar_clock_starting_padding" | ||
119 | android:paddingEnd="@dimen/status_bar_clock_end_padding" | ||
120 | android:gravity="center_vertical" | ||
121 | /> | ||
122 | </FrameLayout> | ||
123 | </LinearLayout> | ||
124 | |||
125 | <LinearLayout | ||
126 | android:layout_height="match_parent" | ||
127 | android:layout_width="wrap_content" | ||
128 | android:gravity="center" | ||
129 | android:paddingStart="@dimen/car_keyline_1" | ||
130 | android:paddingEnd="@dimen/car_keyline_1" | ||
131 | android:id="@+id/lock_screen_nav_buttons" | ||
132 | android:layout_weight="1" | ||
133 | android:visibility="gone"> | ||
134 | |||
135 | <Space | ||
136 | android:layout_height="match_parent" | ||
137 | android:layout_width="0dp" | ||
138 | android:layout_weight="1"/> | ||
139 | |||
140 | <com.android.systemui.statusbar.car.CarNavigationButton | ||
141 | android:id="@+id/hvac_lockscreen" | ||
142 | style="@style/NavigationBarButton" | ||
143 | systemui:intent="intent:#Intent;action=android.car.intent.action.TOGGLE_HVAC_CONTROLS;end" | ||
144 | systemui:broadcast="true" | ||
145 | android:src="@drawable/car_ic_hvac" | ||
146 | android:background="?android:attr/selectableItemBackground" | ||
147 | /> | ||
148 | |||
149 | <Space | ||
150 | style="@style/NavigationBarButton"/> | ||
151 | |||
152 | <com.android.systemui.statusbar.policy.Clock | ||
153 | android:id="@+id/clock_lockscreen" | ||
154 | android:textAppearance="@style/TextAppearance.StatusBar.Clock" | ||
155 | android:layout_width="wrap_content" | ||
156 | android:layout_height="match_parent" | ||
157 | android:singleLine="true" | ||
158 | android:paddingStart="@dimen/status_bar_clock_starting_padding" | ||
159 | android:paddingEnd="@dimen/status_bar_clock_end_padding" | ||
160 | android:gravity="center_vertical" | ||
161 | /> | ||
162 | </LinearLayout> | ||
163 | |||
164 | </com.android.systemui.statusbar.car.CarNavigationBarView> | ||
165 | |||
diff --git a/car_product/overlay/frameworks/base/packages/SystemUI/res/values/styles.xml b/car_product/overlay/frameworks/base/packages/SystemUI/res/values/styles.xml index 1fc3503f..68fc641d 100644 --- a/car_product/overlay/frameworks/base/packages/SystemUI/res/values/styles.xml +++ b/car_product/overlay/frameworks/base/packages/SystemUI/res/values/styles.xml | |||
@@ -27,4 +27,11 @@ | |||
27 | <item name="android:padding">22dp</item> | 27 | <item name="android:padding">22dp</item> |
28 | </style> | 28 | </style> |
29 | 29 | ||
30 | <style name="NavigationBarButton"> | ||
31 | <item name="android:layout_height">56dp</item> | ||
32 | <item name="android:layout_width">76dp</item> | ||
33 | <item name="android:paddingStart">@dimen/car_padding_1</item> | ||
34 | <item name="android:paddingEnd">@dimen/car_padding_1</item> | ||
35 | </style> | ||
36 | |||
30 | </resources> | 37 | </resources> |
diff --git a/service/src/com/android/car/CarAudioService.java b/service/src/com/android/car/CarAudioService.java index 1e2e48ec..372bbba1 100644 --- a/service/src/com/android/car/CarAudioService.java +++ b/service/src/com/android/car/CarAudioService.java | |||
@@ -489,6 +489,7 @@ public class CarAudioService extends ICarAudio.Stub implements CarServiceBase { | |||
489 | // Note that one can not register audio mix for same bus more than once. | 489 | // Note that one can not register audio mix for same bus more than once. |
490 | for (int i = 0; i < mCarAudioDeviceInfos.size(); i++) { | 490 | for (int i = 0; i < mCarAudioDeviceInfos.size(); i++) { |
491 | int busNumber = mCarAudioDeviceInfos.keyAt(i); | 491 | int busNumber = mCarAudioDeviceInfos.keyAt(i); |
492 | boolean hasContext = false; | ||
492 | CarAudioDeviceInfo info = mCarAudioDeviceInfos.valueAt(i); | 493 | CarAudioDeviceInfo info = mCarAudioDeviceInfos.valueAt(i); |
493 | AudioFormat mixFormat = new AudioFormat.Builder() | 494 | AudioFormat mixFormat = new AudioFormat.Builder() |
494 | .setSampleRate(info.getSampleRate()) | 495 | .setSampleRate(info.getSampleRate()) |
@@ -498,6 +499,7 @@ public class CarAudioService extends ICarAudio.Stub implements CarServiceBase { | |||
498 | AudioMixingRule.Builder mixingRuleBuilder = new AudioMixingRule.Builder(); | 499 | AudioMixingRule.Builder mixingRuleBuilder = new AudioMixingRule.Builder(); |
499 | for (int j = 0; j < mContextToBus.size(); j++) { | 500 | for (int j = 0; j < mContextToBus.size(); j++) { |
500 | if (mContextToBus.valueAt(j) == busNumber) { | 501 | if (mContextToBus.valueAt(j) == busNumber) { |
502 | hasContext = true; | ||
501 | int contextNumber = mContextToBus.keyAt(j); | 503 | int contextNumber = mContextToBus.keyAt(j); |
502 | int[] usages = getUsagesForContext(contextNumber); | 504 | int[] usages = getUsagesForContext(contextNumber); |
503 | for (int usage : usages) { | 505 | for (int usage : usages) { |
@@ -512,12 +514,17 @@ public class CarAudioService extends ICarAudio.Stub implements CarServiceBase { | |||
512 | + " usages: " + Arrays.toString(usages)); | 514 | + " usages: " + Arrays.toString(usages)); |
513 | } | 515 | } |
514 | } | 516 | } |
515 | AudioMix audioMix = new AudioMix.Builder(mixingRuleBuilder.build()) | 517 | if (hasContext) { |
516 | .setFormat(mixFormat) | 518 | // It's a valid case that an audio output bus is defined in |
517 | .setDevice(info.getAudioDeviceInfo()) | 519 | // audio_policy_configuration and no context is assigned to it. |
518 | .setRouteFlags(AudioMix.ROUTE_FLAG_RENDER) | 520 | // In such case, do not build a policy mix with zero rules. |
519 | .build(); | 521 | AudioMix audioMix = new AudioMix.Builder(mixingRuleBuilder.build()) |
520 | builder.addMix(audioMix); | 522 | .setFormat(mixFormat) |
523 | .setDevice(info.getAudioDeviceInfo()) | ||
524 | .setRouteFlags(AudioMix.ROUTE_FLAG_RENDER) | ||
525 | .build(); | ||
526 | builder.addMix(audioMix); | ||
527 | } | ||
521 | } | 528 | } |
522 | 529 | ||
523 | // 4th, attach the {@link AudioPolicyVolumeCallback} | 530 | // 4th, attach the {@link AudioPolicyVolumeCallback} |
diff --git a/service/src/com/android/car/CarDrivingStateService.java b/service/src/com/android/car/CarDrivingStateService.java index 5759cb70..575e1c67 100644 --- a/service/src/com/android/car/CarDrivingStateService.java +++ b/service/src/com/android/car/CarDrivingStateService.java | |||
@@ -32,6 +32,7 @@ import android.util.Log; | |||
32 | 32 | ||
33 | import java.io.PrintWriter; | 33 | import java.io.PrintWriter; |
34 | import java.util.ArrayList; | 34 | import java.util.ArrayList; |
35 | import java.util.LinkedList; | ||
35 | import java.util.List; | 36 | import java.util.List; |
36 | 37 | ||
37 | /** | 38 | /** |
@@ -42,6 +43,7 @@ import java.util.List; | |||
42 | public class CarDrivingStateService extends ICarDrivingState.Stub implements CarServiceBase { | 43 | public class CarDrivingStateService extends ICarDrivingState.Stub implements CarServiceBase { |
43 | private static final String TAG = "CarDrivingState"; | 44 | private static final String TAG = "CarDrivingState"; |
44 | private static final boolean DBG = false; | 45 | private static final boolean DBG = false; |
46 | private static final int MAX_TRANSITION_LOG_SIZE = 20; | ||
45 | private final Context mContext; | 47 | private final Context mContext; |
46 | private CarSensorService mSensorService; | 48 | private CarSensorService mSensorService; |
47 | // List of clients listening to driving state events. | 49 | // List of clients listening to driving state events. |
@@ -54,7 +56,8 @@ public class CarDrivingStateService extends ICarDrivingState.Stub implements Car | |||
54 | private CarDrivingStateEvent mCurrentDrivingState; | 56 | private CarDrivingStateEvent mCurrentDrivingState; |
55 | private CarSensorEvent mLastGear; | 57 | private CarSensorEvent mLastGear; |
56 | private CarSensorEvent mLastSpeed; | 58 | private CarSensorEvent mLastSpeed; |
57 | 59 | // For dumpsys logging | |
60 | private final LinkedList<Utils.TransitionLog> mTransitionLogs = new LinkedList<>(); | ||
58 | 61 | ||
59 | public CarDrivingStateService(Context context, CarSensorService sensorService) { | 62 | public CarDrivingStateService(Context context, CarSensorService sensorService) { |
60 | mContext = context; | 63 | mContext = context; |
@@ -254,7 +257,11 @@ public class CarDrivingStateService extends ICarDrivingState.Stub implements Car | |||
254 | 257 | ||
255 | @Override | 258 | @Override |
256 | public void dump(PrintWriter writer) { | 259 | public void dump(PrintWriter writer) { |
257 | 260 | writer.println("Driving state chane log:"); | |
261 | for (Utils.TransitionLog tLog : mTransitionLogs) { | ||
262 | writer.println(tLog); | ||
263 | } | ||
264 | writer.println("Current Driving State: " + mCurrentDrivingState.eventValue); | ||
258 | } | 265 | } |
259 | 266 | ||
260 | /** | 267 | /** |
@@ -291,6 +298,8 @@ public class CarDrivingStateService extends ICarDrivingState.Stub implements Car | |||
291 | if (drivingState == mCurrentDrivingState.eventValue) { | 298 | if (drivingState == mCurrentDrivingState.eventValue) { |
292 | break; | 299 | break; |
293 | } | 300 | } |
301 | addTransitionLog(TAG, mCurrentDrivingState.eventValue, drivingState, | ||
302 | System.currentTimeMillis()); | ||
294 | // Update if there is a change in state. | 303 | // Update if there is a change in state. |
295 | mCurrentDrivingState = createDrivingStateEvent(drivingState); | 304 | mCurrentDrivingState = createDrivingStateEvent(drivingState); |
296 | 305 | ||
@@ -306,6 +315,15 @@ public class CarDrivingStateService extends ICarDrivingState.Stub implements Car | |||
306 | } | 315 | } |
307 | } | 316 | } |
308 | 317 | ||
318 | private void addTransitionLog(String name, int from, int to, long timestamp) { | ||
319 | if (mTransitionLogs.size() >= MAX_TRANSITION_LOG_SIZE) { | ||
320 | mTransitionLogs.remove(); | ||
321 | } | ||
322 | |||
323 | Utils.TransitionLog tLog = new Utils.TransitionLog(name, from, to, timestamp); | ||
324 | mTransitionLogs.add(tLog); | ||
325 | } | ||
326 | |||
309 | /** | 327 | /** |
310 | * Infers the current driving state of the car from the other Car Sensor properties like | 328 | * Infers the current driving state of the car from the other Car Sensor properties like |
311 | * Current Gear, Speed etc. | 329 | * Current Gear, Speed etc. |
@@ -388,4 +406,5 @@ public class CarDrivingStateService extends ICarDrivingState.Stub implements Car | |||
388 | private static CarDrivingStateEvent createDrivingStateEvent(int eventValue) { | 406 | private static CarDrivingStateEvent createDrivingStateEvent(int eventValue) { |
389 | return new CarDrivingStateEvent(eventValue, SystemClock.elapsedRealtimeNanos()); | 407 | return new CarDrivingStateEvent(eventValue, SystemClock.elapsedRealtimeNanos()); |
390 | } | 408 | } |
409 | |||
391 | } | 410 | } |
diff --git a/service/src/com/android/car/CarStorageMonitoringService.java b/service/src/com/android/car/CarStorageMonitoringService.java index c0015807..80434c1c 100644 --- a/service/src/com/android/car/CarStorageMonitoringService.java +++ b/service/src/com/android/car/CarStorageMonitoringService.java | |||
@@ -18,13 +18,13 @@ package com.android.car; | |||
18 | 18 | ||
19 | import android.car.Car; | 19 | import android.car.Car; |
20 | import android.car.storagemonitoring.CarStorageMonitoringManager; | 20 | import android.car.storagemonitoring.CarStorageMonitoringManager; |
21 | import android.car.storagemonitoring.IIoStatsListener; | ||
22 | import android.car.storagemonitoring.ICarStorageMonitoring; | 21 | import android.car.storagemonitoring.ICarStorageMonitoring; |
23 | import android.car.storagemonitoring.LifetimeWriteInfo; | 22 | import android.car.storagemonitoring.IIoStatsListener; |
24 | import android.car.storagemonitoring.UidIoRecord; | 23 | import android.car.storagemonitoring.IoStats; |
25 | import android.car.storagemonitoring.IoStatsEntry; | 24 | import android.car.storagemonitoring.IoStatsEntry; |
26 | import android.car.storagemonitoring.IoStatsEntry.Metrics; | 25 | import android.car.storagemonitoring.IoStatsEntry.Metrics; |
27 | import android.car.storagemonitoring.IoStats; | 26 | import android.car.storagemonitoring.LifetimeWriteInfo; |
27 | import android.car.storagemonitoring.UidIoRecord; | ||
28 | import android.car.storagemonitoring.WearEstimate; | 28 | import android.car.storagemonitoring.WearEstimate; |
29 | import android.car.storagemonitoring.WearEstimateChange; | 29 | import android.car.storagemonitoring.WearEstimateChange; |
30 | import android.content.ActivityNotFoundException; | 30 | import android.content.ActivityNotFoundException; |
@@ -37,6 +37,7 @@ import android.os.RemoteException; | |||
37 | import android.util.JsonWriter; | 37 | import android.util.JsonWriter; |
38 | import android.util.Log; | 38 | import android.util.Log; |
39 | import android.util.SparseArray; | 39 | import android.util.SparseArray; |
40 | |||
40 | import com.android.car.internal.CarPermission; | 41 | import com.android.car.internal.CarPermission; |
41 | import com.android.car.storagemonitoring.IoStatsTracker; | 42 | import com.android.car.storagemonitoring.IoStatsTracker; |
42 | import com.android.car.storagemonitoring.UidIoStatsProvider; | 43 | import com.android.car.storagemonitoring.UidIoStatsProvider; |
@@ -45,6 +46,11 @@ import com.android.car.storagemonitoring.WearHistory; | |||
45 | import com.android.car.storagemonitoring.WearInformation; | 46 | import com.android.car.storagemonitoring.WearInformation; |
46 | import com.android.car.storagemonitoring.WearInformationProvider; | 47 | import com.android.car.storagemonitoring.WearInformationProvider; |
47 | import com.android.car.systeminterface.SystemInterface; | 48 | import com.android.car.systeminterface.SystemInterface; |
49 | |||
50 | import org.json.JSONArray; | ||
51 | import org.json.JSONException; | ||
52 | import org.json.JSONObject; | ||
53 | |||
48 | import java.io.File; | 54 | import java.io.File; |
49 | import java.io.FileWriter; | 55 | import java.io.FileWriter; |
50 | import java.io.IOException; | 56 | import java.io.IOException; |
@@ -62,9 +68,6 @@ import java.util.Objects; | |||
62 | import java.util.Optional; | 68 | import java.util.Optional; |
63 | import java.util.stream.Collectors; | 69 | import java.util.stream.Collectors; |
64 | import java.util.stream.IntStream; | 70 | import java.util.stream.IntStream; |
65 | import org.json.JSONArray; | ||
66 | import org.json.JSONException; | ||
67 | import org.json.JSONObject; | ||
68 | 71 | ||
69 | public class CarStorageMonitoringService extends ICarStorageMonitoring.Stub | 72 | public class CarStorageMonitoringService extends ICarStorageMonitoring.Stub |
70 | implements CarServiceBase { | 73 | implements CarServiceBase { |
@@ -112,7 +115,9 @@ public class CarStorageMonitoringService extends ICarStorageMonitoring.Stub | |||
112 | Resources resources = mContext.getResources(); | 115 | Resources resources = mContext.getResources(); |
113 | mConfiguration = new Configuration(resources); | 116 | mConfiguration = new Configuration(resources); |
114 | 117 | ||
115 | Log.d(TAG, "service configuration: " + mConfiguration); | 118 | if (Log.isLoggable(TAG, Log.DEBUG)) { |
119 | Log.d(TAG, "service configuration: " + mConfiguration); | ||
120 | } | ||
116 | 121 | ||
117 | mUidIoStatsProvider = systemInterface.getUidIoStatsProvider(); | 122 | mUidIoStatsProvider = systemInterface.getUidIoStatsProvider(); |
118 | mUptimeTrackerFile = new File(systemInterface.getFilesDir(), UPTIME_TRACKER_FILENAME); | 123 | mUptimeTrackerFile = new File(systemInterface.getFilesDir(), UPTIME_TRACKER_FILENAME); |
diff --git a/service/src/com/android/car/CarUxRestrictionsManagerService.java b/service/src/com/android/car/CarUxRestrictionsManagerService.java index 823075e3..289706da 100644 --- a/service/src/com/android/car/CarUxRestrictionsManagerService.java +++ b/service/src/com/android/car/CarUxRestrictionsManagerService.java | |||
@@ -36,6 +36,7 @@ import org.xmlpull.v1.XmlPullParserException; | |||
36 | import java.io.IOException; | 36 | import java.io.IOException; |
37 | import java.io.PrintWriter; | 37 | import java.io.PrintWriter; |
38 | import java.util.ArrayList; | 38 | import java.util.ArrayList; |
39 | import java.util.LinkedList; | ||
39 | import java.util.List; | 40 | import java.util.List; |
40 | 41 | ||
41 | /** | 42 | /** |
@@ -46,6 +47,7 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S | |||
46 | CarServiceBase { | 47 | CarServiceBase { |
47 | private static final String TAG = "CarUxR"; | 48 | private static final String TAG = "CarUxR"; |
48 | private static final boolean DBG = false; | 49 | private static final boolean DBG = false; |
50 | private static final int MAX_TRANSITION_LOG_SIZE = 20; | ||
49 | private final Context mContext; | 51 | private final Context mContext; |
50 | private final CarDrivingStateService mDrivingStateService; | 52 | private final CarDrivingStateService mDrivingStateService; |
51 | private final CarSensorService mCarSensorService; | 53 | private final CarSensorService mCarSensorService; |
@@ -55,6 +57,9 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S | |||
55 | private CarUxRestrictions mCurrentUxRestrictions; | 57 | private CarUxRestrictions mCurrentUxRestrictions; |
56 | private float mCurrentMovingSpeed; | 58 | private float mCurrentMovingSpeed; |
57 | private boolean mFallbackToDefaults; | 59 | private boolean mFallbackToDefaults; |
60 | // For dumpsys logging | ||
61 | private final LinkedList<Utils.TransitionLog> mTransitionLogs = new LinkedList<>(); | ||
62 | |||
58 | 63 | ||
59 | public CarUxRestrictionsManagerService(Context context, CarDrivingStateService drvService, | 64 | public CarUxRestrictionsManagerService(Context context, CarDrivingStateService drvService, |
60 | CarSensorService sensorService) { | 65 | CarSensorService sensorService) { |
@@ -244,6 +249,10 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S | |||
244 | "Requires DO? " + mCurrentUxRestrictions.isRequiresDistractionOptimization()); | 249 | "Requires DO? " + mCurrentUxRestrictions.isRequiresDistractionOptimization()); |
245 | writer.println("Current UXR: " + mCurrentUxRestrictions.getActiveRestrictions()); | 250 | writer.println("Current UXR: " + mCurrentUxRestrictions.getActiveRestrictions()); |
246 | mHelper.dump(writer); | 251 | mHelper.dump(writer); |
252 | writer.println("UX Restriction change log:"); | ||
253 | for (Utils.TransitionLog tlog : mTransitionLogs) { | ||
254 | writer.println(tlog); | ||
255 | } | ||
247 | } | 256 | } |
248 | 257 | ||
249 | /** | 258 | /** |
@@ -355,6 +364,17 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S | |||
355 | // Ignore dispatching if the restrictions has not changed. | 364 | // Ignore dispatching if the restrictions has not changed. |
356 | return; | 365 | return; |
357 | } | 366 | } |
367 | // for dumpsys logging | ||
368 | StringBuilder extraInfo = new StringBuilder(); | ||
369 | extraInfo.append( | ||
370 | mCurrentUxRestrictions.isRequiresDistractionOptimization() ? "DO -> " | ||
371 | : "No DO -> "); | ||
372 | extraInfo.append( | ||
373 | uxRestrictions.isRequiresDistractionOptimization() ? "DO" : "No DO"); | ||
374 | addTransitionLog(TAG, mCurrentUxRestrictions.getActiveRestrictions(), | ||
375 | uxRestrictions.getActiveRestrictions(), System.currentTimeMillis(), | ||
376 | extraInfo.toString()); | ||
377 | |||
358 | mCurrentUxRestrictions = uxRestrictions; | 378 | mCurrentUxRestrictions = uxRestrictions; |
359 | if (DBG) { | 379 | if (DBG) { |
360 | Log.d(TAG, "dispatching to " + mUxRClients.size() + " clients"); | 380 | Log.d(TAG, "dispatching to " + mUxRClients.size() + " clients"); |
@@ -382,4 +402,14 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S | |||
382 | } | 402 | } |
383 | return mHelper.createUxRestrictionsEvent(requiresOpt, restrictions); | 403 | return mHelper.createUxRestrictionsEvent(requiresOpt, restrictions); |
384 | } | 404 | } |
405 | |||
406 | private void addTransitionLog(String name, int from, int to, long timestamp, String extra) { | ||
407 | if (mTransitionLogs.size() >= MAX_TRANSITION_LOG_SIZE) { | ||
408 | mTransitionLogs.remove(); | ||
409 | } | ||
410 | |||
411 | Utils.TransitionLog tLog = new Utils.TransitionLog(name, from, to, timestamp, extra); | ||
412 | mTransitionLogs.add(tLog); | ||
413 | } | ||
414 | |||
385 | } | 415 | } |
diff --git a/service/src/com/android/car/Utils.java b/service/src/com/android/car/Utils.java index 7c9c9214..78f5a8e0 100644 --- a/service/src/com/android/car/Utils.java +++ b/service/src/com/android/car/Utils.java | |||
@@ -32,4 +32,47 @@ public class Utils { | |||
32 | 32 | ||
33 | } | 33 | } |
34 | } | 34 | } |
35 | |||
36 | /** | ||
37 | * An utility class to dump transition events across different car service components. | ||
38 | * The output will be of the form | ||
39 | * <p> | ||
40 | * "Time <svc name>: [optional context information] changed from <from state> to <to state>" | ||
41 | * This can be used in conjunction with the dump() method to dump this information through | ||
42 | * adb shell dumpsys activity service com.android.car | ||
43 | * <p> | ||
44 | * A specific service in CarService can choose to use a circular buffer of N records to keep | ||
45 | * track of the last N transitions. | ||
46 | * | ||
47 | */ | ||
48 | public static class TransitionLog { | ||
49 | private String mServiceName; // name of the service or tag | ||
50 | private int mFromState; // old state | ||
51 | private int mToState; // new state | ||
52 | private long mTimestampMs; // System.currentTimeMillis() | ||
53 | private String mExtra; // Additional information as a String | ||
54 | |||
55 | public TransitionLog(String name, int fromState, int toState, long timestamp, | ||
56 | String extra) { | ||
57 | this(name, fromState, toState, timestamp); | ||
58 | mExtra = extra; | ||
59 | } | ||
60 | |||
61 | public TransitionLog(String name, int fromState, int toState, long timeStamp) { | ||
62 | mServiceName = name; | ||
63 | mFromState = fromState; | ||
64 | mToState = toState; | ||
65 | mTimestampMs = timeStamp; | ||
66 | } | ||
67 | |||
68 | private CharSequence timeToLog(long timestamp) { | ||
69 | return android.text.format.DateFormat.format("MM-dd HH:mm:ss", timestamp); | ||
70 | } | ||
71 | |||
72 | @Override | ||
73 | public String toString() { | ||
74 | return timeToLog(mTimestampMs) + " " + mServiceName + ": " + (mExtra != null ? mExtra | ||
75 | : "") + " changed from " + mFromState + " to " + mToState; | ||
76 | } | ||
77 | } | ||
35 | } | 78 | } |
diff --git a/tests/carservice_unit_test/src/com/android/car/CarUserManagerTest.java b/tests/carservice_unit_test/src/com/android/car/CarUserManagerTest.java index b30b37cd..ff24b8e4 100644 --- a/tests/carservice_unit_test/src/com/android/car/CarUserManagerTest.java +++ b/tests/carservice_unit_test/src/com/android/car/CarUserManagerTest.java | |||
@@ -80,6 +80,7 @@ public class CarUserManagerTest { | |||
80 | when(mContext.getSystemService(Context.ACTIVITY_SERVICE)).thenReturn(mActivityManager); | 80 | when(mContext.getSystemService(Context.ACTIVITY_SERVICE)).thenReturn(mActivityManager); |
81 | when(mContext.getResources()) | 81 | when(mContext.getResources()) |
82 | .thenReturn(InstrumentationRegistry.getTargetContext().getResources()); | 82 | .thenReturn(InstrumentationRegistry.getTargetContext().getResources()); |
83 | when(mContext.getApplicationContext()).thenReturn(mContext); | ||
83 | mHelper = new CarUserManagerHelper(mContext); | 84 | mHelper = new CarUserManagerHelper(mContext); |
84 | 85 | ||
85 | mCurrentProcessUser = createUserInfoForId(UserHandle.myUserId()); | 86 | mCurrentProcessUser = createUserInfoForId(UserHandle.myUserId()); |
diff --git a/tests/robotests/src/com/android/car/users/CarUserManagerRoboTest.java b/tests/robotests/src/com/android/car/users/CarUserManagerRoboTest.java index be16b2ed..977ee7c3 100644 --- a/tests/robotests/src/com/android/car/users/CarUserManagerRoboTest.java +++ b/tests/robotests/src/com/android/car/users/CarUserManagerRoboTest.java | |||
@@ -56,6 +56,7 @@ public class CarUserManagerRoboTest { | |||
56 | RuntimeEnvironment.application.getSystemService(UserManager.class)); | 56 | RuntimeEnvironment.application.getSystemService(UserManager.class)); |
57 | when(mContext.getSystemService(Context.ACTIVITY_SERVICE)).thenReturn( | 57 | when(mContext.getSystemService(Context.ACTIVITY_SERVICE)).thenReturn( |
58 | RuntimeEnvironment.application.getSystemService(ActivityManager.class)); | 58 | RuntimeEnvironment.application.getSystemService(ActivityManager.class)); |
59 | when(mContext.getApplicationContext()).thenReturn(mContext); | ||
59 | mHelper = new CarUserManagerHelper(mContext); | 60 | mHelper = new CarUserManagerHelper(mContext); |
60 | } | 61 | } |
61 | 62 | ||
diff --git a/tests/vehiclehal_test/src/com/android/car/vehiclehal/test/E2ePerformanceTest.java b/tests/vehiclehal_test/src/com/android/car/vehiclehal/test/E2ePerformanceTest.java index 8b5e8d71..da6e74a9 100644 --- a/tests/vehiclehal_test/src/com/android/car/vehiclehal/test/E2ePerformanceTest.java +++ b/tests/vehiclehal_test/src/com/android/car/vehiclehal/test/E2ePerformanceTest.java | |||
@@ -87,21 +87,33 @@ public class E2ePerformanceTest { | |||
87 | private final CarConnectionListener mConnectionListener = new CarConnectionListener(); | 87 | private final CarConnectionListener mConnectionListener = new CarConnectionListener(); |
88 | private Context mContext; | 88 | private Context mContext; |
89 | private Car mCar; | 89 | private Car mCar; |
90 | private HalEventsGenerator mEventsGenerator; | ||
90 | 91 | ||
91 | private static Handler sEventHandler; | 92 | private static Handler sEventHandler; |
92 | private static final HandlerThread sHandlerThread = new HandlerThread(TAG); | 93 | private static final HandlerThread sHandlerThread = new HandlerThread(TAG); |
93 | 94 | ||
94 | private static final int DEFAULT_WAIT_TIMEOUT_MS = 1000; | 95 | private static final int DEFAULT_WAIT_TIMEOUT_MS = 1000; |
95 | 96 | ||
97 | /** | ||
98 | * The following property and the two command bits indicate VHAL to start/stop linear fake data | ||
99 | * generation process. It must match kGenerateFakeDataControllingProperty that is defined in | ||
100 | * default VHAL implementation: | ||
101 | * | ||
102 | * hardware/interfaces/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultConfig.h | ||
103 | * | ||
104 | * TODO: Move the following definition to a common place that can be shared within package | ||
105 | */ | ||
96 | private static final int GENERATE_FAKE_DATA_CONTROLLING_PROPERTY = 0x0666 | 106 | private static final int GENERATE_FAKE_DATA_CONTROLLING_PROPERTY = 0x0666 |
97 | | VehiclePropertyGroup.VENDOR | 107 | | VehiclePropertyGroup.VENDOR |
98 | | VehicleArea.GLOBAL | 108 | | VehicleArea.GLOBAL |
99 | | VehiclePropertyType.MIXED; | 109 | | VehiclePropertyType.MIXED; |
100 | 110 | ||
101 | private static final int CMD_START = 1; | 111 | /** |
102 | private static final int CMD_STOP = 0; | 112 | * The two command bits are sent via GENERATE_FAKE_DATA_CONTROLLING_PROPERTY to start/stop |
103 | 113 | * linear fake data generation from VHAL | |
104 | private HalEventsGenerator mEventsGenerator; | 114 | */ |
115 | private static final int CMD_START_LINEAR = 0; | ||
116 | private static final int CMD_STOP_LINEAR = 1; | ||
105 | 117 | ||
106 | @BeforeClass | 118 | @BeforeClass |
107 | public static void setupEventHandler() { | 119 | public static void setupEventHandler() { |
@@ -438,7 +450,7 @@ public class E2ePerformanceTest { | |||
438 | void start(int propId) throws RemoteException { | 450 | void start(int propId) throws RemoteException { |
439 | VehiclePropValue request = | 451 | VehiclePropValue request = |
440 | VehiclePropValueBuilder.newBuilder(GENERATE_FAKE_DATA_CONTROLLING_PROPERTY) | 452 | VehiclePropValueBuilder.newBuilder(GENERATE_FAKE_DATA_CONTROLLING_PROPERTY) |
441 | .addIntValue(CMD_START, propId) | 453 | .addIntValue(CMD_START_LINEAR, propId) |
442 | .setInt64Value(mIntervalMs * 1000_000) | 454 | .setInt64Value(mIntervalMs * 1000_000) |
443 | .addFloatValue(mInitialValue, mDispersion, mIncrement) | 455 | .addFloatValue(mInitialValue, mDispersion, mIncrement) |
444 | .build(); | 456 | .build(); |
@@ -452,7 +464,7 @@ public class E2ePerformanceTest { | |||
452 | void stop(int propId) throws RemoteException { | 464 | void stop(int propId) throws RemoteException { |
453 | VehiclePropValue request = | 465 | VehiclePropValue request = |
454 | VehiclePropValueBuilder.newBuilder(GENERATE_FAKE_DATA_CONTROLLING_PROPERTY) | 466 | VehiclePropValueBuilder.newBuilder(GENERATE_FAKE_DATA_CONTROLLING_PROPERTY) |
455 | .addIntValue(CMD_STOP, propId) | 467 | .addIntValue(CMD_STOP_LINEAR, propId) |
456 | .build(); | 468 | .build(); |
457 | assertEquals(StatusCode.OK, mVehicle.set(request)); | 469 | assertEquals(StatusCode.OK, mVehicle.set(request)); |
458 | } | 470 | } |