Merge "Add event logging for device admin."
diff --git a/src/com/android/settings/DeviceAdminAdd.java b/src/com/android/settings/DeviceAdminAdd.java
index 6234038..8bfdf92 100644
--- a/src/com/android/settings/DeviceAdminAdd.java
+++ b/src/com/android/settings/DeviceAdminAdd.java
@@ -38,6 +38,7 @@
 import android.os.RemoteCallback;
 import android.os.RemoteException;
 import android.text.TextUtils.TruncateAt;
+import android.util.EventLog;
 import android.util.Log;
 import android.view.Display;
 import android.view.View;
@@ -55,19 +56,19 @@
 
 public class DeviceAdminAdd extends Activity {
     static final String TAG = "DeviceAdminAdd";
-    
+
     static final int DIALOG_WARNING = 1;
 
     private static final int MAX_ADD_MSG_LINES_PORTRAIT = 5;
     private static final int MAX_ADD_MSG_LINES_LANDSCAPE = 2;
     private static final int MAX_ADD_MSG_LINES = 15;
-    
+
     Handler mHandler;
-    
+
     DevicePolicyManager mDPM;
     DeviceAdminInfo mDeviceAdmin;
     CharSequence mAddMsgText;
-    
+
     ImageView mAdminIcon;
     TextView mAdminName;
     TextView mAdminDescription;
@@ -78,19 +79,19 @@
     ViewGroup mAdminPolicies;
     Button mActionButton;
     Button mCancelButton;
-    
+
     final ArrayList<View> mAddingPolicies = new ArrayList<View>();
     final ArrayList<View> mActivePolicies = new ArrayList<View>();
-    
+
     boolean mAdding;
     boolean mRefreshing;
-    
+
     @Override
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
         mHandler = new Handler(getMainLooper());
-        
+
         mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
 
         if ((getIntent().getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
@@ -98,7 +99,7 @@
             finish();
             return;
         }
-        
+
         ComponentName cn = (ComponentName)getIntent().getParcelableExtra(
                 DevicePolicyManager.EXTRA_DEVICE_ADMIN);
         if (cn == null) {
@@ -163,7 +164,7 @@
             finish();
             return;
         }
-        
+
         // This admin already exists, an we have two options at this point.  If new policy
         // bits are set, show the user the new list.  If nothing has changed, simply return
         // "OK" immediately.
@@ -189,7 +190,7 @@
         mAddMsgText = getIntent().getCharSequenceExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION);
 
         setContentView(R.layout.device_admin_add);
-        
+
         mAdminIcon = (ImageView)findViewById(R.id.admin_icon);
         mAdminName = (TextView)findViewById(R.id.admin_name);
         mAdminDescription = (TextView)findViewById(R.id.admin_description);
@@ -210,6 +211,8 @@
         mCancelButton = (Button) findViewById(R.id.cancel_button);
         mCancelButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
+                EventLog.writeEvent(EventLogTags.EXP_DET_DEVICE_ADMIN_DECLINED_BY_USER,
+                    mDeviceAdmin.getActivityInfo().applicationInfo.uid);
                 finish();
             }
         });
@@ -220,6 +223,8 @@
                     try {
                         mDPM.setActiveAdmin(mDeviceAdmin.getComponent(), mRefreshing);
                         setResult(Activity.RESULT_OK);
+                        EventLog.writeEvent(EventLogTags.EXP_DET_DEVICE_ADMIN_ACTIVATED_BY_USER,
+                            mDeviceAdmin.getActivityInfo().applicationInfo.uid);
                     } catch (RuntimeException e) {
                         // Something bad happened...  could be that it was
                         // already set, though.
@@ -264,13 +269,13 @@
             }
         });
     }
-    
+
     @Override
     protected void onResume() {
         super.onResume();
         updateInterface();
     }
-    
+
     @Override
     protected Dialog onCreateDialog(int id, Bundle args) {
         switch (id) {
@@ -291,17 +296,17 @@
             }
             default:
                 return super.onCreateDialog(id, args);
-                    
+
         }
     }
-    
+
     static void setViewVisibility(ArrayList<View> views, int visibility) {
         final int N = views.size();
         for (int i=0; i<N; i++) {
             views.get(i).setVisibility(visibility);
         }
     }
-    
+
     void updateInterface() {
         mAdminIcon.setImageDrawable(mDeviceAdmin.loadIcon(getPackageManager()));
         mAdminName.setText(mDeviceAdmin.loadLabel(getPackageManager()));
diff --git a/src/com/android/settings/EventLogTags.logtags b/src/com/android/settings/EventLogTags.logtags
index 3e87c53..b21623c 100644
--- a/src/com/android/settings/EventLogTags.logtags
+++ b/src/com/android/settings/EventLogTags.logtags
@@ -4,3 +4,9 @@
 
 # log the type of screen lock when user sets lock screen
 90200 lock_screen_type (type|3)
+
+# log whether user accepted and activated device admin
+90201 exp_det_device_admin_activated_by_user (app_signature|3)
+
+# log whether user declined activation of device admin
+90202 exp_det_device_admin_declined_by_user (app_signature|3)