Search in sources :

Example 1 with OverrideAllowedState

use of com.android.internal.compat.OverrideAllowedState 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();
}
Also used : OverrideAllowedState(com.android.internal.compat.OverrideAllowedState) PreferenceManager(androidx.preference.PreferenceManager) CompatibilityChangeInfo(com.android.internal.compat.CompatibilityChangeInfo) Before(org.junit.Before)

Example 2 with OverrideAllowedState

use of com.android.internal.compat.OverrideAllowedState in project android_packages_apps_Settings by omnirom.

the class PlatformCompatDashboardTest method createPreferenceForChange_cannotOverride_createDisabledEntry.

@Test
public void createPreferenceForChange_cannotOverride_createDisabledEntry() throws RemoteException {
    CompatibilityChangeInfo enabledChange = mChanges[0];
    CompatibilityChangeConfig config = new CompatibilityChangeConfig(new ChangeConfig(new HashSet<Long>(Arrays.asList(enabledChange.getId())), new HashSet<Long>()));
    when(mOverrideValidator.getOverrideAllowedState(anyLong(), anyString())).thenReturn(new OverrideAllowedState(DISABLED_NOT_DEBUGGABLE, -1, -1));
    Preference preference = mDashboard.createPreferenceForChange(mContext, enabledChange, config);
    SwitchPreference switchPreference = (SwitchPreference) preference;
    assertThat(preference.getSummary()).isEqualTo(mChanges[0].getName());
    assertThat(preference instanceof SwitchPreference).isTrue();
    assertThat(switchPreference.isChecked()).isTrue();
    assertThat(switchPreference.isEnabled()).isFalse();
}
Also used : OverrideAllowedState(com.android.internal.compat.OverrideAllowedState) SwitchPreference(androidx.preference.SwitchPreference) Preference(androidx.preference.Preference) SwitchPreference(androidx.preference.SwitchPreference) ChangeConfig(android.compat.Compatibility.ChangeConfig) CompatibilityChangeConfig(com.android.internal.compat.CompatibilityChangeConfig) CompatibilityChangeConfig(com.android.internal.compat.CompatibilityChangeConfig) CompatibilityChangeInfo(com.android.internal.compat.CompatibilityChangeInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

CompatibilityChangeInfo (com.android.internal.compat.CompatibilityChangeInfo)2 OverrideAllowedState (com.android.internal.compat.OverrideAllowedState)2 ChangeConfig (android.compat.Compatibility.ChangeConfig)1 Preference (androidx.preference.Preference)1 PreferenceManager (androidx.preference.PreferenceManager)1 SwitchPreference (androidx.preference.SwitchPreference)1 CompatibilityChangeConfig (com.android.internal.compat.CompatibilityChangeConfig)1 HashSet (java.util.HashSet)1 Before (org.junit.Before)1 Test (org.junit.Test)1