import android.content.Context;
import android.os.Build;
+import android.view.View;
/**
* Log all the things.
public static final int ACTION_BAN_APP_NOTES = 146;
public static final int NOTIFICATION_ZEN_MODE_EVENT_RULE = 147;
public static final int ACTION_DISMISS_ALL_NOTES = 148;
+ public static final int QS_DND_DETAILS = 149;
+ 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 void visible(Context context, int category) throws IllegalArgumentException {
if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
EventLogTags.writeSysuiViewVisibility(category, 100);
}
- public static void hidden(Context context, int category) {
+ public static void hidden(Context context, int category) throws IllegalArgumentException {
if (Build.IS_DEBUGGABLE && category == VIEW_UNKNOWN) {
throw new IllegalArgumentException("Must define metric category");
}
EventLogTags.writeSysuiViewVisibility(category, 0);
}
+ public static void visibility(Context context, int category, boolean visibile)
+ throws IllegalArgumentException {
+ if (visibile) {
+ visible(context, category);
+ } else {
+ hidden(context, category);
+ }
+ }
+
+ public static void visibility(Context context, int category, int vis)
+ throws IllegalArgumentException {
+ visibility(context, category, vis == View.VISIBLE);
+ }
+
public static void action(Context context, int category) {
action(context, category, "");
}
import android.widget.ImageView;
import android.widget.TextView;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile.DetailAdapter;
public void setExpanded(boolean expanded) {
if (mExpanded == expanded) return;
mExpanded = expanded;
+ MetricsLogger.visibility(mContext, MetricsLogger.QS_PANEL, mExpanded);
if (!mExpanded) {
closeDetail();
+ } else {
+ logTiles();
}
}
mDetailContent.removeAllViews();
mDetail.bringToFront();
mDetailContent.addView(r.detailView);
+ MetricsLogger.visible(mContext, detailAdapter.getMetricsCategory());
setDetailRecord(r);
listener = mHideGridContentWhenDone;
} else {
+ MetricsLogger.hidden(mContext, mDetailRecord.detailAdapter.getMetricsCategory());
mClosingDetail = true;
setGridContentVisibility(true);
listener = mTeardownDetailWhenDone;
}
}
mBrightnessView.setVisibility(newVis);
+ if (mGridContentVisible != visible) {
+ MetricsLogger.visibility(mContext, MetricsLogger.QS_PANEL, newVis);
+ }
mGridContentVisible = visible;
}
+ private void logTiles() {
+ for (int i = 0; i < mRecords.size(); i++) {
+ TileRecord tileRecord = mRecords.get(i);
+ if (tileRecord.tile.getState().visible) {
+ MetricsLogger.visible(mContext, tileRecord.tile.getMetricsCategory());
+ }
+ }
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int width = MeasureSpec.getSize(widthMeasureSpec);
import android.view.View;
import android.view.ViewGroup;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.qs.QSTile.State;
import com.android.systemui.statusbar.policy.BluetoothController;
import com.android.systemui.statusbar.policy.CastController;
private boolean mAnnounceNextStateChange;
abstract protected TState newTileState();
- abstract protected void handleClick();
abstract protected void handleUpdateState(TState state, Object arg);
+ /**
+ * Declare the category of this tile.
+ *
+ * Categories are defined in {@link com.android.internal.logging.MetricsLogger}
+ * or if there is no relevant existing category you may define one in
+ * {@link com.android.systemui.qs.QSTile}.
+ */
+ abstract public int getMetricsCategory();
+
protected QSTile(Host host) {
mHost = host;
mContext = host.getContext();
View createDetailView(Context context, View convertView, ViewGroup parent);
Intent getSettingsIntent();
void setToggleState(boolean state);
+ int getMetricsCategory();
}
// safe to call from any thread
handleRefreshState(null);
}
+ protected void handleClick() {
+ MetricsLogger.action(mContext, getMetricsCategory(), getMetricsPackage());
+ };
+
protected void handleSecondaryClick() {
// optional
}
// optional
}
+ protected String getMetricsPackage() {
+ return "";
+ }
+
protected void handleRefreshState(Object arg) {
handleUpdateState(mTmpState, arg);
final boolean changed = mTmpState.copyTo(mState);
import android.net.ConnectivityManager;
import android.provider.Settings.Global;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.GlobalSetting;
import com.android.systemui.qs.QSTile;
@Override
public void handleClick() {
+ super.handleClick();
setEnabled(!mState.value);
mEnable.setAllowAnimation(true);
mDisable.setAllowAnimation(true);
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_AIRPLANEMODE;
+ }
+
+ @Override
protected String composeChangeAnnouncement() {
if (mState.value) {
return mContext.getString(R.string.accessibility_quick_settings_airplane_changed_on);
import android.view.View;
import android.view.ViewGroup;
+import com.android.internal.logging.MetricsLogger;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.systemui.R;
import com.android.systemui.qs.QSDetailItems;
@Override
protected void handleClick() {
+ super.handleClick();
final boolean isEnabled = (Boolean)mState.value;
mController.setBluetoothEnabled(!isEnabled);
}
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_BLUETOOTH;
+ }
+
+ @Override
protected String composeChangeAnnouncement() {
if (mState.value) {
return mContext.getString(R.string.accessibility_quick_settings_bluetooth_changed_on);
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_BLUETOOTH_DETAILS;
+ }
+
+ @Override
public View createDetailView(Context context, View convertView, ViewGroup parent) {
mItems = QSDetailItems.convertOrInflate(context, convertView, parent);
mItems.setTagSuffix("Bluetooth");
import android.view.View.OnAttachStateChangeListener;
import android.view.ViewGroup;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSDetailItems;
import com.android.systemui.qs.QSDetailItems.Item;
@Override
protected void handleClick() {
+ super.handleClick();
showDetail(true);
}
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_CAST;
+ }
+
+ @Override
protected String composeChangeAnnouncement() {
if (!mState.value) {
// We only announce when it's turned off to avoid vocal overflow.
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_CAST_DETAILS;
+ }
+
+ @Override
public View createDetailView(Context context, View convertView, ViewGroup parent) {
mItems = QSDetailItems.convertOrInflate(context, convertView, parent);
mItems.setTagSuffix("Cast");
import android.view.View;
import android.view.ViewGroup;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.qs.QSTileView;
@Override
protected void handleClick() {
+ super.handleClick();
if (mDataController.isMobileDataSupported()) {
showDetail(true);
} else {
state.label);
}
+ @Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_CELLULAR;
+ }
+
// Remove the period from the network name
public static String removeTrailingPeriod(String string) {
if (string == null) return null;
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_DATAUSAGEDETAIL;
+ }
+
+ @Override
public View createDetailView(Context context, View convertView, ViewGroup parent) {
final DataUsageDetailView v = (DataUsageDetailView) (convertView != null
? convertView
import android.provider.Settings.Secure;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
@Override
protected void handleClick() {
+ super.handleClick();
mSetting.setValue(mState.value ? 0 : 1);
mEnable.setAllowAnimation(true);
mDisable.setAllowAnimation(true);
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_COLORINVERSION;
+ }
+
+ @Override
protected String composeChangeAnnouncement() {
if (mState.value) {
return mContext.getString(
import android.view.View.OnAttachStateChangeListener;
import android.view.ViewGroup;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
@Override
public void handleClick() {
+ super.handleClick();
if (mState.value) {
mController.setZen(Global.ZEN_MODE_OFF, null, TAG);
} else {
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_DND;
+ }
+
+ @Override
protected String composeChangeAnnouncement() {
if (mState.value) {
return mContext.getString(R.string.accessibility_quick_settings_dnd_changed_on);
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_DND_DETAILS;
+ }
+
+ @Override
public View createDetailView(Context context, View convertView, ViewGroup parent) {
final ZenModePanel zmp = convertView != null ? (ZenModePanel) convertView
: (ZenModePanel) LayoutInflater.from(context).inflate(
import android.app.ActivityManager;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.FlashlightController;
@Override
protected void handleClick() {
+ super.handleClick();
if (ActivityManager.isUserAMonkey()) {
return;
}
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_FLASHLIGHT;
+ }
+
+ @Override
protected String composeChangeAnnouncement() {
if (mState.value) {
return mContext.getString(R.string.accessibility_quick_settings_flashlight_changed_on);
import android.content.Context;
import android.content.Intent;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.qs.UsageTracker;
@Override
protected void handleClick() {
+ super.handleClick();
final boolean isEnabled = (Boolean) mState.value;
mController.setHotspotEnabled(!isEnabled);
mEnable.setAllowAnimation(true);
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_HOTSPOT;
+ }
+
+ @Override
protected String composeChangeAnnouncement() {
if (mState.value) {
return mContext.getString(R.string.accessibility_quick_settings_hotspot_changed_on);
import android.text.TextUtils;
import android.util.Log;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.qs.QSTile;
import java.util.Arrays;
private PendingIntent mOnLongClick;
private String mOnLongClickUri;
private int mCurrentUserId;
+ private String mIntentPackage;
private IntentTile(Host host, String action) {
super(host);
@Override
protected void handleClick() {
+ super.handleClick();
sendIntent("click", mOnClick, mOnClickUri);
}
mOnClickUri = intent.getStringExtra("onClickUri");
mOnLongClick = intent.getParcelableExtra("onLongClick");
mOnLongClickUri = intent.getStringExtra("onLongClickUri");
+ mIntentPackage = intent.getStringExtra("package");
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_INTENT;
+ }
+
+ @Override
+ protected String getMetricsPackage() {
+ return mIntentPackage == null ? "" : mIntentPackage;
}
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
package com.android.systemui.qs.tiles;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
@Override
protected void handleClick() {
+ super.handleClick();
final boolean wasEnabled = (Boolean) mState.value;
mController.setLocationEnabled(!wasEnabled);
mEnable.setAllowAnimation(true);
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_LOCATION;
+ }
+
+ @Override
protected String composeChangeAnnouncement() {
if (mState.value) {
return mContext.getString(R.string.accessibility_quick_settings_location_changed_on);
import android.content.res.Configuration;
+import com.android.internal.logging.MetricsLogger;
import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.policy.RotationLockController;
@Override
protected void handleClick() {
+ super.handleClick();
if (mController == null) return;
final boolean newState = !mState.value;
mController.setRotationLocked(newState);
R.string.accessibility_rotation_lock_off);
}
+ @Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_ROTATIONLOCK;
+ }
+
/**
* Get the correct accessibility string based on the state
*
import android.view.View;
import android.view.ViewGroup;
+import com.android.internal.logging.MetricsLogger;
import com.android.settingslib.wifi.AccessPoint;
import com.android.systemui.R;
import com.android.systemui.qs.QSDetailItems;
@Override
protected void handleClick() {
+ super.handleClick();
mState.copyTo(mStateBeforeClick);
mController.setWifiEnabled(!mState.enabled);
}
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_WIFI;
+ }
+
+ @Override
protected boolean shouldAnnouncementBeDelayed() {
return mStateBeforeClick.enabled == mState.enabled;
}
}
@Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_WIFI_DETAILS;
+ }
+
+ @Override
public View createDetailView(Context context, View convertView, ViewGroup parent) {
if (DEBUG) Log.d(TAG, "createDetailView convertView=" + (convertView != null));
mAccessPoints = null;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
+import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.UserIcons;
import com.android.systemui.BitmapHelper;
import com.android.systemui.GuestResumeSessionReceiver;
@Override
public void setToggleState(boolean state) {
}
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsLogger.QS_USERDETAIL;
+ }
};
private final KeyguardMonitor.Callback mCallback = new KeyguardMonitor.Callback() {