Merge "Use unique Handler for media, and synchronize it" into qt-qpr1-dev
am: fd6f170e31
Change-Id: I794799d85e407cdd110f9a72a061b1250443ce09
This commit is contained in:
@@ -49,6 +49,7 @@ import androidx.slice.builders.SliceAction;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||
import com.android.systemui.Dependency;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||
import com.android.systemui.statusbar.NotificationMediaManager;
|
||||
@@ -58,7 +59,6 @@ import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
||||
import com.android.systemui.statusbar.policy.NextAlarmController;
|
||||
import com.android.systemui.statusbar.policy.NextAlarmControllerImpl;
|
||||
import com.android.systemui.statusbar.policy.ZenModeController;
|
||||
import com.android.systemui.statusbar.policy.ZenModeControllerImpl;
|
||||
import com.android.systemui.util.wakelock.SettableWakeLock;
|
||||
import com.android.systemui.util.wakelock.WakeLock;
|
||||
|
||||
@@ -103,8 +103,8 @@ public class KeyguardSliceProvider extends SliceProvider implements
|
||||
protected final Uri mMediaUri;
|
||||
private final Date mCurrentTime = new Date();
|
||||
private final Handler mHandler;
|
||||
private final Handler mMediaHandler;
|
||||
private final AlarmManager.OnAlarmListener mUpdateNextAlarm = this::updateNextAlarm;
|
||||
private final Object mMediaToken = new Object();
|
||||
private DozeParameters mDozeParameters;
|
||||
@VisibleForTesting
|
||||
protected SettableWakeLock mMediaWakeLock;
|
||||
@@ -169,17 +169,13 @@ public class KeyguardSliceProvider extends SliceProvider implements
|
||||
}
|
||||
};
|
||||
|
||||
public KeyguardSliceProvider() {
|
||||
this(new Handler());
|
||||
}
|
||||
|
||||
public static KeyguardSliceProvider getAttachedInstance() {
|
||||
return KeyguardSliceProvider.sInstance;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
KeyguardSliceProvider(Handler handler) {
|
||||
mHandler = handler;
|
||||
public KeyguardSliceProvider() {
|
||||
mHandler = new Handler();
|
||||
mMediaHandler = new Handler();
|
||||
mSliceUri = Uri.parse(KEYGUARD_SLICE_URI);
|
||||
mHeaderUri = Uri.parse(KEYGUARD_HEADER_URI);
|
||||
mDateUri = Uri.parse(KEYGUARD_DATE_URI);
|
||||
@@ -320,7 +316,7 @@ public class KeyguardSliceProvider extends SliceProvider implements
|
||||
mContentResolver = getContext().getContentResolver();
|
||||
mNextAlarmController = new NextAlarmControllerImpl(getContext());
|
||||
mNextAlarmController.addCallback(this);
|
||||
mZenModeController = new ZenModeControllerImpl(getContext(), mHandler);
|
||||
mZenModeController = Dependency.get(ZenModeController.class);
|
||||
mZenModeController.addCallback(this);
|
||||
mDatePattern = getContext().getString(R.string.system_ui_aod_date_pattern);
|
||||
mPendingIntent = PendingIntent.getActivity(getContext(), 0, new Intent(), 0);
|
||||
@@ -462,16 +458,18 @@ public class KeyguardSliceProvider extends SliceProvider implements
|
||||
public void onMetadataOrStateChanged(MediaMetadata metadata, @PlaybackState.State int state) {
|
||||
synchronized (this) {
|
||||
boolean nextVisible = NotificationMediaManager.isPlayingState(state);
|
||||
mHandler.removeCallbacksAndMessages(mMediaToken);
|
||||
mMediaHandler.removeCallbacksAndMessages(null);
|
||||
if (mMediaIsVisible && !nextVisible && mStatusBarState != StatusBarState.SHADE) {
|
||||
// We need to delay this event for a few millis when stopping to avoid jank in the
|
||||
// animation. The media app might not send its update when buffering, and the slice
|
||||
// would end up without a header for 0.5 second.
|
||||
mMediaWakeLock.setAcquired(true);
|
||||
mHandler.postDelayed(() -> {
|
||||
updateMediaStateLocked(metadata, state);
|
||||
mMediaWakeLock.setAcquired(false);
|
||||
}, mMediaToken, 2000);
|
||||
mMediaHandler.postDelayed(() -> {
|
||||
synchronized (this) {
|
||||
updateMediaStateLocked(metadata, state);
|
||||
mMediaWakeLock.setAcquired(false);
|
||||
}
|
||||
}, 2000);
|
||||
} else {
|
||||
mMediaWakeLock.setAcquired(false);
|
||||
updateMediaStateLocked(metadata, state);
|
||||
|
||||
Reference in New Issue
Block a user