Reland add FeatureProvider for SyncAcrossDevices Settings integration.
Prior CL ag/26930404 was reverted because an unused class was trimmed in AOSP, causing test cases to throw NoClassDefFoundError exceptions. This CL combines ag/26930404 and ag/26995936 to address the failure. Bug: 330498032 Test: atest FakeFeatureFactory, atest SyncAcrossDevicesPreferenceControllerTest Change-Id: I0a7ebccdebcad20e06d7542d7c4a0005885f393b
This commit is contained in:
@@ -13182,4 +13182,7 @@
|
|||||||
|
|
||||||
<!-- Provider Model: summary of converted in SIM category. [CHAR LIMIT=50] -->
|
<!-- Provider Model: summary of converted in SIM category. [CHAR LIMIT=50] -->
|
||||||
<string name="sim_category_converted_sim">Converted to eSIM. Remove and discard.</string>
|
<string name="sim_category_converted_sim">Converted to eSIM. Remove and discard.</string>
|
||||||
|
|
||||||
|
<!--Title for Sync Across Devices category-->
|
||||||
|
<string name="sync_across_devices_title">Sync across devices</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -108,6 +108,11 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="sync_across_devices"
|
||||||
|
android:title="@string/sync_across_devices_title"
|
||||||
|
settings:controller="com.android.settings.notification.syncacrossdevices.SyncAcrossDevicesPreferenceController"/>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="advanced_section_header"
|
android:key="advanced_section_header"
|
||||||
android:title="@string/advanced_section_header">
|
android:title="@string/advanced_section_header">
|
||||||
|
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.notification.syncacrossdevices;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
/** Callback to add or remove {@link Preference} in Sync Across Devices feature. */
|
||||||
|
public interface SyncAcrossDevicesFeatureCallback {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a sync across devices feature is added
|
||||||
|
*
|
||||||
|
* @param preference present the feature
|
||||||
|
*/
|
||||||
|
void onFeatureAdded(@Nullable Preference preference);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a sync across devices feature is removed
|
||||||
|
*
|
||||||
|
* @param preference present the feature
|
||||||
|
*/
|
||||||
|
void onFeatureRemoved(@Nullable Preference preference);
|
||||||
|
}
|
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.notification.syncacrossdevices;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
/** Feature provider for the Sync Across Devices. */
|
||||||
|
public interface SyncAcrossDevicesFeatureProvider {
|
||||||
|
|
||||||
|
/** Returns the SyncAcrossDevicesFeatureUpdater of the Sync Across Devices feature */
|
||||||
|
@Nullable
|
||||||
|
SyncAcrossDevicesFeatureUpdater getSyncAcrossDevicesFeatureUpdater(
|
||||||
|
@NonNull Context context,
|
||||||
|
@NonNull SyncAcrossDevicesFeatureCallback featurePreferenceCallback);
|
||||||
|
}
|
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.notification.syncacrossdevices;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
/** Default implementation for {@link SyncAcrossDevicesFeatureProvider} */
|
||||||
|
public class SyncAcrossDevicesFeatureProviderImpl implements SyncAcrossDevicesFeatureProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public SyncAcrossDevicesFeatureUpdater getSyncAcrossDevicesFeatureUpdater(
|
||||||
|
@NonNull Context context,
|
||||||
|
@NonNull SyncAcrossDevicesFeatureCallback featurePreferenceCallback) {
|
||||||
|
return new SyncAcrossDevicesFeatureUpdater() {};
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.notification.syncacrossdevices;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the sync across devices feature state. It notifies the upper level whether to add/remove
|
||||||
|
* the preference through {@link SyncAcrossDevicesFeatureCallback}
|
||||||
|
*/
|
||||||
|
public interface SyncAcrossDevicesFeatureUpdater {
|
||||||
|
|
||||||
|
/** Forces to update the list of the Sync Across Devices feature. */
|
||||||
|
default void forceUpdate() {}
|
||||||
|
|
||||||
|
/** Sets the context to generate the {@link Preference}, so it could get the correct theme. */
|
||||||
|
default void setPreferenceContext(@Nullable Context preferenceContext) {}
|
||||||
|
}
|
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.notification.syncacrossdevices;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceGroup;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.core.BasePreferenceController;
|
||||||
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
|
|
||||||
|
public class SyncAcrossDevicesPreferenceController extends BasePreferenceController
|
||||||
|
implements PreferenceControllerMixin, SyncAcrossDevicesFeatureCallback {
|
||||||
|
|
||||||
|
private static final String TAG = "SyncXDevicesPrefCtr";
|
||||||
|
|
||||||
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
|
private PreferenceGroup mPreferenceGroup;
|
||||||
|
private SyncAcrossDevicesFeatureUpdater mSyncAcrossDevicesFeatureUpdater;
|
||||||
|
|
||||||
|
public SyncAcrossDevicesPreferenceController(@NonNull Context context, @NonNull String key) {
|
||||||
|
super(context, key);
|
||||||
|
SyncAcrossDevicesFeatureProvider syncAcrossDevicesFeatureProvider =
|
||||||
|
FeatureFactory.getFeatureFactory().getSyncAcrossDevicesFeatureProvider();
|
||||||
|
mSyncAcrossDevicesFeatureUpdater =
|
||||||
|
syncAcrossDevicesFeatureProvider.getSyncAcrossDevicesFeatureUpdater(context, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||||
|
super.displayPreference(screen);
|
||||||
|
mPreferenceGroup = screen.findPreference(getPreferenceKey());
|
||||||
|
mPreferenceGroup.setVisible(false);
|
||||||
|
if (isAvailable()) {
|
||||||
|
final Context context = screen.getContext();
|
||||||
|
mSyncAcrossDevicesFeatureUpdater.setPreferenceContext(context);
|
||||||
|
mSyncAcrossDevicesFeatureUpdater.forceUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAvailabilityStatus() {
|
||||||
|
return mSyncAcrossDevicesFeatureUpdater != null ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFeatureAdded(@Nullable Preference preference) {
|
||||||
|
if (preference == null) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "onFeatureAdded receives null preference. Ignore.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mPreferenceGroup.addPreference(preference);
|
||||||
|
updatePreferenceVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFeatureRemoved(@Nullable Preference preference) {
|
||||||
|
if (preference == null) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "onFeatureRemoved receives null preference. Ignore.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mPreferenceGroup.removePreference(preference);
|
||||||
|
updatePreferenceVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePreferenceVisibility() {
|
||||||
|
mPreferenceGroup.setVisible(mPreferenceGroup.getPreferenceCount() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public void setPreferenceGroup(@NonNull PreferenceGroup preferenceGroup) {
|
||||||
|
mPreferenceGroup = preferenceGroup;
|
||||||
|
}
|
||||||
|
}
|
@@ -38,6 +38,7 @@ import com.android.settings.fuelgauge.PowerUsageFeatureProvider
|
|||||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider
|
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider
|
||||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
||||||
import com.android.settings.localepicker.LocaleFeatureProvider
|
import com.android.settings.localepicker.LocaleFeatureProvider
|
||||||
|
import com.android.settings.notification.syncacrossdevices.SyncAcrossDevicesFeatureProvider
|
||||||
import com.android.settings.onboarding.OnboardingFeatureProvider
|
import com.android.settings.onboarding.OnboardingFeatureProvider
|
||||||
import com.android.settings.overlay.FeatureFactory.Companion.setFactory
|
import com.android.settings.overlay.FeatureFactory.Companion.setFactory
|
||||||
import com.android.settings.panel.PanelFeatureProvider
|
import com.android.settings.panel.PanelFeatureProvider
|
||||||
@@ -188,6 +189,11 @@ abstract class FeatureFactory {
|
|||||||
*/
|
*/
|
||||||
abstract val audioSharingFeatureProvider: AudioSharingFeatureProvider
|
abstract val audioSharingFeatureProvider: AudioSharingFeatureProvider
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets implementation for sync across devices related feature.
|
||||||
|
*/
|
||||||
|
abstract val syncAcrossDevicesFeatureProvider: SyncAcrossDevicesFeatureProvider
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var _factory: FeatureFactory? = null
|
private var _factory: FeatureFactory? = null
|
||||||
|
|
||||||
|
@@ -55,6 +55,8 @@ import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvid
|
|||||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
||||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProviderImpl
|
import com.android.settings.inputmethod.KeyboardSettingsFeatureProviderImpl
|
||||||
import com.android.settings.localepicker.LocaleFeatureProviderImpl
|
import com.android.settings.localepicker.LocaleFeatureProviderImpl
|
||||||
|
import com.android.settings.notification.syncacrossdevices.SyncAcrossDevicesFeatureProvider
|
||||||
|
import com.android.settings.notification.syncacrossdevices.SyncAcrossDevicesFeatureProviderImpl
|
||||||
import com.android.settings.panel.PanelFeatureProviderImpl
|
import com.android.settings.panel.PanelFeatureProviderImpl
|
||||||
import com.android.settings.search.SearchFeatureProvider
|
import com.android.settings.search.SearchFeatureProvider
|
||||||
import com.android.settings.search.SearchFeatureProviderImpl
|
import com.android.settings.search.SearchFeatureProviderImpl
|
||||||
@@ -197,4 +199,8 @@ open class FeatureFactoryImpl : FeatureFactory() {
|
|||||||
override val audioSharingFeatureProvider: AudioSharingFeatureProvider by lazy {
|
override val audioSharingFeatureProvider: AudioSharingFeatureProvider by lazy {
|
||||||
AudioSharingFeatureProviderImpl()
|
AudioSharingFeatureProviderImpl()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val syncAcrossDevicesFeatureProvider: SyncAcrossDevicesFeatureProvider by lazy {
|
||||||
|
SyncAcrossDevicesFeatureProviderImpl()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2024 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.notification.syncacrossdevices;
|
||||||
|
|
||||||
|
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||||
|
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||||
|
|
||||||
|
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.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.preference.Preference;
|
||||||
|
import androidx.preference.PreferenceCategory;
|
||||||
|
import androidx.preference.PreferenceGroup;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.MockitoJUnit;
|
||||||
|
import org.mockito.junit.MockitoRule;
|
||||||
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner.class)
|
||||||
|
public class SyncAcrossDevicesPreferenceControllerTest {
|
||||||
|
|
||||||
|
@Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
|
||||||
|
@Mock private SyncAcrossDevicesFeatureUpdater mSyncAcrossDevicesFeatureUpdater;
|
||||||
|
@Mock private PreferenceManager mPreferenceManager;
|
||||||
|
|
||||||
|
private static final String PREFERENCE_KEY = "preference_key";
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
private SyncAcrossDevicesPreferenceController mSyncAcrossDevicesPreferenceController;
|
||||||
|
private PreferenceGroup mPreferenceGroup;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
SyncAcrossDevicesFeatureProvider provider =
|
||||||
|
FakeFeatureFactory.setupForTest().getSyncAcrossDevicesFeatureProvider();
|
||||||
|
doReturn(mSyncAcrossDevicesFeatureUpdater)
|
||||||
|
.when(provider)
|
||||||
|
.getSyncAcrossDevicesFeatureUpdater(any(), any());
|
||||||
|
|
||||||
|
mSyncAcrossDevicesPreferenceController =
|
||||||
|
new SyncAcrossDevicesPreferenceController(mContext, PREFERENCE_KEY);
|
||||||
|
|
||||||
|
mPreferenceGroup = spy(new PreferenceCategory(mContext));
|
||||||
|
doReturn(mPreferenceManager).when(mPreferenceGroup).getPreferenceManager();
|
||||||
|
mPreferenceGroup.setVisible(false);
|
||||||
|
|
||||||
|
mPreferenceGroup.setKey(mSyncAcrossDevicesPreferenceController.getPreferenceKey());
|
||||||
|
mSyncAcrossDevicesPreferenceController.setPreferenceGroup(mPreferenceGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAvailabilityStatus_noFeatureUpdater_returnUnSupported() {
|
||||||
|
SyncAcrossDevicesFeatureProvider provider =
|
||||||
|
FakeFeatureFactory.setupForTest().getSyncAcrossDevicesFeatureProvider();
|
||||||
|
doReturn(null).when(provider).getSyncAcrossDevicesFeatureUpdater(any(), any());
|
||||||
|
|
||||||
|
SyncAcrossDevicesPreferenceController syncAcrossDevicesPreferenceController =
|
||||||
|
new SyncAcrossDevicesPreferenceController(mContext, PREFERENCE_KEY);
|
||||||
|
|
||||||
|
assertThat(syncAcrossDevicesPreferenceController.getAvailabilityStatus())
|
||||||
|
.isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAvailabilityStatus_withFeatureUpdater_returnSupported() {
|
||||||
|
assertThat(mSyncAcrossDevicesPreferenceController.getAvailabilityStatus())
|
||||||
|
.isEqualTo(AVAILABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePreferenceVisibility_addFeaturePreference_shouldShowPreference() {
|
||||||
|
Preference preference = new Preference(mContext);
|
||||||
|
|
||||||
|
mSyncAcrossDevicesPreferenceController.onFeatureAdded(preference);
|
||||||
|
|
||||||
|
assertThat(mPreferenceGroup.isVisible()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePreferenceVisibility_removeFeaturePreference_shouldHidePreference() {
|
||||||
|
Preference preference = new Preference(mContext);
|
||||||
|
|
||||||
|
mSyncAcrossDevicesPreferenceController.onFeatureAdded(preference);
|
||||||
|
mSyncAcrossDevicesPreferenceController.onFeatureRemoved(preference);
|
||||||
|
|
||||||
|
assertThat(mPreferenceGroup.isVisible()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDisplayPreference_availabilityStatusIsAvailable_shouldForceUpdated() {
|
||||||
|
PreferenceManager preferenceManager = new PreferenceManager(mContext);
|
||||||
|
PreferenceScreen preferenceScreen = preferenceManager.createPreferenceScreen(mContext);
|
||||||
|
preferenceScreen.addPreference(mPreferenceGroup);
|
||||||
|
|
||||||
|
mSyncAcrossDevicesPreferenceController.displayPreference(preferenceScreen);
|
||||||
|
|
||||||
|
verify(mSyncAcrossDevicesFeatureUpdater, times(1)).setPreferenceContext(any());
|
||||||
|
verify(mSyncAcrossDevicesFeatureUpdater, times(1)).forceUpdate();
|
||||||
|
}
|
||||||
|
}
|
@@ -40,6 +40,7 @@ import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
|||||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
|
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
|
||||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider;
|
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider;
|
||||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||||
|
import com.android.settings.notification.syncacrossdevices.SyncAcrossDevicesFeatureProvider;
|
||||||
import com.android.settings.onboarding.OnboardingFeatureProvider;
|
import com.android.settings.onboarding.OnboardingFeatureProvider;
|
||||||
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
@@ -103,6 +104,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
|
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
|
||||||
public DisplayFeatureProvider mDisplayFeatureProvider;
|
public DisplayFeatureProvider mDisplayFeatureProvider;
|
||||||
public AudioSharingFeatureProvider mAudioSharingFeatureProvider;
|
public AudioSharingFeatureProvider mAudioSharingFeatureProvider;
|
||||||
|
public SyncAcrossDevicesFeatureProvider mSyncAcrossDevicesFeatureProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this in {@code @Before} method of the test class to use fake factory.
|
* Call this in {@code @Before} method of the test class to use fake factory.
|
||||||
@@ -150,9 +152,10 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
mStylusFeatureProvider = mock(StylusFeatureProvider.class);
|
mStylusFeatureProvider = mock(StylusFeatureProvider.class);
|
||||||
mOnboardingFeatureProvider = mock(OnboardingFeatureProvider.class);
|
mOnboardingFeatureProvider = mock(OnboardingFeatureProvider.class);
|
||||||
mFastPairFeatureProvider = mock(FastPairFeatureProvider.class);
|
mFastPairFeatureProvider = mock(FastPairFeatureProvider.class);
|
||||||
mPrivateSpaceLoginFeatureProvider = mock(PrivateSpaceLoginFeatureProvider.class);
|
mPrivateSpaceLoginFeatureProvider = mock(PrivateSpaceLoginFeatureProvider.class);
|
||||||
mDisplayFeatureProvider = mock(DisplayFeatureProvider.class);
|
mDisplayFeatureProvider = mock(DisplayFeatureProvider.class);
|
||||||
mAudioSharingFeatureProvider = mock(AudioSharingFeatureProvider.class);
|
mAudioSharingFeatureProvider = mock(AudioSharingFeatureProvider.class);
|
||||||
|
mSyncAcrossDevicesFeatureProvider = mock(SyncAcrossDevicesFeatureProvider.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -340,5 +343,10 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
public AudioSharingFeatureProvider getAudioSharingFeatureProvider() {
|
public AudioSharingFeatureProvider getAudioSharingFeatureProvider() {
|
||||||
return mAudioSharingFeatureProvider;
|
return mAudioSharingFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SyncAcrossDevicesFeatureProvider getSyncAcrossDevicesFeatureProvider() {
|
||||||
|
return mSyncAcrossDevicesFeatureProvider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@ import com.android.settings.fuelgauge.PowerUsageFeatureProvider
|
|||||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider
|
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider
|
||||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider
|
||||||
import com.android.settings.localepicker.LocaleFeatureProvider
|
import com.android.settings.localepicker.LocaleFeatureProvider
|
||||||
|
import com.android.settings.notification.syncacrossdevices.SyncAcrossDevicesFeatureProvider
|
||||||
import com.android.settings.overlay.DockUpdaterFeatureProvider
|
import com.android.settings.overlay.DockUpdaterFeatureProvider
|
||||||
import com.android.settings.overlay.FeatureFactory
|
import com.android.settings.overlay.FeatureFactory
|
||||||
import com.android.settings.overlay.SurveyFeatureProvider
|
import com.android.settings.overlay.SurveyFeatureProvider
|
||||||
@@ -152,4 +153,6 @@ class FakeFeatureFactory : FeatureFactory() {
|
|||||||
get() = TODO("Not yet implemented")
|
get() = TODO("Not yet implemented")
|
||||||
override val audioSharingFeatureProvider: AudioSharingFeatureProvider
|
override val audioSharingFeatureProvider: AudioSharingFeatureProvider
|
||||||
get() = TODO("Not yet implemented")
|
get() = TODO("Not yet implemented")
|
||||||
|
override val syncAcrossDevicesFeatureProvider: SyncAcrossDevicesFeatureProvider
|
||||||
|
get() = TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
|
@@ -40,6 +40,7 @@ import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
|||||||
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
|
import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
|
||||||
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider;
|
import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider;
|
||||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||||
|
import com.android.settings.notification.syncacrossdevices.SyncAcrossDevicesFeatureProvider;
|
||||||
import com.android.settings.onboarding.OnboardingFeatureProvider;
|
import com.android.settings.onboarding.OnboardingFeatureProvider;
|
||||||
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
import com.android.settings.overlay.DockUpdaterFeatureProvider;
|
||||||
import com.android.settings.overlay.FeatureFactory;
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
@@ -102,6 +103,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
|
public PrivateSpaceLoginFeatureProvider mPrivateSpaceLoginFeatureProvider;
|
||||||
public DisplayFeatureProvider mDisplayFeatureProvider;
|
public DisplayFeatureProvider mDisplayFeatureProvider;
|
||||||
public AudioSharingFeatureProvider mAudioSharingFeatureProvider;
|
public AudioSharingFeatureProvider mAudioSharingFeatureProvider;
|
||||||
|
public SyncAcrossDevicesFeatureProvider mSyncAcrossDevicesFeatureProvider;
|
||||||
|
|
||||||
/** Call this in {@code @Before} method of the test class to use fake factory. */
|
/** Call this in {@code @Before} method of the test class to use fake factory. */
|
||||||
public static FakeFeatureFactory setupForTest() {
|
public static FakeFeatureFactory setupForTest() {
|
||||||
@@ -154,6 +156,7 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
mPrivateSpaceLoginFeatureProvider = mock(PrivateSpaceLoginFeatureProvider.class);
|
mPrivateSpaceLoginFeatureProvider = mock(PrivateSpaceLoginFeatureProvider.class);
|
||||||
mDisplayFeatureProvider = mock(DisplayFeatureProvider.class);
|
mDisplayFeatureProvider = mock(DisplayFeatureProvider.class);
|
||||||
mAudioSharingFeatureProvider = mock(AudioSharingFeatureProvider.class);
|
mAudioSharingFeatureProvider = mock(AudioSharingFeatureProvider.class);
|
||||||
|
mSyncAcrossDevicesFeatureProvider = mock(SyncAcrossDevicesFeatureProvider.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -341,4 +344,9 @@ public class FakeFeatureFactory extends FeatureFactory {
|
|||||||
public AudioSharingFeatureProvider getAudioSharingFeatureProvider() {
|
public AudioSharingFeatureProvider getAudioSharingFeatureProvider() {
|
||||||
return mAudioSharingFeatureProvider;
|
return mAudioSharingFeatureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SyncAcrossDevicesFeatureProvider getSyncAcrossDevicesFeatureProvider() {
|
||||||
|
return mSyncAcrossDevicesFeatureProvider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user