Merge "Move Volume control Binder calls to worker thread" into tm-dev
This commit is contained in:
@@ -181,7 +181,7 @@ public interface VolumeDialogController {
|
|||||||
public interface Callbacks {
|
public interface Callbacks {
|
||||||
int VERSION = 1;
|
int VERSION = 1;
|
||||||
|
|
||||||
void onShowRequested(int reason);
|
void onShowRequested(int reason, boolean keyguardLocked, int lockTaskModeState);
|
||||||
void onDismissRequested(int reason);
|
void onDismissRequested(int reason);
|
||||||
void onStateChanged(State state);
|
void onStateChanged(State state);
|
||||||
void onLayoutDirectionChanged(int layoutDirection);
|
void onLayoutDirectionChanged(int layoutDirection);
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class VolumeDialogComponent implements VolumeComponent, TunerService.Tuna
|
|||||||
|
|
||||||
private void applyConfiguration() {
|
private void applyConfiguration() {
|
||||||
mController.setVolumePolicy(mVolumePolicy);
|
mController.setVolumePolicy(mVolumePolicy);
|
||||||
mController.showDndTile(true);
|
mController.showDndTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package com.android.systemui.volume;
|
|||||||
|
|
||||||
import static android.media.AudioManager.RINGER_MODE_NORMAL;
|
import static android.media.AudioManager.RINGER_MODE_NORMAL;
|
||||||
|
|
||||||
|
import android.app.ActivityManager;
|
||||||
|
import android.app.KeyguardManager;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -91,10 +93,8 @@ import javax.inject.Inject;
|
|||||||
public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpable {
|
public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpable {
|
||||||
private static final String TAG = Util.logTag(VolumeDialogControllerImpl.class);
|
private static final String TAG = Util.logTag(VolumeDialogControllerImpl.class);
|
||||||
|
|
||||||
|
|
||||||
private static final int TOUCH_FEEDBACK_TIMEOUT_MS = 1000;
|
private static final int TOUCH_FEEDBACK_TIMEOUT_MS = 1000;
|
||||||
private static final int DYNAMIC_STREAM_START_INDEX = 100;
|
private static final int DYNAMIC_STREAM_START_INDEX = 100;
|
||||||
private static final int VIBRATE_HINT_DURATION = 50;
|
|
||||||
private static final AudioAttributes SONIFICIATION_VIBRATION_ATTRIBUTES =
|
private static final AudioAttributes SONIFICIATION_VIBRATION_ATTRIBUTES =
|
||||||
new AudioAttributes.Builder()
|
new AudioAttributes.Builder()
|
||||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||||
@@ -122,14 +122,16 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
private final PackageManager mPackageManager;
|
private final PackageManager mPackageManager;
|
||||||
private final MediaRouter2Manager mRouter2Manager;
|
private final MediaRouter2Manager mRouter2Manager;
|
||||||
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
private final WakefulnessLifecycle mWakefulnessLifecycle;
|
||||||
private AudioManager mAudio;
|
private final AudioManager mAudio;
|
||||||
private IAudioService mAudioService;
|
private final IAudioService mAudioService;
|
||||||
private final NotificationManager mNoMan;
|
private final NotificationManager mNoMan;
|
||||||
private final SettingObserver mObserver;
|
private final SettingObserver mObserver;
|
||||||
private final Receiver mReceiver = new Receiver();
|
private final Receiver mReceiver = new Receiver();
|
||||||
private final RingerModeObservers mRingerModeObservers;
|
private final RingerModeObservers mRingerModeObservers;
|
||||||
private final MediaSessions mMediaSessions;
|
private final MediaSessions mMediaSessions;
|
||||||
private final CaptioningManager mCaptioningManager;
|
private final CaptioningManager mCaptioningManager;
|
||||||
|
private final KeyguardManager mKeyguardManager;
|
||||||
|
private final ActivityManager mActivityManager;
|
||||||
protected C mCallbacks = new C();
|
protected C mCallbacks = new C();
|
||||||
private final State mState = new State();
|
private final State mState = new State();
|
||||||
protected final MediaSessionsCallbacks mMediaSessionsCallbacksW;
|
protected final MediaSessionsCallbacks mMediaSessionsCallbacksW;
|
||||||
@@ -141,9 +143,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
private long mLastToggledRingerOn;
|
private long mLastToggledRingerOn;
|
||||||
private boolean mDeviceInteractive = true;
|
private boolean mDeviceInteractive = true;
|
||||||
|
|
||||||
private boolean mDestroyed;
|
|
||||||
private VolumePolicy mVolumePolicy;
|
private VolumePolicy mVolumePolicy;
|
||||||
private boolean mShowDndTile = true;
|
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
private UserActivityListener mUserActivityListener;
|
private UserActivityListener mUserActivityListener;
|
||||||
|
|
||||||
@@ -176,7 +176,10 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
AccessibilityManager accessibilityManager,
|
AccessibilityManager accessibilityManager,
|
||||||
PackageManager packageManager,
|
PackageManager packageManager,
|
||||||
WakefulnessLifecycle wakefulnessLifecycle,
|
WakefulnessLifecycle wakefulnessLifecycle,
|
||||||
CaptioningManager captioningManager) {
|
CaptioningManager captioningManager,
|
||||||
|
KeyguardManager keyguardManager,
|
||||||
|
ActivityManager activityManager
|
||||||
|
) {
|
||||||
mContext = context.getApplicationContext();
|
mContext = context.getApplicationContext();
|
||||||
mPackageManager = packageManager;
|
mPackageManager = packageManager;
|
||||||
mWakefulnessLifecycle = wakefulnessLifecycle;
|
mWakefulnessLifecycle = wakefulnessLifecycle;
|
||||||
@@ -202,6 +205,9 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
mHasVibrator = mVibrator.hasVibrator();
|
mHasVibrator = mVibrator.hasVibrator();
|
||||||
mAudioService = iAudioService;
|
mAudioService = iAudioService;
|
||||||
mCaptioningManager = captioningManager;
|
mCaptioningManager = captioningManager;
|
||||||
|
mKeyguardManager = keyguardManager;
|
||||||
|
mActivityManager = activityManager;
|
||||||
|
|
||||||
|
|
||||||
boolean accessibilityVolumeStreamActive = accessibilityManager
|
boolean accessibilityVolumeStreamActive = accessibilityManager
|
||||||
.isAccessibilityVolumeStreamActive();
|
.isAccessibilityVolumeStreamActive();
|
||||||
@@ -247,7 +253,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
public void register() {
|
public void register() {
|
||||||
setVolumeController();
|
setVolumeController();
|
||||||
setVolumePolicy(mVolumePolicy);
|
setVolumePolicy(mVolumePolicy);
|
||||||
showDndTile(mShowDndTile);
|
showDndTile();
|
||||||
try {
|
try {
|
||||||
mMediaSessions.init();
|
mMediaSessions.init();
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
@@ -272,10 +278,8 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
|
|
||||||
public void dump(PrintWriter pw, String[] args) {
|
public void dump(PrintWriter pw, String[] args) {
|
||||||
pw.println(VolumeDialogControllerImpl.class.getSimpleName() + " state:");
|
pw.println(VolumeDialogControllerImpl.class.getSimpleName() + " state:");
|
||||||
pw.print(" mDestroyed: "); pw.println(mDestroyed);
|
|
||||||
pw.print(" mVolumePolicy: "); pw.println(mVolumePolicy);
|
pw.print(" mVolumePolicy: "); pw.println(mVolumePolicy);
|
||||||
pw.print(" mState: "); pw.println(mState.toString(4));
|
pw.print(" mState: "); pw.println(mState.toString(4));
|
||||||
pw.print(" mShowDndTile: "); pw.println(mShowDndTile);
|
|
||||||
pw.print(" mHasVibrator: "); pw.println(mHasVibrator);
|
pw.print(" mHasVibrator: "); pw.println(mHasVibrator);
|
||||||
synchronized (mMediaSessionsCallbacksW.mRemoteStreams) {
|
synchronized (mMediaSessionsCallbacksW.mRemoteStreams) {
|
||||||
pw.print(" mRemoteStreams: ");
|
pw.print(" mRemoteStreams: ");
|
||||||
@@ -293,7 +297,6 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setUserActivityListener(UserActivityListener listener) {
|
public void setUserActivityListener(UserActivityListener listener) {
|
||||||
if (mDestroyed) return;
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
mUserActivityListener = listener;
|
mUserActivityListener = listener;
|
||||||
}
|
}
|
||||||
@@ -304,7 +307,6 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getState() {
|
public void getState() {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.sendEmptyMessage(W.GET_STATE);
|
mWorker.sendEmptyMessage(W.GET_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,48 +319,39 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void getCaptionsComponentState(boolean fromTooltip) {
|
public void getCaptionsComponentState(boolean fromTooltip) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.GET_CAPTIONS_COMPONENT_STATE, fromTooltip).sendToTarget();
|
mWorker.obtainMessage(W.GET_CAPTIONS_COMPONENT_STATE, fromTooltip).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyVisible(boolean visible) {
|
public void notifyVisible(boolean visible) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.NOTIFY_VISIBLE, visible ? 1 : 0, 0).sendToTarget();
|
mWorker.obtainMessage(W.NOTIFY_VISIBLE, visible ? 1 : 0, 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void userActivity() {
|
public void userActivity() {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.removeMessages(W.USER_ACTIVITY);
|
mWorker.removeMessages(W.USER_ACTIVITY);
|
||||||
mWorker.sendEmptyMessage(W.USER_ACTIVITY);
|
mWorker.sendEmptyMessage(W.USER_ACTIVITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRingerMode(int value, boolean external) {
|
public void setRingerMode(int value, boolean external) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.SET_RINGER_MODE, value, external ? 1 : 0).sendToTarget();
|
mWorker.obtainMessage(W.SET_RINGER_MODE, value, external ? 1 : 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZenMode(int value) {
|
public void setZenMode(int value) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.SET_ZEN_MODE, value, 0).sendToTarget();
|
mWorker.obtainMessage(W.SET_ZEN_MODE, value, 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setExitCondition(Condition condition) {
|
public void setExitCondition(Condition condition) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.SET_EXIT_CONDITION, condition).sendToTarget();
|
mWorker.obtainMessage(W.SET_EXIT_CONDITION, condition).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamMute(int stream, boolean mute) {
|
public void setStreamMute(int stream, boolean mute) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.SET_STREAM_MUTE, stream, mute ? 1 : 0).sendToTarget();
|
mWorker.obtainMessage(W.SET_STREAM_MUTE, stream, mute ? 1 : 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamVolume(int stream, int level) {
|
public void setStreamVolume(int stream, int level) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.SET_STREAM_VOLUME, stream, level).sendToTarget();
|
mWorker.obtainMessage(W.SET_STREAM_VOLUME, stream, level).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveStream(int stream) {
|
public void setActiveStream(int stream) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.SET_ACTIVE_STREAM, stream, 0).sendToTarget();
|
mWorker.obtainMessage(W.SET_ACTIVE_STREAM, stream, 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,7 +385,6 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onNotifyVisibleW(boolean visible) {
|
private void onNotifyVisibleW(boolean visible) {
|
||||||
if (mDestroyed) return;
|
|
||||||
mAudio.notifyVolumeControllerVisible(mVolumeController, visible);
|
mAudio.notifyVolumeControllerVisible(mVolumeController, visible);
|
||||||
if (!visible) {
|
if (!visible) {
|
||||||
if (updateActiveStreamW(-1)) {
|
if (updateActiveStreamW(-1)) {
|
||||||
@@ -465,7 +457,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
mCallbacks.onStateChanged(mState);
|
mCallbacks.onStateChanged(mState);
|
||||||
}
|
}
|
||||||
if (showUI) {
|
if (showUI) {
|
||||||
mCallbacks.onShowRequested(Events.SHOW_REASON_VOLUME_CHANGED);
|
onShowRequestedW(Events.SHOW_REASON_VOLUME_CHANGED);
|
||||||
}
|
}
|
||||||
if (showVibrateHint) {
|
if (showVibrateHint) {
|
||||||
mCallbacks.onShowVibrateHint();
|
mCallbacks.onShowVibrateHint();
|
||||||
@@ -645,6 +637,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onShowRequestedW(int reason) {
|
||||||
|
mCallbacks.onShowRequested(reason, mKeyguardManager.isKeyguardLocked(),
|
||||||
|
mActivityManager.getLockTaskModeState());
|
||||||
|
}
|
||||||
|
|
||||||
private void onSetRingerModeW(int mode, boolean external) {
|
private void onSetRingerModeW(int mode, boolean external) {
|
||||||
if (external) {
|
if (external) {
|
||||||
mAudio.setRingerMode(mode);
|
mAudio.setRingerMode(mode);
|
||||||
@@ -687,9 +684,9 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
mCallbacks.onDismissRequested(reason);
|
mCallbacks.onDismissRequested(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDndTile(boolean visible) {
|
public void showDndTile() {
|
||||||
if (D.BUG) Log.d(TAG, "showDndTile");
|
if (D.BUG) Log.d(TAG, "showDndTile");
|
||||||
DndTile.setVisible(mContext, visible);
|
DndTile.setVisible(mContext, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class VC extends IVolumeController.Stub {
|
private final class VC extends IVolumeController.Stub {
|
||||||
@@ -699,7 +696,6 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
public void displaySafeVolumeWarning(int flags) throws RemoteException {
|
public void displaySafeVolumeWarning(int flags) throws RemoteException {
|
||||||
if (D.BUG) Log.d(TAG, "displaySafeVolumeWarning "
|
if (D.BUG) Log.d(TAG, "displaySafeVolumeWarning "
|
||||||
+ Util.audioManagerFlagsToString(flags));
|
+ Util.audioManagerFlagsToString(flags));
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.SHOW_SAFETY_WARNING, flags, 0).sendToTarget();
|
mWorker.obtainMessage(W.SHOW_SAFETY_WARNING, flags, 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -707,7 +703,6 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
public void volumeChanged(int streamType, int flags) throws RemoteException {
|
public void volumeChanged(int streamType, int flags) throws RemoteException {
|
||||||
if (D.BUG) Log.d(TAG, "volumeChanged " + AudioSystem.streamToString(streamType)
|
if (D.BUG) Log.d(TAG, "volumeChanged " + AudioSystem.streamToString(streamType)
|
||||||
+ " " + Util.audioManagerFlagsToString(flags));
|
+ " " + Util.audioManagerFlagsToString(flags));
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.VOLUME_CHANGED, streamType, flags).sendToTarget();
|
mWorker.obtainMessage(W.VOLUME_CHANGED, streamType, flags).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -719,14 +714,12 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
@Override
|
@Override
|
||||||
public void setLayoutDirection(int layoutDirection) throws RemoteException {
|
public void setLayoutDirection(int layoutDirection) throws RemoteException {
|
||||||
if (D.BUG) Log.d(TAG, "setLayoutDirection");
|
if (D.BUG) Log.d(TAG, "setLayoutDirection");
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.LAYOUT_DIRECTION_CHANGED, layoutDirection, 0).sendToTarget();
|
mWorker.obtainMessage(W.LAYOUT_DIRECTION_CHANGED, layoutDirection, 0).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dismiss() throws RemoteException {
|
public void dismiss() throws RemoteException {
|
||||||
if (D.BUG) Log.d(TAG, "dismiss requested");
|
if (D.BUG) Log.d(TAG, "dismiss requested");
|
||||||
if (mDestroyed) return;
|
|
||||||
mWorker.obtainMessage(W.DISMISS_REQUESTED, Events.DISMISS_REASON_VOLUME_CONTROLLER, 0)
|
mWorker.obtainMessage(W.DISMISS_REQUESTED, Events.DISMISS_REASON_VOLUME_CONTROLLER, 0)
|
||||||
.sendToTarget();
|
.sendToTarget();
|
||||||
mWorker.sendEmptyMessage(W.DISMISS_REQUESTED);
|
mWorker.sendEmptyMessage(W.DISMISS_REQUESTED);
|
||||||
@@ -735,7 +728,6 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
@Override
|
@Override
|
||||||
public void setA11yMode(int mode) {
|
public void setA11yMode(int mode) {
|
||||||
if (D.BUG) Log.d(TAG, "setA11yMode to " + mode);
|
if (D.BUG) Log.d(TAG, "setA11yMode to " + mode);
|
||||||
if (mDestroyed) return;
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case VolumePolicy.A11Y_MODE_MEDIA_A11Y_VOLUME:
|
case VolumePolicy.A11Y_MODE_MEDIA_A11Y_VOLUME:
|
||||||
// "legacy" mode
|
// "legacy" mode
|
||||||
@@ -798,7 +790,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class C implements Callbacks {
|
static class C implements Callbacks {
|
||||||
private final Map<Callbacks, Handler> mCallbackMap = new ConcurrentHashMap<>();
|
private final Map<Callbacks, Handler> mCallbackMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public void add(Callbacks callback, Handler handler) {
|
public void add(Callbacks callback, Handler handler) {
|
||||||
@@ -811,12 +803,15 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onShowRequested(final int reason) {
|
public void onShowRequested(
|
||||||
|
final int reason,
|
||||||
|
final boolean keyguardLocked,
|
||||||
|
final int lockTaskModeState) {
|
||||||
for (final Map.Entry<Callbacks, Handler> entry : mCallbackMap.entrySet()) {
|
for (final Map.Entry<Callbacks, Handler> entry : mCallbackMap.entrySet()) {
|
||||||
entry.getValue().post(new Runnable() {
|
entry.getValue().post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
entry.getKey().onShowRequested(reason);
|
entry.getKey().onShowRequested(reason, keyguardLocked, lockTaskModeState);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -923,7 +918,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAccessibilityModeChanged(Boolean showA11yStream) {
|
public void onAccessibilityModeChanged(Boolean showA11yStream) {
|
||||||
boolean show = showA11yStream == null ? false : showA11yStream;
|
boolean show = showA11yStream != null && showA11yStream;
|
||||||
for (final Map.Entry<Callbacks, Handler> entry : mCallbackMap.entrySet()) {
|
for (final Map.Entry<Callbacks, Handler> entry : mCallbackMap.entrySet()) {
|
||||||
entry.getValue().post(new Runnable() {
|
entry.getValue().post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -937,7 +932,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
@Override
|
@Override
|
||||||
public void onCaptionComponentStateChanged(
|
public void onCaptionComponentStateChanged(
|
||||||
Boolean isComponentEnabled, Boolean fromTooltip) {
|
Boolean isComponentEnabled, Boolean fromTooltip) {
|
||||||
boolean componentEnabled = isComponentEnabled == null ? false : isComponentEnabled;
|
boolean componentEnabled = isComponentEnabled != null && isComponentEnabled;
|
||||||
for (final Map.Entry<Callbacks, Handler> entry : mCallbackMap.entrySet()) {
|
for (final Map.Entry<Callbacks, Handler> entry : mCallbackMap.entrySet()) {
|
||||||
entry.getValue().post(
|
entry.getValue().post(
|
||||||
() -> entry.getKey().onCaptionComponentStateChanged(
|
() -> entry.getKey().onCaptionComponentStateChanged(
|
||||||
@@ -1183,7 +1178,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
mCallbacks.onStateChanged(mState);
|
mCallbacks.onStateChanged(mState);
|
||||||
}
|
}
|
||||||
if (showUI) {
|
if (showUI) {
|
||||||
mCallbacks.onShowRequested(Events.SHOW_REASON_REMOTE_VOLUME_CHANGED);
|
onShowRequestedW(Events.SHOW_REASON_REMOTE_VOLUME_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
private State mState;
|
private State mState;
|
||||||
private SafetyWarningDialog mSafetyWarning;
|
private SafetyWarningDialog mSafetyWarning;
|
||||||
private boolean mHovering = false;
|
private boolean mHovering = false;
|
||||||
private boolean mShowActiveStreamOnly;
|
private final boolean mShowActiveStreamOnly;
|
||||||
private boolean mConfigChanged = false;
|
private boolean mConfigChanged = false;
|
||||||
private boolean mIsAnimatingDismiss = false;
|
private boolean mIsAnimatingDismiss = false;
|
||||||
private boolean mHasSeenODICaptionsTooltip;
|
private boolean mHasSeenODICaptionsTooltip;
|
||||||
@@ -327,7 +327,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void init(int windowType, Callback callback) {
|
public void init(int windowType, Callback callback) {
|
||||||
initDialog();
|
initDialog(mActivityManager.getLockTaskModeState());
|
||||||
|
|
||||||
mAccessibility.init();
|
mAccessibility.init();
|
||||||
|
|
||||||
@@ -394,7 +394,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
Region.Op.UNION);
|
Region.Op.UNION);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDialog() {
|
private void initDialog(int lockTaskModeState) {
|
||||||
mDialog = new CustomDialog(mContext);
|
mDialog = new CustomDialog(mContext);
|
||||||
|
|
||||||
initDimens();
|
initDimens();
|
||||||
@@ -589,7 +589,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
|
|
||||||
updateRowsH(getActiveRow());
|
updateRowsH(getActiveRow());
|
||||||
initRingerH();
|
initRingerH();
|
||||||
initSettingsH();
|
initSettingsH(lockTaskModeState);
|
||||||
initODICaptionsH();
|
initODICaptionsH();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1034,12 +1034,11 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
mIsRingerDrawerOpen = false;
|
mIsRingerDrawerOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initSettingsH() {
|
private void initSettingsH(int lockTaskModeState) {
|
||||||
if (mSettingsView != null) {
|
if (mSettingsView != null) {
|
||||||
mSettingsView.setVisibility(
|
mSettingsView.setVisibility(
|
||||||
mDeviceProvisionedController.isCurrentUserSetup() &&
|
mDeviceProvisionedController.isCurrentUserSetup() &&
|
||||||
mActivityManager.getLockTaskModeState() == LOCK_TASK_MODE_NONE ?
|
lockTaskModeState == LOCK_TASK_MODE_NONE ? VISIBLE : GONE);
|
||||||
VISIBLE : GONE);
|
|
||||||
}
|
}
|
||||||
if (mSettingsIcon != null) {
|
if (mSettingsIcon != null) {
|
||||||
mSettingsIcon.setOnClickListener(v -> {
|
mSettingsIcon.setOnClickListener(v -> {
|
||||||
@@ -1292,7 +1291,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showH(int reason) {
|
private void showH(int reason, boolean keyguardLocked, int lockTaskModeState) {
|
||||||
Trace.beginSection("VolumeDialogImpl#showH");
|
Trace.beginSection("VolumeDialogImpl#showH");
|
||||||
if (D.BUG) Log.d(TAG, "showH r=" + Events.SHOW_REASONS[reason]);
|
if (D.BUG) Log.d(TAG, "showH r=" + Events.SHOW_REASONS[reason]);
|
||||||
mHandler.removeMessages(H.SHOW);
|
mHandler.removeMessages(H.SHOW);
|
||||||
@@ -1300,16 +1299,16 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
rescheduleTimeoutH();
|
rescheduleTimeoutH();
|
||||||
|
|
||||||
if (mConfigChanged) {
|
if (mConfigChanged) {
|
||||||
initDialog(); // resets mShowing to false
|
initDialog(lockTaskModeState); // resets mShowing to false
|
||||||
mConfigurableTexts.update();
|
mConfigurableTexts.update();
|
||||||
mConfigChanged = false;
|
mConfigChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
initSettingsH();
|
initSettingsH(lockTaskModeState);
|
||||||
mShowing = true;
|
mShowing = true;
|
||||||
mIsAnimatingDismiss = false;
|
mIsAnimatingDismiss = false;
|
||||||
mDialog.show();
|
mDialog.show();
|
||||||
Events.writeEvent(Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked());
|
Events.writeEvent(Events.EVENT_SHOW_DIALOG, reason, keyguardLocked);
|
||||||
mController.notifyVisible(true);
|
mController.notifyVisible(true);
|
||||||
mController.getCaptionsComponentState(false);
|
mController.getCaptionsComponentState(false);
|
||||||
checkODICaptionsTooltip(false);
|
checkODICaptionsTooltip(false);
|
||||||
@@ -1810,14 +1809,6 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
mContext, com.android.internal.R.attr.textColorOnAccent);
|
mContext, com.android.internal.R.attr.textColorOnAccent);
|
||||||
|
|
||||||
row.sliderProgressSolid.setTintList(colorTint);
|
row.sliderProgressSolid.setTintList(colorTint);
|
||||||
if (row.sliderBgIcon != null) {
|
|
||||||
row.sliderBgIcon.setTintList(colorTint);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (row.sliderBgSolid != null) {
|
|
||||||
row.sliderBgSolid.setTintList(bgTint);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (row.sliderProgressIcon != null) {
|
if (row.sliderProgressIcon != null) {
|
||||||
row.sliderProgressIcon.setTintList(bgTint);
|
row.sliderProgressIcon.setTintList(bgTint);
|
||||||
}
|
}
|
||||||
@@ -2046,8 +2037,8 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
private final VolumeDialogController.Callbacks mControllerCallbackH
|
private final VolumeDialogController.Callbacks mControllerCallbackH
|
||||||
= new VolumeDialogController.Callbacks() {
|
= new VolumeDialogController.Callbacks() {
|
||||||
@Override
|
@Override
|
||||||
public void onShowRequested(int reason) {
|
public void onShowRequested(int reason, boolean keyguardLocked, int lockTaskModeState) {
|
||||||
showH(reason);
|
showH(reason, keyguardLocked, lockTaskModeState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2130,7 +2121,8 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message msg) {
|
public void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case SHOW: showH(msg.arg1); break;
|
case SHOW: showH(msg.arg1, VolumeDialogImpl.this.mKeyguard.isKeyguardLocked(),
|
||||||
|
VolumeDialogImpl.this.mActivityManager.getLockTaskModeState()); break;
|
||||||
case DISMISS: dismissH(msg.arg1); break;
|
case DISMISS: dismissH(msg.arg1); break;
|
||||||
case RECHECK: recheckH((VolumeRow) msg.obj); break;
|
case RECHECK: recheckH((VolumeRow) msg.obj); break;
|
||||||
case RECHECK_ALL: recheckH(null); break;
|
case RECHECK_ALL: recheckH(null); break;
|
||||||
@@ -2152,7 +2144,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
* within the bounds of the volume dialog, will fall through to the window below.
|
* within the bounds of the volume dialog, will fall through to the window below.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
public boolean dispatchTouchEvent(@NonNull MotionEvent ev) {
|
||||||
rescheduleTimeoutH();
|
rescheduleTimeoutH();
|
||||||
return super.dispatchTouchEvent(ev);
|
return super.dispatchTouchEvent(ev);
|
||||||
}
|
}
|
||||||
@@ -2176,7 +2168,7 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
* volume dialog.
|
* volume dialog.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(@NonNull MotionEvent event) {
|
||||||
if (mShowing) {
|
if (mShowing) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
|
||||||
dismissH(Events.DISMISS_REASON_TOUCH_OUTSIDE);
|
dismissH(Events.DISMISS_REASON_TOUCH_OUTSIDE);
|
||||||
@@ -2265,8 +2257,6 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
private View view;
|
private View view;
|
||||||
private TextView header;
|
private TextView header;
|
||||||
private ImageButton icon;
|
private ImageButton icon;
|
||||||
private Drawable sliderBgSolid;
|
|
||||||
private AlphaTintDrawableWrapper sliderBgIcon;
|
|
||||||
private Drawable sliderProgressSolid;
|
private Drawable sliderProgressSolid;
|
||||||
private AlphaTintDrawableWrapper sliderProgressIcon;
|
private AlphaTintDrawableWrapper sliderProgressIcon;
|
||||||
private SeekBar slider;
|
private SeekBar slider;
|
||||||
@@ -2280,7 +2270,6 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
private int iconMuteRes;
|
private int iconMuteRes;
|
||||||
private boolean important;
|
private boolean important;
|
||||||
private boolean defaultStream;
|
private boolean defaultStream;
|
||||||
private ColorStateList cachedTint;
|
|
||||||
private int iconState; // from Events
|
private int iconState; // from Events
|
||||||
private ObjectAnimator anim; // slider progress animation for non-touch-related updates
|
private ObjectAnimator anim; // slider progress animation for non-touch-related updates
|
||||||
private int animTargetProgress;
|
private int animTargetProgress;
|
||||||
@@ -2295,9 +2284,6 @@ public class VolumeDialogImpl implements VolumeDialog,
|
|||||||
if (sliderProgressIcon != null) {
|
if (sliderProgressIcon != null) {
|
||||||
sliderProgressIcon.setDrawable(view.getResources().getDrawable(iconRes, theme));
|
sliderProgressIcon.setDrawable(view.getResources().getDrawable(iconRes, theme));
|
||||||
}
|
}
|
||||||
if (sliderBgIcon != null) {
|
|
||||||
sliderBgIcon.setDrawable(view.getResources().getDrawable(iconRes, theme));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.android.systemui.volume;
|
package com.android.systemui.volume;
|
||||||
|
|
||||||
|
import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@@ -23,6 +25,8 @@ 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.app.ActivityManager;
|
||||||
|
import android.app.KeyguardManager;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -91,6 +95,10 @@ public class VolumeDialogControllerImplTest extends SysuiTestCase {
|
|||||||
private WakefulnessLifecycle mWakefullnessLifcycle;
|
private WakefulnessLifecycle mWakefullnessLifcycle;
|
||||||
@Mock
|
@Mock
|
||||||
private CaptioningManager mCaptioningManager;
|
private CaptioningManager mCaptioningManager;
|
||||||
|
@Mock
|
||||||
|
private KeyguardManager mKeyguardManager;
|
||||||
|
@Mock
|
||||||
|
private ActivityManager mActivityManager;
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@@ -112,7 +120,8 @@ public class VolumeDialogControllerImplTest extends SysuiTestCase {
|
|||||||
mVolumeController = new TestableVolumeDialogControllerImpl(mContext,
|
mVolumeController = new TestableVolumeDialogControllerImpl(mContext,
|
||||||
mBroadcastDispatcher, mRingerModeTracker, mThreadFactory, mAudioManager,
|
mBroadcastDispatcher, mRingerModeTracker, mThreadFactory, mAudioManager,
|
||||||
mNotificationManager, mVibrator, mIAudioService, mAccessibilityManager,
|
mNotificationManager, mVibrator, mIAudioService, mAccessibilityManager,
|
||||||
mPackageManager, mWakefullnessLifcycle, mCaptioningManager, mCallback);
|
mPackageManager, mWakefullnessLifcycle, mCaptioningManager, mKeyguardManager,
|
||||||
|
mActivityManager, mCallback);
|
||||||
mVolumeController.setEnableDialogs(true, true);
|
mVolumeController.setEnableDialogs(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +138,8 @@ public class VolumeDialogControllerImplTest extends SysuiTestCase {
|
|||||||
when(mWakefullnessLifcycle.getWakefulness()).thenReturn(
|
when(mWakefullnessLifcycle.getWakefulness()).thenReturn(
|
||||||
WakefulnessLifecycle.WAKEFULNESS_AWAKE);
|
WakefulnessLifecycle.WAKEFULNESS_AWAKE);
|
||||||
mVolumeController.onVolumeChangedW(0, AudioManager.FLAG_SHOW_UI);
|
mVolumeController.onVolumeChangedW(0, AudioManager.FLAG_SHOW_UI);
|
||||||
verify(mCallback, never()).onShowRequested(Events.SHOW_REASON_VOLUME_CHANGED);
|
verify(mCallback, never()).onShowRequested(Events.SHOW_REASON_VOLUME_CHANGED, false,
|
||||||
|
LOCK_TASK_MODE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -138,7 +148,8 @@ public class VolumeDialogControllerImplTest extends SysuiTestCase {
|
|||||||
when(mWakefullnessLifcycle.getWakefulness()).thenReturn(
|
when(mWakefullnessLifcycle.getWakefulness()).thenReturn(
|
||||||
WakefulnessLifecycle.WAKEFULNESS_AWAKE);
|
WakefulnessLifecycle.WAKEFULNESS_AWAKE);
|
||||||
mVolumeController.onVolumeChangedW(0, AudioManager.FLAG_SHOW_UI);
|
mVolumeController.onVolumeChangedW(0, AudioManager.FLAG_SHOW_UI);
|
||||||
verify(mCallback, times(1)).onShowRequested(Events.SHOW_REASON_VOLUME_CHANGED);
|
verify(mCallback, times(1)).onShowRequested(Events.SHOW_REASON_VOLUME_CHANGED, false,
|
||||||
|
LOCK_TASK_MODE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -151,7 +162,8 @@ public class VolumeDialogControllerImplTest extends SysuiTestCase {
|
|||||||
when(mWakefullnessLifcycle.getWakefulness()).thenReturn(
|
when(mWakefullnessLifcycle.getWakefulness()).thenReturn(
|
||||||
WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP);
|
WakefulnessLifecycle.WAKEFULNESS_GOING_TO_SLEEP);
|
||||||
mVolumeController.onVolumeChangedW(0, AudioManager.FLAG_SHOW_UI);
|
mVolumeController.onVolumeChangedW(0, AudioManager.FLAG_SHOW_UI);
|
||||||
verify(mCallback, times(1)).onShowRequested(Events.SHOW_REASON_VOLUME_CHANGED);
|
verify(mCallback, times(1)).onShowRequested(Events.SHOW_REASON_VOLUME_CHANGED, false,
|
||||||
|
LOCK_TASK_MODE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -188,10 +200,13 @@ public class VolumeDialogControllerImplTest extends SysuiTestCase {
|
|||||||
PackageManager packageManager,
|
PackageManager packageManager,
|
||||||
WakefulnessLifecycle wakefulnessLifecycle,
|
WakefulnessLifecycle wakefulnessLifecycle,
|
||||||
CaptioningManager captioningManager,
|
CaptioningManager captioningManager,
|
||||||
|
KeyguardManager keyguardManager,
|
||||||
|
ActivityManager activityManager,
|
||||||
C callback) {
|
C callback) {
|
||||||
super(context, broadcastDispatcher, ringerModeTracker, theadFactory, audioManager,
|
super(context, broadcastDispatcher, ringerModeTracker, theadFactory, audioManager,
|
||||||
notificationManager, optionalVibrator, iAudioService, accessibilityManager,
|
notificationManager, optionalVibrator, iAudioService, accessibilityManager,
|
||||||
packageManager, wakefulnessLifecycle, captioningManager);
|
packageManager, wakefulnessLifecycle, captioningManager, keyguardManager,
|
||||||
|
activityManager);
|
||||||
mCallbacks = callback;
|
mCallbacks = callback;
|
||||||
|
|
||||||
ArgumentCaptor<WakefulnessLifecycle.Observer> observerCaptor =
|
ArgumentCaptor<WakefulnessLifecycle.Observer> observerCaptor =
|
||||||
|
|||||||
Reference in New Issue
Block a user