log more settings actions

  airplane mode
  bluetooth
  cell data
  do not disturb

Bug: 20264417
Change-Id: I726033a126fba9f9dffc916806d636feea04033b
diff --git a/src/com/android/settings/AirplaneModeEnabler.java b/src/com/android/settings/AirplaneModeEnabler.java
index 06648db..39f6114 100644
--- a/src/com/android/settings/AirplaneModeEnabler.java
+++ b/src/com/android/settings/AirplaneModeEnabler.java
@@ -27,6 +27,7 @@
 import android.preference.SwitchPreference;
 import android.provider.Settings;
 
+import com.android.internal.logging.MetricsLogger;
 import com.android.internal.telephony.PhoneStateIntentReceiver;
 import com.android.internal.telephony.TelephonyProperties;
 import com.android.settingslib.WirelessUtils;
@@ -120,7 +121,9 @@
                     SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE))) {
             // In ECM mode, do not update database at this point
         } else {
-            setAirplaneModeOn((Boolean) newValue);
+            Boolean value = (Boolean) newValue;
+            MetricsLogger.action(mContext, MetricsLogger.ACTION_AIRPLANE_TOGGLE, value);
+            setAirplaneModeOn(value);
         }
         return true;
     }
diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java
index 7eec3df..ed5de25 100644
--- a/src/com/android/settings/DataUsageSummary.java
+++ b/src/com/android/settings/DataUsageSummary.java
@@ -1217,10 +1217,11 @@
         public void onClick(View v) {
             if (mBinding) return;
 
-            final boolean dataEnabled = !mDataEnabled.isChecked();
+            final boolean enabled = !mDataEnabled.isChecked();
             final String currentTab = mCurrentTab;
             if (isMobileTab(currentTab)) {
-                if (dataEnabled) {
+                MetricsLogger.action(getContext(), MetricsLogger.ACTION_CELL_DATA_TOGGLE, enabled);
+                if (enabled) {
                     // If we are showing the Sim Card tile then we are a Multi-Sim device.
                     if (Utils.showSimCardTile(getActivity())) {
                         handleMultiSimDataDialog();
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index 1c9eeb6..e83f483 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -27,6 +27,7 @@
 import android.widget.Switch;
 import android.widget.Toast;
 
+import com.android.internal.logging.MetricsLogger;
 import com.android.settings.R;
 import com.android.settings.search.Index;
 import com.android.settings.widget.SwitchBar;
@@ -184,6 +185,8 @@
             switchView.setChecked(false);
         }
 
+        MetricsLogger.action(mContext, MetricsLogger.ACTION_BLUETOOTH_TOGGLE, isChecked);
+
         if (mLocalAdapter != null) {
             mLocalAdapter.setBluetoothEnabled(isChecked);
         }
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 1d0dc7e..9ec4be1 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -231,16 +231,19 @@
         switch (item.getItemId()) {
             case MENU_ID_SCAN:
                 if (mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON) {
+                    MetricsLogger.action(getActivity(), MetricsLogger.ACTION_BLUETOOTH_SCAN);
                     startScanning();
                 }
                 return true;
 
             case MENU_ID_RENAME_DEVICE:
+                MetricsLogger.action(getActivity(), MetricsLogger.ACTION_BLUETOOTH_RENAME);
                 new BluetoothNameDialogFragment().show(
                         getFragmentManager(), "rename device");
                 return true;
 
             case MENU_ID_SHOW_RECEIVED:
+                MetricsLogger.action(getActivity(), MetricsLogger.ACTION_BLUETOOTH_FILES);
                 Intent intent = new Intent(BTOPP_ACTION_OPEN_RECEIVED_FILES);
                 getActivity().sendBroadcast(intent);
                 return true;
diff --git a/src/com/android/settings/notification/ZenModeAutomationSettings.java b/src/com/android/settings/notification/ZenModeAutomationSettings.java
index 5b62844..ef22572 100644
--- a/src/com/android/settings/notification/ZenModeAutomationSettings.java
+++ b/src/com/android/settings/notification/ZenModeAutomationSettings.java
@@ -96,6 +96,7 @@
         new ZenRuleNameDialog(mContext, mServiceListing, null, mConfig.getAutomaticRuleNames()) {
             @Override
             public void onOk(String ruleName, RuleInfo ri) {
+                MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ADD_RULE_OK);
                 final ZenRule rule = new ZenRule();
                 rule.name = ruleName;
                 rule.enabled = true;
@@ -168,6 +169,7 @@
         p.setOnPreferenceClickListener(new OnPreferenceClickListener() {
             @Override
             public boolean onPreferenceClick(Preference preference) {
+                MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ADD_RULE);
                 showAddRuleDialog();
                 return true;
             }
diff --git a/src/com/android/settings/notification/ZenModePrioritySettings.java b/src/com/android/settings/notification/ZenModePrioritySettings.java
index 4907cf0..6e34bf7 100644
--- a/src/com/android/settings/notification/ZenModePrioritySettings.java
+++ b/src/com/android/settings/notification/ZenModePrioritySettings.java
@@ -57,6 +57,7 @@
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 if (mDisableListeners) return true;
                 final boolean val = (Boolean) newValue;
+                MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ALLOW_REMINDERS, val);
                 if (val == mConfig.allowReminders) return true;
                 if (DEBUG) Log.d(TAG, "onPrefChange allowReminders=" + val);
                 final ZenModeConfig newConfig = mConfig.copy();
@@ -71,6 +72,7 @@
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 if (mDisableListeners) return true;
                 final boolean val = (Boolean) newValue;
+                MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ALLOW_EVENTS, val);
                 if (val == mConfig.allowEvents) return true;
                 if (DEBUG) Log.d(TAG, "onPrefChange allowEvents=" + val);
                 final ZenModeConfig newConfig = mConfig.copy();
@@ -86,6 +88,7 @@
             public boolean onItemSelected(int pos, Object newValue) {
                 if (mDisableListeners) return true;
                 final int val = (Integer) newValue;
+                MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ALLOW_MESSAGES, val);
                 final boolean allowMessages = val != SOURCE_NONE;
                 final int allowMessagesFrom = val == SOURCE_NONE ? mConfig.allowMessagesFrom : val;
                 if (allowMessages == mConfig.allowMessages
@@ -108,6 +111,7 @@
             public boolean onItemSelected(int pos, Object newValue) {
                 if (mDisableListeners) return true;
                 final int val = (Integer) newValue;
+                MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ALLOW_CALLS, val);
                 final boolean allowCalls = val != SOURCE_NONE;
                 final int allowCallsFrom = val == SOURCE_NONE ? mConfig.allowCallsFrom : val;
                 if (allowCalls == mConfig.allowCalls
@@ -132,6 +136,7 @@
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 if (mDisableListeners) return true;
                 final boolean val = (Boolean) newValue;
+                MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ALLOW_REPEAT_CALLS, val);
                 if (val == mConfig.allowRepeatCallers) return true;
                 if (DEBUG) Log.d(TAG, "onPrefChange allowRepeatCallers=" + val);
                 final ZenModeConfig newConfig = mConfig.copy();
diff --git a/src/com/android/settings/notification/ZenModeRuleSettingsBase.java b/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
index cf66da8..9ba7e92 100644
--- a/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
+++ b/src/com/android/settings/notification/ZenModeRuleSettingsBase.java
@@ -36,6 +36,7 @@
 import android.widget.Switch;
 import android.widget.Toast;
 
+import com.android.internal.logging.MetricsLogger;
 import com.android.settings.DropDownPreference;
 import com.android.settings.R;
 import com.android.settings.SettingsActivity;
@@ -152,6 +153,7 @@
         if (mDisableListeners) return;
         final boolean enabled = isChecked;
         if (enabled == mRule.enabled) return;
+        MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_ENABLE_RULE, enabled);
         if (DEBUG) Log.d(TAG, "onSwitchChanged enabled=" + enabled);
         mRule.enabled = enabled;
         mRule.snoozing = false;
@@ -198,6 +200,7 @@
     public boolean onOptionsItemSelected(MenuItem item) {
         if (DEBUG) Log.d(TAG, "onOptionsItemSelected " + item.getItemId());
         if (item.getItemId() == R.id.delete) {
+            MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_DELETE_RULE);
             showDeleteRuleDialog();
             return true;
         }
@@ -234,6 +237,7 @@
                 .setPositiveButton(R.string.zen_mode_delete_rule_button, new OnClickListener() {
                     @Override
                     public void onClick(DialogInterface dialog, int which) {
+                        MetricsLogger.action(mContext, MetricsLogger.ACTION_ZEN_DELETE_RULE_OK);
                         mDeleting = true;
                         mConfig.automaticRules.remove(mRuleId);
                         setZenModeConfig(mConfig);