Smartspace - Support Do Not Disturb

Add support for systemui to inform smartspace about do not disturb
settings. Address some minor spacing issues. Fix how smartspace loads
through dagger.

Fixes: 185970916
Test: atest KeyguardClockSwitchControllerTest
Change-Id: Id19244ceb45fb70a28d780fa5edefab35a5e42c4
This commit is contained in:
Matt Pietal
2021-05-04 12:41:40 -04:00
parent 25a8b5f625
commit d5ea029ae6
7 changed files with 39 additions and 20 deletions

View File

@@ -20,10 +20,13 @@ import android.app.PendingIntent;
import android.app.smartspace.SmartspaceAction;
import android.app.smartspace.SmartspaceTarget;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.os.Parcelable;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.android.systemui.plugins.annotations.ProvidesInterface;
import java.util.List;
@@ -50,6 +53,11 @@ public interface BcSmartspaceDataPlugin extends Plugin {
return null;
}
/**
* As the smartspace view becomes available, allow listeners to receive an event.
*/
default void addOnAttachStateChangeListener(View.OnAttachStateChangeListener listener) { }
/** Updates Smartspace data and propagates it to any listeners. */
void onTargetsAvailable(List<SmartspaceTarget> targets);
@@ -83,6 +91,11 @@ public interface BcSmartspaceDataPlugin extends Plugin {
* When on the lockscreen, use the FalsingManager to help detect errant touches
*/
void setFalsingManager(com.android.systemui.plugins.FalsingManager falsingManager);
/**
* Set or clear any Do Not Disturb information.
*/
void setDnd(@Nullable Icon dndIcon, @Nullable String description);
}
/** Interface for launching Intents, which can differ on the lockscreen */

View File

@@ -80,6 +80,6 @@
android:layout_width="match_parent"
android:layout_height="@dimen/notification_shelf_height"
android:layout_below="@id/keyguard_status_area"
android:paddingStart="@dimen/below_clock_padding_start"
android:paddingStart="@dimen/below_clock_padding_start_extra"
/>
</com.android.keyguard.KeyguardClockSwitch>

View File

@@ -94,4 +94,5 @@
<!-- additional offset for clock switch area items -->
<dimen name="clock_padding_start">28dp</dimen>
<dimen name="below_clock_padding_start">32dp</dimen>
<dimen name="below_clock_padding_start_extra">36dp</dimen>
</resources>

View File

@@ -45,7 +45,6 @@ import com.android.internal.colorextraction.ColorExtractor;
import com.android.keyguard.clock.ClockManager;
import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.dagger.qualifiers.Main;
@@ -69,6 +68,7 @@ import com.android.systemui.util.ViewController;
import com.android.systemui.util.settings.SecureSettings;
import java.util.Locale;
import java.util.Optional;
import java.util.TimeZone;
import java.util.concurrent.Executor;
@@ -89,7 +89,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private final Executor mUiExecutor;
private final BatteryController mBatteryController;
private final FeatureFlags mFeatureFlags;
private final SystemUIFactory mSystemUIFactory;
/**
* Clock for both small and large sizes
@@ -152,6 +151,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
// If set, will replace keyguard_status_area
private BcSmartspaceDataPlugin.SmartspaceView mSmartspaceView;
private Optional<BcSmartspaceDataPlugin> mSmartspacePlugin;
@Inject
public KeyguardClockSwitchController(
@@ -165,14 +165,14 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
@Main Executor uiExecutor,
BatteryController batteryController,
ConfigurationController configurationController,
SystemUIFactory systemUIFactory,
ActivityStarter activityStarter,
FalsingManager falsingManager,
KeyguardUpdateMonitor keyguardUpdateMonitor,
KeyguardBypassController bypassController,
@Main Handler handler,
UserTracker userTracker,
SecureSettings secureSettings) {
SecureSettings secureSettings,
Optional<BcSmartspaceDataPlugin> smartspacePlugin) {
super(keyguardClockSwitch);
mStatusBarStateController = statusBarStateController;
mColorExtractor = colorExtractor;
@@ -184,7 +184,6 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mUiExecutor = uiExecutor;
mBatteryController = batteryController;
mConfigurationController = configurationController;
mSystemUIFactory = systemUIFactory;
mActivityStarter = activityStarter;
mFalsingManager = falsingManager;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
@@ -192,6 +191,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mHandler = handler;
mUserTracker = userTracker;
mSecureSettings = secureSettings;
mSmartspacePlugin = smartspacePlugin;
}
/**
@@ -237,8 +237,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mStatusBarStateController.addCallback(mStatusBarStateListener);
mConfigurationController.addCallback(mConfigurationListener);
BcSmartspaceDataPlugin smartspaceDataPlugin = mSystemUIFactory.getSmartspaceDataProvider();
if (mFeatureFlags.isSmartspaceEnabled() && smartspaceDataPlugin != null) {
if (mFeatureFlags.isSmartspaceEnabled() && mSmartspacePlugin.isPresent()) {
BcSmartspaceDataPlugin smartspaceDataPlugin = mSmartspacePlugin.get();
View ksa = mView.findViewById(R.id.keyguard_status_area);
int ksaIndex = mView.indexOfChild(ksa);
ksa.setVisibility(View.GONE);

View File

@@ -29,7 +29,6 @@ import com.android.systemui.dagger.GlobalRootComponent;
import com.android.systemui.dagger.SysUIComponent;
import com.android.systemui.dagger.WMComponent;
import com.android.systemui.navigationbar.gestural.BackGestureTfClassifierProvider;
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
import com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider;
import com.android.wm.shell.transition.Transitions;
@@ -210,8 +209,4 @@ public class SystemUIFactory {
AssetManager am, String modelName) {
return new BackGestureTfClassifierProvider();
}
public BcSmartspaceDataPlugin getSmartspaceDataProvider() {
return null;
}
}

View File

@@ -38,6 +38,7 @@ import com.android.systemui.dump.DumpManager;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.log.dagger.LogModule;
import com.android.systemui.model.SysUiState;
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.dagger.PowerModule;
import com.android.systemui.recents.Recents;
@@ -150,6 +151,9 @@ public abstract class SystemUIModule {
@BindsOptionalOf
abstract HeadsUpManager optionalHeadsUpManager();
@BindsOptionalOf
abstract BcSmartspaceDataPlugin optionalBcSmartspaceDataPlugin();
@BindsOptionalOf
abstract Recents optionalRecents();

View File

@@ -32,6 +32,7 @@ import android.app.smartspace.SmartspaceTarget;
import android.content.Context;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.drawable.Icon;
import android.os.Handler;
import android.os.UserHandle;
import android.test.suitebuilder.annotation.SmallTest;
@@ -41,10 +42,11 @@ import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.annotation.Nullable;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.keyguard.clock.ClockManager;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.colorextraction.SysuiColorExtractor;
@@ -74,6 +76,7 @@ import org.mockito.verification.VerificationMode;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Executor;
@SmallTest
@@ -117,12 +120,12 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
@Mock
ConfigurationController mConfigurationController;
@Mock
Optional<BcSmartspaceDataPlugin> mOptionalSmartspaceDataProvider;
@Mock
BcSmartspaceDataPlugin mSmartspaceDataProvider;
@Mock
SmartspaceView mSmartspaceView;
@Mock
SystemUIFactory mSystemUIFactory;
@Mock
ActivityStarter mActivityStarter;
@Mock
FalsingManager mFalsingManager;
@@ -162,7 +165,6 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
when(mFeatureFlags.isSmartspaceEnabled()).thenReturn(true);
when(mView.isAttachedToWindow()).thenReturn(true);
when(mResources.getString(anyInt())).thenReturn("h:mm");
when(mSystemUIFactory.getSmartspaceDataProvider()).thenReturn(mSmartspaceDataProvider);
mController = new KeyguardClockSwitchController(
mView,
mStatusBarStateController,
@@ -175,14 +177,14 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
mExecutor,
mBatteryController,
mConfigurationController,
mSystemUIFactory,
mActivityStarter,
mFalsingManager,
mKeyguardUpdateMonitor,
mBypassController,
mHandler,
mUserTracker,
mSecureSettings
mSecureSettings,
mOptionalSmartspaceDataProvider
);
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
@@ -190,6 +192,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
mStatusArea = new View(getContext());
when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea);
when(mOptionalSmartspaceDataProvider.isPresent()).thenReturn(true);
when(mOptionalSmartspaceDataProvider.get()).thenReturn(mSmartspaceDataProvider);
when(mSmartspaceDataProvider.getView(any())).thenReturn(mSmartspaceView);
}
@@ -260,7 +264,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
@Test
public void testSmartspaceEnabledNoDataProviderShowsKeyguardStatusArea() {
when(mFeatureFlags.isSmartspaceEnabled()).thenReturn(true);
when(mSystemUIFactory.getSmartspaceDataProvider()).thenReturn(null);
when(mOptionalSmartspaceDataProvider.isPresent()).thenReturn(false);
mController.init();
assertEquals(View.VISIBLE, mStatusArea.getVisibility());
@@ -389,5 +393,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
public void setIntentStarter(IntentStarter intentStarter) { }
public void setFalsingManager(FalsingManager falsingManager) { }
public void setDnd(@Nullable Icon dndIcon, @Nullable String description) { }
}
}