diff --git a/Android.bp b/Android.bp index 861f95ff784..e3f68e17dc1 100644 --- a/Android.bp +++ b/Android.bp @@ -55,6 +55,7 @@ android_library { ], srcs: ["src/**/*.java", "src/**/*.kt"], + use_resource_processor: true, resource_dirs: [ "res", "res-export", // for external usage @@ -136,6 +137,7 @@ android_app { ], static_libs: ["Settings-core"], uses_libs: ["org.apache.http.legacy"], + use_resource_processor: true, resource_dirs: [], optimize: { proguard_flags_files: ["proguard.flags"], diff --git a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollIntroFragment.kt b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollIntroFragment.kt index 4205225aef9..7b27637c643 100644 --- a/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollIntroFragment.kt +++ b/src/com/android/settings/biometrics2/ui/view/FingerprintEnrollIntroFragment.kt @@ -50,9 +50,9 @@ import com.google.android.setupdesign.template.RequireScrollMixin import com.google.android.setupdesign.util.DeviceHelper import com.google.android.setupdesign.util.DynamicColorPalette import com.google.android.setupdesign.util.DynamicColorPalette.ColorType.ACCENT +import java.util.function.Supplier import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch -import java.util.function.Supplier /** * Fingerprint intro onboarding page fragment implementation @@ -324,6 +324,6 @@ fun FragmentActivity.bindFingerprintEnrollIntroView( ) } - view.findViewById(R.id.sud_scroll_view)?.importantForAccessibility = - View.IMPORTANT_FOR_ACCESSIBILITY_YES + view.findViewById(com.google.android.setupdesign.R.id.sud_scroll_view) + ?.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_YES } diff --git a/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinish.kt b/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinish.kt index c55b4edaafd..98df572c808 100644 --- a/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinish.kt +++ b/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinish.kt @@ -18,12 +18,10 @@ package com.android.settings.remoteauth.finish import android.os.Bundle import android.view.View - +import com.airbnb.lottie.LottieAnimationView import com.android.settings.R import com.android.settings.remoteauth.RemoteAuthEnrollBase import com.android.settingslib.widget.LottieColorUtils - -import com.airbnb.lottie.LottieAnimationView import com.google.android.setupcompat.template.FooterButton /** @@ -45,7 +43,7 @@ class RemoteAuthEnrollFinish : .setText(R.string.security_settings_remoteauth_enroll_finish_btn_next) .setListener(this::onPrimaryFooterButtonClick) .setButtonType(FooterButton.ButtonType.NEXT) - .setTheme(R.style.SudGlifButton_Primary) + .setTheme(com.google.android.setupdesign.R.style.SudGlifButton_Primary) .build() } diff --git a/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroduction.kt b/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroduction.kt index 21b8af21e11..f0de88e19d2 100644 --- a/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroduction.kt +++ b/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroduction.kt @@ -49,7 +49,7 @@ class RemoteAuthEnrollIntroduction : .setText(R.string.security_settings_remoteauth_enroll_introduction_agree) .setListener(::onPrimaryFooterButtonClick) .setButtonType(FooterButton.ButtonType.OPT_IN) - .setTheme(R.style.SudGlifButton_Primary) + .setTheme(com.google.android.setupdesign.R.style.SudGlifButton_Primary) .build() } @@ -58,7 +58,7 @@ class RemoteAuthEnrollIntroduction : .setText(R.string.security_settings_remoteauth_enroll_introduction_disagree) .setListener(::onSecondaryFooterButtonClick) .setButtonType(FooterButton.ButtonType.NEXT) - .setTheme(R.style.SudGlifButton_Primary) + .setTheme(com.google.android.setupdesign.R.style.SudGlifButton_Primary) .build() } diff --git a/src/com/android/settings/search/actionbar/SearchMenuController.java b/src/com/android/settings/search/actionbar/SearchMenuController.java index 98c9c1fed60..8d0c89a5c88 100644 --- a/src/com/android/settings/search/actionbar/SearchMenuController.java +++ b/src/com/android/settings/search/actionbar/SearchMenuController.java @@ -86,8 +86,8 @@ public class SearchMenuController implements LifecycleObserver, OnCreateOptionsM return; } final MenuItem searchItem = menu.add(Menu.NONE, MENU_SEARCH, 0 /* order */, - R.string.search_menu); - searchItem.setIcon(R.drawable.ic_search_24dp); + com.android.settingslib.search.R.string.search_menu); + searchItem.setIcon(com.android.settingslib.search.R.drawable.ic_search_24dp); searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); searchItem.setOnMenuItemClickListener(target -> { diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp index c2b7c6a7875..2bd8721d70e 100644 --- a/tests/robotests/Android.bp +++ b/tests/robotests/Android.bp @@ -1,7 +1,3 @@ - //############################################################ -// Build SettingsRoboTestStub.apk which includes test-only resources.# -//############################################################ - package { // See: http://go/android-license-faq // A large-scale-change added 'default_applicable_licenses' to import @@ -11,6 +7,7 @@ package { default_applicable_licenses: ["packages_apps_Settings_license"], } +// Build SettingsRoboTestStub.apk which includes test-only resources. android_app { name: "SettingsRoboTestStub", defaults: [ @@ -25,33 +22,8 @@ android_app { static_libs: [ "Settings-core", - "androidx-constraintlayout_constraintlayout", - "androidx.slice_slice-builders", - "androidx.slice_slice-core", - "androidx.slice_slice-view", - "androidx.core_core", - "androidx.appcompat_appcompat", - "androidx.cardview_cardview", "androidx.fragment_fragment-testing", - "androidx.preference_preference", - "androidx.recyclerview_recyclerview", - "androidx.window_window", - "com.google.android.material_material", - "setupcompat", - "setupdesign", - "androidx.lifecycle_lifecycle-runtime", - "androidx.test.core", - "androidx.test.runner", - "androidx.test.ext.junit", "frameworks-base-testutils", - "guava", - "jsr305", - "settings-contextual-card-protos-lite", - "settings-log-bridge-protos-lite", - "settings-telephony-protos-lite", - "contextualcards", - "settings-logtags", - "zxing-core-1.7", ], aaptflags: ["--extra-packages com.android.settings"], @@ -67,9 +39,7 @@ android_app { ], } -//############################################################ -// Settings Robolectric test target. # -//############################################################ +// Settings Robolectric test target. android_robolectric_test { name: "SettingsRoboTests", srcs: [ @@ -79,12 +49,12 @@ android_robolectric_test { static_libs: [ "SettingsLib-robo-testutils", - "android-support-annotations", + "Settings-robo-testutils", "androidx.test.core", + "androidx.test.espresso.core", + "androidx.test.ext.junit", "androidx.test.rules", "androidx.test.runner", - "androidx.test.ext.junit", - "androidx.test.espresso.core", ], libs: [ @@ -109,7 +79,7 @@ android_robolectric_test { java_library { name: "Settings-robo-testutils", - srcs: ["src/com/android/settings/testutils/**/*.java"], + srcs: ["testutils/**/*.java"], libs: [ "Settings-core", diff --git a/tests/robotests/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinishTest.kt b/tests/robotests/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinishTest.kt index 7bb5c454b2d..0f9911b3df2 100644 --- a/tests/robotests/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinishTest.kt +++ b/tests/robotests/src/com/android/settings/remoteauth/finish/RemoteAuthEnrollFinishTest.kt @@ -35,21 +35,29 @@ class RemoteAuthEnrollFinishTest { @Test fun testRemoteAuthenticatorEnrollFinish_hasHeader() { - launchFragmentInContainer(Bundle(), R.style.SudThemeGlif) - .onFragment { - assertThat((it.view as GlifLayout).headerText) - .isEqualTo(mContext.getString( - R.string.security_settings_remoteauth_enroll_finish_title)) - } + launchFragmentInContainer( + Bundle(), + com.google.android.setupdesign.R.style.SudThemeGlif, + ).onFragment { + assertThat((it.view as GlifLayout).headerText) + .isEqualTo( + mContext.getString(R.string.security_settings_remoteauth_enroll_finish_title) + ) + } } @Test fun testRemoteAuthenticatorEnrollFinish_hasDescription() { - launchFragmentInContainer(Bundle(), R.style.SudThemeGlif) - .onFragment { - assertThat((it.view as GlifLayout).descriptionText) - .isEqualTo(mContext.getString( - R.string.security_settings_remoteauth_enroll_finish_description)) - } + launchFragmentInContainer( + Bundle(), + com.google.android.setupdesign.R.style.SudThemeGlif, + ).onFragment { + assertThat((it.view as GlifLayout).descriptionText) + .isEqualTo( + mContext.getString( + R.string.security_settings_remoteauth_enroll_finish_description + ) + ) + } } -} \ No newline at end of file +} diff --git a/tests/robotests/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroductionTest.kt b/tests/robotests/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroductionTest.kt index a271184e413..1ca011905db 100644 --- a/tests/robotests/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroductionTest.kt +++ b/tests/robotests/src/com/android/settings/remoteauth/introduction/RemoteAuthEnrollIntroductionTest.kt @@ -30,23 +30,31 @@ import org.robolectric.RobolectricTestRunner @RunWith(RobolectricTestRunner::class) class RemoteAuthEnrollIntroductionTest { - private var mContext : Context = ApplicationProvider.getApplicationContext() + private var mContext: Context = ApplicationProvider.getApplicationContext() @Test fun testRemoteAuthenticatorEnrollIntroduction_hasHeader() { - launchFragmentInContainer(Bundle(), R.style.SudThemeGlif) - .onFragment { - assertThat((it.view as GlifLayout).headerText) - .isEqualTo(mContext.getString(R.string.security_settings_remoteauth_enroll_introduction_title)) - } + launchFragmentInContainer( + Bundle(), + com.google.android.setupdesign.R.style.SudThemeGlif, + ).onFragment { + assertThat((it.view as GlifLayout).headerText) + .isEqualTo(mContext.getString(R.string.security_settings_remoteauth_enroll_introduction_title)) + } } @Test fun testRemoteAuthenticatorEnrollIntroduction_hasDescription() { - launchFragmentInContainer(Bundle(), R.style.SudThemeGlif) - .onFragment { - assertThat((it.view as GlifLayout).descriptionText) - .isEqualTo(mContext.getString(R.string.security_settings_remoteauth_enroll_introduction_message)) - } + launchFragmentInContainer( + Bundle(), + com.google.android.setupdesign.R.style.SudThemeGlif, + ).onFragment { + assertThat((it.view as GlifLayout).descriptionText) + .isEqualTo( + mContext.getString( + R.string.security_settings_remoteauth_enroll_introduction_message + ) + ) + } } -} \ No newline at end of file +} diff --git a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java index eb6ad0cb137..d898e64d682 100644 --- a/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java +++ b/tests/robotests/src/com/android/settings/search/actionbar/SearchMenuControllerTest.java @@ -33,7 +33,6 @@ import android.view.MenuItem; import androidx.fragment.app.FragmentActivity; -import com.android.settings.R; import com.android.settings.core.InstrumentedFragment; import com.android.settings.testutils.shadow.ShadowUtils; @@ -72,7 +71,7 @@ public class SearchMenuControllerTest { when(mHost.getActivity()).thenReturn(mActivity); when(mMenu.add(Menu.NONE, MENU_SEARCH, 0 /* order */, - R.string.search_menu)) + com.android.settingslib.search.R.string.search_menu)) .thenReturn(mock(MenuItem.class)); } @@ -82,7 +81,7 @@ public class SearchMenuControllerTest { mHost.getSettingsLifecycle().onCreateOptionsMenu(mMenu, null /* inflater */); verify(mMenu).add(Menu.NONE, MENU_SEARCH, 0 /* order */, - R.string.search_menu); + com.android.settingslib.search.R.string.search_menu); } @Test diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppInfoBase.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppInfoBase.java deleted file mode 100644 index f8cdb2269a9..00000000000 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppInfoBase.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2017 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.testutils.shadow; - -import com.android.settings.applications.AppInfoBase; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; - -@Implements(AppInfoBase.class) -public class ShadowAppInfoBase { - - @Implementation - protected void onResume() { - // No-op. - } - - @Implementation - protected void onPause() { - // No-op. - } -} diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowApplicationsState.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowApplicationsState.java deleted file mode 100644 index 8239ed9ab83..00000000000 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowApplicationsState.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2018 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.testutils.shadow; - -import android.os.Looper; - -import com.android.settingslib.applications.ApplicationsState; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; - -@Implements(ApplicationsState.class) -public class ShadowApplicationsState { - @Implementation - protected Looper getBackgroundLooper() { - return Looper.getMainLooper(); - } -} diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDataSaverBackend.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDataSaverBackend.java deleted file mode 100644 index 4d1a2ed3044..00000000000 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowDataSaverBackend.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.android.settings.testutils.shadow; - -import com.android.settings.datausage.DataSaverBackend; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; - -@Implements(DataSaverBackend.class) -public class ShadowDataSaverBackend { - - private static boolean isEnabled = true; - - @Implementation - protected boolean isDataSaverEnabled() { - return isEnabled; - } - - @Implementation - protected void setDataSaverEnabled(boolean enabled) { - isEnabled = enabled; - } -} diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowInputManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowInputManager.java deleted file mode 100644 index c0f71342b8c..00000000000 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowInputManager.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016 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.testutils.shadow; - -import static org.robolectric.util.ReflectionHelpers.ClassParameter.from; - -import android.hardware.input.IInputManager; -import android.hardware.input.InputManager; -import android.os.Handler; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; -import org.robolectric.util.ReflectionHelpers; - -import java.util.ArrayList; -import java.util.List; - -/** - * Shadow for {@link InputManager} that has accessors for registered - * {@link InputManager.InputDeviceListener}s. - */ -@Implements(value = InputManager.class, callThroughByDefault = false) -public class ShadowInputManager { - - private List mInputDeviceListeners; - - @Implementation - protected void __constructor__(IInputManager service) { - mInputDeviceListeners = new ArrayList<>(); - } - - @Implementation - protected static InputManager getInstance() { - return ReflectionHelpers.callConstructor( - InputManager.class, - from(IInputManager.class, null)); - } - - @Implementation - protected void registerInputDeviceListener(InputManager.InputDeviceListener listener, - Handler handler) { - // TODO: Use handler. - if (!mInputDeviceListeners.contains(listener)) { - mInputDeviceListeners.add(listener); - } - } - - @Implementation - protected void unregisterInputDeviceListener(InputManager.InputDeviceListener listener) { - mInputDeviceListeners.remove(listener); - } -} diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNetworkDetailsTracker.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNetworkDetailsTracker.java deleted file mode 100644 index 5df9ba52603..00000000000 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowNetworkDetailsTracker.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2020 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.testutils.shadow; - -import static org.mockito.Mockito.mock; - -import android.content.Context; -import android.net.ConnectivityManager; -import android.net.NetworkScoreManager; -import android.net.wifi.WifiManager; -import android.os.Handler; - -import androidx.annotation.NonNull; -import androidx.lifecycle.Lifecycle; - -import com.android.wifitrackerlib.NetworkDetailsTracker; -import com.android.wifitrackerlib.WifiEntry; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; - -import java.time.Clock; - -@Implements(NetworkDetailsTracker.class) -public class ShadowNetworkDetailsTracker { - - @Implementation - public static NetworkDetailsTracker createNetworkDetailsTracker(@NonNull Lifecycle lifecycle, - @NonNull Context context, - @NonNull WifiManager wifiManager, - @NonNull ConnectivityManager connectivityManager, - @NonNull NetworkScoreManager networkScoreManager, - @NonNull Handler mainHandler, - @NonNull Handler workerHandler, - @NonNull Clock clock, - long maxScanAgeMillis, - long scanIntervalMillis, - String key) { - return mock(NetworkDetailsTracker.class); - } - - @Implementation - public WifiEntry getWifiEntry() { - return mock(WifiEntry.class); - } -} diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java deleted file mode 100644 index 6a6f7108388..00000000000 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowPermissionControllerManager.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 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.testutils.shadow; - -import android.annotation.CallbackExecutor; -import android.content.Context; -import android.os.Handler; -import android.permission.PermissionControllerManager; - -import androidx.annotation.NonNull; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; - -import java.util.concurrent.Executor; - -@Implements(PermissionControllerManager.class) -public class ShadowPermissionControllerManager { - - protected void __constructor__(Context contexts, Handler handler) { - // no nothing, everything is shadowed - } - - @Implementation - public void getPermissionUsages(boolean countSystem, long numMillis, - @NonNull @CallbackExecutor Executor executor, - @NonNull PermissionControllerManager.OnPermissionUsageResultCallback callback) { - - // Do nothing - } -} diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java deleted file mode 100644 index ea57bf7e89d..00000000000 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiManager.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2017 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.testutils.shadow; - -import static org.robolectric.RuntimeEnvironment.application; - -import android.net.wifi.ScanResult; -import android.net.wifi.SoftApConfiguration; -import android.net.wifi.WifiConfiguration; -import android.net.wifi.WifiManager; -import android.net.wifi.hotspot2.PasspointConfiguration; - -import org.robolectric.annotation.HiddenApi; -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; -import org.robolectric.shadow.api.Shadow; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Implements(value = WifiManager.class) -public class ShadowWifiManager extends org.robolectric.shadows.ShadowWifiManager { - - private List mPasspointConfiguration; - - public WifiConfiguration savedWifiConfig; - private SoftApConfiguration mSavedApConfig; - - @Implementation - protected SoftApConfiguration getSoftApConfiguration() { - return mSavedApConfig; - } - - @Implementation - protected boolean setSoftApConfiguration(SoftApConfiguration softApConfig) { - mSavedApConfig = softApConfig; - return true; - } - - @HiddenApi // @SystemApi - @Implementation - protected void connect(WifiConfiguration config, WifiManager.ActionListener listener) { - savedWifiConfig = config; - } - - @HiddenApi - @Implementation - protected void save(WifiConfiguration config, WifiManager.ActionListener listener) { - savedWifiConfig = config; - } - - @Implementation - protected List getPasspointConfigurations() { - return mPasspointConfiguration == null ? Collections.emptyList() : mPasspointConfiguration; - } - - @Implementation - protected void addOrUpdatePasspointConfiguration(PasspointConfiguration config) { - if (mPasspointConfiguration == null) { - mPasspointConfiguration = new ArrayList<>(); - } - mPasspointConfiguration.add(config); - } - - @Implementation - protected boolean isDualModeSupported() { - return false; - } - - @Implementation - protected List getScanResults() { - return new ArrayList(); - } - - public static ShadowWifiManager get() { - return Shadow.extract(application.getSystemService(WifiManager.class)); - } -} diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiP2pManager.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiP2pManager.java deleted file mode 100644 index 2fd8f6b5e36..00000000000 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowWifiP2pManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2018 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.testutils.shadow; - -import android.net.wifi.p2p.WifiP2pManager; - -import org.robolectric.annotation.Implementation; -import org.robolectric.annotation.Implements; -import org.robolectric.annotation.Resetter; - -/** - * Shadow class for WifiP2pManager. - */ -@Implements(value = WifiP2pManager.class) -public class ShadowWifiP2pManager extends org.robolectric.shadows.ShadowWifiP2pManager { - - private static int sFactoryResetCount; - - @Implementation - protected void factoryReset(WifiP2pManager.Channel c, WifiP2pManager.ActionListener listener) { - if (c != null) { - sFactoryResetCount++; - } else { - throw new IllegalArgumentException("channel must be non-null."); - } - } - - @Resetter - public static void reset() { - sFactoryResetCount = 0; - } - - /** - * Return the count of factoryReset called. - * - * @return the count of factoryReset called. - */ - public static int getFactoryResetCount() { - return sFactoryResetCount; - } -} diff --git a/tests/robotests/src/com/android/settings/testutils/CustomActivity.java b/tests/robotests/testutils/com/android/settings/testutils/CustomActivity.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/CustomActivity.java rename to tests/robotests/testutils/com/android/settings/testutils/CustomActivity.java diff --git a/tests/robotests/src/com/android/settings/testutils/DatabaseTestUtils.java b/tests/robotests/testutils/com/android/settings/testutils/DatabaseTestUtils.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/DatabaseTestUtils.java rename to tests/robotests/testutils/com/android/settings/testutils/DatabaseTestUtils.java diff --git a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java b/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java similarity index 99% rename from tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java rename to tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java index d586db575e6..c8db62f877c 100644 --- a/tests/robotests/src/com/android/settings/testutils/FakeFeatureFactory.java +++ b/tests/robotests/testutils/com/android/settings/testutils/FakeFeatureFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2023 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. @@ -11,7 +11,7 @@ * 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 + * limitations under the License. */ package com.android.settings.testutils; @@ -23,7 +23,6 @@ import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider; import com.android.settings.accessibility.AccessibilitySearchFeatureProvider; import com.android.settings.accounts.AccountFeatureProvider; import com.android.settings.applications.ApplicationFeatureProvider; -import com.android.settings.onboarding.OnboardingFeatureProvider; import com.android.settings.biometrics.face.FaceFeatureProvider; import com.android.settings.biometrics2.factory.BiometricsRepositoryProvider; import com.android.settings.bluetooth.BluetoothFeatureProvider; @@ -39,6 +38,7 @@ import com.android.settings.fuelgauge.PowerUsageFeatureProvider; import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider; import com.android.settings.inputmethod.KeyboardSettingsFeatureProvider; import com.android.settings.localepicker.LocaleFeatureProvider; +import com.android.settings.onboarding.OnboardingFeatureProvider; import com.android.settings.overlay.DockUpdaterFeatureProvider; import com.android.settings.overlay.FeatureFactory; import com.android.settings.overlay.SupportFeatureProvider; diff --git a/tests/robotests/src/com/android/settings/testutils/ResolveInfoBuilder.java b/tests/robotests/testutils/com/android/settings/testutils/ResolveInfoBuilder.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/ResolveInfoBuilder.java rename to tests/robotests/testutils/com/android/settings/testutils/ResolveInfoBuilder.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/SettingsShadowResources.java similarity index 82% rename from tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/SettingsShadowResources.java index 8ca577c00e2..b2d5484dcb2 100644 --- a/tests/robotests/src/com/android/settings/testutils/shadow/SettingsShadowResources.java +++ b/tests/robotests/testutils/com/android/settings/testutils/shadow/SettingsShadowResources.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2023 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.testutils.shadow; import static org.robolectric.RuntimeEnvironment.application; diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityServiceInfo.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowAccessibilityServiceInfo.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessibilityServiceInfo.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowAccessibilityServiceInfo.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowActivity.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowActivity.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowActivity.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowActivity.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowActivityEmbeddingUtils.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowActivityEmbeddingUtils.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowActivityEmbeddingUtils.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowActivityEmbeddingUtils.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java similarity index 82% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java index e595cb6948b..d6d17f864c2 100644 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java +++ b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowAlertDialogCompat.java @@ -38,39 +38,40 @@ public class ShadowAlertDialogCompat extends ShadowDialog { @SuppressLint("StaticFieldLeak") @Nullable - private static ShadowAlertDialogCompat latestSupportAlertDialog; + private static ShadowAlertDialogCompat sLatestSupportAlertDialog; @RealObject - private AlertDialog realAlertDialog; + private AlertDialog mRealAlertDialog; @Implementation public void show() { super.show(); - latestSupportAlertDialog = this; + sLatestSupportAlertDialog = this; } public CharSequence getMessage() { - final Object alertController = ReflectionHelpers.getField(realAlertDialog, "mAlert"); + final Object alertController = ReflectionHelpers.getField(mRealAlertDialog, "mAlert"); return ReflectionHelpers.getField(alertController, "mMessage"); } public CharSequence getTitle() { - final Object alertController = ReflectionHelpers.getField(realAlertDialog, "mAlert"); + final Object alertController = ReflectionHelpers.getField(mRealAlertDialog, "mAlert"); return ReflectionHelpers.getField(alertController, "mTitle"); } public View getView() { - final Object alertController = ReflectionHelpers.getField(realAlertDialog, "mAlert"); + final Object alertController = ReflectionHelpers.getField(mRealAlertDialog, "mAlert"); return ReflectionHelpers.getField(alertController, "mView"); } @Nullable public static AlertDialog getLatestAlertDialog() { - return latestSupportAlertDialog == null ? null : latestSupportAlertDialog.realAlertDialog; + return sLatestSupportAlertDialog == null + ? null : sLatestSupportAlertDialog.mRealAlertDialog; } @Resetter public static void reset() { - latestSupportAlertDialog = null; + sLatestSupportAlertDialog = null; } public static ShadowAlertDialogCompat shadowOf(AlertDialog alertDialog) { @@ -78,6 +79,6 @@ public class ShadowAlertDialogCompat extends ShadowDialog { } public void clickOnItem(int index) { - Shadows.shadowOf(realAlertDialog.getListView()).performItemClick(index); + Shadows.shadowOf(mRealAlertDialog.getListView()).performItemClick(index); } -} \ No newline at end of file +} diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowBluetoothAdapter.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowConnectivityManager.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowConnectivityManager.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowConnectivityManager.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessPoint.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowDataSaverBackend.java similarity index 63% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessPoint.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowDataSaverBackend.java index 7d206f45047..f97a70e5997 100644 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAccessPoint.java +++ b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowDataSaverBackend.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 The Android Open Source Project + * Copyright (C) 2023 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. @@ -16,16 +16,23 @@ package com.android.settings.testutils.shadow; -import com.android.settingslib.wifi.AccessPoint; +import com.android.settings.datausage.DataSaverBackend; import org.robolectric.annotation.Implementation; import org.robolectric.annotation.Implements; -@Implements(AccessPoint.class) -public class ShadowAccessPoint { +@Implements(DataSaverBackend.class) +public class ShadowDataSaverBackend { + + private static boolean sIsEnabled = true; @Implementation - protected String getSavedNetworkSummary() { - return "saved"; + protected boolean isDataSaverEnabled() { + return sIsEnabled; + } + + @Implementation + protected void setDataSaverEnabled(boolean enabled) { + sIsEnabled = enabled; } } diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowFragment.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowFragment.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowFragment.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowFragment.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowInteractionJankMonitor.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowInteractionJankMonitor.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowInteractionJankMonitor.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowInteractionJankMonitor.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java similarity index 94% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java index 9afcd37e08f..d0bb2bf24a2 100644 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java +++ b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowLockPatternUtils.java @@ -114,8 +114,8 @@ public class ShadowLockPatternUtils { } @Implementation - protected byte[] getPasswordHistoryHashFactor(LockscreenCredential currentPassword, - int userId) { + protected byte[] getPasswordHistoryHashFactor( + LockscreenCredential currentPassword, int userId) { return null; } @@ -130,8 +130,8 @@ public class ShadowLockPatternUtils { } @Implementation - public @DevicePolicyManager.PasswordComplexity int getRequestedPasswordComplexity(int userId, - boolean deviceWideOnly) { + @DevicePolicyManager.PasswordComplexity + public int getRequestedPasswordComplexity(int userId, boolean deviceWideOnly) { int complexity = sUserToComplexityMap.getOrDefault(userId, DevicePolicyManager.PASSWORD_COMPLEXITY_NONE); if (!deviceWideOnly) { @@ -178,14 +178,16 @@ public class ShadowLockPatternUtils { } @Implementation - public boolean setLockCredential(@NonNull LockscreenCredential newCredential, + public boolean setLockCredential( + @NonNull LockscreenCredential newCredential, @NonNull LockscreenCredential savedCredential, int userHandle) { setIsSecure(userHandle, true); return true; } @Implementation - public boolean checkCredential(@NonNull LockscreenCredential credential, int userId, + public boolean checkCredential( + @NonNull LockscreenCredential credential, int userId, @Nullable LockPatternUtils.CheckCredentialProgressCallback progressCallback) throws LockPatternUtils.RequestThrottledException { return true; diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowThreadUtils.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowThreadUtils.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowThreadUtils.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowThreadUtils.java diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowUserManager.java similarity index 98% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowUserManager.java index 324a82964ae..0b3d3f9103a 100644 --- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUserManager.java +++ b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowUserManager.java @@ -52,7 +52,7 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager private final Set mManagedProfiles = new HashSet<>(); private final Set mEnabledTypes = new HashSet<>(); private boolean mIsQuietModeEnabled = false; - private int[] profileIdsForUser = new int[0]; + private int[] mProfileIdsForUser = new int[0]; private boolean mUserSwitchEnabled; private Bundle mDefaultGuestUserRestriction = new Bundle(); private boolean mIsGuestUser = false; @@ -154,11 +154,11 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager @Implementation protected int[] getProfileIdsWithDisabled(@UserIdInt int userId) { - return profileIdsForUser; + return mProfileIdsForUser; } public void setProfileIdsWithDisabled(int[] profileIds) { - profileIdsForUser = profileIds; + mProfileIdsForUser = profileIds; } @Implementation diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java b/tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowUtils.java similarity index 100% rename from tests/robotests/src/com/android/settings/testutils/shadow/ShadowUtils.java rename to tests/robotests/testutils/com/android/settings/testutils/shadow/ShadowUtils.java