Loading src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java +64 −15 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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<>(); Loading Loading @@ -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; Loading @@ -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 { Loading @@ -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 { Loading @@ -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; } Loading @@ -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); Loading Loading @@ -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; Loading Loading
src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java +64 −15 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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<>(); Loading Loading @@ -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; Loading @@ -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 { Loading @@ -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 { Loading @@ -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; } Loading @@ -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); Loading Loading @@ -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; Loading