diff options
author | William Luh <williamluh@google.com> | 2013-11-22 15:42:40 -0800 |
---|---|---|
committer | William Luh <williamluh@google.com> | 2013-11-22 15:45:33 -0800 |
commit | 64e676a5863dc928546d047fe2e504cd54d3f835 (patch) | |
tree | 7a2028a310223dccfb4b465473d7a0e57df0f076 /src/com/android/settings/DeviceAdminAdd.java | |
parent | c384651a2b32057df78d31ebcb4c61c682c4c810 (diff) | |
download | packages_apps_Settings-64e676a5863dc928546d047fe2e504cd54d3f835.zip packages_apps_Settings-64e676a5863dc928546d047fe2e504cd54d3f835.tar.gz packages_apps_Settings-64e676a5863dc928546d047fe2e504cd54d3f835.tar.bz2 |
Add event logging for device admin.
This allows us to gather metrics about unwanted device admin apps. User consent from Verify Apps is required.
Bug: 11253927
Change-Id: I449929772f63f426426f7726d3d21e7c1512e6ce
Diffstat (limited to 'src/com/android/settings/DeviceAdminAdd.java')
-rw-r--r-- | src/com/android/settings/DeviceAdminAdd.java | 37 |
1 files changed, 21 insertions, 16 deletions
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.Handler; 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 @@ import java.util.List; 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 @@ public class DeviceAdminAdd extends Activity { 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 @@ public class DeviceAdminAdd extends Activity { finish(); return; } - + ComponentName cn = (ComponentName)getIntent().getParcelableExtra( DevicePolicyManager.EXTRA_DEVICE_ADMIN); if (cn == null) { @@ -163,7 +164,7 @@ public class DeviceAdminAdd extends Activity { 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 @@ public class DeviceAdminAdd extends Activity { 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 @@ public class DeviceAdminAdd extends Activity { 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 @@ public class DeviceAdminAdd extends Activity { 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 @@ public class DeviceAdminAdd extends Activity { } }); } - + @Override protected void onResume() { super.onResume(); updateInterface(); } - + @Override protected Dialog onCreateDialog(int id, Bundle args) { switch (id) { @@ -291,17 +296,17 @@ public class DeviceAdminAdd extends Activity { } 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())); |