summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorInseob Kim2018-12-13 20:02:32 -0600
committerandroid-build-merger2018-12-13 20:02:32 -0600
commitcbeffcf8fd534a5b4f6461b2e42f08b474f5aa1c (patch)
tree0899ef88fd2381d57ae6a4e21421fee433ef90cc
parent7f1a5aa666874bdb0877cd8142a77263cec7b7af (diff)
parentf877f3a4823b5efcacc0d82a7a8c51961e7db128 (diff)
downloadplatform-packages-services-car-cbeffcf8fd534a5b4f6461b2e42f08b474f5aa1c.tar.gz
platform-packages-services-car-cbeffcf8fd534a5b4f6461b2e42f08b474f5aa1c.tar.xz
platform-packages-services-car-cbeffcf8fd534a5b4f6461b2e42f08b474f5aa1c.zip
Merge "Schematize Car system properties" am: 45e78cc5ee
am: f877f3a482 Change-Id: I0e5162053c753d57f2d7364df3a07a040602d313
-rw-r--r--car-lib/src/android/car/user/CarUserManagerHelper.java5
-rw-r--r--tests/carservice_unit_test/src/com/android/car/CarUserManagerHelperTest.java13
2 files changed, 9 insertions, 9 deletions
diff --git a/car-lib/src/android/car/user/CarUserManagerHelper.java b/car-lib/src/android/car/user/CarUserManagerHelper.java
index ce509436..29535fc8 100644
--- a/car-lib/src/android/car/user/CarUserManagerHelper.java
+++ b/car-lib/src/android/car/user/CarUserManagerHelper.java
@@ -29,10 +29,10 @@ import android.graphics.Bitmap;
29import android.graphics.drawable.BitmapDrawable; 29import android.graphics.drawable.BitmapDrawable;
30import android.graphics.drawable.Drawable; 30import android.graphics.drawable.Drawable;
31import android.os.Bundle; 31import android.os.Bundle;
32import android.os.SystemProperties;
33import android.os.UserHandle; 32import android.os.UserHandle;
34import android.os.UserManager; 33import android.os.UserManager;
35import android.provider.Settings; 34import android.provider.Settings;
35import android.sysprop.CarProperties;
36import android.util.Log; 36import android.util.Log;
37 37
38import com.android.internal.util.UserIcons; 38import com.android.internal.util.UserIcons;
@@ -56,7 +56,6 @@ import java.util.Set;
56 */ 56 */
57public class CarUserManagerHelper { 57public class CarUserManagerHelper {
58 private static final String TAG = "CarUserManagerHelper"; 58 private static final String TAG = "CarUserManagerHelper";
59 private static final String HEADLESS_SYSTEM_USER = "android.car.systemuser.headless";
60 /** 59 /**
61 * Default set of restrictions for Non-Admin users. 60 * Default set of restrictions for Non-Admin users.
62 */ 61 */
@@ -247,7 +246,7 @@ public class CarUserManagerHelper {
247 * @return {@boolean true} if headless system user. 246 * @return {@boolean true} if headless system user.
248 */ 247 */
249 public boolean isHeadlessSystemUser() { 248 public boolean isHeadlessSystemUser() {
250 return SystemProperties.getBoolean(HEADLESS_SYSTEM_USER, false); 249 return CarProperties.headless_system_user().orElse(false);
251 } 250 }
252 251
253 /** 252 /**
diff --git a/tests/carservice_unit_test/src/com/android/car/CarUserManagerHelperTest.java b/tests/carservice_unit_test/src/com/android/car/CarUserManagerHelperTest.java
index 7f53da56..5ec5f083 100644
--- a/tests/carservice_unit_test/src/com/android/car/CarUserManagerHelperTest.java
+++ b/tests/carservice_unit_test/src/com/android/car/CarUserManagerHelperTest.java
@@ -42,6 +42,7 @@ import android.os.UserManager;
42import android.support.test.InstrumentationRegistry; 42import android.support.test.InstrumentationRegistry;
43import android.support.test.filters.SmallTest; 43import android.support.test.filters.SmallTest;
44import android.support.test.runner.AndroidJUnit4; 44import android.support.test.runner.AndroidJUnit4;
45import android.sysprop.CarProperties;
45 46
46import org.junit.Before; 47import org.junit.Before;
47import org.junit.Test; 48import org.junit.Test;
@@ -106,7 +107,7 @@ public class CarUserManagerHelperTest {
106 107
107 // Restore the non-headless state before every test. Individual tests can set the property 108 // Restore the non-headless state before every test. Individual tests can set the property
108 // to true to test the headless system user scenario. 109 // to true to test the headless system user scenario.
109 SystemProperties.set("android.car.systemuser.headless", "false"); 110 CarProperties.headless_system_user(false);
110 } 111 }
111 112
112 @Test 113 @Test
@@ -123,7 +124,7 @@ public class CarUserManagerHelperTest {
123 // System user will not be returned when calling get all users. 124 // System user will not be returned when calling get all users.
124 @Test 125 @Test
125 public void testHeadlessUser0GetAllUsers_NotReturnSystemUser() { 126 public void testHeadlessUser0GetAllUsers_NotReturnSystemUser() {
126 SystemProperties.set("android.car.systemuser.headless", "true"); 127 CarProperties.headless_system_user(true);
127 UserInfo otherUser1 = createUserInfoForId(10); 128 UserInfo otherUser1 = createUserInfoForId(10);
128 UserInfo otherUser2 = createUserInfoForId(11); 129 UserInfo otherUser2 = createUserInfoForId(11);
129 UserInfo otherUser3 = createUserInfoForId(12); 130 UserInfo otherUser3 = createUserInfoForId(12);
@@ -271,7 +272,7 @@ public class CarUserManagerHelperTest {
271 assertThat(mCarUserManagerHelper.getMaxSupportedUsers()).isEqualTo(11); 272 assertThat(mCarUserManagerHelper.getMaxSupportedUsers()).isEqualTo(11);
272 273
273 // In headless user 0 model, we want to exclude the system user. 274 // In headless user 0 model, we want to exclude the system user.
274 SystemProperties.set("android.car.systemuser.headless", "true"); 275 CarProperties.headless_system_user(true);
275 assertThat(mCarUserManagerHelper.getMaxSupportedUsers()).isEqualTo(10); 276 assertThat(mCarUserManagerHelper.getMaxSupportedUsers()).isEqualTo(10);
276 } 277 }
277 278
@@ -315,7 +316,7 @@ public class CarUserManagerHelperTest {
315 316
316 @Test 317 @Test
317 public void testHeadlessSystemUser_IsUserLimitReached() { 318 public void testHeadlessSystemUser_IsUserLimitReached() {
318 SystemProperties.set("android.car.systemuser.headless", "true"); 319 CarProperties.headless_system_user(true);
319 UserInfo user1 = createUserInfoForId(10); 320 UserInfo user1 = createUserInfoForId(10);
320 UserInfo user2 = 321 UserInfo user2 =
321 new UserInfo(/* id= */ 11, /* name = */ "user11", UserInfo.FLAG_MANAGED_PROFILE); 322 new UserInfo(/* id= */ 11, /* name = */ "user11", UserInfo.FLAG_MANAGED_PROFILE);
@@ -743,7 +744,7 @@ public class CarUserManagerHelperTest {
743 744
744 @Test 745 @Test
745 public void testGetInitialUserWithValidLastActiveUser() { 746 public void testGetInitialUserWithValidLastActiveUser() {
746 SystemProperties.set("android.car.systemuser.headless", "true"); 747 CarProperties.headless_system_user(true);
747 int lastActiveUserId = 12; 748 int lastActiveUserId = 12;
748 749
749 UserInfo otherUser1 = createUserInfoForId(lastActiveUserId - 2); 750 UserInfo otherUser1 = createUserInfoForId(lastActiveUserId - 2);
@@ -759,7 +760,7 @@ public class CarUserManagerHelperTest {
759 760
760 @Test 761 @Test
761 public void testGetInitialUserWithNonExistLastActiveUser() { 762 public void testGetInitialUserWithNonExistLastActiveUser() {
762 SystemProperties.set("android.car.systemuser.headless", "true"); 763 CarProperties.headless_system_user(true);
763 int lastActiveUserId = 12; 764 int lastActiveUserId = 12;
764 765
765 UserInfo otherUser1 = createUserInfoForId(lastActiveUserId - 2); 766 UserInfo otherUser1 = createUserInfoForId(lastActiveUserId - 2);