diff options
author | 2024-05-24 09:34:52 -0400 | |
---|---|---|
committer | 2024-05-29 21:45:15 -0400 | |
commit | 5c9c3a7462dc45907ee30516f43aff68ada3d06d (patch) | |
tree | 00325e5d41b4e1bc8eefd1b6011d7778f2578207 /tests/activity | |
parent | 68c1cb781b1ed97398857b7b3054764a1173ec7f (diff) |
Disable sharing when device is under active FRP lock
Prevent FRP bypass scenarios involving share intents
This CL includes a cleanup of our Settings abstraction to
cover Global, Secure and System, and updates existing tests.
Bug: 327645387
Test: atest IntentResolver-tests-unit
Test: atest ChooserActivityTest#chooserDisabledWhileDeviceFrpLocked
Flag: EXEMPT refactor
Change-Id: I928b6ea68aa8d6d710dc51eb70acd2cc2ec682c3
Diffstat (limited to 'tests/activity')
-rw-r--r-- | tests/activity/src/com/android/intentresolver/ChooserActivityTest.java | 15 | ||||
-rw-r--r-- | tests/activity/src/com/android/intentresolver/platform/FakeSettingsModule.kt | 33 |
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 66f7650d..24b7fb12 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; @@ -130,6 +131,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; @@ -233,6 +235,9 @@ public class ChooserActivityTest { @ApplicationContext Context mContext; + @Inject + GlobalSettings mGlobalSettings; + /** An arbitrary pre-installed activity that handles this type of intent. */ @BindValue @ImageEditor @@ -2754,6 +2759,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() +} |