Merge "move PermissionsSummaryHelper into SettingsLib to share with car settings Bug: 34679894 Test: make RunSettingsRoboTests -j128 Change-Id: I53a3f3d8d2a05b33d2cff52a06236dd7d31dbe63"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4c8ba07..871de12 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3077,7 +3077,8 @@
<activity android:name=".Settings$SupportDashboardActivity"
android:label="@string/page_tab_title_support"
- android:icon="@drawable/ic_help">
+ android:icon="@drawable/ic_help"
+ android:enabled="@bool/config_support_enabled">
<intent-filter android:priority="0">
<action android:name="com.android.settings.action.SETTINGS"/>
</intent-filter>
diff --git a/res/layout/encryption_interstitial_header.xml b/res/layout/encryption_interstitial_header.xml
index 9601fa8..b4f6dbb 100644
--- a/res/layout/encryption_interstitial_header.xml
+++ b/res/layout/encryption_interstitial_header.xml
@@ -15,7 +15,9 @@
limitations under the License.
-->
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+<TextView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/encryption_interstitial_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
diff --git a/res/values/config.xml b/res/values/config.xml
index 1ebc4c7..0fa2b71 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -64,4 +64,7 @@
<!-- If the Storage Manager settings are enabled. -->
<bool name="config_storage_manager_settings_enabled">false</bool>
+ <!-- If the support features are enabled. -->
+ <bool name="config_support_enabled">false</bool>
+
</resources>
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index 1b18b18..4f24381 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -196,6 +196,9 @@
@Override
public boolean onPreferenceTreeClick(Preference preference) {
final String key = preference.getKey();
+ if (key == null) {
+ return super.onPreferenceTreeClick(preference);
+ }
if (key.equals(KEY_ENCRYPT_REQUIRE_PASSWORD)) {
final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
if (accEn && !mPasswordRequired) {
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index 1b9b3b3..d0275ba 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -31,6 +31,10 @@
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Configuration;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
import android.nfc.NfcAdapter;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -679,6 +683,13 @@
mDevelopmentPreferencesListener = null;
}
+ @Override
+ public void setTaskDescription(ActivityManager.TaskDescription taskDescription) {
+ final Bitmap icon = getBitmapFromXmlResource(R.drawable.ic_launcher_settings);
+ taskDescription.setIcon(icon);
+ super.setTaskDescription(taskDescription);
+ }
+
protected boolean isValidFragment(String fragmentName) {
// Almost all fragments are wrapped in this,
// except for a few that have their own activities.
@@ -1114,4 +1125,17 @@
}
super.onActivityResult(requestCode, resultCode, data);
}
+
+ @VisibleForTesting
+ Bitmap getBitmapFromXmlResource(int drawableRes) {
+ Drawable drawable = getResources().getDrawable(drawableRes, getTheme());
+ Canvas canvas = new Canvas();
+ Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
+ drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
+ canvas.setBitmap(bitmap);
+ drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
+ drawable.draw(canvas);
+
+ return bitmap;
+ }
}
diff --git a/src/com/android/settings/applications/InstalledAppDetails.java b/src/com/android/settings/applications/InstalledAppDetails.java
index 0669d28..53f53c4 100755
--- a/src/com/android/settings/applications/InstalledAppDetails.java
+++ b/src/com/android/settings/applications/InstalledAppDetails.java
@@ -491,23 +491,7 @@
if (mFinishing) {
return;
}
- boolean showIt = true;
- if (mUpdatedSysApp) {
- showIt = false;
- } else if (mAppEntry == null) {
- showIt = false;
- } else if ((mAppEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
- showIt = false;
- } else if (mPackageInfo == null || mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
- showIt = false;
- } else if (UserHandle.myUserId() != 0) {
- showIt = false;
- } else if (mUserManager.getUsers().size() < 2) {
- showIt = false;
- } else if (PackageUtil.countPackageInUsers(mPm, mUserManager, mPackageName) < 2) {
- showIt = false;
- }
- menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(showIt);
+ menu.findItem(UNINSTALL_ALL_USERS_MENU).setVisible(shouldShowUninstallForAll(mAppEntry));
mUpdatedSysApp = (mAppEntry.info.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
MenuItem uninstallUpdatesItem = menu.findItem(UNINSTALL_UPDATES);
uninstallUpdatesItem.setVisible(mUpdatedSysApp && !mAppsControlDisallowedBySystem);
@@ -574,6 +558,28 @@
}
@VisibleForTesting
+ boolean shouldShowUninstallForAll(ApplicationsState.AppEntry appEntry) {
+ boolean showIt = true;
+ if (mUpdatedSysApp) {
+ showIt = false;
+ } else if (appEntry == null) {
+ showIt = false;
+ } else if ((appEntry.info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+ showIt = false;
+ } else if (mPackageInfo == null || mDpm.packageHasActiveAdmins(mPackageInfo.packageName)) {
+ showIt = false;
+ } else if (UserHandle.myUserId() != 0) {
+ showIt = false;
+ } else if (mUserManager.getUsers().size() < 2) {
+ showIt = false;
+ } else if (PackageUtil.countPackageInUsers(mPm, mUserManager, mPackageName) < 2
+ && (appEntry.info.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
+ showIt = false;
+ }
+ return showIt;
+ }
+
+ @VisibleForTesting
int getInstallationStatus(ApplicationInfo info) {
if ((info.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
return R.string.not_installed;
diff --git a/src/com/android/settings/gestures/AssistGestureSettings.java b/src/com/android/settings/gestures/AssistGestureSettings.java
index f457320..1d82720 100644
--- a/src/com/android/settings/gestures/AssistGestureSettings.java
+++ b/src/com/android/settings/gestures/AssistGestureSettings.java
@@ -22,6 +22,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -51,8 +52,13 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle());
+ }
+
+ private static List<PreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new AssistGesturePreferenceController(context, getLifecycle()));
+ controllers.add(new AssistGesturePreferenceController(context, lifecycle));
return controllers;
}
@@ -69,6 +75,11 @@
sir.xmlResId = R.xml.assist_gesture_settings;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null /* lifecycle */);
+ }
};
}
diff --git a/src/com/android/settings/gestures/DoubleTapPowerSettings.java b/src/com/android/settings/gestures/DoubleTapPowerSettings.java
index 9251f0b..b17341a 100644
--- a/src/com/android/settings/gestures/DoubleTapPowerSettings.java
+++ b/src/com/android/settings/gestures/DoubleTapPowerSettings.java
@@ -22,6 +22,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -51,8 +52,13 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle());
+ }
+
+ private static List<PreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new DoubleTapPowerPreferenceController(context, getLifecycle()));
+ controllers.add(new DoubleTapPowerPreferenceController(context, lifecycle));
return controllers;
}
@@ -69,5 +75,10 @@
sir.xmlResId = R.xml.double_tap_power_settings;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null /* lifecycle */);
+ }
};
}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenSettings.java b/src/com/android/settings/gestures/DoubleTapScreenSettings.java
index f374f9e..a215dae 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenSettings.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenSettings.java
@@ -24,6 +24,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -53,8 +54,13 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle());
+ }
+
+ private static List<PreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new DoubleTapScreenPreferenceController(context, getLifecycle(),
+ controllers.add(new DoubleTapScreenPreferenceController(context, lifecycle,
new AmbientDisplayConfiguration(context), UserHandle.myUserId()));
return controllers;
}
@@ -72,5 +78,10 @@
sir.xmlResId = R.xml.double_tap_screen_settings;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null /* lifecycle */);
+ }
};
}
diff --git a/src/com/android/settings/gestures/DoubleTwistGestureSettings.java b/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
index 5f5b873..bee9474 100644
--- a/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
+++ b/src/com/android/settings/gestures/DoubleTwistGestureSettings.java
@@ -22,6 +22,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -51,8 +52,13 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle());
+ }
+
+ private static List<PreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new DoubleTwistPreferenceController(context, getLifecycle()));
+ controllers.add(new DoubleTwistPreferenceController(context, lifecycle));
return controllers;
}
@@ -69,5 +75,11 @@
sir.xmlResId = R.xml.double_twist_gesture_settings;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null /* lifecycle */);
+ }
};
+
}
diff --git a/src/com/android/settings/gestures/PickupGestureSettings.java b/src/com/android/settings/gestures/PickupGestureSettings.java
index 08e61fa..e4d12f2 100644
--- a/src/com/android/settings/gestures/PickupGestureSettings.java
+++ b/src/com/android/settings/gestures/PickupGestureSettings.java
@@ -24,6 +24,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -53,8 +54,13 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle());
+ }
+
+ private static List<PreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new PickupGesturePreferenceController(context, getLifecycle(),
+ controllers.add(new PickupGesturePreferenceController(context, lifecycle,
new AmbientDisplayConfiguration(context), UserHandle.myUserId()));
return controllers;
}
@@ -72,6 +78,11 @@
sir.xmlResId = R.xml.pick_up_gesture_settings;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null /* lifecycle */);
+ }
};
}
diff --git a/src/com/android/settings/gestures/SwipeToNotificationSettings.java b/src/com/android/settings/gestures/SwipeToNotificationSettings.java
index 155412c..d948e55 100644
--- a/src/com/android/settings/gestures/SwipeToNotificationSettings.java
+++ b/src/com/android/settings/gestures/SwipeToNotificationSettings.java
@@ -22,6 +22,7 @@
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
+import com.android.settings.core.lifecycle.Lifecycle;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -51,8 +52,13 @@
@Override
protected List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, getLifecycle());
+ }
+
+ private static List<PreferenceController> buildPreferenceControllers(Context context,
+ Lifecycle lifecycle) {
final List<PreferenceController> controllers = new ArrayList<>();
- controllers.add(new SwipeToNotificationPreferenceController(context, getLifecycle()));
+ controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle));
return controllers;
}
@@ -69,5 +75,10 @@
sir.xmlResId = R.xml.swipe_to_notification_settings;
return Arrays.asList(sir);
}
+
+ @Override
+ public List<PreferenceController> getPreferenceControllers(Context context) {
+ return buildPreferenceControllers(context, null /* lifecycle */);
+ }
};
}
diff --git a/tests/app/src/com/android/settings/EncryptionInterstitialTest.java b/tests/app/src/com/android/settings/EncryptionInterstitialTest.java
new file mode 100644
index 0000000..6487818
--- /dev/null
+++ b/tests/app/src/com/android/settings/EncryptionInterstitialTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2017 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;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static android.support.test.espresso.Espresso.onView;
+import static android.support.test.espresso.matcher.ViewMatchers.withId;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class EncryptionInterstitialTest {
+
+ private Instrumentation mInstrumentation;
+ private Context mContext;
+
+ @Before
+ public void setUp() {
+ mInstrumentation = InstrumentationRegistry.getInstrumentation();
+ mContext = mInstrumentation.getTargetContext();
+ }
+
+ @Test
+ public void clickHeader_shouldNotCrash() {
+ mInstrumentation.startActivitySync(
+ new Intent().setClassName(mContext, EncryptionInterstitial.class.getName()));
+ onView(withId(R.id.encryption_interstitial_header));
+ // Nothing should happen
+ }
+}
diff --git a/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider b/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
index cb04679..8184d2c 100644
--- a/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
+++ b/tests/robotests/assets/grandfather_not_sharing_pref_controllers_with_search_provider
@@ -1,11 +1,5 @@
-com.android.settings.gestures.PickupGestureSettings
com.android.settings.language.LanguageAndInputSettings
com.android.settings.enterprise.EnterprisePrivacySettings
-com.android.settings.gestures.DoubleTapScreenSettings
com.android.settings.applications.AdvancedAppSettings
-com.android.settings.gestures.AssistGestureSettings
com.android.settings.fuelgauge.PowerUsageSummary
-com.android.settings.gestures.SwipeToNotificationSettings
com.android.settings.inputmethod.InputMethodAndLanguageSettings
-com.android.settings.gestures.DoubleTapPowerSettings
-com.android.settings.gestures.DoubleTwistGestureSettings
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/SettingsActivityTest.java b/tests/robotests/src/com/android/settings/SettingsActivityTest.java
index df7a454..6a5b935 100644
--- a/tests/robotests/src/com/android/settings/SettingsActivityTest.java
+++ b/tests/robotests/src/com/android/settings/SettingsActivityTest.java
@@ -16,12 +16,13 @@
package com.android.settings;
+import android.app.ActivityManager;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Bitmap;
import com.android.settings.testutils.FakeFeatureFactory;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,9 +33,12 @@
import org.robolectric.annotation.Config;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@@ -45,7 +49,10 @@
private Context mContext;
@Mock
private FragmentManager mFragmentManager;
-
+ @Mock
+ private ActivityManager.TaskDescription mTaskDescription;
+ @Mock
+ private Bitmap mBitmap;
private SettingsActivity mActivity;
@Before
@@ -53,14 +60,16 @@
MockitoAnnotations.initMocks(this);
FakeFeatureFactory.setupForTest(mContext);
final FakeFeatureFactory factory =
- (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
+ (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
when(factory.dashboardFeatureProvider.isEnabled()).thenReturn(true);
+
+ mActivity = spy(new SettingsActivity());
+ doReturn(mBitmap).when(mActivity).getBitmapFromXmlResource(anyInt());
}
@Test
public void testQueryTextChange_shouldUpdate() {
final String testQuery = "abc";
- mActivity = new SettingsActivity();
assertThat(mActivity.mSearchQuery).isNull();
try {
@@ -83,4 +92,11 @@
mActivity.launchSettingFragment(null, true, mock(Intent.class));
}
+
+ @Test
+ public void testSetTaskDescription_IconChanged() {
+ mActivity.setTaskDescription(mTaskDescription);
+
+ verify(mTaskDescription).setIcon(any());
+ }
}
diff --git a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
index dc37079..2a703ef 100644
--- a/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/InstalledAppDetailsTest.java
@@ -16,22 +16,44 @@
package com.android.settings.applications;
+import android.app.admin.DevicePolicyManager;
import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.os.UserManager;
import com.android.settings.R;
import com.android.settings.SettingsRobolectricTestRunner;
import com.android.settings.TestConfig;
+import com.android.settingslib.applications.ApplicationsState.AppEntry;
+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 org.robolectric.util.ReflectionHelpers;
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public final class InstalledAppDetailsTest {
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private UserManager mUserManager;
+ @Mock
+ private DevicePolicyManager mDevicePolicyManager;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
@Test
public void getInstallationStatus_notInstalled_shouldReturnUninstalled() {
final InstalledAppDetails mAppDetail = new InstalledAppDetails();
@@ -60,4 +82,39 @@
assertThat(mAppDetail.getInstallationStatus(info)).isEqualTo(R.string.disabled);
}
+ @Test
+ public void shouldShowUninstallForAll_installForOneOtherUserOnly_shouldReturnTrue() {
+ when(mDevicePolicyManager.packageHasActiveAdmins(anyString())).thenReturn(false);
+ when(mUserManager.getUsers().size()).thenReturn(2);
+ final InstalledAppDetails mAppDetail = new InstalledAppDetails();
+ ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
+ ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
+ final ApplicationInfo info = new ApplicationInfo();
+ info.enabled = true;
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+
+ assertThat(mAppDetail.shouldShowUninstallForAll(appEntry)).isTrue();
+ }
+
+ @Test
+ public void shouldShowUninstallForAll_installForSelfOnly_shouldReturnFalse() {
+ when(mDevicePolicyManager.packageHasActiveAdmins(anyString())).thenReturn(false);
+ when(mUserManager.getUsers().size()).thenReturn(2);
+ final InstalledAppDetails mAppDetail = new InstalledAppDetails();
+ ReflectionHelpers.setField(mAppDetail, "mDpm", mDevicePolicyManager);
+ ReflectionHelpers.setField(mAppDetail, "mUserManager", mUserManager);
+ final ApplicationInfo info = new ApplicationInfo();
+ info.flags = ApplicationInfo.FLAG_INSTALLED;
+ info.enabled = true;
+ final AppEntry appEntry = mock(AppEntry.class);
+ appEntry.info = info;
+ final PackageInfo packageInfo = mock(PackageInfo.class);
+ ReflectionHelpers.setField(mAppDetail, "mPackageInfo", packageInfo);
+
+ assertThat(mAppDetail.shouldShowUninstallForAll(appEntry)).isFalse();
+ }
+
}
diff --git a/tests/robotests/src/com/android/settings/support/SupportConfigTest.java b/tests/robotests/src/com/android/settings/support/SupportConfigTest.java
new file mode 100644
index 0000000..7c1d587
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/support/SupportConfigTest.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 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.support;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import static com.google.common.truth.Truth.assertThat;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class SupportConfigTest {
+
+ @Test
+ public void getConfigForSupportFeature_shouldBeDisabled() {
+ final boolean supportEnabled = RuntimeEnvironment.application.getResources()
+ .getBoolean(R.bool.config_support_enabled);
+ assertThat(supportEnabled).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
index cc55a4e..181ae64 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java
@@ -56,6 +56,10 @@
// TODO: Remove this once Robolectric is updated.
if (id == com.android.settings.R.drawable.switchbar_background) {
return new ColorDrawable();
+ } else if (id == com.android.settings.R.drawable.ic_launcher_settings) {
+ // ic_launcher_settings uses adaptive-icon, which is not supported by robolectric,
+ // change it to a normal drawable.
+ id = com.android.settings.R.drawable.ic_settings_wireless;
}
return super.loadDrawable(value, id, theme);
}