Merge "Replace ACTION_USER_SWITCHED with UserTracker" into tm-qpr-dev am: dfe2c5cc43
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20503000 Change-Id: Ica83332fd02f71f32db8ccf6101fd3593f720449 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -17,24 +17,25 @@
|
|||||||
package com.android.systemui;
|
package com.android.systemui;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.Log;
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.qs.QSUserSwitcherEvent;
|
import com.android.systemui.qs.QSUserSwitcherEvent;
|
||||||
import com.android.systemui.settings.UserTracker;
|
import com.android.systemui.settings.UserTracker;
|
||||||
import com.android.systemui.statusbar.phone.SystemUIDialog;
|
import com.android.systemui.statusbar.phone.SystemUIDialog;
|
||||||
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||||
import com.android.systemui.util.settings.SecureSettings;
|
import com.android.systemui.util.settings.SecureSettings;
|
||||||
|
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.assisted.Assisted;
|
import dagger.assisted.Assisted;
|
||||||
@@ -44,31 +45,66 @@ import dagger.assisted.AssistedInject;
|
|||||||
/**
|
/**
|
||||||
* Manages notification when a guest session is resumed.
|
* Manages notification when a guest session is resumed.
|
||||||
*/
|
*/
|
||||||
public class GuestResumeSessionReceiver extends BroadcastReceiver {
|
public class GuestResumeSessionReceiver {
|
||||||
|
|
||||||
private static final String TAG = GuestResumeSessionReceiver.class.getSimpleName();
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static final String SETTING_GUEST_HAS_LOGGED_IN = "systemui.guest_has_logged_in";
|
public static final String SETTING_GUEST_HAS_LOGGED_IN = "systemui.guest_has_logged_in";
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public AlertDialog mNewSessionDialog;
|
public AlertDialog mNewSessionDialog;
|
||||||
|
private final Executor mMainExecutor;
|
||||||
private final UserTracker mUserTracker;
|
private final UserTracker mUserTracker;
|
||||||
private final SecureSettings mSecureSettings;
|
private final SecureSettings mSecureSettings;
|
||||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
|
||||||
private final ResetSessionDialog.Factory mResetSessionDialogFactory;
|
private final ResetSessionDialog.Factory mResetSessionDialogFactory;
|
||||||
private final GuestSessionNotification mGuestSessionNotification;
|
private final GuestSessionNotification mGuestSessionNotification;
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public final UserTracker.Callback mUserChangedCallback =
|
||||||
|
new UserTracker.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
|
cancelDialog();
|
||||||
|
|
||||||
|
UserInfo currentUser = mUserTracker.getUserInfo();
|
||||||
|
if (!currentUser.isGuest()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int guestLoginState = mSecureSettings.getIntForUser(
|
||||||
|
SETTING_GUEST_HAS_LOGGED_IN, 0, newUser);
|
||||||
|
|
||||||
|
if (guestLoginState == 0) {
|
||||||
|
// set 1 to indicate, 1st login
|
||||||
|
guestLoginState = 1;
|
||||||
|
mSecureSettings.putIntForUser(SETTING_GUEST_HAS_LOGGED_IN, guestLoginState,
|
||||||
|
newUser);
|
||||||
|
} else if (guestLoginState == 1) {
|
||||||
|
// set 2 to indicate, 2nd or later login
|
||||||
|
guestLoginState = 2;
|
||||||
|
mSecureSettings.putIntForUser(SETTING_GUEST_HAS_LOGGED_IN, guestLoginState,
|
||||||
|
newUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
mGuestSessionNotification.createPersistentNotification(currentUser,
|
||||||
|
(guestLoginState <= 1));
|
||||||
|
|
||||||
|
if (guestLoginState > 1) {
|
||||||
|
mNewSessionDialog = mResetSessionDialogFactory.create(newUser);
|
||||||
|
mNewSessionDialog.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GuestResumeSessionReceiver(
|
public GuestResumeSessionReceiver(
|
||||||
|
@Main Executor mainExecutor,
|
||||||
UserTracker userTracker,
|
UserTracker userTracker,
|
||||||
SecureSettings secureSettings,
|
SecureSettings secureSettings,
|
||||||
BroadcastDispatcher broadcastDispatcher,
|
|
||||||
GuestSessionNotification guestSessionNotification,
|
GuestSessionNotification guestSessionNotification,
|
||||||
ResetSessionDialog.Factory resetSessionDialogFactory) {
|
ResetSessionDialog.Factory resetSessionDialogFactory) {
|
||||||
|
mMainExecutor = mainExecutor;
|
||||||
mUserTracker = userTracker;
|
mUserTracker = userTracker;
|
||||||
mSecureSettings = secureSettings;
|
mSecureSettings = secureSettings;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
|
||||||
mGuestSessionNotification = guestSessionNotification;
|
mGuestSessionNotification = guestSessionNotification;
|
||||||
mResetSessionDialogFactory = resetSessionDialogFactory;
|
mResetSessionDialogFactory = resetSessionDialogFactory;
|
||||||
}
|
}
|
||||||
@@ -77,49 +113,7 @@ public class GuestResumeSessionReceiver extends BroadcastReceiver {
|
|||||||
* Register this receiver with the {@link BroadcastDispatcher}
|
* Register this receiver with the {@link BroadcastDispatcher}
|
||||||
*/
|
*/
|
||||||
public void register() {
|
public void register() {
|
||||||
IntentFilter f = new IntentFilter(Intent.ACTION_USER_SWITCHED);
|
mUserTracker.addCallback(mUserChangedCallback, mMainExecutor);
|
||||||
mBroadcastDispatcher.registerReceiver(this, f, null /* handler */, UserHandle.SYSTEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
String action = intent.getAction();
|
|
||||||
|
|
||||||
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
|
|
||||||
cancelDialog();
|
|
||||||
|
|
||||||
int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
|
|
||||||
if (userId == UserHandle.USER_NULL) {
|
|
||||||
Log.e(TAG, intent + " sent to " + TAG + " without EXTRA_USER_HANDLE");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserInfo currentUser = mUserTracker.getUserInfo();
|
|
||||||
if (!currentUser.isGuest()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int guestLoginState = mSecureSettings.getIntForUser(
|
|
||||||
SETTING_GUEST_HAS_LOGGED_IN, 0, userId);
|
|
||||||
|
|
||||||
if (guestLoginState == 0) {
|
|
||||||
// set 1 to indicate, 1st login
|
|
||||||
guestLoginState = 1;
|
|
||||||
mSecureSettings.putIntForUser(SETTING_GUEST_HAS_LOGGED_IN, guestLoginState, userId);
|
|
||||||
} else if (guestLoginState == 1) {
|
|
||||||
// set 2 to indicate, 2nd or later login
|
|
||||||
guestLoginState = 2;
|
|
||||||
mSecureSettings.putIntForUser(SETTING_GUEST_HAS_LOGGED_IN, guestLoginState, userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
mGuestSessionNotification.createPersistentNotification(currentUser,
|
|
||||||
(guestLoginState <= 1));
|
|
||||||
|
|
||||||
if (guestLoginState > 1) {
|
|
||||||
mNewSessionDialog = mResetSessionDialogFactory.create(userId);
|
|
||||||
mNewSessionDialog.show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelDialog() {
|
private void cancelDialog() {
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_M
|
|||||||
import android.annotation.IdRes;
|
import android.annotation.IdRes;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@@ -45,7 +42,6 @@ import android.hardware.graphics.common.DisplayDecorationSupport;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.os.Trace;
|
import android.os.Trace;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.provider.Settings.Secure;
|
import android.provider.Settings.Secure;
|
||||||
import android.util.DisplayUtils;
|
import android.util.DisplayUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -68,7 +64,6 @@ import androidx.annotation.VisibleForTesting;
|
|||||||
|
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.decor.CutoutDecorProviderFactory;
|
import com.android.systemui.decor.CutoutDecorProviderFactory;
|
||||||
@@ -128,7 +123,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
private DisplayManager mDisplayManager;
|
private DisplayManager mDisplayManager;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected boolean mIsRegistered;
|
protected boolean mIsRegistered;
|
||||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final Executor mMainExecutor;
|
private final Executor mMainExecutor;
|
||||||
private final TunerService mTunerService;
|
private final TunerService mTunerService;
|
||||||
@@ -302,7 +296,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
public ScreenDecorations(Context context,
|
public ScreenDecorations(Context context,
|
||||||
@Main Executor mainExecutor,
|
@Main Executor mainExecutor,
|
||||||
SecureSettings secureSettings,
|
SecureSettings secureSettings,
|
||||||
BroadcastDispatcher broadcastDispatcher,
|
|
||||||
TunerService tunerService,
|
TunerService tunerService,
|
||||||
UserTracker userTracker,
|
UserTracker userTracker,
|
||||||
PrivacyDotViewController dotViewController,
|
PrivacyDotViewController dotViewController,
|
||||||
@@ -312,7 +305,6 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
mContext = context;
|
mContext = context;
|
||||||
mMainExecutor = mainExecutor;
|
mMainExecutor = mainExecutor;
|
||||||
mSecureSettings = secureSettings;
|
mSecureSettings = secureSettings;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
|
||||||
mTunerService = tunerService;
|
mTunerService = tunerService;
|
||||||
mUserTracker = userTracker;
|
mUserTracker = userTracker;
|
||||||
mDotViewController = dotViewController;
|
mDotViewController = dotViewController;
|
||||||
@@ -598,10 +590,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
mColorInversionSetting.onChange(false);
|
mColorInversionSetting.onChange(false);
|
||||||
updateColorInversion(mColorInversionSetting.getValue());
|
updateColorInversion(mColorInversionSetting.getValue());
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
mUserTracker.addCallback(mUserChangedCallback, mExecutor);
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
|
||||||
mBroadcastDispatcher.registerReceiver(mUserSwitchIntentReceiver, filter,
|
|
||||||
mExecutor, UserHandle.ALL);
|
|
||||||
mIsRegistered = true;
|
mIsRegistered = true;
|
||||||
} else {
|
} else {
|
||||||
mMainExecutor.execute(() -> mTunerService.removeTunable(this));
|
mMainExecutor.execute(() -> mTunerService.removeTunable(this));
|
||||||
@@ -610,7 +599,7 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
mColorInversionSetting.setListening(false);
|
mColorInversionSetting.setListening(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mBroadcastDispatcher.unregisterReceiver(mUserSwitchIntentReceiver);
|
mUserTracker.removeCallback(mUserChangedCallback);
|
||||||
mIsRegistered = false;
|
mIsRegistered = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -897,18 +886,18 @@ public class ScreenDecorations implements CoreStartable, Tunable , Dumpable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BroadcastReceiver mUserSwitchIntentReceiver = new BroadcastReceiver() {
|
private final UserTracker.Callback mUserChangedCallback =
|
||||||
@Override
|
new UserTracker.Callback() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
@Override
|
||||||
int newUserId = mUserTracker.getUserId();
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "UserSwitched newUserId=" + newUserId);
|
Log.d(TAG, "UserSwitched newUserId=" + newUser);
|
||||||
}
|
}
|
||||||
// update color inversion setting to the new user
|
// update color inversion setting to the new user
|
||||||
mColorInversionSetting.setUserId(newUserId);
|
mColorInversionSetting.setUserId(newUser);
|
||||||
updateColorInversion(mColorInversionSetting.getValue());
|
updateColorInversion(mColorInversionSetting.getValue());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private void updateColorInversion(int colorsInvertedValue) {
|
private void updateColorInversion(int colorsInvertedValue) {
|
||||||
mTintColor = colorsInvertedValue != 0 ? Color.WHITE : Color.BLACK;
|
mTintColor = colorsInvertedValue != 0 ? Color.WHITE : Color.BLACK;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import android.util.Log
|
|||||||
import com.android.internal.annotations.VisibleForTesting
|
import com.android.internal.annotations.VisibleForTesting
|
||||||
import com.android.systemui.Dumpable
|
import com.android.systemui.Dumpable
|
||||||
import com.android.systemui.backup.BackupHelper
|
import com.android.systemui.backup.BackupHelper
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher
|
|
||||||
import com.android.systemui.controls.ControlStatus
|
import com.android.systemui.controls.ControlStatus
|
||||||
import com.android.systemui.controls.ControlsServiceInfo
|
import com.android.systemui.controls.ControlsServiceInfo
|
||||||
import com.android.systemui.controls.management.ControlsListingController
|
import com.android.systemui.controls.management.ControlsListingController
|
||||||
@@ -60,11 +59,10 @@ class ControlsControllerImpl @Inject constructor (
|
|||||||
private val uiController: ControlsUiController,
|
private val uiController: ControlsUiController,
|
||||||
private val bindingController: ControlsBindingController,
|
private val bindingController: ControlsBindingController,
|
||||||
private val listingController: ControlsListingController,
|
private val listingController: ControlsListingController,
|
||||||
private val broadcastDispatcher: BroadcastDispatcher,
|
|
||||||
private val userFileManager: UserFileManager,
|
private val userFileManager: UserFileManager,
|
||||||
|
private val userTracker: UserTracker,
|
||||||
optionalWrapper: Optional<ControlsFavoritePersistenceWrapper>,
|
optionalWrapper: Optional<ControlsFavoritePersistenceWrapper>,
|
||||||
dumpManager: DumpManager,
|
dumpManager: DumpManager,
|
||||||
userTracker: UserTracker
|
|
||||||
) : Dumpable, ControlsController {
|
) : Dumpable, ControlsController {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -121,18 +119,15 @@ class ControlsControllerImpl @Inject constructor (
|
|||||||
userChanging = false
|
userChanging = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private val userSwitchReceiver = object : BroadcastReceiver() {
|
private val userTrackerCallback = object : UserTracker.Callback {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onUserChanged(newUser: Int, userContext: Context) {
|
||||||
if (intent.action == Intent.ACTION_USER_SWITCHED) {
|
userChanging = true
|
||||||
userChanging = true
|
val newUserHandle = UserHandle.of(newUser)
|
||||||
val newUser =
|
if (currentUser == newUserHandle) {
|
||||||
UserHandle.of(intent.getIntExtra(Intent.EXTRA_USER_HANDLE, sendingUserId))
|
userChanging = false
|
||||||
if (currentUser == newUser) {
|
return
|
||||||
userChanging = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setValuesForUser(newUser)
|
|
||||||
}
|
}
|
||||||
|
setValuesForUser(newUserHandle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,12 +229,7 @@ class ControlsControllerImpl @Inject constructor (
|
|||||||
dumpManager.registerDumpable(javaClass.name, this)
|
dumpManager.registerDumpable(javaClass.name, this)
|
||||||
resetFavorites()
|
resetFavorites()
|
||||||
userChanging = false
|
userChanging = false
|
||||||
broadcastDispatcher.registerReceiver(
|
userTracker.addCallback(userTrackerCallback, executor)
|
||||||
userSwitchReceiver,
|
|
||||||
IntentFilter(Intent.ACTION_USER_SWITCHED),
|
|
||||||
executor,
|
|
||||||
UserHandle.ALL
|
|
||||||
)
|
|
||||||
context.registerReceiver(
|
context.registerReceiver(
|
||||||
restoreFinishedReceiver,
|
restoreFinishedReceiver,
|
||||||
IntentFilter(BackupHelper.ACTION_RESTORE_FINISHED),
|
IntentFilter(BackupHelper.ACTION_RESTORE_FINISHED),
|
||||||
@@ -251,7 +241,7 @@ class ControlsControllerImpl @Inject constructor (
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun destroy() {
|
fun destroy() {
|
||||||
broadcastDispatcher.unregisterReceiver(userSwitchReceiver)
|
userTracker.removeCallback(userTrackerCallback)
|
||||||
context.unregisterReceiver(restoreFinishedReceiver)
|
context.unregisterReceiver(restoreFinishedReceiver)
|
||||||
listingController.removeCallback(listingCallback)
|
listingController.removeCallback(listingCallback)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.android.systemui.dagger;
|
|||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
|
||||||
import com.android.systemui.GuestResetOrExitSessionReceiver;
|
import com.android.systemui.GuestResetOrExitSessionReceiver;
|
||||||
import com.android.systemui.GuestResumeSessionReceiver;
|
|
||||||
import com.android.systemui.media.dialog.MediaOutputDialogReceiver;
|
import com.android.systemui.media.dialog.MediaOutputDialogReceiver;
|
||||||
import com.android.systemui.people.widget.PeopleSpaceWidgetPinnedReceiver;
|
import com.android.systemui.people.widget.PeopleSpaceWidgetPinnedReceiver;
|
||||||
import com.android.systemui.people.widget.PeopleSpaceWidgetProvider;
|
import com.android.systemui.people.widget.PeopleSpaceWidgetProvider;
|
||||||
@@ -101,15 +100,6 @@ public abstract class DefaultBroadcastReceiverBinder {
|
|||||||
public abstract BroadcastReceiver bindPeopleSpaceWidgetProvider(
|
public abstract BroadcastReceiver bindPeopleSpaceWidgetProvider(
|
||||||
PeopleSpaceWidgetProvider broadcastReceiver);
|
PeopleSpaceWidgetProvider broadcastReceiver);
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Binds
|
|
||||||
@IntoMap
|
|
||||||
@ClassKey(GuestResumeSessionReceiver.class)
|
|
||||||
public abstract BroadcastReceiver bindGuestResumeSessionReceiver(
|
|
||||||
GuestResumeSessionReceiver broadcastReceiver);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,12 +29,13 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.hardware.display.AmbientDisplayConfiguration;
|
import android.hardware.display.AmbientDisplayConfiguration;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.util.IndentingPrintWriter;
|
import android.util.IndentingPrintWriter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.logging.InstanceId;
|
import com.android.internal.logging.InstanceId;
|
||||||
import com.android.internal.logging.UiEvent;
|
import com.android.internal.logging.UiEvent;
|
||||||
@@ -100,6 +101,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||||
private final AuthController mAuthController;
|
private final AuthController mAuthController;
|
||||||
private final KeyguardStateController mKeyguardStateController;
|
private final KeyguardStateController mKeyguardStateController;
|
||||||
|
private final UserTracker mUserTracker;
|
||||||
private final UiEventLogger mUiEventLogger;
|
private final UiEventLogger mUiEventLogger;
|
||||||
|
|
||||||
private long mNotificationPulseTime;
|
private long mNotificationPulseTime;
|
||||||
@@ -110,6 +112,14 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
private boolean mWantTouchScreenSensors;
|
private boolean mWantTouchScreenSensors;
|
||||||
private boolean mWantSensors;
|
private boolean mWantSensors;
|
||||||
|
|
||||||
|
private final UserTracker.Callback mUserChangedCallback =
|
||||||
|
new UserTracker.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
|
mDozeSensors.onUserSwitched();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public enum DozingUpdateUiEvent implements UiEventLogger.UiEventEnum {
|
public enum DozingUpdateUiEvent implements UiEventLogger.UiEventEnum {
|
||||||
@UiEvent(doc = "Dozing updated due to notification.")
|
@UiEvent(doc = "Dozing updated due to notification.")
|
||||||
@@ -210,6 +220,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
mAuthController = authController;
|
mAuthController = authController;
|
||||||
mUiEventLogger = uiEventLogger;
|
mUiEventLogger = uiEventLogger;
|
||||||
mKeyguardStateController = keyguardStateController;
|
mKeyguardStateController = keyguardStateController;
|
||||||
|
mUserTracker = userTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -234,7 +245,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mNotificationPulseTime = SystemClock.elapsedRealtime();
|
mNotificationPulseTime = SystemClock.elapsedRealtime();
|
||||||
if (!mConfig.pulseOnNotificationEnabled(UserHandle.USER_CURRENT)) {
|
if (!mConfig.pulseOnNotificationEnabled(mUserTracker.getUserId())) {
|
||||||
runIfNotNull(onPulseSuppressedListener);
|
runIfNotNull(onPulseSuppressedListener);
|
||||||
mDozeLog.tracePulseDropped("pulseOnNotificationsDisabled");
|
mDozeLog.tracePulseDropped("pulseOnNotificationsDisabled");
|
||||||
return;
|
return;
|
||||||
@@ -490,12 +501,14 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
mBroadcastReceiver.register(mBroadcastDispatcher);
|
mBroadcastReceiver.register(mBroadcastDispatcher);
|
||||||
mDockManager.addListener(mDockEventListener);
|
mDockManager.addListener(mDockEventListener);
|
||||||
mDozeHost.addCallback(mHostCallback);
|
mDozeHost.addCallback(mHostCallback);
|
||||||
|
mUserTracker.addCallback(mUserChangedCallback, mContext.getMainExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unregisterCallbacks() {
|
private void unregisterCallbacks() {
|
||||||
mBroadcastReceiver.unregister(mBroadcastDispatcher);
|
mBroadcastReceiver.unregister(mBroadcastDispatcher);
|
||||||
mDozeHost.removeCallback(mHostCallback);
|
mDozeHost.removeCallback(mHostCallback);
|
||||||
mDockManager.removeListener(mDockEventListener);
|
mDockManager.removeListener(mDockEventListener);
|
||||||
|
mUserTracker.removeCallback(mUserChangedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopListeningToAllTriggers() {
|
private void stopListeningToAllTriggers() {
|
||||||
@@ -620,9 +633,6 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
requestPulse(DozeLog.PULSE_REASON_INTENT, false, /* performedProxCheck */
|
requestPulse(DozeLog.PULSE_REASON_INTENT, false, /* performedProxCheck */
|
||||||
null /* onPulseSuppressedListener */);
|
null /* onPulseSuppressedListener */);
|
||||||
}
|
}
|
||||||
if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
|
|
||||||
mDozeSensors.onUserSwitched();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(BroadcastDispatcher broadcastDispatcher) {
|
public void register(BroadcastDispatcher broadcastDispatcher) {
|
||||||
@@ -630,7 +640,6 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IntentFilter filter = new IntentFilter(PULSE_ACTION);
|
IntentFilter filter = new IntentFilter(PULSE_ACTION);
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
|
||||||
broadcastDispatcher.registerReceiver(this, filter);
|
broadcastDispatcher.registerReceiver(this, filter);
|
||||||
mRegistered = true;
|
mRegistered = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,12 @@ import com.android.systemui.Dumpable
|
|||||||
import com.android.systemui.broadcast.BroadcastDispatcher
|
import com.android.systemui.broadcast.BroadcastDispatcher
|
||||||
import com.android.systemui.dagger.SysUISingleton
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
import com.android.systemui.dagger.qualifiers.Background
|
import com.android.systemui.dagger.qualifiers.Background
|
||||||
|
import com.android.systemui.dagger.qualifiers.Main
|
||||||
import com.android.systemui.dump.DumpManager
|
import com.android.systemui.dump.DumpManager
|
||||||
import com.android.systemui.media.controls.models.player.MediaData
|
import com.android.systemui.media.controls.models.player.MediaData
|
||||||
import com.android.systemui.media.controls.pipeline.MediaDataManager
|
import com.android.systemui.media.controls.pipeline.MediaDataManager
|
||||||
import com.android.systemui.media.controls.pipeline.RESUME_MEDIA_TIMEOUT
|
import com.android.systemui.media.controls.pipeline.RESUME_MEDIA_TIMEOUT
|
||||||
|
import com.android.systemui.settings.UserTracker
|
||||||
import com.android.systemui.tuner.TunerService
|
import com.android.systemui.tuner.TunerService
|
||||||
import com.android.systemui.util.Utils
|
import com.android.systemui.util.Utils
|
||||||
import com.android.systemui.util.time.SystemClock
|
import com.android.systemui.util.time.SystemClock
|
||||||
@@ -55,6 +57,8 @@ class MediaResumeListener
|
|||||||
constructor(
|
constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val broadcastDispatcher: BroadcastDispatcher,
|
private val broadcastDispatcher: BroadcastDispatcher,
|
||||||
|
private val userTracker: UserTracker,
|
||||||
|
@Main private val mainExecutor: Executor,
|
||||||
@Background private val backgroundExecutor: Executor,
|
@Background private val backgroundExecutor: Executor,
|
||||||
private val tunerService: TunerService,
|
private val tunerService: TunerService,
|
||||||
private val mediaBrowserFactory: ResumeMediaBrowserFactory,
|
private val mediaBrowserFactory: ResumeMediaBrowserFactory,
|
||||||
@@ -77,18 +81,26 @@ constructor(
|
|||||||
private var currentUserId: Int = context.userId
|
private var currentUserId: Int = context.userId
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
val userChangeReceiver =
|
val userUnlockReceiver =
|
||||||
object : BroadcastReceiver() {
|
object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
if (Intent.ACTION_USER_UNLOCKED == intent.action) {
|
if (Intent.ACTION_USER_UNLOCKED == intent.action) {
|
||||||
loadMediaResumptionControls()
|
val userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1)
|
||||||
} else if (Intent.ACTION_USER_SWITCHED == intent.action) {
|
if (userId == currentUserId) {
|
||||||
currentUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1)
|
loadMediaResumptionControls()
|
||||||
loadSavedComponents()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val userTrackerCallback =
|
||||||
|
object : UserTracker.Callback {
|
||||||
|
override fun onUserChanged(newUser: Int, userContext: Context) {
|
||||||
|
currentUserId = newUser
|
||||||
|
loadSavedComponents()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val mediaBrowserCallback =
|
private val mediaBrowserCallback =
|
||||||
object : ResumeMediaBrowser.Callback() {
|
object : ResumeMediaBrowser.Callback() {
|
||||||
override fun addTrack(
|
override fun addTrack(
|
||||||
@@ -126,13 +138,13 @@ constructor(
|
|||||||
dumpManager.registerDumpable(TAG, this)
|
dumpManager.registerDumpable(TAG, this)
|
||||||
val unlockFilter = IntentFilter()
|
val unlockFilter = IntentFilter()
|
||||||
unlockFilter.addAction(Intent.ACTION_USER_UNLOCKED)
|
unlockFilter.addAction(Intent.ACTION_USER_UNLOCKED)
|
||||||
unlockFilter.addAction(Intent.ACTION_USER_SWITCHED)
|
|
||||||
broadcastDispatcher.registerReceiver(
|
broadcastDispatcher.registerReceiver(
|
||||||
userChangeReceiver,
|
userUnlockReceiver,
|
||||||
unlockFilter,
|
unlockFilter,
|
||||||
null,
|
null,
|
||||||
UserHandle.ALL
|
UserHandle.ALL
|
||||||
)
|
)
|
||||||
|
userTracker.addCallback(userTrackerCallback, mainExecutor)
|
||||||
loadSavedComponents()
|
loadSavedComponents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,13 +52,12 @@ import static com.android.systemui.statusbar.phone.CentralSurfaces.dumpBarTransi
|
|||||||
import static com.android.systemui.util.Utils.isGesturalModeOnDefaultDisplay;
|
import static com.android.systemui.util.Utils.isGesturalModeOnDefaultDisplay;
|
||||||
|
|
||||||
import android.annotation.IdRes;
|
import android.annotation.IdRes;
|
||||||
|
import android.annotation.NonNull;
|
||||||
import android.app.ActivityTaskManager;
|
import android.app.ActivityTaskManager;
|
||||||
import android.app.IActivityTaskManager;
|
import android.app.IActivityTaskManager;
|
||||||
import android.app.StatusBarManager;
|
import android.app.StatusBarManager;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Insets;
|
import android.graphics.Insets;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
@@ -114,7 +113,6 @@ import com.android.internal.view.AppearanceRegion;
|
|||||||
import com.android.systemui.Gefingerpoken;
|
import com.android.systemui.Gefingerpoken;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.assist.AssistManager;
|
import com.android.systemui.assist.AssistManager;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
|
||||||
import com.android.systemui.dagger.qualifiers.Background;
|
import com.android.systemui.dagger.qualifiers.Background;
|
||||||
import com.android.systemui.dagger.qualifiers.DisplayId;
|
import com.android.systemui.dagger.qualifiers.DisplayId;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
@@ -132,6 +130,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
|||||||
import com.android.systemui.recents.OverviewProxyService;
|
import com.android.systemui.recents.OverviewProxyService;
|
||||||
import com.android.systemui.recents.Recents;
|
import com.android.systemui.recents.Recents;
|
||||||
import com.android.systemui.settings.UserContextProvider;
|
import com.android.systemui.settings.UserContextProvider;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
import com.android.systemui.shade.ShadeController;
|
import com.android.systemui.shade.ShadeController;
|
||||||
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
|
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;
|
||||||
import com.android.systemui.shared.recents.utilities.Utilities;
|
import com.android.systemui.shared.recents.utilities.Utilities;
|
||||||
@@ -202,7 +201,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
|
|||||||
private final NotificationRemoteInputManager mNotificationRemoteInputManager;
|
private final NotificationRemoteInputManager mNotificationRemoteInputManager;
|
||||||
private final OverviewProxyService mOverviewProxyService;
|
private final OverviewProxyService mOverviewProxyService;
|
||||||
private final NavigationModeController mNavigationModeController;
|
private final NavigationModeController mNavigationModeController;
|
||||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
private final UserTracker mUserTracker;
|
||||||
private final CommandQueue mCommandQueue;
|
private final CommandQueue mCommandQueue;
|
||||||
private final Optional<Pip> mPipOptional;
|
private final Optional<Pip> mPipOptional;
|
||||||
private final Optional<Recents> mRecentsOptional;
|
private final Optional<Recents> mRecentsOptional;
|
||||||
@@ -504,7 +503,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
|
|||||||
StatusBarStateController statusBarStateController,
|
StatusBarStateController statusBarStateController,
|
||||||
StatusBarKeyguardViewManager statusBarKeyguardViewManager,
|
StatusBarKeyguardViewManager statusBarKeyguardViewManager,
|
||||||
SysUiState sysUiFlagsContainer,
|
SysUiState sysUiFlagsContainer,
|
||||||
BroadcastDispatcher broadcastDispatcher,
|
UserTracker userTracker,
|
||||||
CommandQueue commandQueue,
|
CommandQueue commandQueue,
|
||||||
Optional<Pip> pipOptional,
|
Optional<Pip> pipOptional,
|
||||||
Optional<Recents> recentsOptional,
|
Optional<Recents> recentsOptional,
|
||||||
@@ -547,7 +546,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
|
|||||||
mNotificationRemoteInputManager = notificationRemoteInputManager;
|
mNotificationRemoteInputManager = notificationRemoteInputManager;
|
||||||
mOverviewProxyService = overviewProxyService;
|
mOverviewProxyService = overviewProxyService;
|
||||||
mNavigationModeController = navigationModeController;
|
mNavigationModeController = navigationModeController;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
mUserTracker = userTracker;
|
||||||
mCommandQueue = commandQueue;
|
mCommandQueue = commandQueue;
|
||||||
mPipOptional = pipOptional;
|
mPipOptional = pipOptional;
|
||||||
mRecentsOptional = recentsOptional;
|
mRecentsOptional = recentsOptional;
|
||||||
@@ -729,9 +728,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
|
|||||||
prepareNavigationBarView();
|
prepareNavigationBarView();
|
||||||
checkNavBarModes();
|
checkNavBarModes();
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
|
mUserTracker.addCallback(mUserChangedCallback, mContext.getMainExecutor());
|
||||||
mBroadcastDispatcher.registerReceiverWithHandler(mBroadcastReceiver, filter,
|
|
||||||
Handler.getMain(), UserHandle.ALL);
|
|
||||||
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
|
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
|
||||||
notifyNavigationBarScreenOn();
|
notifyNavigationBarScreenOn();
|
||||||
|
|
||||||
@@ -782,7 +779,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
|
|||||||
mView.setUpdateActiveTouchRegionsCallback(null);
|
mView.setUpdateActiveTouchRegionsCallback(null);
|
||||||
getBarTransitions().destroy();
|
getBarTransitions().destroy();
|
||||||
mOverviewProxyService.removeCallback(mOverviewProxyListener);
|
mOverviewProxyService.removeCallback(mOverviewProxyListener);
|
||||||
mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
|
mUserTracker.removeCallback(mUserChangedCallback);
|
||||||
mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
|
mWakefulnessLifecycle.removeObserver(mWakefulnessObserver);
|
||||||
if (mOrientationHandle != null) {
|
if (mOrientationHandle != null) {
|
||||||
resetSecondaryHandle();
|
resetSecondaryHandle();
|
||||||
@@ -1674,21 +1671,14 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
private final UserTracker.Callback mUserChangedCallback =
|
||||||
@Override
|
new UserTracker.Callback() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
@Override
|
||||||
// TODO(193941146): Currently unregistering a receiver through BroadcastDispatcher is
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
// async, but we've already cleared the fields. Just return early in this case.
|
// The accessibility settings may be different for the new user
|
||||||
if (mView == null) {
|
updateAccessibilityStateFlags();
|
||||||
return;
|
}
|
||||||
}
|
};
|
||||||
String action = intent.getAction();
|
|
||||||
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
|
|
||||||
// The accessibility settings may be different for the new user
|
|
||||||
updateAccessibilityStateFlags();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
int getNavigationIconHints() {
|
int getNavigationIconHints() {
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import android.text.format.DateUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.settingslib.fuelgauge.Estimate;
|
import com.android.settingslib.fuelgauge.Estimate;
|
||||||
import com.android.settingslib.utils.ThreadUtils;
|
import com.android.settingslib.utils.ThreadUtils;
|
||||||
@@ -47,6 +49,7 @@ import com.android.systemui.R;
|
|||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.phone.CentralSurfaces;
|
import com.android.systemui.statusbar.phone.CentralSurfaces;
|
||||||
|
|
||||||
@@ -80,6 +83,7 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
|
|||||||
private final PowerManager mPowerManager;
|
private final PowerManager mPowerManager;
|
||||||
private final WarningsUI mWarnings;
|
private final WarningsUI mWarnings;
|
||||||
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
||||||
|
private final UserTracker mUserTracker;
|
||||||
private InattentiveSleepWarningView mOverlayView;
|
private InattentiveSleepWarningView mOverlayView;
|
||||||
private final Configuration mLastConfiguration = new Configuration();
|
private final Configuration mLastConfiguration = new Configuration();
|
||||||
private int mPlugType = 0;
|
private int mPlugType = 0;
|
||||||
@@ -122,12 +126,21 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final UserTracker.Callback mUserChangedCallback =
|
||||||
|
new UserTracker.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
|
mWarnings.userSwitched();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PowerUI(Context context, BroadcastDispatcher broadcastDispatcher,
|
public PowerUI(Context context, BroadcastDispatcher broadcastDispatcher,
|
||||||
CommandQueue commandQueue, Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
|
CommandQueue commandQueue, Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
|
||||||
WarningsUI warningsUI, EnhancedEstimates enhancedEstimates,
|
WarningsUI warningsUI, EnhancedEstimates enhancedEstimates,
|
||||||
WakefulnessLifecycle wakefulnessLifecycle,
|
WakefulnessLifecycle wakefulnessLifecycle,
|
||||||
PowerManager powerManager) {
|
PowerManager powerManager,
|
||||||
|
UserTracker userTracker) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
mBroadcastDispatcher = broadcastDispatcher;
|
||||||
mCommandQueue = commandQueue;
|
mCommandQueue = commandQueue;
|
||||||
@@ -136,6 +149,7 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
|
|||||||
mEnhancedEstimates = enhancedEstimates;
|
mEnhancedEstimates = enhancedEstimates;
|
||||||
mPowerManager = powerManager;
|
mPowerManager = powerManager;
|
||||||
mWakefulnessLifecycle = wakefulnessLifecycle;
|
mWakefulnessLifecycle = wakefulnessLifecycle;
|
||||||
|
mUserTracker = userTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
@@ -154,6 +168,7 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
|
|||||||
false, obs, UserHandle.USER_ALL);
|
false, obs, UserHandle.USER_ALL);
|
||||||
updateBatteryWarningLevels();
|
updateBatteryWarningLevels();
|
||||||
mReceiver.init();
|
mReceiver.init();
|
||||||
|
mUserTracker.addCallback(mUserChangedCallback, mContext.getMainExecutor());
|
||||||
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
|
mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
|
||||||
|
|
||||||
// Check to see if we need to let the user know that the phone previously shut down due
|
// Check to see if we need to let the user know that the phone previously shut down due
|
||||||
@@ -250,7 +265,6 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
|
|||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
|
filter.addAction(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
|
||||||
mBroadcastDispatcher.registerReceiverWithHandler(this, filter, mHandler);
|
mBroadcastDispatcher.registerReceiverWithHandler(this, filter, mHandler);
|
||||||
// Force get initial values. Relying on Sticky behavior until API for getting info.
|
// Force get initial values. Relying on Sticky behavior until API for getting info.
|
||||||
if (!mHasReceivedBattery) {
|
if (!mHasReceivedBattery) {
|
||||||
@@ -332,8 +346,6 @@ public class PowerUI implements CoreStartable, CommandQueue.Callbacks {
|
|||||||
plugged, bucket);
|
plugged, bucket);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (Intent.ACTION_USER_SWITCHED.equals(action)) {
|
|
||||||
mWarnings.userSwitched();
|
|
||||||
} else {
|
} else {
|
||||||
Slog.w(TAG, "unknown intent: " + intent);
|
Slog.w(TAG, "unknown intent: " + intent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,10 +51,13 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.navigationbar.NavigationBarView;
|
import com.android.systemui.navigationbar.NavigationBarView;
|
||||||
import com.android.systemui.navigationbar.NavigationModeController;
|
import com.android.systemui.navigationbar.NavigationModeController;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
import com.android.systemui.shared.system.QuickStepContract;
|
import com.android.systemui.shared.system.QuickStepContract;
|
||||||
import com.android.systemui.statusbar.phone.CentralSurfaces;
|
import com.android.systemui.statusbar.phone.CentralSurfaces;
|
||||||
import com.android.systemui.util.leak.RotationUtils;
|
import com.android.systemui.util.leak.RotationUtils;
|
||||||
@@ -76,6 +79,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
|
|||||||
private final AccessibilityManager mAccessibilityService;
|
private final AccessibilityManager mAccessibilityService;
|
||||||
private final WindowManager mWindowManager;
|
private final WindowManager mWindowManager;
|
||||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||||
|
private final UserTracker mUserTracker;
|
||||||
|
|
||||||
private RequestWindowView mRequestWindow;
|
private RequestWindowView mRequestWindow;
|
||||||
private int mNavBarMode;
|
private int mNavBarMode;
|
||||||
@@ -83,12 +87,21 @@ public class ScreenPinningRequest implements View.OnClickListener,
|
|||||||
/** ID of task to be pinned or locked. */
|
/** ID of task to be pinned or locked. */
|
||||||
private int taskId;
|
private int taskId;
|
||||||
|
|
||||||
|
private final UserTracker.Callback mUserChangedCallback =
|
||||||
|
new UserTracker.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
|
clearPrompt();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ScreenPinningRequest(
|
public ScreenPinningRequest(
|
||||||
Context context,
|
Context context,
|
||||||
Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
|
Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
|
||||||
NavigationModeController navigationModeController,
|
NavigationModeController navigationModeController,
|
||||||
BroadcastDispatcher broadcastDispatcher) {
|
BroadcastDispatcher broadcastDispatcher,
|
||||||
|
UserTracker userTracker) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
|
mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
|
||||||
mAccessibilityService = (AccessibilityManager)
|
mAccessibilityService = (AccessibilityManager)
|
||||||
@@ -97,6 +110,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
|
|||||||
mContext.getSystemService(Context.WINDOW_SERVICE);
|
mContext.getSystemService(Context.WINDOW_SERVICE);
|
||||||
mNavBarMode = navigationModeController.addListener(this);
|
mNavBarMode = navigationModeController.addListener(this);
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
mBroadcastDispatcher = broadcastDispatcher;
|
||||||
|
mUserTracker = userTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearPrompt() {
|
public void clearPrompt() {
|
||||||
@@ -228,9 +242,9 @@ public class ScreenPinningRequest implements View.OnClickListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED);
|
IntentFilter filter = new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
|
||||||
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
filter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||||
mBroadcastDispatcher.registerReceiver(mReceiver, filter);
|
mBroadcastDispatcher.registerReceiver(mReceiver, filter);
|
||||||
|
mUserTracker.addCallback(mUserChangedCallback, mContext.getMainExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inflateView(int rotation) {
|
private void inflateView(int rotation) {
|
||||||
@@ -358,6 +372,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
|
|||||||
@Override
|
@Override
|
||||||
public void onDetachedFromWindow() {
|
public void onDetachedFromWindow() {
|
||||||
mBroadcastDispatcher.unregisterReceiver(mReceiver);
|
mBroadcastDispatcher.unregisterReceiver(mReceiver);
|
||||||
|
mUserTracker.removeCallback(mUserChangedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onConfigurationChanged() {
|
protected void onConfigurationChanged() {
|
||||||
@@ -388,8 +403,7 @@ public class ScreenPinningRequest implements View.OnClickListener,
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
|
if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
|
||||||
post(mUpdateLayoutRunnable);
|
post(mUpdateLayoutRunnable);
|
||||||
} else if (intent.getAction().equals(Intent.ACTION_USER_SWITCHED)
|
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
|| intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
|
||||||
clearPrompt();
|
clearPrompt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,16 @@ import com.android.internal.annotations.VisibleForTesting;
|
|||||||
import com.android.systemui.animation.DialogLaunchAnimator;
|
import com.android.systemui.animation.DialogLaunchAnimator;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
|
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.settings.UserContextProvider;
|
import com.android.systemui.settings.UserContextProvider;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
import com.android.systemui.statusbar.policy.CallbackController;
|
import com.android.systemui.statusbar.policy.CallbackController;
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -55,8 +58,10 @@ public class RecordingController
|
|||||||
private boolean mIsRecording;
|
private boolean mIsRecording;
|
||||||
private PendingIntent mStopIntent;
|
private PendingIntent mStopIntent;
|
||||||
private CountDownTimer mCountDownTimer = null;
|
private CountDownTimer mCountDownTimer = null;
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private final Executor mMainExecutor;
|
||||||
private UserContextProvider mUserContextProvider;
|
private final BroadcastDispatcher mBroadcastDispatcher;
|
||||||
|
private final UserContextProvider mUserContextProvider;
|
||||||
|
private final UserTracker mUserTracker;
|
||||||
|
|
||||||
protected static final String INTENT_UPDATE_STATE =
|
protected static final String INTENT_UPDATE_STATE =
|
||||||
"com.android.systemui.screenrecord.UPDATE_STATE";
|
"com.android.systemui.screenrecord.UPDATE_STATE";
|
||||||
@@ -66,12 +71,13 @@ public class RecordingController
|
|||||||
new CopyOnWriteArrayList<>();
|
new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected final BroadcastReceiver mUserChangeReceiver = new BroadcastReceiver() {
|
final UserTracker.Callback mUserChangedCallback =
|
||||||
@Override
|
new UserTracker.Callback() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
@Override
|
||||||
stopRecording();
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
}
|
stopRecording();
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected final BroadcastReceiver mStateChangeReceiver = new BroadcastReceiver() {
|
protected final BroadcastReceiver mStateChangeReceiver = new BroadcastReceiver() {
|
||||||
@@ -92,10 +98,14 @@ public class RecordingController
|
|||||||
* Create a new RecordingController
|
* Create a new RecordingController
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public RecordingController(BroadcastDispatcher broadcastDispatcher,
|
public RecordingController(@Main Executor mainExecutor,
|
||||||
UserContextProvider userContextProvider) {
|
BroadcastDispatcher broadcastDispatcher,
|
||||||
|
UserContextProvider userContextProvider,
|
||||||
|
UserTracker userTracker) {
|
||||||
|
mMainExecutor = mainExecutor;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
mBroadcastDispatcher = broadcastDispatcher;
|
||||||
mUserContextProvider = userContextProvider;
|
mUserContextProvider = userContextProvider;
|
||||||
|
mUserTracker = userTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create a dialog to show screen recording options to the user. */
|
/** Create a dialog to show screen recording options to the user. */
|
||||||
@@ -139,9 +149,7 @@ public class RecordingController
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
startIntent.send();
|
startIntent.send();
|
||||||
IntentFilter userFilter = new IntentFilter(Intent.ACTION_USER_SWITCHED);
|
mUserTracker.addCallback(mUserChangedCallback, mMainExecutor);
|
||||||
mBroadcastDispatcher.registerReceiver(mUserChangeReceiver, userFilter, null,
|
|
||||||
UserHandle.ALL);
|
|
||||||
|
|
||||||
IntentFilter stateFilter = new IntentFilter(INTENT_UPDATE_STATE);
|
IntentFilter stateFilter = new IntentFilter(INTENT_UPDATE_STATE);
|
||||||
mBroadcastDispatcher.registerReceiver(mStateChangeReceiver, stateFilter, null,
|
mBroadcastDispatcher.registerReceiver(mStateChangeReceiver, stateFilter, null,
|
||||||
@@ -211,7 +219,7 @@ public class RecordingController
|
|||||||
public synchronized void updateState(boolean isRecording) {
|
public synchronized void updateState(boolean isRecording) {
|
||||||
if (!isRecording && mIsRecording) {
|
if (!isRecording && mIsRecording) {
|
||||||
// Unregister receivers if we have stopped recording
|
// Unregister receivers if we have stopped recording
|
||||||
mBroadcastDispatcher.unregisterReceiver(mUserChangeReceiver);
|
mUserTracker.removeCallback(mUserChangedCallback);
|
||||||
mBroadcastDispatcher.unregisterReceiver(mStateChangeReceiver);
|
mBroadcastDispatcher.unregisterReceiver(mStateChangeReceiver);
|
||||||
}
|
}
|
||||||
mIsRecording = isRecording;
|
mIsRecording = isRecording;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.content.IntentSender;
|
|||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.HandlerExecutor;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -37,6 +38,7 @@ import android.util.Log;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.util.SparseBooleanArray;
|
import android.util.SparseBooleanArray;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.internal.statusbar.NotificationVisibility;
|
import com.android.internal.statusbar.NotificationVisibility;
|
||||||
@@ -127,21 +129,6 @@ public class NotificationLockscreenUserManagerImpl implements
|
|||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case Intent.ACTION_USER_SWITCHED:
|
|
||||||
mCurrentUserId = intent.getIntExtra(
|
|
||||||
Intent.EXTRA_USER_HANDLE, UserHandle.USER_ALL);
|
|
||||||
updateCurrentProfilesCache();
|
|
||||||
|
|
||||||
Log.v(TAG, "userId " + mCurrentUserId + " is in the house");
|
|
||||||
|
|
||||||
updateLockscreenNotificationSetting();
|
|
||||||
updatePublicMode();
|
|
||||||
mPresenter.onUserSwitched(mCurrentUserId);
|
|
||||||
|
|
||||||
for (UserChangedListener listener : mListeners) {
|
|
||||||
listener.onUserChanged(mCurrentUserId);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Intent.ACTION_USER_REMOVED:
|
case Intent.ACTION_USER_REMOVED:
|
||||||
int removedUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
|
int removedUserId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
|
||||||
if (removedUserId != -1) {
|
if (removedUserId != -1) {
|
||||||
@@ -181,6 +168,25 @@ public class NotificationLockscreenUserManagerImpl implements
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected final UserTracker.Callback mUserChangedCallback =
|
||||||
|
new UserTracker.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
|
mCurrentUserId = newUser;
|
||||||
|
updateCurrentProfilesCache();
|
||||||
|
|
||||||
|
Log.v(TAG, "userId " + mCurrentUserId + " is in the house");
|
||||||
|
|
||||||
|
updateLockscreenNotificationSetting();
|
||||||
|
updatePublicMode();
|
||||||
|
mPresenter.onUserSwitched(mCurrentUserId);
|
||||||
|
|
||||||
|
for (UserChangedListener listener : mListeners) {
|
||||||
|
listener.onUserChanged(mCurrentUserId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
protected final Context mContext;
|
protected final Context mContext;
|
||||||
private final Handler mMainHandler;
|
private final Handler mMainHandler;
|
||||||
protected final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>();
|
protected final SparseArray<UserInfo> mCurrentProfiles = new SparseArray<>();
|
||||||
@@ -284,7 +290,6 @@ public class NotificationLockscreenUserManagerImpl implements
|
|||||||
null /* handler */, UserHandle.ALL);
|
null /* handler */, UserHandle.ALL);
|
||||||
|
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
|
||||||
filter.addAction(Intent.ACTION_USER_ADDED);
|
filter.addAction(Intent.ACTION_USER_ADDED);
|
||||||
filter.addAction(Intent.ACTION_USER_REMOVED);
|
filter.addAction(Intent.ACTION_USER_REMOVED);
|
||||||
filter.addAction(Intent.ACTION_USER_UNLOCKED);
|
filter.addAction(Intent.ACTION_USER_UNLOCKED);
|
||||||
@@ -298,6 +303,8 @@ public class NotificationLockscreenUserManagerImpl implements
|
|||||||
mContext.registerReceiver(mBaseBroadcastReceiver, internalFilter, PERMISSION_SELF, null,
|
mContext.registerReceiver(mBaseBroadcastReceiver, internalFilter, PERMISSION_SELF, null,
|
||||||
Context.RECEIVER_EXPORTED_UNAUDITED);
|
Context.RECEIVER_EXPORTED_UNAUDITED);
|
||||||
|
|
||||||
|
mUserTracker.addCallback(mUserChangedCallback, new HandlerExecutor(mMainHandler));
|
||||||
|
|
||||||
mCurrentUserId = mUserTracker.getUserId(); // in case we reg'd receiver too late
|
mCurrentUserId = mUserTracker.getUserId(); // in case we reg'd receiver too late
|
||||||
updateCurrentProfilesCache();
|
updateCurrentProfilesCache();
|
||||||
|
|
||||||
|
|||||||
@@ -2,22 +2,20 @@ package com.android.systemui.statusbar.notification.interruption
|
|||||||
|
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import android.app.Notification.VISIBILITY_SECRET
|
import android.app.Notification.VISIBILITY_SECRET
|
||||||
import android.content.BroadcastReceiver
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.content.IntentFilter
|
|
||||||
import android.database.ContentObserver
|
import android.database.ContentObserver
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
|
import android.os.HandlerExecutor
|
||||||
import android.os.UserHandle
|
import android.os.UserHandle
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor
|
import com.android.keyguard.KeyguardUpdateMonitor
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
||||||
import com.android.systemui.CoreStartable
|
import com.android.systemui.CoreStartable
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher
|
|
||||||
import com.android.systemui.dagger.SysUISingleton
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
import com.android.systemui.dagger.qualifiers.Main
|
import com.android.systemui.dagger.qualifiers.Main
|
||||||
import com.android.systemui.plugins.statusbar.StatusBarStateController
|
import com.android.systemui.plugins.statusbar.StatusBarStateController
|
||||||
|
import com.android.systemui.settings.UserTracker
|
||||||
import com.android.systemui.statusbar.NotificationLockscreenUserManager
|
import com.android.systemui.statusbar.NotificationLockscreenUserManager
|
||||||
import com.android.systemui.statusbar.StatusBarState
|
import com.android.systemui.statusbar.StatusBarState
|
||||||
import com.android.systemui.statusbar.SysuiStatusBarStateController
|
import com.android.systemui.statusbar.SysuiStatusBarStateController
|
||||||
@@ -78,7 +76,7 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
|
|||||||
private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
|
private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
|
||||||
private val highPriorityProvider: HighPriorityProvider,
|
private val highPriorityProvider: HighPriorityProvider,
|
||||||
private val statusBarStateController: SysuiStatusBarStateController,
|
private val statusBarStateController: SysuiStatusBarStateController,
|
||||||
private val broadcastDispatcher: BroadcastDispatcher,
|
private val userTracker: UserTracker,
|
||||||
private val secureSettings: SecureSettings,
|
private val secureSettings: SecureSettings,
|
||||||
private val globalSettings: GlobalSettings
|
private val globalSettings: GlobalSettings
|
||||||
) : CoreStartable, KeyguardNotificationVisibilityProvider {
|
) : CoreStartable, KeyguardNotificationVisibilityProvider {
|
||||||
@@ -87,6 +85,15 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
|
|||||||
private val onStateChangedListeners = ListenerSet<Consumer<String>>()
|
private val onStateChangedListeners = ListenerSet<Consumer<String>>()
|
||||||
private var hideSilentNotificationsOnLockscreen: Boolean = false
|
private var hideSilentNotificationsOnLockscreen: Boolean = false
|
||||||
|
|
||||||
|
private val userTrackerCallback = object : UserTracker.Callback {
|
||||||
|
override fun onUserChanged(newUser: Int, userContext: Context) {
|
||||||
|
if (isLockedOrLocking) {
|
||||||
|
// maybe public mode changed
|
||||||
|
notifyStateChanged("onUserSwitched")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun start() {
|
override fun start() {
|
||||||
readShowSilentNotificationSetting()
|
readShowSilentNotificationSetting()
|
||||||
keyguardStateController.addCallback(object : KeyguardStateController.Callback {
|
keyguardStateController.addCallback(object : KeyguardStateController.Callback {
|
||||||
@@ -143,14 +150,7 @@ private class KeyguardNotificationVisibilityProviderImpl @Inject constructor(
|
|||||||
notifyStateChanged("onStatusBarUpcomingStateChanged")
|
notifyStateChanged("onStatusBarUpcomingStateChanged")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
broadcastDispatcher.registerReceiver(object : BroadcastReceiver() {
|
userTracker.addCallback(userTrackerCallback, HandlerExecutor(handler))
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
|
||||||
if (isLockedOrLocking) {
|
|
||||||
// maybe public mode changed
|
|
||||||
notifyStateChanged(intent.action!!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, IntentFilter(Intent.ACTION_USER_SWITCHED))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addOnStateChangedListener(listener: Consumer<String>) {
|
override fun addOnStateChangedListener(listener: Consumer<String>) {
|
||||||
|
|||||||
@@ -15,23 +15,21 @@
|
|||||||
package com.android.systemui.statusbar.phone;
|
package com.android.systemui.statusbar.phone;
|
||||||
|
|
||||||
import android.app.StatusBarManager;
|
import android.app.StatusBarManager;
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.settings.UserTracker;
|
import com.android.systemui.settings.UserTracker;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -43,9 +41,9 @@ public class ManagedProfileControllerImpl implements ManagedProfileController {
|
|||||||
private final List<Callback> mCallbacks = new ArrayList<>();
|
private final List<Callback> mCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
private final Executor mMainExecutor;
|
||||||
private final UserManager mUserManager;
|
private final UserManager mUserManager;
|
||||||
private final UserTracker mUserTracker;
|
private final UserTracker mUserTracker;
|
||||||
private final BroadcastDispatcher mBroadcastDispatcher;
|
|
||||||
private final LinkedList<UserInfo> mProfiles;
|
private final LinkedList<UserInfo> mProfiles;
|
||||||
private boolean mListening;
|
private boolean mListening;
|
||||||
private int mCurrentUser;
|
private int mCurrentUser;
|
||||||
@@ -53,12 +51,12 @@ public class ManagedProfileControllerImpl implements ManagedProfileController {
|
|||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public ManagedProfileControllerImpl(Context context, UserTracker userTracker,
|
public ManagedProfileControllerImpl(Context context, @Main Executor mainExecutor,
|
||||||
BroadcastDispatcher broadcastDispatcher) {
|
UserTracker userTracker) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mMainExecutor = mainExecutor;
|
||||||
mUserManager = UserManager.get(mContext);
|
mUserManager = UserManager.get(mContext);
|
||||||
mUserTracker = userTracker;
|
mUserTracker = userTracker;
|
||||||
mBroadcastDispatcher = broadcastDispatcher;
|
|
||||||
mProfiles = new LinkedList<UserInfo>();
|
mProfiles = new LinkedList<UserInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,30 +128,34 @@ public class ManagedProfileControllerImpl implements ManagedProfileController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setListening(boolean listening) {
|
private void setListening(boolean listening) {
|
||||||
|
if (mListening == listening) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mListening = listening;
|
mListening = listening;
|
||||||
if (listening) {
|
if (listening) {
|
||||||
reloadManagedProfiles();
|
reloadManagedProfiles();
|
||||||
|
mUserTracker.addCallback(mUserChangedCallback, mMainExecutor);
|
||||||
final IntentFilter filter = new IntentFilter();
|
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
|
||||||
filter.addAction(Intent.ACTION_MANAGED_PROFILE_ADDED);
|
|
||||||
filter.addAction(Intent.ACTION_MANAGED_PROFILE_REMOVED);
|
|
||||||
filter.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE);
|
|
||||||
filter.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE);
|
|
||||||
mBroadcastDispatcher.registerReceiver(
|
|
||||||
mReceiver, filter, null /* handler */, UserHandle.ALL);
|
|
||||||
} else {
|
} else {
|
||||||
mBroadcastDispatcher.unregisterReceiver(mReceiver);
|
mUserTracker.removeCallback(mUserChangedCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
private final UserTracker.Callback mUserChangedCallback =
|
||||||
@Override
|
new UserTracker.Callback() {
|
||||||
public void onReceive(Context context, Intent intent) {
|
@Override
|
||||||
reloadManagedProfiles();
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
for (Callback callback : mCallbacks) {
|
reloadManagedProfiles();
|
||||||
callback.onManagedProfileChanged();
|
for (Callback callback : mCallbacks) {
|
||||||
}
|
callback.onManagedProfileChanged();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProfilesChanged(@NonNull List<UserInfo> profiles) {
|
||||||
|
reloadManagedProfiles();
|
||||||
|
for (Callback callback : mCallbacks) {
|
||||||
|
callback.onManagedProfileChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ public class Clock extends TextView implements
|
|||||||
@Override
|
@Override
|
||||||
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
mCurrentUserId = newUser;
|
mCurrentUserId = newUser;
|
||||||
|
updateClock();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -190,7 +191,6 @@ public class Clock extends TextView implements
|
|||||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
|
||||||
|
|
||||||
// NOTE: This receiver could run before this method returns, as it's not dispatching
|
// NOTE: This receiver could run before this method returns, as it's not dispatching
|
||||||
// on the main thread and BroadcastDispatcher may not need to register with Context.
|
// on the main thread and BroadcastDispatcher may not need to register with Context.
|
||||||
|
|||||||
@@ -28,11 +28,14 @@ import androidx.annotation.NonNull;
|
|||||||
import com.android.systemui.Dumpable;
|
import com.android.systemui.Dumpable;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.dump.DumpManager;
|
import com.android.systemui.dump.DumpManager;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -45,22 +48,34 @@ public class NextAlarmControllerImpl extends BroadcastReceiver
|
|||||||
|
|
||||||
private final ArrayList<NextAlarmChangeCallback> mChangeCallbacks = new ArrayList<>();
|
private final ArrayList<NextAlarmChangeCallback> mChangeCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
|
private final UserTracker mUserTracker;
|
||||||
private AlarmManager mAlarmManager;
|
private AlarmManager mAlarmManager;
|
||||||
private AlarmManager.AlarmClockInfo mNextAlarm;
|
private AlarmManager.AlarmClockInfo mNextAlarm;
|
||||||
|
|
||||||
|
private final UserTracker.Callback mUserChangedCallback =
|
||||||
|
new UserTracker.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onUserChanged(int newUser, @NonNull Context userContext) {
|
||||||
|
updateNextAlarm();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public NextAlarmControllerImpl(
|
public NextAlarmControllerImpl(
|
||||||
|
@Main Executor mainExecutor,
|
||||||
AlarmManager alarmManager,
|
AlarmManager alarmManager,
|
||||||
BroadcastDispatcher broadcastDispatcher,
|
BroadcastDispatcher broadcastDispatcher,
|
||||||
DumpManager dumpManager) {
|
DumpManager dumpManager,
|
||||||
|
UserTracker userTracker) {
|
||||||
dumpManager.registerDumpable("NextAlarmController", this);
|
dumpManager.registerDumpable("NextAlarmController", this);
|
||||||
mAlarmManager = alarmManager;
|
mAlarmManager = alarmManager;
|
||||||
|
mUserTracker = userTracker;
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_USER_SWITCHED);
|
|
||||||
filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
|
filter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
|
||||||
broadcastDispatcher.registerReceiver(this, filter, null, UserHandle.ALL);
|
broadcastDispatcher.registerReceiver(this, filter, null, UserHandle.ALL);
|
||||||
|
mUserTracker.addCallback(mUserChangedCallback, mainExecutor);
|
||||||
updateNextAlarm();
|
updateNextAlarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,14 +113,13 @@ public class NextAlarmControllerImpl extends BroadcastReceiver
|
|||||||
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (action.equals(Intent.ACTION_USER_SWITCHED)
|
if (action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) {
|
||||||
|| action.equals(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED)) {
|
|
||||||
updateNextAlarm();
|
updateNextAlarm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateNextAlarm() {
|
private void updateNextAlarm() {
|
||||||
mNextAlarm = mAlarmManager.getNextAlarmClock(UserHandle.USER_CURRENT);
|
mNextAlarm = mAlarmManager.getNextAlarmClock(mUserTracker.getUserId());
|
||||||
fireNextAlarmChanged();
|
fireNextAlarmChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
import com.android.systemui.biometrics.AuthController;
|
import com.android.systemui.biometrics.AuthController;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
|
||||||
import com.android.systemui.decor.CornerDecorProvider;
|
import com.android.systemui.decor.CornerDecorProvider;
|
||||||
import com.android.systemui.decor.CutoutDecorProviderFactory;
|
import com.android.systemui.decor.CutoutDecorProviderFactory;
|
||||||
import com.android.systemui.decor.CutoutDecorProviderImpl;
|
import com.android.systemui.decor.CutoutDecorProviderImpl;
|
||||||
@@ -132,8 +131,6 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private TunerService mTunerService;
|
private TunerService mTunerService;
|
||||||
@Mock
|
@Mock
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
|
||||||
@Mock
|
|
||||||
private UserTracker mUserTracker;
|
private UserTracker mUserTracker;
|
||||||
@Mock
|
@Mock
|
||||||
private PrivacyDotViewController mDotViewController;
|
private PrivacyDotViewController mDotViewController;
|
||||||
@@ -223,8 +220,8 @@ public class ScreenDecorationsTest extends SysuiTestCase {
|
|||||||
mExecutor));
|
mExecutor));
|
||||||
|
|
||||||
mScreenDecorations = spy(new ScreenDecorations(mContext, mExecutor, mSecureSettings,
|
mScreenDecorations = spy(new ScreenDecorations(mContext, mExecutor, mSecureSettings,
|
||||||
mBroadcastDispatcher, mTunerService, mUserTracker, mDotViewController,
|
mTunerService, mUserTracker, mDotViewController, mThreadFactory,
|
||||||
mThreadFactory, mPrivacyDotDecorProviderFactory, mFaceScanningProviderFactory) {
|
mPrivacyDotDecorProviderFactory, mFaceScanningProviderFactory) {
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
super.start();
|
super.start();
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package com.android.systemui.controls.controller
|
package com.android.systemui.controls.controller
|
||||||
|
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.BroadcastReceiver
|
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.ContextWrapper
|
import android.content.ContextWrapper
|
||||||
@@ -31,7 +30,6 @@ import android.testing.AndroidTestingRunner
|
|||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.SysuiTestCase
|
import com.android.systemui.SysuiTestCase
|
||||||
import com.android.systemui.backup.BackupHelper
|
import com.android.systemui.backup.BackupHelper
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher
|
|
||||||
import com.android.systemui.controls.ControlStatus
|
import com.android.systemui.controls.ControlStatus
|
||||||
import com.android.systemui.controls.ControlsServiceInfo
|
import com.android.systemui.controls.ControlsServiceInfo
|
||||||
import com.android.systemui.controls.management.ControlsListingController
|
import com.android.systemui.controls.management.ControlsListingController
|
||||||
@@ -85,10 +83,8 @@ class ControlsControllerImplTest : SysuiTestCase() {
|
|||||||
@Mock
|
@Mock
|
||||||
private lateinit var auxiliaryPersistenceWrapper: AuxiliaryPersistenceWrapper
|
private lateinit var auxiliaryPersistenceWrapper: AuxiliaryPersistenceWrapper
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var broadcastDispatcher: BroadcastDispatcher
|
|
||||||
@Mock
|
|
||||||
private lateinit var listingController: ControlsListingController
|
private lateinit var listingController: ControlsListingController
|
||||||
@Mock(stubOnly = true)
|
@Mock
|
||||||
private lateinit var userTracker: UserTracker
|
private lateinit var userTracker: UserTracker
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var userFileManager: UserFileManager
|
private lateinit var userFileManager: UserFileManager
|
||||||
@@ -104,7 +100,7 @@ class ControlsControllerImplTest : SysuiTestCase() {
|
|||||||
ArgumentCaptor<ControlsBindingController.LoadCallback>
|
ArgumentCaptor<ControlsBindingController.LoadCallback>
|
||||||
|
|
||||||
@Captor
|
@Captor
|
||||||
private lateinit var broadcastReceiverCaptor: ArgumentCaptor<BroadcastReceiver>
|
private lateinit var userTrackerCallbackCaptor: ArgumentCaptor<UserTracker.Callback>
|
||||||
@Captor
|
@Captor
|
||||||
private lateinit var listingCallbackCaptor:
|
private lateinit var listingCallbackCaptor:
|
||||||
ArgumentCaptor<ControlsListingController.ControlsListingCallback>
|
ArgumentCaptor<ControlsListingController.ControlsListingCallback>
|
||||||
@@ -170,16 +166,15 @@ class ControlsControllerImplTest : SysuiTestCase() {
|
|||||||
uiController,
|
uiController,
|
||||||
bindingController,
|
bindingController,
|
||||||
listingController,
|
listingController,
|
||||||
broadcastDispatcher,
|
|
||||||
userFileManager,
|
userFileManager,
|
||||||
|
userTracker,
|
||||||
Optional.of(persistenceWrapper),
|
Optional.of(persistenceWrapper),
|
||||||
mock(DumpManager::class.java),
|
mock(DumpManager::class.java)
|
||||||
userTracker
|
|
||||||
)
|
)
|
||||||
controller.auxiliaryPersistenceWrapper = auxiliaryPersistenceWrapper
|
controller.auxiliaryPersistenceWrapper = auxiliaryPersistenceWrapper
|
||||||
|
|
||||||
verify(broadcastDispatcher).registerReceiver(
|
verify(userTracker).addCallback(
|
||||||
capture(broadcastReceiverCaptor), any(), any(), eq(UserHandle.ALL), anyInt(), any()
|
capture(userTrackerCallbackCaptor), any()
|
||||||
)
|
)
|
||||||
|
|
||||||
verify(listingController).addCallback(capture(listingCallbackCaptor))
|
verify(listingController).addCallback(capture(listingCallbackCaptor))
|
||||||
@@ -227,11 +222,10 @@ class ControlsControllerImplTest : SysuiTestCase() {
|
|||||||
uiController,
|
uiController,
|
||||||
bindingController,
|
bindingController,
|
||||||
listingController,
|
listingController,
|
||||||
broadcastDispatcher,
|
|
||||||
userFileManager,
|
userFileManager,
|
||||||
|
userTracker,
|
||||||
Optional.of(persistenceWrapper),
|
Optional.of(persistenceWrapper),
|
||||||
mock(DumpManager::class.java),
|
mock(DumpManager::class.java)
|
||||||
userTracker
|
|
||||||
)
|
)
|
||||||
assertEquals(listOf(TEST_STRUCTURE_INFO), controller_other.getFavorites())
|
assertEquals(listOf(TEST_STRUCTURE_INFO), controller_other.getFavorites())
|
||||||
}
|
}
|
||||||
@@ -518,14 +512,8 @@ class ControlsControllerImplTest : SysuiTestCase() {
|
|||||||
delayableExecutor.runAllReady()
|
delayableExecutor.runAllReady()
|
||||||
|
|
||||||
reset(persistenceWrapper)
|
reset(persistenceWrapper)
|
||||||
val intent = Intent(Intent.ACTION_USER_SWITCHED).apply {
|
|
||||||
putExtra(Intent.EXTRA_USER_HANDLE, otherUser)
|
|
||||||
}
|
|
||||||
val pendingResult = mock(BroadcastReceiver.PendingResult::class.java)
|
|
||||||
`when`(pendingResult.sendingUserId).thenReturn(otherUser)
|
|
||||||
broadcastReceiverCaptor.value.pendingResult = pendingResult
|
|
||||||
|
|
||||||
broadcastReceiverCaptor.value.onReceive(mContext, intent)
|
userTrackerCallbackCaptor.value.onUserChanged(otherUser, mContext)
|
||||||
|
|
||||||
verify(persistenceWrapper).changeFileAndBackupManager(any(), any())
|
verify(persistenceWrapper).changeFileAndBackupManager(any(), any())
|
||||||
verify(persistenceWrapper).readFavorites()
|
verify(persistenceWrapper).readFavorites()
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import com.android.systemui.media.controls.models.player.MediaData
|
|||||||
import com.android.systemui.media.controls.models.player.MediaDeviceData
|
import com.android.systemui.media.controls.models.player.MediaDeviceData
|
||||||
import com.android.systemui.media.controls.pipeline.MediaDataManager
|
import com.android.systemui.media.controls.pipeline.MediaDataManager
|
||||||
import com.android.systemui.media.controls.pipeline.RESUME_MEDIA_TIMEOUT
|
import com.android.systemui.media.controls.pipeline.RESUME_MEDIA_TIMEOUT
|
||||||
|
import com.android.systemui.settings.UserTracker
|
||||||
import com.android.systemui.tuner.TunerService
|
import com.android.systemui.tuner.TunerService
|
||||||
import com.android.systemui.util.concurrency.FakeExecutor
|
import com.android.systemui.util.concurrency.FakeExecutor
|
||||||
import com.android.systemui.util.time.FakeSystemClock
|
import com.android.systemui.util.time.FakeSystemClock
|
||||||
@@ -79,6 +80,7 @@ private fun <T> any(): T = Mockito.any<T>()
|
|||||||
class MediaResumeListenerTest : SysuiTestCase() {
|
class MediaResumeListenerTest : SysuiTestCase() {
|
||||||
|
|
||||||
@Mock private lateinit var broadcastDispatcher: BroadcastDispatcher
|
@Mock private lateinit var broadcastDispatcher: BroadcastDispatcher
|
||||||
|
@Mock private lateinit var userTracker: UserTracker
|
||||||
@Mock private lateinit var mediaDataManager: MediaDataManager
|
@Mock private lateinit var mediaDataManager: MediaDataManager
|
||||||
@Mock private lateinit var device: MediaDeviceData
|
@Mock private lateinit var device: MediaDeviceData
|
||||||
@Mock private lateinit var token: MediaSession.Token
|
@Mock private lateinit var token: MediaSession.Token
|
||||||
@@ -131,12 +133,15 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
whenever(sharedPrefsEditor.putString(any(), any())).thenReturn(sharedPrefsEditor)
|
whenever(sharedPrefsEditor.putString(any(), any())).thenReturn(sharedPrefsEditor)
|
||||||
whenever(mockContext.packageManager).thenReturn(context.packageManager)
|
whenever(mockContext.packageManager).thenReturn(context.packageManager)
|
||||||
whenever(mockContext.contentResolver).thenReturn(context.contentResolver)
|
whenever(mockContext.contentResolver).thenReturn(context.contentResolver)
|
||||||
|
whenever(mockContext.userId).thenReturn(context.userId)
|
||||||
|
|
||||||
executor = FakeExecutor(clock)
|
executor = FakeExecutor(clock)
|
||||||
resumeListener =
|
resumeListener =
|
||||||
MediaResumeListener(
|
MediaResumeListener(
|
||||||
mockContext,
|
mockContext,
|
||||||
broadcastDispatcher,
|
broadcastDispatcher,
|
||||||
|
userTracker,
|
||||||
|
executor,
|
||||||
executor,
|
executor,
|
||||||
tunerService,
|
tunerService,
|
||||||
resumeBrowserFactory,
|
resumeBrowserFactory,
|
||||||
@@ -177,6 +182,8 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
MediaResumeListener(
|
MediaResumeListener(
|
||||||
context,
|
context,
|
||||||
broadcastDispatcher,
|
broadcastDispatcher,
|
||||||
|
userTracker,
|
||||||
|
executor,
|
||||||
executor,
|
executor,
|
||||||
tunerService,
|
tunerService,
|
||||||
resumeBrowserFactory,
|
resumeBrowserFactory,
|
||||||
@@ -185,7 +192,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
)
|
)
|
||||||
listener.setManager(mediaDataManager)
|
listener.setManager(mediaDataManager)
|
||||||
verify(broadcastDispatcher, never())
|
verify(broadcastDispatcher, never())
|
||||||
.registerReceiver(eq(listener.userChangeReceiver), any(), any(), any(), anyInt(), any())
|
.registerReceiver(eq(listener.userUnlockReceiver), any(), any(), any(), anyInt(), any())
|
||||||
|
|
||||||
// When data is loaded, we do NOT execute or update anything
|
// When data is loaded, we do NOT execute or update anything
|
||||||
listener.onMediaDataLoaded(KEY, OLD_KEY, data)
|
listener.onMediaDataLoaded(KEY, OLD_KEY, data)
|
||||||
@@ -289,7 +296,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
resumeListener.setManager(mediaDataManager)
|
resumeListener.setManager(mediaDataManager)
|
||||||
verify(broadcastDispatcher)
|
verify(broadcastDispatcher)
|
||||||
.registerReceiver(
|
.registerReceiver(
|
||||||
eq(resumeListener.userChangeReceiver),
|
eq(resumeListener.userUnlockReceiver),
|
||||||
any(),
|
any(),
|
||||||
any(),
|
any(),
|
||||||
any(),
|
any(),
|
||||||
@@ -299,7 +306,8 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// When we get an unlock event
|
// When we get an unlock event
|
||||||
val intent = Intent(Intent.ACTION_USER_UNLOCKED)
|
val intent = Intent(Intent.ACTION_USER_UNLOCKED)
|
||||||
resumeListener.userChangeReceiver.onReceive(context, intent)
|
intent.putExtra(Intent.EXTRA_USER_HANDLE, context.userId)
|
||||||
|
resumeListener.userUnlockReceiver.onReceive(context, intent)
|
||||||
|
|
||||||
// Then we should attempt to find recent media for each saved component
|
// Then we should attempt to find recent media for each saved component
|
||||||
verify(resumeBrowser, times(3)).findRecentMedia()
|
verify(resumeBrowser, times(3)).findRecentMedia()
|
||||||
@@ -375,6 +383,8 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
MediaResumeListener(
|
MediaResumeListener(
|
||||||
mockContext,
|
mockContext,
|
||||||
broadcastDispatcher,
|
broadcastDispatcher,
|
||||||
|
userTracker,
|
||||||
|
executor,
|
||||||
executor,
|
executor,
|
||||||
tunerService,
|
tunerService,
|
||||||
resumeBrowserFactory,
|
resumeBrowserFactory,
|
||||||
@@ -386,7 +396,8 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// When we load a component that was played recently
|
// When we load a component that was played recently
|
||||||
val intent = Intent(Intent.ACTION_USER_UNLOCKED)
|
val intent = Intent(Intent.ACTION_USER_UNLOCKED)
|
||||||
resumeListener.userChangeReceiver.onReceive(mockContext, intent)
|
intent.putExtra(Intent.EXTRA_USER_HANDLE, context.userId)
|
||||||
|
resumeListener.userUnlockReceiver.onReceive(mockContext, intent)
|
||||||
|
|
||||||
// We add its resume controls
|
// We add its resume controls
|
||||||
verify(resumeBrowser, times(1)).findRecentMedia()
|
verify(resumeBrowser, times(1)).findRecentMedia()
|
||||||
@@ -404,6 +415,8 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
MediaResumeListener(
|
MediaResumeListener(
|
||||||
mockContext,
|
mockContext,
|
||||||
broadcastDispatcher,
|
broadcastDispatcher,
|
||||||
|
userTracker,
|
||||||
|
executor,
|
||||||
executor,
|
executor,
|
||||||
tunerService,
|
tunerService,
|
||||||
resumeBrowserFactory,
|
resumeBrowserFactory,
|
||||||
@@ -415,7 +428,8 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
|
|
||||||
// When we load a component that is not recent
|
// When we load a component that is not recent
|
||||||
val intent = Intent(Intent.ACTION_USER_UNLOCKED)
|
val intent = Intent(Intent.ACTION_USER_UNLOCKED)
|
||||||
resumeListener.userChangeReceiver.onReceive(mockContext, intent)
|
intent.putExtra(Intent.EXTRA_USER_HANDLE, context.userId)
|
||||||
|
resumeListener.userUnlockReceiver.onReceive(mockContext, intent)
|
||||||
|
|
||||||
// We do not try to add resume controls
|
// We do not try to add resume controls
|
||||||
verify(resumeBrowser, times(0)).findRecentMedia()
|
verify(resumeBrowser, times(0)).findRecentMedia()
|
||||||
@@ -443,6 +457,8 @@ class MediaResumeListenerTest : SysuiTestCase() {
|
|||||||
MediaResumeListener(
|
MediaResumeListener(
|
||||||
mockContext,
|
mockContext,
|
||||||
broadcastDispatcher,
|
broadcastDispatcher,
|
||||||
|
userTracker,
|
||||||
|
executor,
|
||||||
executor,
|
executor,
|
||||||
tunerService,
|
tunerService,
|
||||||
resumeBrowserFactory,
|
resumeBrowserFactory,
|
||||||
|
|||||||
@@ -44,14 +44,11 @@ import static org.mockito.Mockito.times;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.hardware.display.DisplayManagerGlobal;
|
import android.hardware.display.DisplayManagerGlobal;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
import android.telecom.TelecomManager;
|
import android.telecom.TelecomManager;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
@@ -79,7 +76,6 @@ import com.android.systemui.accessibility.AccessibilityButtonModeObserver;
|
|||||||
import com.android.systemui.accessibility.AccessibilityButtonTargetsObserver;
|
import com.android.systemui.accessibility.AccessibilityButtonTargetsObserver;
|
||||||
import com.android.systemui.accessibility.SystemActions;
|
import com.android.systemui.accessibility.SystemActions;
|
||||||
import com.android.systemui.assist.AssistManager;
|
import com.android.systemui.assist.AssistManager;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
|
||||||
import com.android.systemui.dump.DumpManager;
|
import com.android.systemui.dump.DumpManager;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
import com.android.systemui.model.SysUiState;
|
import com.android.systemui.model.SysUiState;
|
||||||
@@ -119,6 +115,7 @@ import org.mockito.Mock;
|
|||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@RunWith(AndroidTestingRunner.class)
|
@RunWith(AndroidTestingRunner.class)
|
||||||
@RunWithLooper(setAsMainLooper = true)
|
@RunWithLooper(setAsMainLooper = true)
|
||||||
@@ -166,7 +163,7 @@ public class NavigationBarTest extends SysuiTestCase {
|
|||||||
@Mock
|
@Mock
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
@Mock
|
@Mock
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private UserTracker mUserTracker;
|
||||||
@Mock
|
@Mock
|
||||||
private UiEventLogger mUiEventLogger;
|
private UiEventLogger mUiEventLogger;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -315,14 +312,10 @@ public class NavigationBarTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRegisteredWithDispatcher() {
|
public void testRegisteredWithUserTracker() {
|
||||||
mNavigationBar.init();
|
mNavigationBar.init();
|
||||||
mNavigationBar.onViewAttached();
|
mNavigationBar.onViewAttached();
|
||||||
verify(mBroadcastDispatcher).registerReceiverWithHandler(
|
verify(mUserTracker).addCallback(any(UserTracker.Callback.class), any(Executor.class));
|
||||||
any(BroadcastReceiver.class),
|
|
||||||
any(IntentFilter.class),
|
|
||||||
any(Handler.class),
|
|
||||||
any(UserHandle.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -463,7 +456,7 @@ public class NavigationBarTest extends SysuiTestCase {
|
|||||||
mStatusBarStateController,
|
mStatusBarStateController,
|
||||||
mStatusBarKeyguardViewManager,
|
mStatusBarKeyguardViewManager,
|
||||||
mMockSysUiState,
|
mMockSysUiState,
|
||||||
mBroadcastDispatcher,
|
mUserTracker,
|
||||||
mCommandQueue,
|
mCommandQueue,
|
||||||
Optional.of(mock(Pip.class)),
|
Optional.of(mock(Pip.class)),
|
||||||
Optional.of(mock(Recents.class)),
|
Optional.of(mock(Recents.class)),
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import com.android.systemui.SysuiTestCase;
|
|||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
import com.android.systemui.keyguard.WakefulnessLifecycle;
|
||||||
import com.android.systemui.power.PowerUI.WarningsUI;
|
import com.android.systemui.power.PowerUI.WarningsUI;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
import com.android.systemui.statusbar.CommandQueue;
|
import com.android.systemui.statusbar.CommandQueue;
|
||||||
import com.android.systemui.statusbar.phone.CentralSurfaces;
|
import com.android.systemui.statusbar.phone.CentralSurfaces;
|
||||||
|
|
||||||
@@ -85,6 +86,7 @@ public class PowerUITest extends SysuiTestCase {
|
|||||||
private PowerUI mPowerUI;
|
private PowerUI mPowerUI;
|
||||||
@Mock private EnhancedEstimates mEnhancedEstimates;
|
@Mock private EnhancedEstimates mEnhancedEstimates;
|
||||||
@Mock private PowerManager mPowerManager;
|
@Mock private PowerManager mPowerManager;
|
||||||
|
@Mock private UserTracker mUserTracker;
|
||||||
@Mock private WakefulnessLifecycle mWakefulnessLifecycle;
|
@Mock private WakefulnessLifecycle mWakefulnessLifecycle;
|
||||||
@Mock private IThermalService mThermalServiceMock;
|
@Mock private IThermalService mThermalServiceMock;
|
||||||
private IThermalEventListener mUsbThermalEventListener;
|
private IThermalEventListener mUsbThermalEventListener;
|
||||||
@@ -682,7 +684,8 @@ public class PowerUITest extends SysuiTestCase {
|
|||||||
private void createPowerUi() {
|
private void createPowerUi() {
|
||||||
mPowerUI = new PowerUI(
|
mPowerUI = new PowerUI(
|
||||||
mContext, mBroadcastDispatcher, mCommandQueue, mCentralSurfacesOptionalLazy,
|
mContext, mBroadcastDispatcher, mCommandQueue, mCentralSurfacesOptionalLazy,
|
||||||
mMockWarnings, mEnhancedEstimates, mWakefulnessLifecycle, mPowerManager);
|
mMockWarnings, mEnhancedEstimates, mWakefulnessLifecycle, mPowerManager,
|
||||||
|
mUserTracker);
|
||||||
mPowerUI.mThermalService = mThermalServiceMock;
|
mPowerUI.mThermalService = mThermalServiceMock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ import androidx.test.filters.SmallTest;
|
|||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.settings.UserContextProvider;
|
import com.android.systemui.settings.UserContextProvider;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
|
import com.android.systemui.util.concurrency.FakeExecutor;
|
||||||
|
import com.android.systemui.util.time.FakeSystemClock;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -49,12 +52,16 @@ import org.mockito.MockitoAnnotations;
|
|||||||
*/
|
*/
|
||||||
public class RecordingControllerTest extends SysuiTestCase {
|
public class RecordingControllerTest extends SysuiTestCase {
|
||||||
|
|
||||||
|
private FakeSystemClock mFakeSystemClock = new FakeSystemClock();
|
||||||
|
private FakeExecutor mMainExecutor = new FakeExecutor(mFakeSystemClock);
|
||||||
@Mock
|
@Mock
|
||||||
private RecordingController.RecordingStateChangeCallback mCallback;
|
private RecordingController.RecordingStateChangeCallback mCallback;
|
||||||
@Mock
|
@Mock
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
@Mock
|
@Mock
|
||||||
private UserContextProvider mUserContextProvider;
|
private UserContextProvider mUserContextProvider;
|
||||||
|
@Mock
|
||||||
|
private UserTracker mUserTracker;
|
||||||
|
|
||||||
private RecordingController mController;
|
private RecordingController mController;
|
||||||
|
|
||||||
@@ -63,7 +70,8 @@ public class RecordingControllerTest extends SysuiTestCase {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mController = new RecordingController(mBroadcastDispatcher, mUserContextProvider);
|
mController = new RecordingController(mMainExecutor, mBroadcastDispatcher,
|
||||||
|
mUserContextProvider, mUserTracker);
|
||||||
mController.addCallback(mCallback);
|
mController.addCallback(mCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +184,7 @@ public class RecordingControllerTest extends SysuiTestCase {
|
|||||||
mController.updateState(true);
|
mController.updateState(true);
|
||||||
|
|
||||||
// and user is changed
|
// and user is changed
|
||||||
Intent intent = new Intent(Intent.ACTION_USER_SWITCHED)
|
mController.mUserChangedCallback.onUserChanged(USER_ID, mContext);
|
||||||
.putExtra(Intent.EXTRA_USER_HANDLE, USER_ID);
|
|
||||||
mController.mUserChangeReceiver.onReceive(mContext, intent);
|
|
||||||
|
|
||||||
// Ensure that the recording was stopped
|
// Ensure that the recording was stopped
|
||||||
verify(mCallback).onRecordingEnd();
|
verify(mCallback).onRecordingEnd();
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar;
|
package com.android.systemui.statusbar;
|
||||||
|
|
||||||
import static android.content.Intent.ACTION_USER_SWITCHED;
|
|
||||||
|
|
||||||
import static junit.framework.Assert.assertFalse;
|
import static junit.framework.Assert.assertFalse;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
@@ -34,7 +32,6 @@ import android.app.Notification;
|
|||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -293,11 +290,9 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testActionUserSwitchedCallsOnUserSwitched() {
|
public void testUserSwitchedCallsOnUserSwitched() {
|
||||||
Intent intent = new Intent()
|
mLockscreenUserManager.getUserTrackerCallbackForTest().onUserChanged(mSecondaryUser.id,
|
||||||
.setAction(ACTION_USER_SWITCHED)
|
mContext);
|
||||||
.putExtra(Intent.EXTRA_USER_HANDLE, mSecondaryUser.id);
|
|
||||||
mLockscreenUserManager.getBaseBroadcastReceiverForTest().onReceive(mContext, intent);
|
|
||||||
verify(mPresenter, times(1)).onUserSwitched(mSecondaryUser.id);
|
verify(mPresenter, times(1)).onUserSwitched(mSecondaryUser.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,6 +361,10 @@ public class NotificationLockscreenUserManagerTest extends SysuiTestCase {
|
|||||||
return mBaseBroadcastReceiver;
|
return mBaseBroadcastReceiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UserTracker.Callback getUserTrackerCallbackForTest() {
|
||||||
|
return mUserChangedCallback;
|
||||||
|
}
|
||||||
|
|
||||||
public ContentObserver getLockscreenSettingsObserverForTest() {
|
public ContentObserver getLockscreenSettingsObserverForTest() {
|
||||||
return mLockscreenSettingsObserver;
|
return mLockscreenSettingsObserver;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,22 +26,17 @@ import static android.app.NotificationManager.IMPORTANCE_MIN;
|
|||||||
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
|
import static com.android.systemui.statusbar.StatusBarState.KEYGUARD;
|
||||||
import static com.android.systemui.statusbar.StatusBarState.SHADE;
|
import static com.android.systemui.statusbar.StatusBarState.SHADE;
|
||||||
import static com.android.systemui.statusbar.notification.collection.EntryUtilKt.modifyEntry;
|
import static com.android.systemui.statusbar.notification.collection.EntryUtilKt.modifyEntry;
|
||||||
import static com.android.systemui.util.mockito.KotlinMockitoHelpersKt.argThat;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
|
||||||
import static org.mockito.ArgumentMatchers.isNull;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -54,10 +49,10 @@ import com.android.keyguard.KeyguardUpdateMonitor;
|
|||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
import com.android.systemui.CoreStartable;
|
import com.android.systemui.CoreStartable;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
|
||||||
import com.android.systemui.dagger.SysUISingleton;
|
import com.android.systemui.dagger.SysUISingleton;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
|
import com.android.systemui.settings.UserTracker;
|
||||||
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
|
||||||
import com.android.systemui.statusbar.RankingBuilder;
|
import com.android.systemui.statusbar.RankingBuilder;
|
||||||
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
import com.android.systemui.statusbar.SysuiStatusBarStateController;
|
||||||
@@ -97,7 +92,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
|
|||||||
@Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
@Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||||
@Mock private HighPriorityProvider mHighPriorityProvider;
|
@Mock private HighPriorityProvider mHighPriorityProvider;
|
||||||
@Mock private SysuiStatusBarStateController mStatusBarStateController;
|
@Mock private SysuiStatusBarStateController mStatusBarStateController;
|
||||||
@Mock private BroadcastDispatcher mBroadcastDispatcher;
|
@Mock private UserTracker mUserTracker;
|
||||||
private final FakeSettings mFakeSettings = new FakeSettings();
|
private final FakeSettings mFakeSettings = new FakeSettings();
|
||||||
|
|
||||||
private KeyguardNotificationVisibilityProvider mKeyguardNotificationVisibilityProvider;
|
private KeyguardNotificationVisibilityProvider mKeyguardNotificationVisibilityProvider;
|
||||||
@@ -117,7 +112,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
|
|||||||
mKeyguardUpdateMonitor,
|
mKeyguardUpdateMonitor,
|
||||||
mHighPriorityProvider,
|
mHighPriorityProvider,
|
||||||
mStatusBarStateController,
|
mStatusBarStateController,
|
||||||
mBroadcastDispatcher,
|
mUserTracker,
|
||||||
mFakeSettings,
|
mFakeSettings,
|
||||||
mFakeSettings);
|
mFakeSettings);
|
||||||
mKeyguardNotificationVisibilityProvider = component.getProvider();
|
mKeyguardNotificationVisibilityProvider = component.getProvider();
|
||||||
@@ -205,23 +200,19 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notifyListeners_onReceiveUserSwitchBroadcast() {
|
public void notifyListeners_onReceiveUserSwitchCallback() {
|
||||||
ArgumentCaptor<BroadcastReceiver> callbackCaptor =
|
ArgumentCaptor<UserTracker.Callback> callbackCaptor =
|
||||||
ArgumentCaptor.forClass(BroadcastReceiver.class);
|
ArgumentCaptor.forClass(UserTracker.Callback.class);
|
||||||
verify(mBroadcastDispatcher).registerReceiver(
|
verify(mUserTracker).addCallback(
|
||||||
callbackCaptor.capture(),
|
callbackCaptor.capture(),
|
||||||
argThat(intentFilter -> intentFilter.hasAction(Intent.ACTION_USER_SWITCHED)),
|
any());
|
||||||
isNull(),
|
UserTracker.Callback callback = callbackCaptor.getValue();
|
||||||
isNull(),
|
|
||||||
eq(Context.RECEIVER_EXPORTED),
|
|
||||||
isNull());
|
|
||||||
BroadcastReceiver callback = callbackCaptor.getValue();
|
|
||||||
|
|
||||||
Consumer<String> listener = mock(Consumer.class);
|
Consumer<String> listener = mock(Consumer.class);
|
||||||
mKeyguardNotificationVisibilityProvider.addOnStateChangedListener(listener);
|
mKeyguardNotificationVisibilityProvider.addOnStateChangedListener(listener);
|
||||||
|
|
||||||
when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
|
when(mStatusBarStateController.getCurrentOrUpcomingState()).thenReturn(KEYGUARD);
|
||||||
callback.onReceive(mContext, new Intent(Intent.ACTION_USER_SWITCHED));
|
callback.onUserChanged(CURR_USER_ID, mContext);
|
||||||
|
|
||||||
verify(listener).accept(anyString());
|
verify(listener).accept(anyString());
|
||||||
}
|
}
|
||||||
@@ -619,7 +610,7 @@ public class KeyguardNotificationVisibilityProviderTest extends SysuiTestCase {
|
|||||||
@BindsInstance KeyguardUpdateMonitor keyguardUpdateMonitor,
|
@BindsInstance KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||||
@BindsInstance HighPriorityProvider highPriorityProvider,
|
@BindsInstance HighPriorityProvider highPriorityProvider,
|
||||||
@BindsInstance SysuiStatusBarStateController statusBarStateController,
|
@BindsInstance SysuiStatusBarStateController statusBarStateController,
|
||||||
@BindsInstance BroadcastDispatcher broadcastDispatcher,
|
@BindsInstance UserTracker userTracker,
|
||||||
@BindsInstance SecureSettings secureSettings,
|
@BindsInstance SecureSettings secureSettings,
|
||||||
@BindsInstance GlobalSettings globalSettings
|
@BindsInstance GlobalSettings globalSettings
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user