DO NOT MERGE: Cherry-pick a bunch fixes to AOSP

Task affinity updates

- Remove task affinity for AppDrawOver Settings
- Remove task affinity for ConfigNotificationSettings

The task affinity is messing with the back stack for this activity when
launched externally

Fixes: 80281932
Fixes: 80290571
Test: manual

Disable uninstall update option for secondary users.

Fixes: 110249550
Test: manual

Suppress some gesture search when there is no hardware

Fixes: 110250839
Test: robotests

Check wifi password length by byte, not char.

Change-Id: Ic25ef766886507211c3de8764c1cffef2b27a025
Fixes: 79209073
Test: robotest
This commit is contained in:
Fan Zhang
2018-08-27 14:28:54 -07:00
parent fcaf926dc1
commit 07e55d97ca
7 changed files with 42 additions and 19 deletions

View File

@@ -91,7 +91,9 @@ public final class AppInfoDashboardFragmentTest {
doReturn(mActivity).when(mFragment).getActivity();
doReturn(mShadowContext).when(mFragment).getContext();
doReturn(mPackageManager).when(mActivity).getPackageManager();
when(mUserManager.isAdminUser()).thenReturn(true);
ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
// Default to not considering any apps to be instant (individual tests can override this).
ReflectionHelpers.setStaticField(AppUtils.class, "sInstantAppDataProvider",
(InstantAppDataProvider) (i -> false));
@@ -102,7 +104,7 @@ public final class AppInfoDashboardFragmentTest {
when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
when(mUserManager.getUsers().size()).thenReturn(2);
ReflectionHelpers.setField(mFragment, "mDpm", mDevicePolicyManager);
ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
final ApplicationInfo info = new ApplicationInfo();
info.enabled = true;
final AppEntry appEntry = mock(AppEntry.class);
@@ -118,7 +120,6 @@ public final class AppInfoDashboardFragmentTest {
when(mDevicePolicyManager.packageHasActiveAdmins(nullable(String.class))).thenReturn(false);
when(mUserManager.getUsers().size()).thenReturn(2);
ReflectionHelpers.setField(mFragment, "mDpm", mDevicePolicyManager);
ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
final ApplicationInfo info = new ApplicationInfo();
info.flags = ApplicationInfo.FLAG_INSTALLED;
info.enabled = true;
@@ -217,7 +218,6 @@ public final class AppInfoDashboardFragmentTest {
final PackageInfo packageInfo = mock(PackageInfo.class);
ReflectionHelpers.setField(mFragment, "mDpm", mDevicePolicyManager);
ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
ReflectionHelpers.setField(mFragment, "mPackageInfo", packageInfo);
assertThat(mFragment.shouldShowUninstallForAll(appEntry)).isFalse();
@@ -258,7 +258,6 @@ public final class AppInfoDashboardFragmentTest {
userInfos.add(new UserInfo(userID1, "User1", UserInfo.FLAG_PRIMARY));
userInfos.add(new UserInfo(userID2, "yue", UserInfo.FLAG_GUEST));
when(mUserManager.getUsers(true)).thenReturn(userInfos);
ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
final ApplicationInfo appInfo = new ApplicationInfo();
appInfo.flags = ApplicationInfo.FLAG_INSTALLED;
when(mPackageManager.getApplicationInfoAsUser(
@@ -282,7 +281,6 @@ public final class AppInfoDashboardFragmentTest {
userInfos.add(new UserInfo(userID1, "User1", UserInfo.FLAG_PRIMARY));
userInfos.add(new UserInfo(userID2, "yue", UserInfo.FLAG_GUEST));
when(mUserManager.getUsers(true)).thenReturn(userInfos);
ReflectionHelpers.setField(mFragment, "mUserManager", mUserManager);
final ApplicationInfo appInfo = new ApplicationInfo();
appInfo.flags = ApplicationInfo.FLAG_INSTALLED;
when(mPackageManager.getApplicationInfoAsUser(

View File

@@ -23,28 +23,33 @@ import android.provider.SearchIndexableResource;
import com.android.settings.R;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settings.testutils.shadow.ShadowUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class)
public class SwipeToNotificationSettingsTest {
@Mock
private Context mContext;
private SwipeToNotificationSettings mFragment;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mFragment = new SwipeToNotificationSettings();
ShadowUtils.reset();
}
@After
public void tearDown() {
ShadowUtils.reset();
}
@Test
@@ -56,10 +61,22 @@ public class SwipeToNotificationSettingsTest {
@Test
public void testSearchIndexProvider_shouldIndexResource() {
final List<SearchIndexableResource> indexRes =
SwipeToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER
.getXmlResourcesToIndex(RuntimeEnvironment.application, true /* enabled */);
SwipeToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER
.getXmlResourcesToIndex(mContext, true /* enabled */);
assertThat(indexRes).isNotNull();
assertThat(indexRes.get(0).xmlResId).isEqualTo(mFragment.getPreferenceScreenResId());
}
@Test
@Config(shadows = ShadowUtils.class)
public void getNonIndexableKeys_noFingerprintHardware_shouldSuppressPage() {
ShadowUtils.setFingerprintManager(null);
final List<String> niks = SwipeToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(mContext);
assertThat(niks).isNotEmpty();
}
}

View File

@@ -29,7 +29,7 @@ public class WifiUtilsTest {
@Test
public void testSSID() {
assertThat(WifiUtils.isSSIDTooLong("123")).isFalse();
assertThat(WifiUtils.isSSIDTooLong("☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎")).isTrue();
assertThat(WifiUtils.isSSIDTooLong("☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎")).isTrue();
assertThat(WifiUtils.isSSIDTooShort("123")).isFalse();
assertThat(WifiUtils.isSSIDTooShort("")).isTrue();