diff options
author | Stanislav Zholnin <zholnin@google.com> | 2019-06-06 22:39:01 +0100 |
---|---|---|
committer | Stanislav Zholnin <zholnin@google.com> | 2019-06-18 12:01:56 +0000 |
commit | 0f0587d8c532657d39848178fc79e47e2b89cc56 (patch) | |
tree | 494e5aa6a44ddf016d97038b1333df8a09b081ba | |
parent | 981ba17a4a8bda4d83328644a2a460cfffb2a38e (diff) | |
download | android_packages_apps_PackageInstaller-0f0587d8c532657d39848178fc79e47e2b89cc56.tar.gz android_packages_apps_PackageInstaller-0f0587d8c532657d39848178fc79e47e2b89cc56.tar.bz2 android_packages_apps_PackageInstaller-0f0587d8c532657d39848178fc79e47e2b89cc56.zip |
Adding logging for GrantPermissionsActivity buttons presented and pressed.
Test: make statsd_testdrive && ./out/host/linux-x86/bin/statsd_testdrive -p com.google.android.permissioncontroller 213
Bug:133401502
Bug:134581123
Change-Id: I51dc90f01f603ac882c03b7c849596c252293dd2
-rw-r--r-- | src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java index b5f9d08b..18de0cd1 100644 --- a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java +++ b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java @@ -19,6 +19,7 @@ package com.android.packageinstaller.permission.ui; import static android.content.pm.PackageManager.PERMISSION_DENIED; import static android.view.WindowManager.LayoutParams.SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS; +import static com.android.packageinstaller.PermissionControllerStatsLog.GRANT_PERMISSIONS_ACTIVITY_BUTTON_ACTIONS; import static com.android.packageinstaller.PermissionControllerStatsLog.PERMISSION_GRANT_REQUEST_RESULT_REPORTED__RESULT__AUTO_DENIED; import static com.android.packageinstaller.PermissionControllerStatsLog.PERMISSION_GRANT_REQUEST_RESULT_REPORTED__RESULT__AUTO_GRANTED; import static com.android.packageinstaller.PermissionControllerStatsLog.PERMISSION_GRANT_REQUEST_RESULT_REPORTED__RESULT__IGNORED; @@ -95,6 +96,7 @@ public class GrantPermissionsActivity extends Activity private long mRequestId; private String[] mRequestedPermissions; + private CharSequence[] mButtonLabels; private ArrayMap<Pair<String, Boolean>, GroupState> mRequestGrantPermissionGroups = new ArrayMap<>(); @@ -641,16 +643,16 @@ public class GrantPermissionsActivity extends Activity } // The button doesn't show when its label is null - CharSequence[] buttonLabels = new CharSequence[NUM_BUTTONS]; - buttonLabels[LABEL_ALLOW_BUTTON] = getString(R.string.grant_dialog_button_allow); - buttonLabels[LABEL_ALLOW_ALWAYS_BUTTON] = null; - buttonLabels[LABEL_ALLOW_FOREGROUND_BUTTON] = null; - buttonLabels[LABEL_DENY_BUTTON] = getString(R.string.grant_dialog_button_deny); + mButtonLabels = new CharSequence[NUM_BUTTONS]; + mButtonLabels[LABEL_ALLOW_BUTTON] = getString(R.string.grant_dialog_button_allow); + mButtonLabels[LABEL_ALLOW_ALWAYS_BUTTON] = null; + mButtonLabels[LABEL_ALLOW_FOREGROUND_BUTTON] = null; + mButtonLabels[LABEL_DENY_BUTTON] = getString(R.string.grant_dialog_button_deny); if (isForegroundPermissionUserSet || isBackgroundPermissionUserSet) { - buttonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] = + mButtonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] = getString(R.string.grant_dialog_button_deny_and_dont_ask_again); } else { - buttonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] = null; + mButtonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] = null; } int messageId; @@ -659,14 +661,14 @@ public class GrantPermissionsActivity extends Activity messageId = groupState.mGroup.getRequest(); if (groupState.mGroup.hasPermissionWithBackgroundMode()) { - buttonLabels[LABEL_ALLOW_BUTTON] = null; - buttonLabels[LABEL_ALLOW_FOREGROUND_BUTTON] = + mButtonLabels[LABEL_ALLOW_BUTTON] = null; + mButtonLabels[LABEL_ALLOW_FOREGROUND_BUTTON] = getString(R.string.grant_dialog_button_allow_foreground); if (needBackgroundPermission) { - buttonLabels[LABEL_ALLOW_ALWAYS_BUTTON] = + mButtonLabels[LABEL_ALLOW_ALWAYS_BUTTON] = getString(R.string.grant_dialog_button_allow_always); if (isForegroundPermissionUserSet || isBackgroundPermissionUserSet) { - buttonLabels[LABEL_DENY_BUTTON] = null; + mButtonLabels[LABEL_DENY_BUTTON] = null; } } } else { @@ -676,11 +678,11 @@ public class GrantPermissionsActivity extends Activity if (needBackgroundPermission) { messageId = groupState.mGroup.getBackgroundRequest(); detailMessageId = groupState.mGroup.getBackgroundRequestDetail(); - buttonLabels[LABEL_ALLOW_BUTTON] = + mButtonLabels[LABEL_ALLOW_BUTTON] = getString(R.string.grant_dialog_button_allow_background); - buttonLabels[LABEL_DENY_BUTTON] = + mButtonLabels[LABEL_DENY_BUTTON] = getString(R.string.grant_dialog_button_deny_background); - buttonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] = + mButtonLabels[LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON] = getString(R.string .grant_dialog_button_deny_background_and_dont_ask_again); } else { @@ -707,7 +709,7 @@ public class GrantPermissionsActivity extends Activity setTitle(message); mViewHandler.updateUi(groupState.mGroup.getName(), numGrantRequests, currentIndex, - icon, message, detailMessage, buttonLabels); + icon, message, detailMessage, mButtonLabels); return true; } @@ -723,6 +725,7 @@ public class GrantPermissionsActivity extends Activity @Override public void onPermissionGrantResult(String name, @GrantPermissionsViewHandler.Result int result) { + logGrantPermissionActivityButtons(name, result); GroupState foregroundGroupState = getForegroundGroupState(name); GroupState backgroundGroupState = getBackgroundGroupState(name); @@ -953,6 +956,52 @@ public class GrantPermissionsActivity extends Activity } } + private void logGrantPermissionActivityButtons(String permissionGroupName, int grantResult) { + int clickedButton = 0; + int presentedButtons = getButtonState(); + switch (grantResult) { + case GRANTED_ALWAYS: + if ((presentedButtons & (1 << LABEL_ALLOW_BUTTON)) != 0) { + clickedButton = 1 << LABEL_ALLOW_BUTTON; + } else { + clickedButton = 1 << LABEL_ALLOW_ALWAYS_BUTTON; + } + break; + case GRANTED_FOREGROUND_ONLY: + clickedButton = 1 << LABEL_ALLOW_FOREGROUND_BUTTON; + break; + case DENIED: + clickedButton = 1 << LABEL_DENY_BUTTON; + break; + case DENIED_DO_NOT_ASK_AGAIN: + clickedButton = 1 << LABEL_DENY_AND_DONT_ASK_AGAIN_BUTTON; + break; + default: + break; + } + + PermissionControllerStatsLog.write(GRANT_PERMISSIONS_ACTIVITY_BUTTON_ACTIONS, + permissionGroupName, mCallingUid, mCallingPackage, presentedButtons, + clickedButton); + Log.v(LOG_TAG, "Logged buttons presented and clicked permissionGroupName=" + + permissionGroupName + " uid=" + mCallingUid + " package=" + mCallingPackage + + " presentedButtons=" + presentedButtons + " clickedButton=" + clickedButton); + } + + private int getButtonState() { + if (mButtonLabels == null) { + return 0; + } + int buttonState = 0; + for (int i = NUM_BUTTONS - 1; i >= 0; i--) { + buttonState *= 2; + if (mButtonLabels[i] != null) { + buttonState++; + } + } + return buttonState; + } + private static final class GroupState { static final int STATE_UNKNOWN = 0; static final int STATE_ALLOWED = 1; |