summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2018-05-24 02:20:44 -0500
committerandroid-build-team Robot2018-05-24 02:20:44 -0500
commitfc0b37e935c25c45722e61d5ff1bb4e7a1d3ab1a (patch)
treea1a6fdde5fea2bb96efd30d0617b964a523c7162
parent290566e49d3062f0ad9ff752fbac0991c112bdb0 (diff)
parent5d1ddac6b5c186e2884a632b2afac32d30ecc922 (diff)
downloadplatform-packages-services-car-fc0b37e935c25c45722e61d5ff1bb4e7a1d3ab1a.tar.gz
platform-packages-services-car-fc0b37e935c25c45722e61d5ff1bb4e7a1d3ab1a.tar.xz
platform-packages-services-car-fc0b37e935c25c45722e61d5ff1bb4e7a1d3ab1a.zip
Snap for 4801384 from 5d1ddac6b5c186e2884a632b2afac32d30ecc922 to pi-release
Change-Id: Id7c6491091eb30ceafcebc08a3604255179fa3fe
-rw-r--r--car-lib/src/android/car/drivingstate/CarUxRestrictions.java5
-rw-r--r--car-lib/src/android/car/user/CarUserManagerHelper.java20
-rw-r--r--service/res/values/config.xml12
-rw-r--r--service/res/xml/car_ux_restrictions_map.xml6
-rw-r--r--tests/carservice_test/src/com/android/car/CarDrivingRestrictionsTest.java28
5 files changed, 52 insertions, 19 deletions
diff --git a/car-lib/src/android/car/drivingstate/CarUxRestrictions.java b/car-lib/src/android/car/drivingstate/CarUxRestrictions.java
index 81dae979..c6c22bc3 100644
--- a/car-lib/src/android/car/drivingstate/CarUxRestrictions.java
+++ b/car-lib/src/android/car/drivingstate/CarUxRestrictions.java
@@ -63,9 +63,8 @@ public class CarUxRestrictions implements Parcelable {
63 63
64 // Default fallback values for the restriction related parameters if the information is 64 // Default fallback values for the restriction related parameters if the information is
65 // not available from the underlying service. 65 // not available from the underlying service.
66 // TODO(b/77606226): Finalize default values. 66 private static final int DEFAULT_MAX_LENGTH = 120;
67 private static final int DEFAULT_MAX_LENGTH = 80; 67 private static final int DEFAULT_MAX_CUMULATIVE_ITEMS = 21;
68 private static final int DEFAULT_MAX_CUMULATIVE_ITEMS = 50;
69 private static final int DEFAULT_MAX_CONTENT_DEPTH = 3; 68 private static final int DEFAULT_MAX_CONTENT_DEPTH = 3;
70 69
71 /** 70 /**
diff --git a/car-lib/src/android/car/user/CarUserManagerHelper.java b/car-lib/src/android/car/user/CarUserManagerHelper.java
index 49ec5afb..ece0ac22 100644
--- a/car-lib/src/android/car/user/CarUserManagerHelper.java
+++ b/car-lib/src/android/car/user/CarUserManagerHelper.java
@@ -88,6 +88,15 @@ public class CarUserManagerHelper {
88 } 88 }
89 89
90 /** 90 /**
91 * Gets UserInfo for the system user.
92 *
93 * @return {@link UserInfo} for the system user.
94 */
95 public UserInfo getSystemUserInfo() {
96 return mUserManager.getUserInfo(UserHandle.USER_SYSTEM);
97 }
98
99 /**
91 * Gets UserInfo for the current foreground user. 100 * Gets UserInfo for the current foreground user.
92 * 101 *
93 * Concept of foreground user is relevant for the multi-user deployment. Foreground user 102 * Concept of foreground user is relevant for the multi-user deployment. Foreground user
@@ -149,13 +158,22 @@ public class CarUserManagerHelper {
149 } 158 }
150 159
151 /** 160 /**
161 * Temporary method: Gets all the users that includes system user.
162 *
163 * @return List of {@code UserInfo} for users that associated with a real person.
164 */
165 public List<UserInfo> getAllUsersIncludingSystemUser() {
166 return mUserManager.getUsers(/*excludeDying=*/true);
167 }
168
169 /**
152 * Get all the users except system user and the one with userId passed in. 170 * Get all the users except system user and the one with userId passed in.
153 * 171 *
154 * @param userId of the user not to be returned. 172 * @param userId of the user not to be returned.
155 * @return All users other than user with userId. 173 * @return All users other than user with userId.
156 */ 174 */
157 private List<UserInfo> getAllUsersExceptSystemUserAndSpecifiedUser(int userId) { 175 private List<UserInfo> getAllUsersExceptSystemUserAndSpecifiedUser(int userId) {
158 List<UserInfo> users = mUserManager.getUsers(true); 176 List<UserInfo> users = mUserManager.getUsers(/*excludeDying=*/true);
159 177
160 for (Iterator<UserInfo> iterator = users.iterator(); iterator.hasNext(); ) { 178 for (Iterator<UserInfo> iterator = users.iterator(); iterator.hasNext(); ) {
161 UserInfo userInfo = iterator.next(); 179 UserInfo userInfo = iterator.next();
diff --git a/service/res/values/config.xml b/service/res/values/config.xml
index 294bd3b9..45e6e0b8 100644
--- a/service/res/values/config.xml
+++ b/service/res/values/config.xml
@@ -39,10 +39,14 @@
39 <!-- Activity to be presented when un-safe activity is launched. Take a look at the javadoc of the 39 <!-- Activity to be presented when un-safe activity is launched. Take a look at the javadoc of the
40 default implementation. --> 40 default implementation. -->
41 <string name="activityBlockingActivity">com.android.car/com.android.car.pm.ActivityBlockingActivity</string> 41 <string name="activityBlockingActivity">com.android.car/com.android.car.pm.ActivityBlockingActivity</string>
42 <!-- Comma separated list of activities that will be allowed. Format of each entry is either 42 <!-- Comma separated list of activities that need to be exempted from getting
43 to specify package name to whitelist the whole package or use format of 43 blocked in a UX restricted state.
44 "packagename/activity_classname" for tagging each activities.--> 44 Format of each entry is either to specify package name to whitelist the whole package or
45 <string name="activityWhitelist">com.android.systemui,com.android.car.dialer,com.android.car.hvac,com.android.car.media,com.android.car.radio,com.android.support.car.lenspicker,com.google.android.setupwizard,com.android.car.home,com.android.car.carlauncher,com.google.android.apps.gmm.fishfood,com.google.android.car.bugreport,com.android.contacts,com.google.android.car.kitchensink,com.google.android.googlequicksearchbox,com.android.settings,com.android.car.messenger</string> 45 use format of "packagename/activity_classname" for tagging each activities.
46 The current implementations expects the following system packages/activities to be
47 whitelisted. For general guidelines to design distraction optimized apps, please refer
48 to Android Auto Driver Distraction Guidelines. -->
49 <string name="activityWhitelist">com.android.systemui,com.google.android.packageinstaller/com.android.packageinstaller.permission.ui.GrantPermissionsActivity</string>
46 <!-- Comma separated list of activities that will be blocked during restricted state. 50 <!-- Comma separated list of activities that will be blocked during restricted state.
47 Format of each entry is either to specify package name to whitelist the whole package 51 Format of each entry is either to specify package name to whitelist the whole package
48 or use format of "packagename/activity_classname" for tagging each activities.--> 52 or use format of "packagename/activity_classname" for tagging each activities.-->
diff --git a/service/res/xml/car_ux_restrictions_map.xml b/service/res/xml/car_ux_restrictions_map.xml
index 017f2b78..385869ad 100644
--- a/service/res/xml/car_ux_restrictions_map.xml
+++ b/service/res/xml/car_ux_restrictions_map.xml
@@ -31,7 +31,7 @@ Note:
31 </DrivingState> 31 </DrivingState>
32 32
33 <DrivingState car:state="idling"> 33 <DrivingState car:state="idling">
34 <Restrictions car:requiresDistractionOptimization="true" car:uxr="baseline"/> 34 <Restrictions car:requiresDistractionOptimization="false" car:uxr="baseline"/>
35 </DrivingState> 35 </DrivingState>
36 36
37 <!-- This is to illustrate how to add multiple speed ranges. The restrictions here 37 <!-- This is to illustrate how to add multiple speed ranges. The restrictions here
@@ -61,9 +61,9 @@ Note:
61 <!-- Configure restriction parameters here--> 61 <!-- Configure restriction parameters here-->
62 <RestrictionParameters> 62 <RestrictionParameters>
63 <!-- Parameters to express displayed String related restrictions --> 63 <!-- Parameters to express displayed String related restrictions -->
64 <StringRestrictions car:maxLength="80"/> 64 <StringRestrictions car:maxLength="120"/>
65 <!-- Parameters to express content related restrictions --> 65 <!-- Parameters to express content related restrictions -->
66 <ContentRestrictions car:maxCumulativeItems="50" car:maxDepth="3"/> 66 <ContentRestrictions car:maxCumulativeItems="21" car:maxDepth="3"/>
67 </RestrictionParameters> 67 </RestrictionParameters>
68 68
69</UxRestrictions> \ No newline at end of file 69</UxRestrictions> \ No newline at end of file
diff --git a/tests/carservice_test/src/com/android/car/CarDrivingRestrictionsTest.java b/tests/carservice_test/src/com/android/car/CarDrivingRestrictionsTest.java
index ff93e668..38fd4b10 100644
--- a/tests/carservice_test/src/com/android/car/CarDrivingRestrictionsTest.java
+++ b/tests/carservice_test/src/com/android/car/CarDrivingRestrictionsTest.java
@@ -17,6 +17,7 @@ package com.android.car;
17 17
18import static com.google.common.truth.Truth.assertThat; 18import static com.google.common.truth.Truth.assertThat;
19 19
20import static org.junit.Assert.assertFalse;
20import static org.junit.Assert.assertNotNull; 21import static org.junit.Assert.assertNotNull;
21import static org.junit.Assert.assertTrue; 22import static org.junit.Assert.assertTrue;
22 23
@@ -88,7 +89,6 @@ public class CarDrivingRestrictionsTest extends MockedCarTestBase {
88 .build()); 89 .build());
89 90
90 // Test Parked state and corresponding restrictions based on car_ux_restrictions_map.xml 91 // Test Parked state and corresponding restrictions based on car_ux_restrictions_map.xml
91 //listener.reset();
92 getMockedVehicleHal().injectEvent( 92 getMockedVehicleHal().injectEvent(
93 VehiclePropValueBuilder.newBuilder(VehicleProperty.GEAR_SELECTION) 93 VehiclePropValueBuilder.newBuilder(VehicleProperty.GEAR_SELECTION)
94 .addIntValue(VehicleGear.GEAR_PARK) 94 .addIntValue(VehicleGear.GEAR_PARK)
@@ -98,7 +98,8 @@ public class CarDrivingRestrictionsTest extends MockedCarTestBase {
98 assertNotNull(drivingEvent); 98 assertNotNull(drivingEvent);
99 assertThat(drivingEvent.eventValue).isEqualTo(CarDrivingStateEvent.DRIVING_STATE_PARKED); 99 assertThat(drivingEvent.eventValue).isEqualTo(CarDrivingStateEvent.DRIVING_STATE_PARKED);
100 100
101 // Test Idling state and corresponding restrictions based on car_ux_restrictions_map.xml 101 // Switch gear to drive. Driving state changes to Idling but the UX restrictions don't
102 // change between parked and idling.
102 listener.reset(); 103 listener.reset();
103 getMockedVehicleHal().injectEvent( 104 getMockedVehicleHal().injectEvent(
104 VehiclePropValueBuilder.newBuilder(VehicleProperty.GEAR_SELECTION) 105 VehiclePropValueBuilder.newBuilder(VehicleProperty.GEAR_SELECTION)
@@ -108,12 +109,6 @@ public class CarDrivingRestrictionsTest extends MockedCarTestBase {
108 drivingEvent = listener.waitForDrivingStateChange(); 109 drivingEvent = listener.waitForDrivingStateChange();
109 assertNotNull(drivingEvent); 110 assertNotNull(drivingEvent);
110 assertThat(drivingEvent.eventValue).isEqualTo(CarDrivingStateEvent.DRIVING_STATE_IDLING); 111 assertThat(drivingEvent.eventValue).isEqualTo(CarDrivingStateEvent.DRIVING_STATE_IDLING);
111 restrictions = listener.waitForUxRestrictionsChange();
112 assertNotNull(restrictions);
113 assertTrue(restrictions.isRequiresDistractionOptimization());
114 assertThat(restrictions.getActiveRestrictions())
115 .isEqualTo(CarUxRestrictions.UX_RESTRICTIONS_BASELINE);
116
117 112
118 // Test Moving state and corresponding restrictions based on car_ux_restrictions_map.xml 113 // Test Moving state and corresponding restrictions based on car_ux_restrictions_map.xml
119 listener.reset(); 114 listener.reset();
@@ -130,6 +125,23 @@ public class CarDrivingRestrictionsTest extends MockedCarTestBase {
130 assertTrue(restrictions.isRequiresDistractionOptimization()); 125 assertTrue(restrictions.isRequiresDistractionOptimization());
131 assertThat(restrictions.getActiveRestrictions()) 126 assertThat(restrictions.getActiveRestrictions())
132 .isEqualTo(CarUxRestrictions.UX_RESTRICTIONS_FULLY_RESTRICTED); 127 .isEqualTo(CarUxRestrictions.UX_RESTRICTIONS_FULLY_RESTRICTED);
128
129 // Test Idling state and corresponding restrictions based on car_ux_restrictions_map.xml
130 listener.reset();
131 getMockedVehicleHal().injectEvent(
132 VehiclePropValueBuilder.newBuilder(VehicleProperty.PERF_VEHICLE_SPEED)
133 .addFloatValue(0.0f)
134 .setTimestamp(SystemClock.elapsedRealtimeNanos())
135 .build());
136 drivingEvent = listener.waitForDrivingStateChange();
137 assertNotNull(drivingEvent);
138 assertThat(drivingEvent.eventValue).isEqualTo(CarDrivingStateEvent.DRIVING_STATE_IDLING);
139 restrictions = listener.waitForUxRestrictionsChange();
140 assertNotNull(restrictions);
141 assertFalse(restrictions.isRequiresDistractionOptimization());
142 assertThat(restrictions.getActiveRestrictions())
143 .isEqualTo(CarUxRestrictions.UX_RESTRICTIONS_BASELINE);
144
133 } 145 }
134 146
135 /** 147 /**