Merge "log more settings actions" into mnc-dev

This commit is contained in:
Chris Wren
2015-05-11 15:07:17 +00:00
committed by Android (Google) Code Review
16 changed files with 62 additions and 26 deletions

View File

@@ -27,7 +27,7 @@ import android.view.View;
*/
public class MetricsLogger implements MetricsConstants {
// These constants are temporary, they should migrate to MetricsConstants.
// next value is 148;
// next value is 179;
public static final int NOTIFICATION_ZEN_MODE_SCHEDULE_RULE = 144;
public static final int NOTIFICATION_ZEN_MODE_EXTERNAL_RULE = 145;
@@ -38,6 +38,32 @@ public class MetricsLogger implements MetricsConstants {
public static final int QS_BLUETOOTH_DETAILS = 150;
public static final int QS_CAST_DETAILS = 151;
public static final int QS_WIFI_DETAILS = 152;
public static final int QS_WIFI_TOGGLE = 153;
public static final int QS_BLUETOOTH_TOGGLE = 154;
public static final int QS_CELLULAR_TOGGLE = 155;
public static final int QS_SWITCH_USER = 156;
public static final int QS_CAST_SELECT = 157;
public static final int QS_CAST_DISCONNECT = 158;
public static final int ACTION_BLUETOOTH_TOGGLE = 159;
public static final int ACTION_BLUETOOTH_SCAN = 160;
public static final int ACTION_BLUETOOTH_RENAME = 161;
public static final int ACTION_BLUETOOTH_FILES = 162;
public static final int QS_DND_TIME = 163;
public static final int QS_DND_CONDITION_SELECT = 164;
public static final int QS_DND_ZEN_SELECT = 165;
public static final int QS_DND_TOGGLE = 166;
public static final int ACTION_ZEN_ALLOW_REMINDERS = 167;
public static final int ACTION_ZEN_ALLOW_EVENTS = 168;
public static final int ACTION_ZEN_ALLOW_MESSAGES = 169;
public static final int ACTION_ZEN_ALLOW_CALLS = 170;
public static final int ACTION_ZEN_ALLOW_REPEAT_CALLS = 171;
public static final int ACTION_ZEN_ADD_RULE = 172;
public static final int ACTION_ZEN_ADD_RULE_OK = 173;
public static final int ACTION_ZEN_DELETE_RULE = 174;
public static final int ACTION_ZEN_DELETE_RULE_OK = 175;
public static final int ACTION_ZEN_ENABLE_RULE = 176;
public static final int ACTION_AIRPLANE_TOGGLE = 177;
public static final int ACTION_CELL_DATA_TOGGLE = 178;
public static void visible(Context context, int category) throws IllegalArgumentException {
if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
@@ -71,6 +97,14 @@ public class MetricsLogger implements MetricsConstants {
action(context, category, "");
}
public static void action(Context context, int category, int value) {
action(context, category, Integer.toString(value));
}
public static void action(Context context, int category, boolean value) {
action(context, category, Boolean.toString(value));
}
public static void action(Context context, int category, String pkg) {
if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
throw new IllegalArgumentException("Must define metric category");

View File

@@ -24,6 +24,7 @@ import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
@@ -67,6 +68,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
private boolean mAnnounceNextStateChange;
abstract protected TState newTileState();
abstract protected void handleClick();
abstract protected void handleUpdateState(TState state, Object arg);
/**
@@ -170,10 +172,6 @@ public abstract class QSTile<TState extends State> implements Listenable {
handleRefreshState(null);
}
protected void handleClick() {
MetricsLogger.action(mContext, getMetricsCategory(), getMetricsPackage());
};
protected void handleSecondaryClick() {
// optional
}
@@ -182,10 +180,6 @@ public abstract class QSTile<TState extends State> implements Listenable {
// optional
}
protected String getMetricsPackage() {
return "";
}
protected void handleRefreshState(Object arg) {
handleUpdateState(mTmpState, arg);
final boolean changed = mTmpState.copyTo(mState);

View File

@@ -56,7 +56,7 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> {
@Override
public void handleClick() {
super.handleClick();
MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
setEnabled(!mState.value);
mEnable.setAllowAnimation(true);
mDisable.setAllowAnimation(true);

View File

@@ -75,8 +75,8 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
super.handleClick();
final boolean isEnabled = (Boolean)mState.value;
MetricsLogger.action(mContext, getMetricsCategory(), !isEnabled);
mController.setBluetoothEnabled(!isEnabled);
}
@@ -184,6 +184,7 @@ public class BluetoothTile extends QSTile<QSTile.BooleanState> {
@Override
public void setToggleState(boolean state) {
MetricsLogger.action(mContext, MetricsLogger.QS_BLUETOOTH_TOGGLE, state);
mController.setBluetoothEnabled(state);
showDetail(false);
}

View File

@@ -86,7 +86,7 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
super.handleClick();
MetricsLogger.action(mContext, getMetricsCategory());
showDetail(true);
}
@@ -246,6 +246,7 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
@Override
public void onDetailItemClick(Item item) {
if (item == null || item.tag == null) return;
MetricsLogger.action(mContext, MetricsLogger.QS_CAST_SELECT);
final CastDevice device = (CastDevice) item.tag;
mController.startCasting(device);
}
@@ -253,6 +254,7 @@ public class CastTile extends QSTile<QSTile.BooleanState> {
@Override
public void onDetailItemDisconnect(Item item) {
if (item == null || item.tag == null) return;
MetricsLogger.action(mContext, MetricsLogger.QS_CAST_DISCONNECT);
final CastDevice device = (CastDevice) item.tag;
mController.stopCasting(device);
}

View File

@@ -76,7 +76,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
@Override
protected void handleClick() {
super.handleClick();
MetricsLogger.action(mContext, getMetricsCategory());
if (mDataController.isMobileDataSupported()) {
showDetail(true);
} else {
@@ -230,6 +230,7 @@ public class CellularTile extends QSTile<QSTile.SignalState> {
@Override
public void setToggleState(boolean state) {
MetricsLogger.action(mContext, MetricsLogger.QS_CELLULAR_TOGGLE, state);
mDataController.setMobileDataEnabled(state);
}

View File

@@ -87,7 +87,7 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
super.handleClick();
MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
mSetting.setValue(mState.value ? 0 : 1);
mEnable.setAllowAnimation(true);
mDisable.setAllowAnimation(true);

View File

@@ -89,7 +89,7 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
@Override
public void handleClick() {
super.handleClick();
MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
if (mState.value) {
mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
} else {
@@ -209,6 +209,7 @@ public class DndTile extends QSTile<QSTile.BooleanState> {
@Override
public void setToggleState(boolean state) {
MetricsLogger.action(mContext, MetricsLogger.QS_DND_TOGGLE, state);
if (!state) {
mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
showDetail(false);

View File

@@ -60,10 +60,10 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements
@Override
protected void handleClick() {
super.handleClick();
if (ActivityManager.isUserAMonkey()) {
return;
}
MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
boolean newState = !mState.value;
refreshState(newState ? UserBoolean.USER_TRUE : UserBoolean.USER_FALSE);
mFlashlightController.setFlashlight(newState);

View File

@@ -69,8 +69,8 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
super.handleClick();
final boolean isEnabled = (Boolean) mState.value;
MetricsLogger.action(mContext, getMetricsCategory(), !isEnabled);
mController.setHotspotEnabled(!isEnabled);
mEnable.setAllowAnimation(true);
mDisable.setAllowAnimation(true);

View File

@@ -84,7 +84,7 @@ public class IntentTile extends QSTile<QSTile.State> {
@Override
protected void handleClick() {
super.handleClick();
MetricsLogger.action(mContext, getMetricsCategory(), mIntentPackage);
sendIntent("click", mOnClick, mOnClickUri);
}
@@ -137,6 +137,7 @@ public class IntentTile extends QSTile<QSTile.State> {
mOnLongClick = intent.getParcelableExtra("onLongClick");
mOnLongClickUri = intent.getStringExtra("onLongClickUri");
mIntentPackage = intent.getStringExtra("package");
mIntentPackage = mIntentPackage == null ? "" : mIntentPackage;
}
@Override
@@ -144,11 +145,6 @@ public class IntentTile extends QSTile<QSTile.State> {
return MetricsLogger.QS_INTENT;
}
@Override
protected String getMetricsPackage() {
return mIntentPackage == null ? "" : mIntentPackage;
}
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {

View File

@@ -59,8 +59,8 @@ public class LocationTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
super.handleClick();
final boolean wasEnabled = (Boolean) mState.value;
MetricsLogger.action(mContext, getMetricsCategory(), !wasEnabled);
mController.setLocationEnabled(!wasEnabled);
mEnable.setAllowAnimation(true);
mDisable.setAllowAnimation(true);

View File

@@ -59,8 +59,8 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> {
@Override
protected void handleClick() {
super.handleClick();
if (mController == null) return;
MetricsLogger.action(mContext, getMetricsCategory(), !mState.value);
final boolean newState = !mState.value;
mController.setRotationLocked(newState);
refreshState(newState ? UserBoolean.USER_TRUE : UserBoolean.USER_FALSE);

View File

@@ -16,6 +16,7 @@
package com.android.systemui.qs.tiles;
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.PseudoGridView;
import com.android.systemui.statusbar.policy.UserSwitcherController;
@@ -84,6 +85,7 @@ public class UserDetailView extends PseudoGridView {
public void onClick(View view) {
UserSwitcherController.UserRecord tag =
(UserSwitcherController.UserRecord) view.getTag();
MetricsLogger.action(mContext, MetricsLogger.QS_SWITCH_USER);
switchTo(tag);
}
}

View File

@@ -94,8 +94,8 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
@Override
protected void handleClick() {
super.handleClick();
mState.copyTo(mStateBeforeClick);
MetricsLogger.action(mContext, getMetricsCategory(), !mState.enabled);
mController.setWifiEnabled(!mState.enabled);
}
@@ -276,6 +276,7 @@ public class WifiTile extends QSTile<QSTile.SignalState> {
@Override
public void setToggleState(boolean state) {
if (DEBUG) Log.d(TAG, "setToggleState " + state);
MetricsLogger.action(mContext, MetricsLogger.QS_WIFI_TOGGLE, state);
mController.setWifiEnabled(state);
showDetail(false);
}

View File

@@ -48,6 +48,7 @@ import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.statusbar.policy.ZenModeController;
@@ -598,6 +599,7 @@ public class ZenModePanel extends LinearLayout {
if (childTag == null || childTag == tag) continue;
childTag.rb.setChecked(false);
}
MetricsLogger.action(mContext, MetricsLogger.QS_DND_CONDITION_SELECT);
select(tag.condition);
announceConditionSelection(tag);
}
@@ -700,6 +702,7 @@ public class ZenModePanel extends LinearLayout {
}
private void onClickTimeButton(View row, ConditionTag tag, boolean up) {
MetricsLogger.action(mContext, MetricsLogger.QS_DND_TIME, up);
Condition newCondition = null;
final int N = MINUTE_BUCKETS.length;
if (mBucketIndex == -1) {
@@ -907,6 +910,7 @@ public class ZenModePanel extends LinearLayout {
public void onSelected(final Object value) {
if (value != null && mZenButtons.isShown() && isAttachedToWindow()) {
final int zen = (Integer) value;
MetricsLogger.action(mContext, MetricsLogger.QS_DND_ZEN_SELECT, zen);
if (DEBUG) Log.d(mTag, "mZenButtonsCallback selected=" + zen);
final Uri realConditionId = getRealConditionId(mSessionExitCondition);
AsyncTask.execute(new Runnable() {