use of com.android.internal.compat.CompatibilityChangeInfo in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboardTest method createPreferenceForChange_defaultEnabledChange_createCheckedEntry.
@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();
assertThat(enabledSwitchPreference.isEnabled()).isTrue();
}
use of com.android.internal.compat.CompatibilityChangeInfo in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboardTest method createPreferenceForChange_defaultDisabledChange_createUncheckedEntry.
@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();
assertThat(disabledSwitchPreference.isEnabled()).isTrue();
}
use of com.android.internal.compat.CompatibilityChangeInfo in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboard method addChangePreferencesToCategory.
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);
}
}
use of com.android.internal.compat.CompatibilityChangeInfo in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboard method addPreferences.
private void addPreferences(ApplicationInfo applicationInfo) {
getPreferenceScreen().removeAll();
getPreferenceScreen().addPreference(createAppPreference(applicationInfo));
// 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.getEnableSinceTargetSdk() > 0) {
List<CompatibilityChangeInfo> sdkChanges;
if (!targetSdkChanges.containsKey(change.getEnableSinceTargetSdk())) {
sdkChanges = new ArrayList<>();
targetSdkChanges.put(change.getEnableSinceTargetSdk(), sdkChanges);
} else {
sdkChanges = targetSdkChanges.get(change.getEnableSinceTargetSdk());
}
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));
}
}
use of com.android.internal.compat.CompatibilityChangeInfo in project android_packages_apps_Settings by omnirom.
the class PlatformCompatDashboardTest method setUp.
@Before
public void setUp() throws RemoteException, NameNotFoundException {
MockitoAnnotations.initMocks(this);
mChanges = new CompatibilityChangeInfo[5];
mChanges[0] = new CompatibilityChangeInfo(1L, "Default_Enabled", 0, 0, false, false, "", false);
mChanges[1] = new CompatibilityChangeInfo(2L, "Default_Disabled", 0, 0, true, false, "", false);
mChanges[2] = new CompatibilityChangeInfo(3L, "Enabled_Since_SDK_1_1", -1, 1, false, false, "", false);
mChanges[3] = new CompatibilityChangeInfo(4L, "Enabled_Since_SDK_1_2", -1, 1, false, false, "", false);
mChanges[4] = new CompatibilityChangeInfo(5L, "Enabled_Since_SDK_2", -1, 2, false, false, "", false);
when(mPlatformCompat.listUIChanges()).thenReturn(mChanges);
when(mPlatformCompat.getOverrideValidator()).thenReturn(mOverrideValidator);
// By default, allow any change
when(mOverrideValidator.getOverrideAllowedState(anyLong(), anyString())).thenReturn(new OverrideAllowedState(ALLOWED, -1, -1));
mContext = spy(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(mContext).when(mDashboard).getContext();
doReturn(mPlatformCompat).when(mDashboard).getPlatformCompat();
doReturn(mPreferenceScreen).when(mDashboard).getPreferenceScreen();
doReturn(mPreferenceManager).when(mDashboard).getPreferenceManager();
doReturn(mPackageManager).when(mContext).getPackageManager();
}
Aggregations