Merge changes from topic "261420432" into tm-qpr-dev am: b200ac2c96
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21405604 Change-Id: Ib1642af8b1aeafa53491f9f21c451a8862bf82ca Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -32,6 +32,7 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.settingslib.dream.DreamBackend;
|
import com.android.settingslib.dream.DreamBackend;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
import com.android.systemui.condition.SelfExecutingMonitor;
|
||||||
import com.android.systemui.dreams.DreamOverlayStateController;
|
import com.android.systemui.dreams.DreamOverlayStateController;
|
||||||
import com.android.systemui.shared.condition.Monitor;
|
import com.android.systemui.shared.condition.Monitor;
|
||||||
import com.android.systemui.util.concurrency.FakeExecutor;
|
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||||
@@ -67,7 +68,6 @@ public class ComplicationTypesUpdaterTest extends SysuiTestCase {
|
|||||||
|
|
||||||
private ComplicationTypesUpdater mController;
|
private ComplicationTypesUpdater mController;
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Monitor mMonitor;
|
private Monitor mMonitor;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -75,6 +75,7 @@ public class ComplicationTypesUpdaterTest extends SysuiTestCase {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
when(mDreamBackend.getEnabledComplications()).thenReturn(new HashSet<>());
|
when(mDreamBackend.getEnabledComplications()).thenReturn(new HashSet<>());
|
||||||
|
|
||||||
|
mMonitor = SelfExecutingMonitor.createInstance();
|
||||||
mController = new ComplicationTypesUpdater(mDreamBackend, mExecutor,
|
mController = new ComplicationTypesUpdater(mDreamBackend, mExecutor,
|
||||||
mSecureSettings, mDreamOverlayStateController, mMonitor);
|
mSecureSettings, mDreamOverlayStateController, mMonitor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.view.View;
|
|||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
import com.android.systemui.condition.SelfExecutingMonitor;
|
||||||
import com.android.systemui.dreams.DreamOverlayStateController;
|
import com.android.systemui.dreams.DreamOverlayStateController;
|
||||||
import com.android.systemui.shared.condition.Monitor;
|
import com.android.systemui.shared.condition.Monitor;
|
||||||
|
|
||||||
@@ -70,13 +71,13 @@ public class DreamClockTimeComplicationTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private ComplicationLayoutParams mLayoutParams;
|
private ComplicationLayoutParams mLayoutParams;
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Monitor mMonitor;
|
private Monitor mMonitor;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
when(mDreamClockTimeViewHolderProvider.get()).thenReturn(mDreamClockTimeViewHolder);
|
when(mDreamClockTimeViewHolderProvider.get()).thenReturn(mDreamClockTimeViewHolder);
|
||||||
|
mMonitor = SelfExecutingMonitor.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import com.android.internal.logging.UiEventLogger;
|
|||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.animation.view.LaunchableImageView;
|
import com.android.systemui.animation.view.LaunchableImageView;
|
||||||
|
import com.android.systemui.condition.SelfExecutingMonitor;
|
||||||
import com.android.systemui.controls.ControlsServiceInfo;
|
import com.android.systemui.controls.ControlsServiceInfo;
|
||||||
import com.android.systemui.controls.controller.ControlsController;
|
import com.android.systemui.controls.controller.ControlsController;
|
||||||
import com.android.systemui.controls.controller.StructureInfo;
|
import com.android.systemui.controls.controller.StructureInfo;
|
||||||
@@ -102,7 +103,6 @@ public class DreamHomeControlsComplicationTest extends SysuiTestCase {
|
|||||||
@Captor
|
@Captor
|
||||||
private ArgumentCaptor<DreamOverlayStateController.Callback> mStateCallbackCaptor;
|
private ArgumentCaptor<DreamOverlayStateController.Callback> mStateCallbackCaptor;
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Monitor mMonitor;
|
private Monitor mMonitor;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -116,6 +116,8 @@ public class DreamHomeControlsComplicationTest extends SysuiTestCase {
|
|||||||
Optional.of(mControlsListingController));
|
Optional.of(mControlsListingController));
|
||||||
when(mControlsComponent.getVisibility()).thenReturn(AVAILABLE);
|
when(mControlsComponent.getVisibility()).thenReturn(AVAILABLE);
|
||||||
when(mView.findViewById(R.id.home_controls_chip)).thenReturn(mHomeControlsView);
|
when(mView.findViewById(R.id.home_controls_chip)).thenReturn(mHomeControlsView);
|
||||||
|
|
||||||
|
mMonitor = SelfExecutingMonitor.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.view.View;
|
|||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
|
import com.android.systemui.condition.SelfExecutingMonitor;
|
||||||
import com.android.systemui.dreams.DreamOverlayStateController;
|
import com.android.systemui.dreams.DreamOverlayStateController;
|
||||||
import com.android.systemui.dreams.smartspace.DreamSmartspaceController;
|
import com.android.systemui.dreams.smartspace.DreamSmartspaceController;
|
||||||
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
|
import com.android.systemui.plugins.BcSmartspaceDataPlugin;
|
||||||
@@ -64,7 +65,6 @@ public class SmartSpaceComplicationTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private View mBcSmartspaceView;
|
private View mBcSmartspaceView;
|
||||||
|
|
||||||
@Mock
|
|
||||||
private Monitor mMonitor;
|
private Monitor mMonitor;
|
||||||
|
|
||||||
private final Set<Condition> mPreconditions = new HashSet<>();
|
private final Set<Condition> mPreconditions = new HashSet<>();
|
||||||
@@ -72,6 +72,7 @@ public class SmartSpaceComplicationTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
mMonitor = SelfExecutingMonitor.createInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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.condition;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.android.systemui.shared.condition.Monitor;
|
||||||
|
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||||
|
import com.android.systemui.util.time.FakeSystemClock;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link SelfExecutingMonitor} creates a monitor that independently executes its logic through
|
||||||
|
* a {@link FakeExecutor}, which is ran at when a subscription is added and removed.
|
||||||
|
*/
|
||||||
|
public class SelfExecutingMonitor extends Monitor {
|
||||||
|
private final FakeExecutor mExecutor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor that allows specifying the FakeExecutor to use.
|
||||||
|
*/
|
||||||
|
public SelfExecutingMonitor(FakeExecutor executor) {
|
||||||
|
super(executor);
|
||||||
|
mExecutor = executor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Subscription.Token addSubscription(@NonNull Subscription subscription) {
|
||||||
|
final Subscription.Token result = super.addSubscription(subscription);
|
||||||
|
mExecutor.runAllReady();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeSubscription(@NonNull Subscription.Token token) {
|
||||||
|
super.removeSubscription(token);
|
||||||
|
mExecutor.runNextReady();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link SelfExecutingMonitor} with a self-managed {@link FakeExecutor}. Use only
|
||||||
|
* for cases where condition state only will be set at when a subscription is added.
|
||||||
|
*/
|
||||||
|
public static SelfExecutingMonitor createInstance() {
|
||||||
|
final FakeSystemClock mFakeSystemClock = new FakeSystemClock();
|
||||||
|
final FakeExecutor mExecutor = new FakeExecutor(mFakeSystemClock);
|
||||||
|
return new SelfExecutingMonitor(mExecutor);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user