Merge "Remove shadow below the actionbar"
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4cdfa25..67f2180 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1185,7 +1185,7 @@
         <activity
             android:name="Settings$LocationSettingsActivity"
             android:label="@string/location_settings_title"
-            android:icon="@drawable/ic_homepage_location"
+            android:icon="@drawable/ic_settings_location"
             android:configChanges="orientation|keyboardHidden|screenSize">
             <intent-filter android:priority="1">
                 <action android:name="android.settings.LOCATION_SOURCE_SETTINGS" />
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e0b165c..7f11827 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -95,8 +95,6 @@
     <!-- Description for the button that makes interface elements larger. [CHAR_LIMIT=NONE] -->
     <string name="font_size_make_larger_desc">Make larger</string>
 
-    <!-- Sample text for font size preview. -->
-    <string name="font_size_preview_text">Servez à ce monsieur une bière et des kiwis.</string>
     <string name="font_size_preview_text_headline">Sample text</string>
     <string name="font_size_preview_text_title"
             translation_description="Title text in sample text used to illustrate how the currently selected font size will appear to the user. NOTE: Translate manually. No not adopt any copyrighted material for translation.">
@@ -10556,6 +10554,17 @@
         <item>@string/game_driver_app_preference_system</item>
     </string-array>
 
+    <!-- Title for App Compatibility Changes dashboard where developers can configure per-app overrides for compatibility changes [CHAR LIMIT=50] -->
+    <string name="platform_compat_dashboard_title">App Compatibility Changes</string>
+    <!-- Summary for App Compatibility Changes dashboard [CHAR LIMIT=NONE] -->
+    <string name="platform_compat_dashboard_summary">Modify app compatibility change overrides</string>
+    <!-- Title for default enabled app compat changes category [CHAR LIMIT=50] -->
+    <string name="platform_compat_default_enabled_title">Default enabled changes</string>
+    <!-- Title for default disabled app compat changes category [CHAR LIMIT=50] -->
+    <string name="platform_compat_default_disabled_title">Default disabled changes</string>
+    <!-- Title for target SDK gated app compat changes category [CHAR LIMIT=50] -->
+    <string name="platform_compat_target_sdk_title">Enabled after SDK <xliff:g id="number" example="29">%d</xliff:g></string>
+
     <!-- Slices Strings -->
 
     <!-- Summary text on a card explaining that a setting does not exist / is not supported on the device [CHAR_LIMIT=NONE]-->
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index fb1e0ba..65a454e 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -215,6 +215,13 @@
             android:fragment="com.android.settings.development.gamedriver.GameDriverDashboard"
             settings:searchable="false" />
 
+        <Preference
+            android:key="platform_compat_dashboard"
+            android:title="@string/platform_compat_dashboard_title"
+            android:summary="@string/platform_compat_dashboard_summary"
+            android:fragment="com.android.settings.development.compat.PlatformCompatDashboard"
+            />
+
     </PreferenceCategory>
 
     <PreferenceCategory
diff --git a/res/xml/platform_compat_settings.xml b/res/xml/platform_compat_settings.xml
new file mode 100644
index 0000000..bee2324
--- /dev/null
+++ b/res/xml/platform_compat_settings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright 2019 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.
+  -->
+
+<PreferenceScreen
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:settings="http://schemas.android.com/apk/res-auto"
+    android:key="platform_compat_dashboard"
+    android:title="@string/platform_compat_dashboard_title">
+</PreferenceScreen>
diff --git a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
index 564f2c3..0d91fdd 100644
--- a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
+++ b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
@@ -31,4 +31,6 @@
     int REQUEST_CODE_ANGLE_DRIVER_PKGS = 4;
 
     int REQUEST_CODE_ANGLE_DRIVER_VALUES = 5;
+
+    int REQUEST_COMPAT_CHANGE_APP = 6;
 }
diff --git a/src/com/android/settings/development/VerifyAppsOverUsbPreferenceController.java b/src/com/android/settings/development/VerifyAppsOverUsbPreferenceController.java
index 20b8f1f..3b05cef 100644
--- a/src/com/android/settings/development/VerifyAppsOverUsbPreferenceController.java
+++ b/src/com/android/settings/development/VerifyAppsOverUsbPreferenceController.java
@@ -146,19 +146,11 @@
                 == AdbPreferenceController.ADB_SETTING_OFF) {
             return false;
         }
-        if (Settings.Global.getInt(cr, Settings.Global.PACKAGE_VERIFIER_ENABLE, SETTING_VALUE_ON)
-                == SETTING_VALUE_OFF) {
-            return false;
-        } else {
-            final Intent verification = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
-            verification.setType(PACKAGE_MIME_TYPE);
-            verification.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
-            final List<ResolveInfo> receivers = mPackageManager.queryBroadcastReceivers(
-                    verification, 0 /* flags */);
-            if (receivers.size() == 0) {
-                return false;
-            }
-        }
-        return true;
+        final Intent verification = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
+        verification.setType(PACKAGE_MIME_TYPE);
+        verification.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+        final List<ResolveInfo> receivers = mPackageManager.queryBroadcastReceivers(
+                verification, 0 /* flags */);
+        return receivers.size() != 0;
     }
 }
diff --git a/src/com/android/settings/development/compat/PlatformCompatDashboard.java b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
new file mode 100644
index 0000000..dab45f2
--- /dev/null
+++ b/src/com/android/settings/development/compat/PlatformCompatDashboard.java
@@ -0,0 +1,276 @@
+/*
+ * Copyright 2019 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.development.compat;
+
+import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_COMPAT_CHANGE_APP;
+
+import android.app.Activity;
+import android.app.settings.SettingsEnums;
+import android.compat.Compatibility.ChangeConfig;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.ArraySet;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.compat.CompatibilityChangeConfig;
+import com.android.internal.compat.CompatibilityChangeInfo;
+import com.android.internal.compat.IPlatformCompat;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.development.AppPicker;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+
+/**
+ * Dashboard for Platform Compat preferences.
+ */
+public class PlatformCompatDashboard extends DashboardFragment {
+    private static final String TAG = "PlatformCompatDashboard";
+    private static final String COMPAT_APP = "compat_app";
+
+    private IPlatformCompat mPlatformCompat;
+
+    private CompatibilityChangeInfo[] mChanges;
+
+    @VisibleForTesting
+    String mSelectedApp;
+
+    @Override
+    public int getMetricsCategory() {
+        return SettingsEnums.SETTINGS_PLATFORM_COMPAT_DASHBOARD;
+    }
+
+    @Override
+    protected String getLogTag() {
+        return TAG;
+    }
+
+    @Override
+    protected int getPreferenceScreenResId() {
+        return R.xml.platform_compat_settings;
+    }
+
+    @Override
+    public int getHelpResource() {
+        return 0;
+    }
+
+    IPlatformCompat getPlatformCompat() {
+        if (mPlatformCompat == null) {
+            mPlatformCompat = IPlatformCompat.Stub
+                    .asInterface(ServiceManager.getService(Context.PLATFORM_COMPAT_SERVICE));
+        }
+        return mPlatformCompat;
+    }
+
+    @Override
+    public void onActivityCreated(Bundle savedInstanceState) {
+        super.onActivityCreated(savedInstanceState);
+        try {
+            mChanges = getPlatformCompat().listAllChanges();
+        } catch (RemoteException e) {
+            throw new RuntimeException("Could not list changes!", e);
+        }
+        startAppPicker();
+    }
+
+    @Override
+    public void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putString(COMPAT_APP, mSelectedApp);
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        if (requestCode == REQUEST_COMPAT_CHANGE_APP) {
+            if (resultCode == Activity.RESULT_OK) {
+                mSelectedApp = data.getAction();
+                addPreferences();
+            }
+            return;
+        }
+        super.onActivityResult(requestCode, resultCode, data);
+    }
+
+    private void addPreferences() {
+        getPreferenceScreen().removeAll();
+        getPreferenceScreen().addPreference(
+                createAppPreference(getApplicationInfo().loadIcon(getPackageManager())));
+        // Differentiate compatibility changes into default enabled, default disabled and enabled
+        // after target sdk.
+        final CompatibilityChangeConfig configMappings = getAppChangeMappings();
+        final List<CompatibilityChangeInfo> enabledChanges = new ArrayList<>();
+        final List<CompatibilityChangeInfo> disabledChanges = new ArrayList<>();
+        final Map<Integer, List<CompatibilityChangeInfo>> targetSdkChanges = new TreeMap<>();
+        for (CompatibilityChangeInfo change : mChanges) {
+            if (change.getEnableAfterTargetSdk() != 0) {
+                List<CompatibilityChangeInfo> sdkChanges;
+                if (!targetSdkChanges.containsKey(change.getEnableAfterTargetSdk())) {
+                    sdkChanges = new ArrayList<>();
+                    targetSdkChanges.put(change.getEnableAfterTargetSdk(), sdkChanges);
+                } else {
+                    sdkChanges = targetSdkChanges.get(change.getEnableAfterTargetSdk());
+                }
+                sdkChanges.add(change);
+            } else if (change.getDisabled()) {
+                disabledChanges.add(change);
+            } else {
+                enabledChanges.add(change);
+            }
+        }
+        createChangeCategoryPreference(enabledChanges, configMappings,
+                getString(R.string.platform_compat_default_enabled_title));
+        createChangeCategoryPreference(disabledChanges, configMappings,
+                getString(R.string.platform_compat_default_disabled_title));
+        for (Integer sdk : targetSdkChanges.keySet()) {
+            createChangeCategoryPreference(targetSdkChanges.get(sdk), configMappings,
+                    getString(R.string.platform_compat_target_sdk_title, sdk));
+        }
+    }
+
+    private CompatibilityChangeConfig getAppChangeMappings() {
+        try {
+            final ApplicationInfo applicationInfo = getApplicationInfo();
+            return getPlatformCompat().getAppConfig(applicationInfo);
+        } catch (RemoteException e) {
+            throw new RuntimeException("Could not get app config!", e);
+        }
+    }
+
+    /**
+     * Create a {@link Preference} for a changeId.
+     *
+     * <p>The {@link Preference} is a toggle switch that can enable or disable the given change for
+     * the currently selected app.</p>
+     */
+    Preference createPreferenceForChange(Context context, CompatibilityChangeInfo change,
+            CompatibilityChangeConfig configMappings) {
+        final boolean currentValue = configMappings.isChangeEnabled(change.getId());
+        final SwitchPreference item = new SwitchPreference(context);
+        final String changeName =
+                change.getName() != null ? change.getName() : "Change_" + change.getId();
+        item.setSummary(changeName);
+        item.setKey(changeName);
+        item.setEnabled(true);
+        item.setChecked(currentValue);
+        item.setOnPreferenceChangeListener(
+                new CompatChangePreferenceChangeListener(change.getId()));
+        return item;
+    }
+
+    /**
+     * Get {@link ApplicationInfo} for the currently selected app.
+     *
+     * @return an {@link ApplicationInfo} instance.
+     */
+    ApplicationInfo getApplicationInfo() {
+        try {
+            return getPackageManager().getApplicationInfo(mSelectedApp, 0);
+        } catch (PackageManager.NameNotFoundException e) {
+            throw new RuntimeException("Could not get ApplicationInfo for selected app!", e);
+        }
+    }
+
+    /**
+     * Create a {@link Preference} for the selected app.
+     *
+     * <p>The {@link Preference} contains the icon, package name and target SDK for the selected
+     * app. Selecting this preference will also re-trigger the app selection dialog.</p>
+     */
+    Preference createAppPreference(Drawable icon) {
+        final ApplicationInfo applicationInfo = getApplicationInfo();
+        final Preference appPreference = new Preference(getPreferenceScreen().getContext());
+        appPreference.setIcon(icon);
+        appPreference.setSummary(mSelectedApp
+                + " SDK "
+                + applicationInfo.targetSdkVersion);
+        appPreference.setKey(mSelectedApp);
+        appPreference.setOnPreferenceClickListener(
+                preference -> {
+                    startAppPicker();
+                    return true;
+                });
+        return appPreference;
+    }
+
+    PreferenceCategory createChangeCategoryPreference(List<CompatibilityChangeInfo> changes,
+            CompatibilityChangeConfig configMappings, String title) {
+        final PreferenceCategory category =
+                new PreferenceCategory(getPreferenceScreen().getContext());
+        category.setTitle(title);
+        getPreferenceScreen().addPreference(category);
+        addChangePreferencesToCategory(changes, category, configMappings);
+        return category;
+    }
+
+    private void addChangePreferencesToCategory(List<CompatibilityChangeInfo> changes,
+            PreferenceCategory category, CompatibilityChangeConfig configMappings) {
+        for (CompatibilityChangeInfo change : changes) {
+            final Preference preference = createPreferenceForChange(getPreferenceScreen().getContext(),
+                    change, configMappings);
+            category.addPreference(preference);
+        }
+    }
+
+    private void startAppPicker() {
+        final Intent intent = new Intent(getContext(), AppPicker.class);
+        startActivityForResult(intent, REQUEST_COMPAT_CHANGE_APP);
+    }
+
+    private class CompatChangePreferenceChangeListener implements OnPreferenceChangeListener {
+        private final long changeId;
+
+        CompatChangePreferenceChangeListener(long changeId) {
+            this.changeId = changeId;
+        }
+
+        @Override
+        public boolean onPreferenceChange(Preference preference, Object newValue) {
+            try {
+                final ArraySet<Long> enabled = new ArraySet<>();
+                final ArraySet<Long> disabled = new ArraySet<>();
+                if ((Boolean) newValue) {
+                    enabled.add(changeId);
+                } else {
+                    disabled.add(changeId);
+                }
+                final CompatibilityChangeConfig overrides =
+                        new CompatibilityChangeConfig(new ChangeConfig(enabled, disabled));
+                getPlatformCompat().setOverrides(overrides, mSelectedApp);
+            } catch (RemoteException e) {
+                e.printStackTrace();
+                return false;
+            }
+            return true;
+        }
+    }
+}
diff --git a/tests/robotests/assets/grandfather_not_implementing_index_provider b/tests/robotests/assets/grandfather_not_implementing_index_provider
index b69d72e..b14fdac 100644
--- a/tests/robotests/assets/grandfather_not_implementing_index_provider
+++ b/tests/robotests/assets/grandfather_not_implementing_index_provider
@@ -36,6 +36,7 @@
 com.android.settings.datausage.DataUsageList
 com.android.settings.datausage.DataUsageSummary
 com.android.settings.datetime.timezone.TimeZoneSettings
+com.android.settings.development.compat.PlatformCompatDashboard
 com.android.settings.deviceinfo.PrivateVolumeSettings
 com.android.settings.deviceinfo.PublicVolumeSettings
 com.android.settings.deviceinfo.StorageProfileFragment
diff --git a/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
index f0961f1..87b9126 100644
--- a/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/development/VerifyAppsOverUsbPreferenceControllerTest.java
@@ -130,17 +130,6 @@
     }
 
     @Test
-    public void updateState_verifierOff_preferenceShouldNotBeChecked() {
-        setupVerifyBroadcastReceivers(true);
-        setupEnforcedAdmin(null);
-        mGlobals.set(Global.ADB_ENABLED, 1 /* setting enabled */)
-                .set(Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1 /* setting enabled */)
-                .set(Global.PACKAGE_VERIFIER_ENABLE, 0 /* setting disabled */);
-        mController.updateState(mPreference);
-        verify(mPreference).setChecked(false);
-    }
-
-    @Test
     public void updateState_noBroadcastReceivers_preferenceShouldNotBeChecked() {
         setupVerifyBroadcastReceivers(false);
         setupEnforcedAdmin(null);
@@ -196,4 +185,4 @@
 
         assertThat(mode).isEqualTo(VerifyAppsOverUsbPreferenceController.SETTING_VALUE_OFF);
     }
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
new file mode 100644
index 0000000..d13b927
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/compat/PlatformCompatDashboardTest.java
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2019 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.development.compat;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.compat.Compatibility.ChangeConfig;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.graphics.drawable.Drawable;
+import android.os.RemoteException;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import com.android.internal.compat.CompatibilityChangeConfig;
+import com.android.internal.compat.CompatibilityChangeInfo;
+import com.android.internal.compat.IPlatformCompat;
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+@RunWith(RobolectricTestRunner.class)
+public class PlatformCompatDashboardTest {
+    private PlatformCompatDashboard mDashboard;
+
+    @Mock
+    private IPlatformCompat mPlatformCompat;
+    private PreferenceScreen mPreferenceScreen;
+    @Mock
+    private ApplicationInfo mApplicationInfo;
+    @Mock
+    private PreferenceManager mPreferenceManager;
+
+    private Context mContext;
+    private CompatibilityChangeInfo[] mChanges;
+    private static final String APP_NAME = "foo.bar.baz";
+
+    @Before
+    public void setUp() throws RemoteException, NameNotFoundException {
+        MockitoAnnotations.initMocks(this);
+        mChanges = new CompatibilityChangeInfo[5];
+        mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, false);
+        mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, true);
+        mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_After_SDK_1_1", 1, false);
+        mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_After_SDK_1_2", 1, false);
+        mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_After_SDK_2", 2, false);
+        when(mPlatformCompat.listAllChanges()).thenReturn(mChanges);
+        mContext = RuntimeEnvironment.application;
+        mPreferenceManager = new PreferenceManager(mContext);
+        mPreferenceScreen = mPreferenceManager.createPreferenceScreen(mContext);
+        mApplicationInfo.packageName = APP_NAME;
+        mDashboard = spy(new PlatformCompatDashboard());
+        mDashboard.mSelectedApp = APP_NAME;
+        doReturn(mApplicationInfo).when(mDashboard).getApplicationInfo();
+        doReturn(mPlatformCompat).when(mDashboard).getPlatformCompat();
+        doReturn(mPreferenceScreen).when(mDashboard).getPreferenceScreen();
+        doReturn(mPreferenceManager).when(mDashboard).getPreferenceManager();
+    }
+
+    @Test
+    public void getHelpResource_shouldNotHaveHelpResource() {
+        assertThat(mDashboard.getHelpResource()).isEqualTo(0);
+    }
+
+    @Test
+    public void getPreferenceScreenResId_shouldBePlatformCompatSettingsResId() {
+        assertThat(mDashboard.getPreferenceScreenResId())
+                .isEqualTo(R.xml.platform_compat_settings);
+    }
+
+    @Test
+    public void createAppPreference_targetSdkEquals1_summaryReturnsAppNameAndTargetSdk() {
+        mApplicationInfo.targetSdkVersion = 1;
+
+        Preference appPreference = mDashboard.createAppPreference(any(Drawable.class));
+
+        assertThat(appPreference.getSummary()).isEqualTo(APP_NAME + " SDK 1");
+    }
+
+    @Test
+    public void createPreferenceForChange_defaultEnabledChange_createCheckedEntry() {
+        CompatibilityChangeInfo enabledChange = mChanges[0];
+        CompatibilityChangeConfig config = new CompatibilityChangeConfig(
+                new ChangeConfig(new HashSet<Long>(Arrays.asList(enabledChange.getId())),
+                        new HashSet<Long>()));
+
+        Preference enabledPreference = mDashboard.createPreferenceForChange(mContext, enabledChange,
+                config);
+
+        SwitchPreference enabledSwitchPreference = (SwitchPreference) enabledPreference;
+
+        assertThat(enabledPreference.getSummary()).isEqualTo(mChanges[0].getName());
+        assertThat(enabledPreference instanceof SwitchPreference).isTrue();
+        assertThat(enabledSwitchPreference.isChecked()).isTrue();
+    }
+
+    @Test
+    public void createPreferenceForChange_defaultDisabledChange_createUncheckedEntry() {
+        CompatibilityChangeInfo disabledChange = mChanges[1];
+        CompatibilityChangeConfig config = new CompatibilityChangeConfig(
+                new ChangeConfig(new HashSet<Long>(),
+                        new HashSet<Long>(Arrays.asList(disabledChange.getId()))));
+
+        Preference disabledPreference = mDashboard.createPreferenceForChange(mContext,
+                disabledChange, config);
+        
+        assertThat(disabledPreference.getSummary()).isEqualTo(mChanges[1].getName());
+        SwitchPreference disabledSwitchPreference = (SwitchPreference) disabledPreference;
+        assertThat(disabledSwitchPreference.isChecked()).isFalse();
+    }
+
+    @Test
+    public void createChangeCategoryPreference_enabledAndDisabled_hasTitleAndEntries() {
+        Set<Long> enabledChanges = new HashSet<>();
+        enabledChanges.add(mChanges[0].getId());
+        enabledChanges.add(mChanges[1].getId());
+        enabledChanges.add(mChanges[2].getId());
+        Set<Long> disabledChanges = new HashSet<>();
+        disabledChanges.add(mChanges[3].getId());
+        disabledChanges.add(mChanges[4].getId());
+        CompatibilityChangeConfig config = new CompatibilityChangeConfig(
+                new ChangeConfig(enabledChanges, disabledChanges));
+        List<CompatibilityChangeInfo> changesToAdd = new ArrayList<>();
+        for (int i = 0; i < mChanges.length; ++i) {
+            changesToAdd.add(new CompatibilityChangeInfo(mChanges[i].getId(), mChanges[i]
+            .getName(),
+                    mChanges[i].getEnableAfterTargetSdk(), mChanges[i].getDisabled()));
+        }
+
+        PreferenceCategory category = mDashboard.createChangeCategoryPreference(changesToAdd,
+        config, "foo");
+
+        assertThat(category.getTitle()).isEqualTo("foo");
+        assertThat(category.getPreferenceCount()).isEqualTo(mChanges.length);
+        for (int i = 0; i < mChanges.length; ++i) {
+            Preference childPreference = category.getPreference(i);
+            assertThat(childPreference instanceof SwitchPreference).isTrue();
+        }
+    }
+}
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
index e64d015..d523866 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettings2Test.java
@@ -50,7 +50,6 @@
 import com.android.wifitrackerlib.WifiPickerTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -241,9 +240,9 @@
     }
 
     @Test
-    @Ignore
     public void onCreateAdapter_hasStableIdsTrue() {
         final PreferenceScreen preferenceScreen = mock(PreferenceScreen.class);
+        when(preferenceScreen.getContext()).thenReturn(mContext);
 
         RecyclerView.Adapter adapter = mWifiSettings2.onCreateAdapter(preferenceScreen);
 
diff --git a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
index ee14ca5..2fe7c5c 100644
--- a/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/WifiSettingsTest.java
@@ -57,7 +57,6 @@
 import com.android.settingslib.wifi.WifiTracker;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
@@ -296,9 +295,9 @@
     }
 
     @Test
-    @Ignore
     public void onCreateAdapter_hasStableIdsTrue() {
         final PreferenceScreen preferenceScreen = mock(PreferenceScreen.class);
+        when(preferenceScreen.getContext()).thenReturn(mContext);
 
         RecyclerView.Adapter adapter = mWifiSettings.onCreateAdapter(preferenceScreen);
 
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
index f0ac336..b990846 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiDetailPreferenceControllerTest.java
@@ -22,6 +22,7 @@
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
@@ -81,7 +82,6 @@
 import com.android.settingslib.wifi.WifiTrackerFactory;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
@@ -1859,18 +1859,17 @@
     }
 
     @Test
-    @Ignore
     public void entityHeader_expiredPasspointR1_shouldHandleExpiration() {
-        setUpForDisconnectedNetwork();
         when(mockAccessPoint.isPasspoint()).thenReturn(true);
         when(mockAccessPoint.isPasspointConfigurationR1()).thenReturn(true);
         when(mockAccessPoint.isExpired()).thenReturn(true);
+        setUpForDisconnectedNetwork();
         String expireSummary = mContext.getResources().getString(
                 com.android.settingslib.R.string.wifi_passpoint_expired);
 
         displayAndResume();
 
-        verify(mockButtonsPref).setButton3Visible(false);
+        verify(mockButtonsPref, atLeastOnce()).setButton3Visible(false);
         verify(mockHeaderController).setSummary(expireSummary);
     }
 
diff --git a/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java b/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
index 8d15224..5b125e9 100644
--- a/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
+++ b/tests/robotests/src/com/android/settings/wifi/details2/WifiDetailPreferenceController2Test.java
@@ -22,6 +22,7 @@
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.ArgumentMatchers.nullable;
+import static org.mockito.Mockito.atLeastOnce;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
@@ -81,7 +82,6 @@
 import com.android.settingslib.wifi.WifiTrackerFactory;
 
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Answers;
@@ -1859,18 +1859,17 @@
     }
 
     @Test
-    @Ignore
     public void entityHeader_expiredPasspointR1_shouldHandleExpiration() {
-        setUpForDisconnectedNetwork();
         when(mMockAccessPoint.isPasspoint()).thenReturn(true);
         when(mMockAccessPoint.isPasspointConfigurationR1()).thenReturn(true);
         when(mMockAccessPoint.isExpired()).thenReturn(true);
+        setUpForDisconnectedNetwork();
         String expireSummary = mContext.getResources().getString(
                 com.android.settingslib.R.string.wifi_passpoint_expired);
 
         displayAndResume();
 
-        verify(mMockButtonsPref).setButton3Visible(false);
+        verify(mMockButtonsPref, atLeastOnce()).setButton3Visible(false);
         verify(mMockHeaderController).setSummary(expireSummary);
     }