diff --git a/res/xml/user_settings.xml b/res/xml/user_settings.xml
index 45d0b90182e..06b73a07297 100644
--- a/res/xml/user_settings.xml
+++ b/res/xml/user_settings.xml
@@ -28,14 +28,4 @@
android:title="@string/user_add_user_or_profile_menu"
android:icon="@drawable/ic_menu_add" />
-
-
-
-
diff --git a/src/com/android/settings/users/UserSettings.java b/src/com/android/settings/users/UserSettings.java
index 000ccf5cbdc..c3a058a1086 100644
--- a/src/com/android/settings/users/UserSettings.java
+++ b/src/com/android/settings/users/UserSettings.java
@@ -27,7 +27,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
-import android.content.pm.ResolveInfo;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
@@ -53,7 +52,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.SimpleAdapter;
-import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.ChooseLockGeneric;
@@ -63,9 +61,6 @@ import com.android.settings.R;
import com.android.settings.SettingsActivity;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
-import com.android.settings.accounts.AddUserWhenLockedPreferenceController;
-import com.android.settings.accounts.EmergencyInfoPreferenceController;
-import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;
@@ -102,9 +97,6 @@ public class UserSettings extends SettingsPreferenceFragment
private static final String KEY_USER_LIST = "user_list";
private static final String KEY_USER_ME = "user_me";
private static final String KEY_ADD_USER = "user_add";
- private static final String KEY_EMERGENCY_INFO = "emergency_info";
-
- private static final String ACTION_EDIT_EMERGENCY_INFO = "android.settings.EDIT_EMERGENGY_INFO";
private static final int MENU_REMOVE_USER = Menu.FIRST;
@@ -136,9 +128,6 @@ public class UserSettings extends SettingsPreferenceFragment
private PreferenceGroup mUserListCategory;
private UserPreference mMePreference;
private DimmableIconPreference mAddUser;
- private PreferenceGroup mLockScreenSettings;
- private RestrictedSwitchPreference mAddUserWhenLocked;
- private Preference mEmergencyInfoPreference;
private int mRemovingUserId = -1;
private int mAddedUserId = 0;
private boolean mAddingUser;
@@ -151,8 +140,6 @@ public class UserSettings extends SettingsPreferenceFragment
private EditUserInfoController mEditUserInfoController =
new EditUserInfoController();
- private EmergencyInfoPreferenceController mEnergencyInfoController;
- private AddUserWhenLockedPreferenceController mAddUserWhenLockedController;
// A place to cache the generated default avatar
private Drawable mDefaultIconDrawable;
@@ -236,14 +223,6 @@ public class UserSettings extends SettingsPreferenceFragment
mAddUser.setTitle(R.string.user_add_user_menu);
}
}
- if (showEmergencyInfoAndAddUsersWhenLock(context)) {
- mLockScreenSettings = (PreferenceGroup) findPreference("lock_screen_settings");
- mAddUserWhenLocked =
- (RestrictedSwitchPreference) findPreference("add_users_when_locked");
- mEmergencyInfoPreference = findPreference(KEY_EMERGENCY_INFO);
- mEnergencyInfoController = new EmergencyInfoPreferenceController(context);
- mAddUserWhenLockedController = new AddUserWhenLockedPreferenceController(context);
- }
setHasOptionsMenu(true);
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_REMOVED);
filter.addAction(Intent.ACTION_USER_INFO_CHANGED);
@@ -658,20 +637,6 @@ public class UserSettings extends SettingsPreferenceFragment
}
}
- @VisibleForTesting
- boolean showEmergencyInfoAndAddUsersWhenLock(Context context) {
- return !FeatureFactory.getFactory(context).getDashboardFeatureProvider(context).isEnabled();
- }
-
- private static boolean emergencyInfoActivityPresent(Context context) {
- Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO).setPackage("com.android.emergency");
- List infos = context.getPackageManager().queryIntentActivities(intent, 0);
- if (infos == null || infos.isEmpty()) {
- return false;
- }
- return true;
- }
-
private void removeUserNow() {
if (mRemovingUserId == UserHandle.myUserId()) {
removeThisUser();
@@ -903,20 +868,6 @@ public class UserSettings extends SettingsPreferenceFragment
}
}
- if (showEmergencyInfoAndAddUsersWhenLock(context)) {
- if (mAddUserWhenLockedController.isAvailable()) {
- mLockScreenSettings.setOrder(Preference.DEFAULT_ORDER);
- preferenceScreen.addPreference(mLockScreenSettings);
- mAddUserWhenLockedController.updateState(mAddUserWhenLocked);
- mAddUserWhenLocked.setOnPreferenceChangeListener(mAddUserWhenLockedController);
- }
-
- if (emergencyInfoActivityPresent(getContext())) {
- mEmergencyInfoPreference.setOnPreferenceClickListener(this);
- mEmergencyInfoPreference.setOrder(Preference.DEFAULT_ORDER);
- preferenceScreen.addPreference(mEmergencyInfoPreference);
- }
- }
}
private int getMaxRealUsers() {
@@ -997,8 +948,6 @@ public class UserSettings extends SettingsPreferenceFragment
} else {
onAddUserClicked(USER_TYPE_USER);
}
- } else if (mEnergencyInfoController != null) {
- mEnergencyInfoController.handlePreferenceTreeClick(pref);
}
return false;
}
@@ -1082,12 +1031,6 @@ public class UserSettings extends SettingsPreferenceFragment
data.screenTitle = res.getString(R.string.user_settings_title);
result.add(data);
}
- if (emergencyInfoActivityPresent(context)) {
- data = new SearchIndexableRaw(context);
- data.title = res.getString(R.string.emergency_info_title);
- data.screenTitle = res.getString(R.string.emergency_info_title);
- result.add(data);
- }
return result;
}
};
diff --git a/tests/app/src/com/android/settings/users/UserSettingsTest.java b/tests/app/src/com/android/settings/users/UserSettingsTest.java
new file mode 100644
index 00000000000..1a339172c5c
--- /dev/null
+++ b/tests/app/src/com/android/settings/users/UserSettingsTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.settings.users;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.filters.SmallTest;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.UiObject;
+import android.support.test.uiautomator.UiSelector;
+import android.support.test.uiautomator.UiScrollable;
+import android.test.InstrumentationTestCase;
+
+import com.android.settings.R;
+
+import org.junit.Test;
+
+@SmallTest
+public class UserSettingsTest extends InstrumentationTestCase {
+
+ private static final String USER_AND_ACCOUNTS = "User & accounts";
+ private static final String USERS = "Users";
+ private static final String EMERGNENCY_INFO = "Emergency information";
+ private static final String ADD_USERS_WHEN_LOCKED = "Add users";
+
+ private UiDevice mDevice;
+ private Context mContext;
+ private String mTargetPackage;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mDevice = UiDevice.getInstance(getInstrumentation());
+ mContext = getInstrumentation().getTargetContext();
+ mTargetPackage = mContext.getPackageName();
+ }
+
+ @Test
+ public void testEmergencyInfoNotExists() throws Exception {
+ launchUserSettings();
+ UiObject emergencyInfoPreference =
+ mDevice.findObject(new UiSelector().text(EMERGNENCY_INFO));
+ assertFalse(emergencyInfoPreference.exists());
+ }
+
+ @Test
+ public void testAddUsersWhenLockedNotExists() throws Exception {
+ launchUserSettings();
+ UiObject addUsersPreference =
+ mDevice.findObject(new UiSelector().text(ADD_USERS_WHEN_LOCKED));
+ assertFalse(addUsersPreference.exists());
+ }
+
+ private void launchSettings() {
+ Intent settingsIntent = new Intent(Intent.ACTION_MAIN)
+ .addCategory(Intent.CATEGORY_LAUNCHER)
+ .setPackage(mTargetPackage)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ getInstrumentation().getContext().startActivity(settingsIntent);
+ }
+
+ private void launchUserSettings() throws Exception {
+ launchSettings();
+ final UiScrollable settings = new UiScrollable(
+ new UiSelector().packageName(mTargetPackage).scrollable(true));
+ final String titleUsersAndAccounts = USER_AND_ACCOUNTS;
+ settings.scrollTextIntoView(titleUsersAndAccounts);
+ mDevice.findObject(new UiSelector().text(titleUsersAndAccounts)).click();
+ mDevice.findObject(new UiSelector().text(USERS)).click();
+ }
+
+}
diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
deleted file mode 100644
index 005ac199fcc..00000000000
--- a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-package com.android.settings.users;
-
-import android.content.Context;
-
-import com.android.settings.SettingsRobolectricTestRunner;
-import com.android.settings.TestConfig;
-import com.android.settings.testutils.FakeFeatureFactory;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Answers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.robolectric.annotation.Config;
-
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.when;
-
-@RunWith(SettingsRobolectricTestRunner.class)
-@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
-public class UserSettingsTest {
-
- @Mock(answer = Answers.RETURNS_DEEP_STUBS)
- private Context mContext;
-
- private FakeFeatureFactory mFeatureFactory;
- private UserSettings mSetting;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- FakeFeatureFactory.setupForTest(mContext);
- mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
- mSetting = new UserSettings();
- }
-
- @Test
- public void testShowEmergencyInfoAndAddUsers_IAEnabled_shouldReturnFalse() {
- when(mFeatureFactory.dashboardFeatureProvider.isEnabled()).thenReturn(true);
- assertThat(mSetting.showEmergencyInfoAndAddUsersWhenLock(mContext)).isFalse();
- }
-
- @Test
- public void testShowEmergencyInfoAndAddUsers_IADisabled_shouldReturnTrue() {
- when(mFeatureFactory.dashboardFeatureProvider.isEnabled()).thenReturn(false);
- assertThat(mSetting.showEmergencyInfoAndAddUsersWhenLock(mContext)).isTrue();
- }
-
-}