diff options
author | Chris Wren <cwren@android.com> | 2015-06-18 19:57:48 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-18 19:57:50 +0000 |
commit | 5e275f9fc0e655a273fc62ce297c9d5a069d7ed7 (patch) | |
tree | 7c6165d50ed87342082cd4ab2a2c343f40e97022 /packages | |
parent | 3fa285f93e2810cbd31a71490b364be2b6636d9d (diff) | |
parent | e565ee6ccbac4e820eb2737890aadb5efe9d4e3b (diff) | |
download | frameworks_base-5e275f9fc0e655a273fc62ce297c9d5a069d7ed7.zip frameworks_base-5e275f9fc0e655a273fc62ce297c9d5a069d7ed7.tar.gz frameworks_base-5e275f9fc0e655a273fc62ce297c9d5a069d7ed7.tar.bz2 |
Merge "instrument volume controls" into mnc-dev
Diffstat (limited to 'packages')
3 files changed, 49 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/volume/Events.java b/packages/SystemUI/src/com/android/systemui/volume/Events.java index 12dca94..893c939 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/Events.java +++ b/packages/SystemUI/src/com/android/systemui/volume/Events.java @@ -16,11 +16,13 @@ package com.android.systemui.volume; +import android.content.Context; import android.media.AudioManager; import android.media.AudioSystem; import android.provider.Settings.Global; import android.util.Log; +import com.android.internal.logging.MetricsLogger; import com.android.systemui.volume.VolumeDialogController.State; import java.util.Arrays; @@ -47,6 +49,7 @@ public class Events { public static final int EVENT_ZEN_MODE_CHANGED = 13; // (mode|int) public static final int EVENT_SUPPRESSOR_CHANGED = 14; // (component|string) (name|string) public static final int EVENT_MUTE_CHANGED = 15; // (stream|int) (muted|bool) + public static final int EVENT_TOUCH_LEVEL_DONE = 16; // (stream|int) (level|bool) private static final String[] EVENT_TAGS = { "show_dialog", @@ -65,6 +68,7 @@ public class Events { "zen_mode_changed", "suppressor_changed", "mute_changed", + "touch_level_done", }; public static final int DISMISS_REASON_UNKNOWN = 0; @@ -100,36 +104,59 @@ public class Events { public static Callback sCallback; - public static void writeEvent(int tag, Object... list) { + public static void writeEvent(Context context, int tag, Object... list) { final long time = System.currentTimeMillis(); final StringBuilder sb = new StringBuilder("writeEvent ").append(EVENT_TAGS[tag]); if (list != null && list.length > 0) { sb.append(" "); switch (tag) { case EVENT_SHOW_DIALOG: + MetricsLogger.visible(context, MetricsLogger.VOLUME_DIALOG); + MetricsLogger.histogram(context, "volume_from_keyguard", + (Boolean) list[1] ? 1 : 0); sb.append(SHOW_REASONS[(Integer) list[0]]).append(" keyguard=").append(list[1]); break; case EVENT_EXPAND: + MetricsLogger.visibility(context, MetricsLogger.VOLUME_DIALOG_DETAILS, + (Boolean) list[0]); sb.append(list[0]); break; case EVENT_DISMISS_DIALOG: + MetricsLogger.hidden(context, MetricsLogger.VOLUME_DIALOG); sb.append(DISMISS_REASONS[(Integer) list[0]]); break; case EVENT_ACTIVE_STREAM_CHANGED: + MetricsLogger.action(context, MetricsLogger.ACTION_VOLUME_STREAM, + (Integer) list[0]); sb.append(AudioSystem.streamToString((Integer) list[0])); break; case EVENT_ICON_CLICK: + MetricsLogger.action(context, MetricsLogger.ACTION_VOLUME_ICON, + (Integer) list[1]); sb.append(AudioSystem.streamToString((Integer) list[0])).append(' ') .append(iconStateToString((Integer) list[1])); break; + case EVENT_TOUCH_LEVEL_DONE: + MetricsLogger.action(context, MetricsLogger.ACTION_VOLUME_SLIDER, + (Integer) list[1]); + // fall through case EVENT_TOUCH_LEVEL_CHANGED: case EVENT_LEVEL_CHANGED: case EVENT_MUTE_CHANGED: sb.append(AudioSystem.streamToString((Integer) list[0])).append(' ') .append(list[1]); break; - case EVENT_INTERNAL_RINGER_MODE_CHANGED: + case EVENT_KEY: + MetricsLogger.action(context, MetricsLogger.ACTION_VOLUME_KEY, + (Integer) list[1]); + sb.append(AudioSystem.streamToString((Integer) list[0])).append(' ') + .append(list[1]); + break; case EVENT_EXTERNAL_RINGER_MODE_CHANGED: + MetricsLogger.action(context, MetricsLogger.ACTION_RINGER_MODE, + (Integer) list[0]); + // fall through + case EVENT_INTERNAL_RINGER_MODE_CHANGED: sb.append(ringerModeToString((Integer) list[0])); break; case EVENT_ZEN_MODE_CHANGED: diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java index aa891b6..5b2eb84 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java @@ -369,7 +369,7 @@ public class VolumeDialog { row.icon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - Events.writeEvent(Events.EVENT_ICON_CLICK, row.stream, row.iconState); + Events.writeEvent(mContext, Events.EVENT_ICON_CLICK, row.stream, row.iconState); mController.setActiveStream(row.stream); if (row.stream == AudioManager.STREAM_RING) { final boolean hasVibrator = mController.hasVibrator(); @@ -417,7 +417,7 @@ public class VolumeDialog { if (mShowing) return; mShowing = true; mDialog.show(); - Events.writeEvent(Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked()); + Events.writeEvent(mContext, Events.EVENT_SHOW_DIALOG, reason, mKeyguard.isKeyguardLocked()); mController.notifyVisible(true); } @@ -444,7 +444,7 @@ public class VolumeDialog { if (!mShowing) return; mShowing = false; mDialog.dismiss(); - Events.writeEvent(Events.EVENT_DISMISS_DIALOG, reason); + Events.writeEvent(mContext, Events.EVENT_DISMISS_DIALOG, reason); setExpandedH(false); mController.notifyVisible(false); synchronized (mSafetyWarningLock) { @@ -834,7 +834,7 @@ public class VolumeDialog { public void onClick(View v) { if (mExpanding) return; final boolean newExpand = !mExpanded; - Events.writeEvent(Events.EVENT_EXPAND, v); + Events.writeEvent(mContext, Events.EVENT_EXPAND, newExpand); setExpandedH(newExpand); } }; @@ -845,7 +845,7 @@ public class VolumeDialog { mSettingsButton.postDelayed(new Runnable() { @Override public void run() { - Events.writeEvent(Events.EVENT_SETTINGS_CLICK); + Events.writeEvent(mContext, Events.EVENT_SETTINGS_CLICK); if (mCallback != null) { mCallback.onSettingsClicked(); } @@ -933,7 +933,8 @@ public class VolumeDialog { if (mRow.requestedLevel != userLevel) { mController.setStreamVolume(mRow.stream, userLevel); mRow.requestedLevel = userLevel; - Events.writeEvent(Events.EVENT_TOUCH_LEVEL_CHANGED, mRow.stream, userLevel); + Events.writeEvent(mContext, Events.EVENT_TOUCH_LEVEL_CHANGED, mRow.stream, + userLevel); } } } @@ -951,6 +952,7 @@ public class VolumeDialog { mRow.tracking = false; mRow.userAttempt = SystemClock.uptimeMillis(); int userLevel = getImpliedLevel(seekBar, seekBar.getProgress()); + Events.writeEvent(mContext, Events.EVENT_TOUCH_LEVEL_DONE, mRow.stream, userLevel); if (mRow.ss.level != userLevel) { mHandler.sendMessageDelayed(mHandler.obtainMessage(H.RECHECK, mRow), USER_ATTEMPT_GRACE_PERIOD); diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java index c6d9e46..9a59a2a 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialogController.java @@ -104,7 +104,7 @@ public class VolumeDialogController { public VolumeDialogController(Context context, ComponentName component) { mContext = context.getApplicationContext(); - Events.writeEvent(Events.EVENT_COLLECTION_STARTED); + Events.writeEvent(mContext, Events.EVENT_COLLECTION_STARTED); mComponent = component; mWorkerThread = new HandlerThread(VolumeDialogController.class.getSimpleName()); mWorkerThread.start(); @@ -168,7 +168,7 @@ public class VolumeDialogController { if (D.BUG) Log.d(TAG, "destroy"); if (mDestroyed) return; mDestroyed = true; - Events.writeEvent(Events.EVENT_COLLECTION_STOPPED); + Events.writeEvent(mContext, Events.EVENT_COLLECTION_STOPPED); mMediaSessions.destroy(); mObserver.destroy(); mReceiver.destroy(); @@ -293,7 +293,8 @@ public class VolumeDialogController { if (showUI) { changed |= updateActiveStreamW(stream); } - changed |= updateStreamLevelW(stream, mAudio.getLastAudibleStreamVolume(stream)); + int lastAudibleStreamVolume = mAudio.getLastAudibleStreamVolume(stream); + changed |= updateStreamLevelW(stream, lastAudibleStreamVolume); changed |= checkRoutedToBluetoothW(showUI ? AudioManager.STREAM_MUSIC : stream); if (changed) { mCallbacks.onStateChanged(mState); @@ -308,14 +309,14 @@ public class VolumeDialogController { mCallbacks.onShowSilentHint(); } if (changed && fromKey) { - Events.writeEvent(Events.EVENT_KEY); + Events.writeEvent(mContext, Events.EVENT_KEY, stream, lastAudibleStreamVolume); } } private boolean updateActiveStreamW(int activeStream) { if (activeStream == mState.activeStream) return false; mState.activeStream = activeStream; - Events.writeEvent(Events.EVENT_ACTIVE_STREAM_CHANGED, activeStream); + Events.writeEvent(mContext, Events.EVENT_ACTIVE_STREAM_CHANGED, activeStream); if (D.BUG) Log.d(TAG, "updateActiveStreamW " + activeStream); final int s = activeStream < DYNAMIC_STREAM_START_INDEX ? activeStream : -1; if (D.BUG) Log.d(TAG, "forceVolumeControlStream " + s); @@ -364,7 +365,7 @@ public class VolumeDialogController { if (ss.level == level) return false; ss.level = level; if (isLogWorthy(stream)) { - Events.writeEvent(Events.EVENT_LEVEL_CHANGED, stream, level); + Events.writeEvent(mContext, Events.EVENT_LEVEL_CHANGED, stream, level); } return true; } @@ -387,7 +388,7 @@ public class VolumeDialogController { if (ss.muted == muted) return false; ss.muted = muted; if (isLogWorthy(stream)) { - Events.writeEvent(Events.EVENT_MUTE_CHANGED, stream, muted); + Events.writeEvent(mContext, Events.EVENT_MUTE_CHANGED, stream, muted); } if (muted && isRinger(stream)) { updateRingerModeInternalW(mAudio.getRingerModeInternal()); @@ -410,7 +411,7 @@ public class VolumeDialogController { if (Objects.equals(mState.effectsSuppressor, effectsSuppressor)) return false; mState.effectsSuppressor = effectsSuppressor; mState.effectsSuppressorName = getApplicationName(mContext, mState.effectsSuppressor); - Events.writeEvent(Events.EVENT_SUPPRESSOR_CHANGED, mState.effectsSuppressor, + Events.writeEvent(mContext, Events.EVENT_SUPPRESSOR_CHANGED, mState.effectsSuppressor, mState.effectsSuppressorName); return true; } @@ -434,21 +435,21 @@ public class VolumeDialogController { Settings.Global.ZEN_MODE, Settings.Global.ZEN_MODE_OFF); if (mState.zenMode == zen) return false; mState.zenMode = zen; - Events.writeEvent(Events.EVENT_ZEN_MODE_CHANGED, zen); + Events.writeEvent(mContext, Events.EVENT_ZEN_MODE_CHANGED, zen); return true; } private boolean updateRingerModeExternalW(int rm) { if (rm == mState.ringerModeExternal) return false; mState.ringerModeExternal = rm; - Events.writeEvent(Events.EVENT_EXTERNAL_RINGER_MODE_CHANGED, rm); + Events.writeEvent(mContext, Events.EVENT_EXTERNAL_RINGER_MODE_CHANGED, rm); return true; } private boolean updateRingerModeInternalW(int rm) { if (rm == mState.ringerModeInternal) return false; mState.ringerModeInternal = rm; - Events.writeEvent(Events.EVENT_INTERNAL_RINGER_MODE_CHANGED, rm); + Events.writeEvent(mContext, Events.EVENT_INTERNAL_RINGER_MODE_CHANGED, rm); return true; } |