Merge "Use unique Handler for media, and synchronize it" into qt-qpr1-dev am: fd6f170e31
am: b019786efc
Change-Id: If01a4374dffbd1e883f2801419288b1ebb678daf
This commit is contained in:
@@ -60,7 +60,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;
|
||||
|
||||
@@ -107,8 +106,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;
|
||||
@@ -174,17 +173,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);
|
||||
@@ -328,7 +323,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);
|
||||
@@ -470,16 +465,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