Merge "Add date/weather decoupling config for smartspace" into tm-qpr-dev am: 6f9c227d29
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20877485 Change-Id: Id5a2efad3cabec4a5813bc138571991376877d80 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
9ae44d928c
@@ -29,6 +29,7 @@ java_library {
|
|||||||
"src/**/*.java",
|
"src/**/*.java",
|
||||||
"src/**/*.kt",
|
"src/**/*.kt",
|
||||||
"bcsmartspace/src/**/*.java",
|
"bcsmartspace/src/**/*.java",
|
||||||
|
"bcsmartspace/src/**/*.kt",
|
||||||
],
|
],
|
||||||
|
|
||||||
static_libs: [
|
static_libs: [
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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.systemui.plugins
|
||||||
|
|
||||||
|
// TODO(b/265360975): Evaluate this plugin approach.
|
||||||
|
/** Plugin to provide BC smartspace configuration */
|
||||||
|
interface BcSmartspaceConfigPlugin {
|
||||||
|
/** Gets default date/weather disabled status. */
|
||||||
|
val isDefaultDateWeatherDisabled: Boolean
|
||||||
|
}
|
||||||
@@ -93,6 +93,11 @@ public interface BcSmartspaceDataPlugin extends Plugin {
|
|||||||
interface SmartspaceView {
|
interface SmartspaceView {
|
||||||
void registerDataProvider(BcSmartspaceDataPlugin plugin);
|
void registerDataProvider(BcSmartspaceDataPlugin plugin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets {@link BcSmartspaceConfigPlugin}.
|
||||||
|
*/
|
||||||
|
void registerConfigProvider(BcSmartspaceConfigPlugin configProvider);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Primary color for unprotected text
|
* Primary color for unprotected text
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ import com.android.systemui.motiontool.MotionToolModule;
|
|||||||
import com.android.systemui.navigationbar.NavigationBarComponent;
|
import com.android.systemui.navigationbar.NavigationBarComponent;
|
||||||
import com.android.systemui.notetask.NoteTaskModule;
|
import com.android.systemui.notetask.NoteTaskModule;
|
||||||
import com.android.systemui.people.PeopleModule;
|
import com.android.systemui.people.PeopleModule;
|
||||||
|
import com.android.systemui.plugins.BcSmartspaceConfigPlugin;
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
|
||||||
import com.android.systemui.privacy.PrivacyModule;
|
import com.android.systemui.privacy.PrivacyModule;
|
||||||
import com.android.systemui.qs.FgsManagerController;
|
import com.android.systemui.qs.FgsManagerController;
|
||||||
@@ -210,6 +211,9 @@ public abstract class SystemUIModule {
|
|||||||
@BindsOptionalOf
|
@BindsOptionalOf
|
||||||
abstract BcSmartspaceDataPlugin optionalBcSmartspaceDataPlugin();
|
abstract BcSmartspaceDataPlugin optionalBcSmartspaceDataPlugin();
|
||||||
|
|
||||||
|
@BindsOptionalOf
|
||||||
|
abstract BcSmartspaceConfigPlugin optionalBcSmartspaceConfigPlugin();
|
||||||
|
|
||||||
@BindsOptionalOf
|
@BindsOptionalOf
|
||||||
abstract Recents optionalRecents();
|
abstract Recents optionalRecents();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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.systemui.smartspace.config
|
||||||
|
|
||||||
|
import com.android.systemui.flags.FeatureFlags
|
||||||
|
import com.android.systemui.flags.Flags
|
||||||
|
import com.android.systemui.plugins.BcSmartspaceConfigPlugin
|
||||||
|
|
||||||
|
class BcSmartspaceConfigProvider(private val featureFlags: FeatureFlags) :
|
||||||
|
BcSmartspaceConfigPlugin {
|
||||||
|
override val isDefaultDateWeatherDisabled: Boolean
|
||||||
|
get() = featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)
|
||||||
|
}
|
||||||
@@ -43,6 +43,7 @@ import com.android.systemui.dagger.qualifiers.Main
|
|||||||
import com.android.systemui.flags.FeatureFlags
|
import com.android.systemui.flags.FeatureFlags
|
||||||
import com.android.systemui.flags.Flags
|
import com.android.systemui.flags.Flags
|
||||||
import com.android.systemui.plugins.ActivityStarter
|
import com.android.systemui.plugins.ActivityStarter
|
||||||
|
import com.android.systemui.plugins.BcSmartspaceConfigPlugin
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceTargetListener
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceTargetListener
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
|
||||||
@@ -60,11 +61,11 @@ import java.util.Optional
|
|||||||
import java.util.concurrent.Executor
|
import java.util.concurrent.Executor
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/** Controller for managing the smartspace view on the lockscreen */
|
||||||
* Controller for managing the smartspace view on the lockscreen
|
|
||||||
*/
|
|
||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
class LockscreenSmartspaceController @Inject constructor(
|
class LockscreenSmartspaceController
|
||||||
|
@Inject
|
||||||
|
constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val featureFlags: FeatureFlags,
|
private val featureFlags: FeatureFlags,
|
||||||
private val smartspaceManager: SmartspaceManager,
|
private val smartspaceManager: SmartspaceManager,
|
||||||
@@ -81,7 +82,8 @@ class LockscreenSmartspaceController @Inject constructor(
|
|||||||
@Main private val uiExecutor: Executor,
|
@Main private val uiExecutor: Executor,
|
||||||
@Background private val bgExecutor: Executor,
|
@Background private val bgExecutor: Executor,
|
||||||
@Main private val handler: Handler,
|
@Main private val handler: Handler,
|
||||||
optionalPlugin: Optional<BcSmartspaceDataPlugin>
|
optionalPlugin: Optional<BcSmartspaceDataPlugin>,
|
||||||
|
optionalConfigPlugin: Optional<BcSmartspaceConfigPlugin>,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "LockscreenSmartspaceController"
|
private const val TAG = "LockscreenSmartspaceController"
|
||||||
@@ -89,6 +91,7 @@ class LockscreenSmartspaceController @Inject constructor(
|
|||||||
|
|
||||||
private var session: SmartspaceSession? = null
|
private var session: SmartspaceSession? = null
|
||||||
private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
|
private val plugin: BcSmartspaceDataPlugin? = optionalPlugin.orElse(null)
|
||||||
|
private val configPlugin: BcSmartspaceConfigPlugin? = optionalConfigPlugin.orElse(null)
|
||||||
|
|
||||||
// Smartspace can be used on multiple displays, such as when the user casts their screen
|
// Smartspace can be used on multiple displays, such as when the user casts their screen
|
||||||
private var smartspaceViews = mutableSetOf<SmartspaceView>()
|
private var smartspaceViews = mutableSetOf<SmartspaceView>()
|
||||||
@@ -240,6 +243,7 @@ class LockscreenSmartspaceController @Inject constructor(
|
|||||||
val ssView = plugin.getView(parent)
|
val ssView = plugin.getView(parent)
|
||||||
ssView.setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
ssView.setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
||||||
ssView.registerDataProvider(plugin)
|
ssView.registerDataProvider(plugin)
|
||||||
|
ssView.registerConfigProvider(configPlugin)
|
||||||
|
|
||||||
ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter {
|
ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter {
|
||||||
override fun startIntent(view: View, intent: Intent, showOnLockscreen: Boolean) {
|
override fun startIntent(view: View, intent: Intent, showOnLockscreen: Boolean) {
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* 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.systemui.smartspace
|
||||||
|
|
||||||
|
import android.testing.AndroidTestingRunner
|
||||||
|
import androidx.test.filters.SmallTest
|
||||||
|
import com.android.systemui.SysuiTestCase
|
||||||
|
import com.android.systemui.flags.FeatureFlags
|
||||||
|
import com.android.systemui.flags.Flags
|
||||||
|
import com.android.systemui.smartspace.config.BcSmartspaceConfigProvider
|
||||||
|
import com.android.systemui.util.mockito.whenever
|
||||||
|
import junit.framework.Assert.assertFalse
|
||||||
|
import junit.framework.Assert.assertTrue
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
|
@SmallTest
|
||||||
|
@RunWith(AndroidTestingRunner::class)
|
||||||
|
class BcSmartspaceConfigProviderTest : SysuiTestCase() {
|
||||||
|
@Mock private lateinit var featureFlags: FeatureFlags
|
||||||
|
|
||||||
|
private lateinit var configProvider: BcSmartspaceConfigProvider
|
||||||
|
|
||||||
|
@Before
|
||||||
|
fun setUp() {
|
||||||
|
MockitoAnnotations.initMocks(this)
|
||||||
|
configProvider = BcSmartspaceConfigProvider(featureFlags)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun isDefaultDateWeatherDisabled_flagIsTrue_returnsTrue() {
|
||||||
|
whenever(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(true)
|
||||||
|
|
||||||
|
assertTrue(configProvider.isDefaultDateWeatherDisabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun isDefaultDateWeatherDisabled_flagIsFalse_returnsFalse() {
|
||||||
|
whenever(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(false)
|
||||||
|
|
||||||
|
assertFalse(configProvider.isDefaultDateWeatherDisabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import android.view.ViewGroup
|
|||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
import com.android.systemui.dreams.smartspace.DreamSmartspaceController
|
import com.android.systemui.dreams.smartspace.DreamSmartspaceController
|
||||||
|
import com.android.systemui.plugins.BcSmartspaceConfigPlugin
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
|
||||||
import com.android.systemui.plugins.FalsingManager
|
import com.android.systemui.plugins.FalsingManager
|
||||||
@@ -94,6 +95,8 @@ class DreamSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
private class TestView(context: Context?) : View(context), SmartspaceView {
|
private class TestView(context: Context?) : View(context), SmartspaceView {
|
||||||
override fun registerDataProvider(plugin: BcSmartspaceDataPlugin?) {}
|
override fun registerDataProvider(plugin: BcSmartspaceDataPlugin?) {}
|
||||||
|
|
||||||
|
override fun registerConfigProvider(plugin: BcSmartspaceConfigPlugin?) {}
|
||||||
|
|
||||||
override fun setPrimaryTextColor(color: Int) {}
|
override fun setPrimaryTextColor(color: Int) {}
|
||||||
|
|
||||||
override fun setIsDreaming(isDreaming: Boolean) {}
|
override fun setIsDreaming(isDreaming: Boolean) {}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import com.android.systemui.SysuiTestCase
|
|||||||
import com.android.systemui.flags.FeatureFlags
|
import com.android.systemui.flags.FeatureFlags
|
||||||
import com.android.systemui.flags.Flags
|
import com.android.systemui.flags.Flags
|
||||||
import com.android.systemui.plugins.ActivityStarter
|
import com.android.systemui.plugins.ActivityStarter
|
||||||
|
import com.android.systemui.plugins.BcSmartspaceConfigPlugin
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceTargetListener
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceTargetListener
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin.SmartspaceView
|
||||||
@@ -114,6 +115,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
@Mock
|
@Mock
|
||||||
private lateinit var plugin: BcSmartspaceDataPlugin
|
private lateinit var plugin: BcSmartspaceDataPlugin
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private lateinit var configPlugin: BcSmartspaceConfigPlugin
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var controllerListener: SmartspaceTargetListener
|
private lateinit var controllerListener: SmartspaceTargetListener
|
||||||
|
|
||||||
@@ -209,7 +213,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
executor,
|
executor,
|
||||||
bgExecutor,
|
bgExecutor,
|
||||||
handler,
|
handler,
|
||||||
Optional.of(plugin)
|
Optional.of(plugin),
|
||||||
|
Optional.of(configPlugin),
|
||||||
)
|
)
|
||||||
|
|
||||||
verify(deviceProvisionedController).addCallback(capture(deviceProvisionedCaptor))
|
verify(deviceProvisionedController).addCallback(capture(deviceProvisionedCaptor))
|
||||||
@@ -520,6 +525,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
verify(smartspaceManager, never()).createSmartspaceSession(any())
|
verify(smartspaceManager, never()).createSmartspaceSession(any())
|
||||||
verify(smartspaceView2).setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
verify(smartspaceView2).setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
||||||
verify(smartspaceView2).registerDataProvider(plugin)
|
verify(smartspaceView2).registerDataProvider(plugin)
|
||||||
|
verify(smartspaceView2).registerConfigProvider(configPlugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -557,6 +563,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
verify(smartspaceView).setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
verify(smartspaceView).setUiSurface(BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
|
||||||
verify(smartspaceView).registerDataProvider(plugin)
|
verify(smartspaceView).registerDataProvider(plugin)
|
||||||
|
verify(smartspaceView).registerConfigProvider(configPlugin)
|
||||||
verify(smartspaceSession)
|
verify(smartspaceSession)
|
||||||
.addOnTargetsAvailableListener(any(), capture(sessionListenerCaptor))
|
.addOnTargetsAvailableListener(any(), capture(sessionListenerCaptor))
|
||||||
sessionListener = sessionListenerCaptor.value
|
sessionListener = sessionListenerCaptor.value
|
||||||
@@ -638,6 +645,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
override fun registerDataProvider(plugin: BcSmartspaceDataPlugin?) {
|
override fun registerDataProvider(plugin: BcSmartspaceDataPlugin?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun registerConfigProvider(plugin: BcSmartspaceConfigPlugin?) {
|
||||||
|
}
|
||||||
|
|
||||||
override fun setPrimaryTextColor(color: Int) {
|
override fun setPrimaryTextColor(color: Int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user