summaryrefslogtreecommitdiff
path: root/tests/activity
diff options
context:
space:
mode:
author Mark Renouf <mrenouf@google.com> 2024-05-30 17:24:32 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2024-05-30 17:24:32 +0000
commit057e8a500d3211cb47d000b0520f8c8f4dfc5e00 (patch)
tree71e440b84be8000040489c3a8f9bc3ed1b8c869f /tests/activity
parent813b8c3690d4fcf1c3e9a185d56741a5ffd3c571 (diff)
parent5c9c3a7462dc45907ee30516f43aff68ada3d06d (diff)
Merge "Disable sharing when device is under active FRP lock" into main
Diffstat (limited to 'tests/activity')
-rw-r--r--tests/activity/src/com/android/intentresolver/ChooserActivityTest.java15
-rw-r--r--tests/activity/src/com/android/intentresolver/platform/FakeSettingsModule.kt33
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/activity/src/com/android/intentresolver/ChooserActivityTest.java b/tests/activity/src/com/android/intentresolver/ChooserActivityTest.java
index a16e201b..a8b8b2e9 100644
--- a/tests/activity/src/com/android/intentresolver/ChooserActivityTest.java
+++ b/tests/activity/src/com/android/intentresolver/ChooserActivityTest.java
@@ -91,6 +91,7 @@ import android.os.UserHandle;
import android.platform.test.flag.junit.CheckFlagsRule;
import android.platform.test.flag.junit.DeviceFlagsValueProvider;
import android.provider.DeviceConfig;
+import android.provider.Settings;
import android.service.chooser.ChooserAction;
import android.service.chooser.ChooserTarget;
import android.text.Spannable;
@@ -134,6 +135,7 @@ import com.android.intentresolver.logging.EventLog;
import com.android.intentresolver.logging.FakeEventLog;
import com.android.intentresolver.platform.AppPredictionAvailable;
import com.android.intentresolver.platform.AppPredictionModule;
+import com.android.intentresolver.platform.GlobalSettings;
import com.android.intentresolver.platform.ImageEditor;
import com.android.intentresolver.platform.ImageEditorModule;
import com.android.intentresolver.shared.model.User;
@@ -237,6 +239,9 @@ public class ChooserActivityTest {
@ApplicationContext
Context mContext;
+ @Inject
+ GlobalSettings mGlobalSettings;
+
/** An arbitrary pre-installed activity that handles this type of intent. */
@BindValue
@ImageEditor
@@ -2769,6 +2774,16 @@ public class ChooserActivityTest {
assertThat(activity.getCurrentUserHandle(), is(PERSONAL_USER_HANDLE));
}
+ @Test
+ public void chooserDisabledWhileDeviceFrpLocked() {
+ mGlobalSettings.putBoolean(Settings.Global.SECURE_FRP_MODE, true);
+ Intent viewIntent = createSendTextIntent();
+ ChooserWrapperActivity activity = mActivityRule.launchActivity(
+ Intent.createChooser(viewIntent, "chooser test"));
+ waitForIdle();
+ assertTrue(activity.isFinishing());
+ }
+
private Intent createChooserIntent(Intent intent, Intent[] initialIntents) {
Intent chooserIntent = new Intent();
chooserIntent.setAction(Intent.ACTION_CHOOSER);
diff --git a/tests/activity/src/com/android/intentresolver/platform/FakeSettingsModule.kt b/tests/activity/src/com/android/intentresolver/platform/FakeSettingsModule.kt
new file mode 100644
index 00000000..9295f054
--- /dev/null
+++ b/tests/activity/src/com/android/intentresolver/platform/FakeSettingsModule.kt
@@ -0,0 +1,33 @@
+/*
+ * 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.intentresolver.platform
+
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.components.SingletonComponent
+import dagger.hilt.testing.TestInstallIn
+import javax.inject.Singleton
+
+@Module
+@TestInstallIn(components = [SingletonComponent::class], replaces = [SettingsModule::class])
+object FakeSettingsModule {
+ @Provides @Singleton fun secureSettings(): SecureSettings = FakeSettings()
+
+ @Provides @Singleton fun systemSettings(): SystemSettings = FakeSettings()
+
+ @Provides @Singleton fun globalSettings(): GlobalSettings = FakeSettings()
+}