From cc340d6ebe649664620e6b8bb59f2e21058733ca Mon Sep 17 00:00:00 2001 From: Richard MacGregor Date: Thu, 23 Jan 2025 10:55:07 -0800 Subject: set minSdk for ReservedForTestingProfileGroupExclusivityRole Bug: 383538899 Flag: EXEMPT bugfix Relnote: N/A Test: atest RoleManagerMultiUserTest Change-Id: I03f3dfd9a6c915c0ec4a95adc559d08de95d4c50 --- ...stingProfileGroupExclusivityRoleUiBehavior.java | 79 -------------------- ...stingProfileGroupExclusivityRoleUiBehavior.java | 83 ++++++++++++++++++++++ 2 files changed, 83 insertions(+), 79 deletions(-) delete mode 100644 PermissionController/src/com/android/permissioncontroller/role/ui/behavior/ReservedForTestingProfileGroupExclusivityRoleUiBehavior.java create mode 100644 PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v36/ReservedForTestingProfileGroupExclusivityRoleUiBehavior.java (limited to 'PermissionController/src') diff --git a/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/ReservedForTestingProfileGroupExclusivityRoleUiBehavior.java b/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/ReservedForTestingProfileGroupExclusivityRoleUiBehavior.java deleted file mode 100644 index be51a1e17..000000000 --- a/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/ReservedForTestingProfileGroupExclusivityRoleUiBehavior.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.permissioncontroller.role.ui.behavior; - -import android.content.Context; -import android.content.pm.ApplicationInfo; -import android.os.UserHandle; - -import androidx.annotation.NonNull; -import androidx.preference.Preference; - -import com.android.permissioncontroller.permission.utils.Utils; -import com.android.permissioncontroller.role.ui.RequestRoleItemView; -import com.android.permissioncontroller.role.ui.TwoTargetPreference; -import com.android.role.controller.model.Role; -import com.android.role.controller.util.UserUtils; - -import java.util.List; - -public class ReservedForTestingProfileGroupExclusivityRoleUiBehavior implements RoleUiBehavior { - @Override - public void preparePreferenceAsUser(@NonNull Role role, @NonNull TwoTargetPreference preference, - @NonNull List applicationInfos, @NonNull UserHandle user, - @NonNull Context context) { - if (!applicationInfos.isEmpty()) { - preparePreferenceInternal(preference.asPreference(), applicationInfos.get(0), false, - user, context); - } - } - - @Override - public void prepareApplicationPreferenceAsUser(@NonNull Role role, - @NonNull Preference preference, @NonNull ApplicationInfo applicationInfo, - @NonNull UserHandle user, @NonNull Context context) { - preparePreferenceInternal(preference, applicationInfo, true, user, context); - } - - @Override - public void prepareRequestRoleItemViewAsUser(@NonNull Role role, - @NonNull RequestRoleItemView itemView, @NonNull ApplicationInfo applicationInfo, - @NonNull UserHandle user, @NonNull Context context) { - Context userContext = UserUtils.getUserContext(context, user); - String title = getTitle(applicationInfo, userContext); - itemView.getTitleTextView().setText(title); - } - - private void preparePreferenceInternal(@NonNull Preference preference, - @NonNull ApplicationInfo applicationInfo, boolean setTitle, @NonNull UserHandle user, - @NonNull Context context) { - Context userContext = UserUtils.getUserContext(context, user); - String title = getTitle(applicationInfo, userContext); - if (setTitle) { - preference.setTitle(title); - } else { - preference.setSummary(title); - } - } - - @NonNull - private static String getTitle(@NonNull ApplicationInfo applicationInfo, - @NonNull Context context) { - return Utils.getFullAppLabel(applicationInfo, context) + "@" - + UserHandle.getUserHandleForUid(applicationInfo.uid).getIdentifier(); - } -} diff --git a/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v36/ReservedForTestingProfileGroupExclusivityRoleUiBehavior.java b/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v36/ReservedForTestingProfileGroupExclusivityRoleUiBehavior.java new file mode 100644 index 000000000..00b1ce5b1 --- /dev/null +++ b/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v36/ReservedForTestingProfileGroupExclusivityRoleUiBehavior.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.permissioncontroller.role.ui.behavior.v36; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.os.Build; +import android.os.UserHandle; + +import androidx.annotation.NonNull; +import androidx.annotation.RequiresApi; +import androidx.preference.Preference; + +import com.android.permissioncontroller.permission.utils.Utils; +import com.android.permissioncontroller.role.ui.RequestRoleItemView; +import com.android.permissioncontroller.role.ui.TwoTargetPreference; +import com.android.permissioncontroller.role.ui.behavior.RoleUiBehavior; +import com.android.role.controller.model.Role; +import com.android.role.controller.util.UserUtils; + +import java.util.List; + +@RequiresApi(Build.VERSION_CODES.BAKLAVA) +public class ReservedForTestingProfileGroupExclusivityRoleUiBehavior implements RoleUiBehavior { + @Override + public void preparePreferenceAsUser(@NonNull Role role, @NonNull TwoTargetPreference preference, + @NonNull List applicationInfos, @NonNull UserHandle user, + @NonNull Context context) { + if (!applicationInfos.isEmpty()) { + preparePreferenceInternal(preference.asPreference(), applicationInfos.get(0), false, + user, context); + } + } + + @Override + public void prepareApplicationPreferenceAsUser(@NonNull Role role, + @NonNull Preference preference, @NonNull ApplicationInfo applicationInfo, + @NonNull UserHandle user, @NonNull Context context) { + preparePreferenceInternal(preference, applicationInfo, true, user, context); + } + + @Override + public void prepareRequestRoleItemViewAsUser(@NonNull Role role, + @NonNull RequestRoleItemView itemView, @NonNull ApplicationInfo applicationInfo, + @NonNull UserHandle user, @NonNull Context context) { + Context userContext = UserUtils.getUserContext(context, user); + String title = getTitle(applicationInfo, userContext); + itemView.getTitleTextView().setText(title); + } + + private void preparePreferenceInternal(@NonNull Preference preference, + @NonNull ApplicationInfo applicationInfo, boolean setTitle, @NonNull UserHandle user, + @NonNull Context context) { + Context userContext = UserUtils.getUserContext(context, user); + String title = getTitle(applicationInfo, userContext); + if (setTitle) { + preference.setTitle(title); + } else { + preference.setSummary(title); + } + } + + @NonNull + private static String getTitle(@NonNull ApplicationInfo applicationInfo, + @NonNull Context context) { + return Utils.getFullAppLabel(applicationInfo, context) + "@" + + UserHandle.getUserHandleForUid(applicationInfo.uid).getIdentifier(); + } +} -- cgit v1.2.3-59-g8ed1b