diff options
author | Roman Birg <roman@cyngn.com> | 2016-03-17 09:18:56 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-03-17 14:04:51 -0700 |
commit | 14b45bc6286782cd6c3dcd9a9162ed9abb7d4d95 (patch) | |
tree | 381fa522bd750e589edd64b6d54f172a3b418b8b /packages/SystemUI | |
parent | e45d8f20f1dc3bb424cfab7611cdeb00a0f82e92 (diff) | |
download | frameworks_base-14b45bc6286782cd6c3dcd9a9162ed9abb7d4d95.zip frameworks_base-14b45bc6286782cd6c3dcd9a9162ed9abb7d4d95.tar.gz frameworks_base-14b45bc6286782cd6c3dcd9a9162ed9abb7d4d95.tar.bz2 |
SystemUI: more consistent visualizer logic
- only call setVisible from screen on and screen off methods
- eagerly unregister self to make sure we don't get added twice as a
listener
- Add some debugging under the DEBUG flag
Change-Id: Iada13058f87d4c8d8c8b60f6eebf055652ff2c8d
Signed-off-by: Roman Birg <roman@cyngn.com>
Diffstat (limited to 'packages/SystemUI')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/VisualizerView.java | 38 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java | 4 |
2 files changed, 36 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/VisualizerView.java b/packages/SystemUI/src/com/android/systemui/statusbar/VisualizerView.java index 1991602..40e4330 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/VisualizerView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/VisualizerView.java @@ -26,19 +26,21 @@ import android.media.audiofx.Visualizer; import android.os.AsyncTask; import android.os.Handler; import android.os.UserHandle; -import android.provider.Settings; import android.support.v7.graphics.Palette; import android.util.AttributeSet; +import android.util.Log; import android.view.View; + import com.android.systemui.cm.UserContentObserver; import com.android.systemui.statusbar.policy.KeyguardMonitor; import cyanogenmod.providers.CMSettings; -import java.util.Arrays; - public class VisualizerView extends View implements Palette.PaletteAsyncListener, KeyguardMonitor.Callback { + private static final String TAG = VisualizerView.class.getSimpleName(); + private static final boolean DEBUG = false; + private Paint mPaint; private Visualizer mVisualizer; private ObjectAnimator mVisualizerColorAnimator; @@ -89,9 +91,14 @@ public class VisualizerView extends View implements Palette.PaletteAsyncListener private final Runnable mLinkVisualizer = new Runnable() { @Override public void run() { + if (DEBUG) { + Log.w(TAG, "+++ mLinkVisualizer run()"); + } + try { mVisualizer = new Visualizer(0); } catch (Exception e) { + Log.e(TAG, "error initializing visualizer", e); return; } @@ -101,17 +108,26 @@ public class VisualizerView extends View implements Palette.PaletteAsyncListener false, true); mVisualizer.setEnabled(true); + if (DEBUG) { + Log.w(TAG, "--- mLinkVisualizer run()"); + } } }; private final Runnable mUnlinkVisualizer = new Runnable() { @Override public void run() { + if (DEBUG) { + Log.w(TAG, "+++ mUnlinkVisualizer run(), mVisualizer: " + mVisualizer); + } if (mVisualizer != null) { mVisualizer.setEnabled(false); mVisualizer.release(); mVisualizer = null; } + if (DEBUG) { + Log.w(TAG, "--- mUninkVisualizer run()"); + } } }; @@ -223,6 +239,7 @@ public class VisualizerView extends View implements Palette.PaletteAsyncListener mKeyguardMonitor = kgm; if (isAttachedToWindow()) { // otherwise we might never register ourselves + mKeyguardMonitor.removeCallback(this); mKeyguardMonitor.addCallback(this); updateViewVisibility(); } @@ -230,6 +247,9 @@ public class VisualizerView extends View implements Palette.PaletteAsyncListener public void setVisible(boolean visible) { if (mVisible != visible) { + if (DEBUG) { + Log.i(TAG, "setVisible() called with visible = [" + visible + "]"); + } mVisible = visible; checkStateChanged(); } @@ -237,6 +257,9 @@ public class VisualizerView extends View implements Palette.PaletteAsyncListener public void setDozing(boolean dozing) { if (mDozing != dozing) { + if (DEBUG) { + Log.i(TAG, "setDozing() called with dozing = [" + dozing + "]"); + } mDozing = dozing; checkStateChanged(); } @@ -244,6 +267,9 @@ public class VisualizerView extends View implements Palette.PaletteAsyncListener public void setPlaying(boolean playing) { if (mPlaying != playing) { + if (DEBUG) { + Log.i(TAG, "setPlaying() called with playing = [" + playing + "]"); + } mPlaying = playing; checkStateChanged(); } @@ -251,6 +277,9 @@ public class VisualizerView extends View implements Palette.PaletteAsyncListener public void setPowerSaveMode(boolean powerSaveMode) { if (mPowerSaveMode != powerSaveMode) { + if (DEBUG) { + Log.i(TAG, "setPowerSaveMode() called with powerSaveMode = [" + powerSaveMode + "]"); + } mPowerSaveMode = powerSaveMode; checkStateChanged(); } @@ -258,6 +287,9 @@ public class VisualizerView extends View implements Palette.PaletteAsyncListener public void setOccluded(boolean occluded) { if (mOccluded != occluded) { + if (DEBUG) { + Log.i(TAG, "setOccluded() called with occluded = [" + occluded + "]"); + } mOccluded = occluded; checkStateChanged(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index c5e74a5..adff973 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -2188,7 +2188,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, if (!mKeyguardFadingAway && keyguardVisible && backdropBitmap != null && mScreenOn) { // if there's album art, ensure visualizer is visible - mVisualizerView.setVisible(true); mVisualizerView.setPlaying(mMediaController != null && mMediaController.getPlaybackState() != null && mMediaController.getPlaybackState().getState() @@ -4510,7 +4509,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, - StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION, StatusBarIconController.DEFAULT_TINT_ANIMATION_DURATION); disable(mDisabledUnmodified1, mDisabledUnmodified2, fadeoutDuration > 0 /* animate */); - mVisualizerView.setVisible(false); } public boolean isKeyguardFadingAway() { @@ -4871,7 +4869,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, mWakeUpTouchLocation = null; mStackScroller.setAnimationsEnabled(false); updateVisibleToUser(); - mVisualizerView.setVisible(false); if (mQSTileHost.isEditing()) { mQSTileHost.setEditing(false); } @@ -4920,6 +4917,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, } public void onScreenTurnedOff() { + mVisualizerView.setVisible(false); if (mNotificationPanel.hasExternalKeyguardView()) { mNotificationPanel.getExternalKeyguardView().onScreenTurnedOff(); } |