summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PermissionController/res/drawable-v34/safety_center_brand_chip_background.xml2
-rw-r--r--PermissionController/res/values-v34/dimens.xml4
-rw-r--r--PermissionController/res/values/overlayable.xml3
-rw-r--r--PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java129
-rw-r--r--PermissionController/src/com/android/permissioncontroller/safetycenter/ui/PrivacySubpageFragment.kt22
-rw-r--r--PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java6
-rw-r--r--PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterDashboardFragment.java10
-rw-r--r--PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterFragment.kt4
-rw-r--r--PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterSubpageFragment.kt14
-rw-r--r--tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/PrivacySubpageTest.kt4
-rw-r--r--tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterTestConfigs.kt22
11 files changed, 145 insertions, 75 deletions
diff --git a/PermissionController/res/drawable-v34/safety_center_brand_chip_background.xml b/PermissionController/res/drawable-v34/safety_center_brand_chip_background.xml
index 69cd83cbf..2d216edd8 100644
--- a/PermissionController/res/drawable-v34/safety_center_brand_chip_background.xml
+++ b/PermissionController/res/drawable-v34/safety_center_brand_chip_background.xml
@@ -16,5 +16,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?attr/colorSurface" />
- <corners android:radius="@dimen/safety_center_brand_chip_corner_radius"/>
+ <corners android:radius="@dimen/sc_brand_chip_corner_radius"/>
</shape> \ No newline at end of file
diff --git a/PermissionController/res/values-v34/dimens.xml b/PermissionController/res/values-v34/dimens.xml
index e4571d714..7b3cd9d7c 100644
--- a/PermissionController/res/values-v34/dimens.xml
+++ b/PermissionController/res/values-v34/dimens.xml
@@ -18,5 +18,7 @@
<dimen name="permission_rationale_purpose_list_bullet_radius">1.5dp</dimen>
<dimen name="permission_rationale_purpose_list_bullet_indent">9dp</dimen>
- <dimen name="safety_center_brand_chip_corner_radius">24dp</dimen>
+ <dimen name="sc_action_button_list_margin">@dimen/sc_spacing_xxsmall</dimen>
+ <dimen name="sc_button_corner_radius_small">4dp</dimen>
+ <dimen name="sc_brand_chip_corner_radius">24dp</dimen>
</resources> \ No newline at end of file
diff --git a/PermissionController/res/values/overlayable.xml b/PermissionController/res/values/overlayable.xml
index dc2055e6a..7ee44a210 100644
--- a/PermissionController/res/values/overlayable.xml
+++ b/PermissionController/res/values/overlayable.xml
@@ -387,10 +387,11 @@
<item type="dimen" name="sc_entry_group_collapsed_padding_bottom" />
<item type="dimen" name="sc_card_margin_bottom" />
<item type="dimen" name="sc_button_corner_radius" />
+ <item type="dimen" name="sc_button_corner_radius_small" />
<item type="dimen" name="sc_card_corner_radius_large" />
<item type="dimen" name="sc_card_corner_radius_medium" />
<item type="dimen" name="sc_card_corner_radius_xsmall" />
- <item type="dimen" name="safety_center_brand_chip_corner_radius" />
+ <item type="dimen" name="sc_brand_chip_corner_radius" />
<item type="color" name="safety_center_button_info" />
<item type="color" name="safety_center_button_recommend" />
diff --git a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java
index 134b64d7c..0a15ee4bb 100644
--- a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java
+++ b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/IssueCardPreference.java
@@ -56,6 +56,9 @@ import com.android.safetycenter.internaldata.SafetyCenterIssueId;
import com.android.safetycenter.internaldata.SafetyCenterIssueKey;
import com.google.android.material.button.MaterialButton;
+import com.google.android.material.shape.AbsoluteCornerSize;
+import com.google.android.material.shape.CornerSize;
+import com.google.android.material.shape.ShapeAppearanceModel;
import java.util.Objects;
@@ -156,34 +159,30 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
holder.itemView.setContentDescription(contentDescription);
holder.itemView.setClickable(false);
+ configureButtonList(holder);
+ configureSafetyProtectionView(holder);
+ maybeStartResolutionAnimation(holder);
+
+ mSafetyCenterViewModel
+ .getInteractionLogger()
+ .recordForIssue(Action.SAFETY_ISSUE_VIEWED, mIssue, mIsDismissed);
+ }
+
+ private void configureButtonList(PreferenceViewHolder holder) {
LinearLayout buttonList =
((LinearLayout) holder.findViewById(R.id.issue_card_action_button_list));
buttonList.removeAllViews(); // This view may be recycled from another issue
- boolean isFirstButton = true;
- for (SafetyCenterIssue.Action action : mIssue.getActions()) {
+
+ for (int i = 0; i < mIssue.getActions().size(); i++) {
+ SafetyCenterIssue.Action action = mIssue.getActions().get(i);
ActionButtonBuilder builder =
- new ActionButtonBuilder(action, holder.itemView.getContext());
- builder.isLargeScreen(buttonList instanceof EqualWidthContainer);
- if (isFirstButton) {
- builder.setAsPrimaryButton();
- if (!mIsDismissed) {
- builder.setAsFilledButton();
- }
- isFirstButton = false;
- }
+ new ActionButtonBuilder(action, holder.itemView.getContext())
+ .setIndex(i)
+ .setActionButtonListSize(mIssue.getActions().size())
+ .setIsDismissed(mIsDismissed)
+ .setIsLargeScreen(buttonList instanceof EqualWidthContainer);
builder.buildAndAddToView(buttonList);
-
- if (mResolvedIssueActionId != null && mResolvedIssueActionId.equals(action.getId())) {
- mIssueCardAnimator.transitionToIssueResolvedThenMarkComplete(
- getContext(), holder, action);
- }
}
-
- configureSafetyProtectionView(holder);
-
- mSafetyCenterViewModel
- .getInteractionLogger()
- .recordForIssue(Action.SAFETY_ISSUE_VIEWED, mIssue, mIsDismissed);
}
private void configureSafetyProtectionView(PreferenceViewHolder holder) {
@@ -206,6 +205,19 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
}
}
+ private void maybeStartResolutionAnimation(PreferenceViewHolder holder) {
+ if (mResolvedIssueActionId == null) {
+ return;
+ }
+
+ for (SafetyCenterIssue.Action action : mIssue.getActions()) {
+ if (action.getId().equals(mResolvedIssueActionId)) {
+ mIssueCardAnimator.transitionToIssueResolvedThenMarkComplete(
+ getContext(), holder, action);
+ }
+ }
+ }
+
public int getSeverityLevel() {
return mIssue.getSeverityLevel();
}
@@ -394,8 +406,9 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
private final SafetyCenterIssue.Action mAction;
private final Context mContext;
private final ContextThemeWrapper mContextThemeWrapper;
- private boolean mIsPrimaryButton = false;
- private boolean mIsFilled = false;
+ private int mIndex;
+ private int mActionButtonListSize;
+ private boolean mIsDismissed = false;
private boolean mIsLargeScreen = false;
ActionButtonBuilder(SafetyCenterIssue.Action action, Context context) {
@@ -405,23 +418,43 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
new ContextThemeWrapper(context, R.style.Theme_MaterialComponents_DayNight);
}
- public ActionButtonBuilder setAsPrimaryButton() {
- mIsPrimaryButton = true;
+ public ActionButtonBuilder setIndex(int index) {
+ mIndex = index;
return this;
}
- public ActionButtonBuilder setAsFilledButton() {
- mIsFilled = true;
+ public ActionButtonBuilder setActionButtonListSize(int actionButtonListSize) {
+ mActionButtonListSize = actionButtonListSize;
return this;
}
- public ActionButtonBuilder isLargeScreen(boolean isLargeScreen) {
+ public ActionButtonBuilder setIsDismissed(boolean isDismissed) {
+ mIsDismissed = isDismissed;
+ return this;
+ }
+
+ public ActionButtonBuilder setIsLargeScreen(boolean isLargeScreen) {
mIsLargeScreen = isLargeScreen;
return this;
}
+ private boolean isPrimaryButton() {
+ return mIndex == 0;
+ }
+
+ private boolean isLastButton() {
+ return mIndex == (mActionButtonListSize - 1);
+ }
+
+ private boolean isFilled() {
+ return isPrimaryButton() && !mIsDismissed;
+ }
+
public void buildAndAddToView(LinearLayout buttonList) {
MaterialButton button = new MaterialButton(mContextThemeWrapper, null, getStyle());
+ if (SdkLevel.isAtLeastU()) {
+ configureGroupStyleCorners(button);
+ }
setButtonColors(button);
setButtonLayout(button);
button.setText(mAction.getLabel());
@@ -434,7 +467,7 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
mIssue,
mAction,
mTaskId,
- mIsPrimaryButton,
+ isPrimaryButton(),
mIsDismissed)
.showNow(mDialogFragmentManager, /* tag= */ null);
} else {
@@ -452,7 +485,7 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
mSafetyCenterViewModel
.getInteractionLogger()
.recordForIssue(
- mIsPrimaryButton
+ isPrimaryButton()
? Action.ISSUE_PRIMARY_ACTION_CLICKED
: Action.ISSUE_SECONDARY_ACTION_CLICKED,
mIssue,
@@ -464,8 +497,36 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
buttonList.addView(button);
}
+ /**
+ * Configures "group-style" corners for this button, where the first button in the list has
+ * large corners on top and the last button in the list has large corners on bottom.
+ */
+ @RequiresApi(UPSIDE_DOWN_CAKE)
+ private void configureGroupStyleCorners(MaterialButton button) {
+ button.setCornerRadiusResource(R.dimen.sc_button_corner_radius_small);
+ ShapeAppearanceModel.Builder shapeAppearanceModelBuilder =
+ button.getShapeAppearanceModel().toBuilder();
+
+ CornerSize largeCornerSize =
+ new AbsoluteCornerSize(
+ mContext.getResources()
+ .getDimensionPixelSize(R.dimen.sc_button_corner_radius));
+ if (isPrimaryButton()) {
+ shapeAppearanceModelBuilder
+ .setTopLeftCornerSize(largeCornerSize)
+ .setTopRightCornerSize(largeCornerSize);
+ }
+ if (isLastButton()) {
+ shapeAppearanceModelBuilder
+ .setBottomLeftCornerSize(largeCornerSize)
+ .setBottomRightCornerSize(largeCornerSize);
+ }
+
+ button.setShapeAppearanceModel(shapeAppearanceModelBuilder.build());
+ }
+
private void maybeAddSpaceToView(LinearLayout buttonList) {
- if (mIsPrimaryButton) {
+ if (isPrimaryButton()) {
return;
}
@@ -478,11 +539,11 @@ public class IssueCardPreference extends Preference implements ComparablePrefere
}
private int getStyle() {
- return mIsFilled ? R.attr.scActionButtonStyle : R.attr.scSecondaryActionButtonStyle;
+ return isFilled() ? R.attr.scActionButtonStyle : R.attr.scSecondaryActionButtonStyle;
}
private void setButtonColors(MaterialButton button) {
- if (mIsFilled) {
+ if (isFilled()) {
button.setBackgroundTintList(
ContextCompat.getColorStateList(
mContext,
diff --git a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/PrivacySubpageFragment.kt b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/PrivacySubpageFragment.kt
index 7befb2f7c..82166b1e5 100644
--- a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/PrivacySubpageFragment.kt
+++ b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/PrivacySubpageFragment.kt
@@ -24,9 +24,8 @@ import androidx.annotation.RequiresApi
import androidx.lifecycle.ViewModelProvider
import androidx.preference.Preference
import androidx.preference.PreferenceGroup
-import com.android.permissioncontroller.Constants
+import com.android.permissioncontroller.Constants.EXTRA_SESSION_ID
import com.android.permissioncontroller.R
-import com.android.permissioncontroller.permission.utils.Utils
import com.android.permissioncontroller.safetycenter.SafetyCenterConstants.PRIVACY_SOURCES_GROUP_ID
import com.android.permissioncontroller.safetycenter.ui.SafetyBrandChipPreference.Companion.closeSubpage
import com.android.permissioncontroller.safetycenter.ui.model.PrivacyControlsViewModel
@@ -45,18 +44,16 @@ class PrivacySubpageFragment : SafetyCenterFragment() {
private lateinit var subpageGenericEntryGroup: PreferenceGroup
private lateinit var subpageDataEntryGroup: PreferenceGroup
private lateinit var privacyControlsViewModel: PrivacyControlsViewModel
- private var sessionId = Constants.INVALID_SESSION_ID
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
super.onCreatePreferences(savedInstanceState, rootKey)
setPreferencesFromResource(R.xml.privacy_subpage, rootKey)
- sessionId = Utils.getOrGenerateSessionId(requireActivity().getIntent())
subpageBrandChip = getPreferenceScreen().findPreference(BRAND_CHIP_KEY)!!
subpageIssueGroup = getPreferenceScreen().findPreference(ISSUE_GROUP_KEY)!!
subpageGenericEntryGroup = getPreferenceScreen().findPreference(GENERIC_ENTRY_GROUP_KEY)!!
subpageDataEntryGroup = getPreferenceScreen().findPreference(DATA_ENTRY_GROUP_KEY)!!
- subpageBrandChip.setupListener(requireActivity(), sessionId)
+ subpageBrandChip.setupListener(requireActivity(), safetyCenterSessionId)
val factory = PrivacyControlsViewModelFactory(requireActivity().getApplication())
privacyControlsViewModel =
@@ -71,7 +68,7 @@ class PrivacySubpageFragment : SafetyCenterFragment() {
override fun configureInteractionLogger() {
val logger = safetyCenterViewModel.interactionLogger
- logger.sessionId = sessionId
+ logger.sessionId = safetyCenterSessionId
logger.navigationSource = NavigationSource.fromIntent(requireActivity().getIntent())
logger.viewType = ViewType.SUBPAGE
logger.groupId = PRIVACY_SOURCES_GROUP_ID
@@ -90,7 +87,7 @@ class PrivacySubpageFragment : SafetyCenterFragment() {
TAG,
"$PRIVACY_SOURCES_GROUP_ID doesn't match any of the existing SafetySourcesGroup IDs"
)
- closeSubpage(requireActivity(), requireContext(), sessionId)
+ closeSubpage(requireActivity(), requireContext(), safetyCenterSessionId)
return
}
@@ -197,5 +194,16 @@ class PrivacySubpageFragment : SafetyCenterFragment() {
private const val ISSUE_GROUP_KEY: String = "subpage_issue_group"
private const val GENERIC_ENTRY_GROUP_KEY: String = "subpage_generic_entry_group"
private const val DATA_ENTRY_GROUP_KEY: String = "subpage_data_entry_group"
+
+ /** Creates an instance of PrivacySubpageFragment with the arguments set */
+ @JvmStatic
+ fun newInstance(sessionId: Long): PrivacySubpageFragment {
+ val args = Bundle()
+ args.putLong(EXTRA_SESSION_ID, sessionId)
+
+ val subpageFragment = PrivacySubpageFragment()
+ subpageFragment.setArguments(args)
+ return subpageFragment
+ }
}
}
diff --git a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java
index f9ec852ca..2b92cfe19 100644
--- a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java
+++ b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterActivity.java
@@ -44,6 +44,7 @@ import androidx.fragment.app.Fragment;
import com.android.permissioncontroller.Constants;
import com.android.permissioncontroller.PermissionControllerStatsLog;
import com.android.permissioncontroller.R;
+import com.android.permissioncontroller.permission.utils.Utils;
import com.android.permissioncontroller.safetycenter.ui.model.PrivacyControlsViewModel.Pref;
import com.android.settingslib.activityembedding.ActivityEmbeddingUtils;
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
@@ -203,12 +204,13 @@ public final class SafetyCenterActivity extends CollapsingToolbarBaseActivity {
return openHomepage();
}
+ long sessionId = Utils.getOrGenerateSessionId(getIntent());
if (Objects.equals(groupId, PRIVACY_SOURCES_GROUP_ID)) {
logPrivacySourceMetric();
- return new PrivacySubpageFragment();
+ return PrivacySubpageFragment.newInstance(sessionId);
}
- return SafetyCenterSubpageFragment.newInstance(groupId);
+ return SafetyCenterSubpageFragment.newInstance(sessionId, groupId);
}
@RequiresApi(UPSIDE_DOWN_CAKE)
diff --git a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterDashboardFragment.java b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterDashboardFragment.java
index b59177d43..02b9a46ff 100644
--- a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterDashboardFragment.java
+++ b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterDashboardFragment.java
@@ -44,7 +44,6 @@ import androidx.annotation.RequiresApi;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceGroup;
-import com.android.permissioncontroller.Constants;
import com.android.permissioncontroller.R;
import com.android.permissioncontroller.safetycenter.ui.model.SafetyCenterUiData;
import com.android.permissioncontroller.safetycenter.ui.model.StatusUiData;
@@ -73,7 +72,6 @@ public final class SafetyCenterDashboardFragment extends SafetyCenterFragment {
private PreferenceGroup mEntriesGroup;
private PreferenceGroup mStaticEntriesGroup;
private boolean mIsQuickSettingsFragment;
- private long mSessionId = Constants.INVALID_SESSION_ID;
public SafetyCenterDashboardFragment() {}
@@ -100,9 +98,6 @@ public final class SafetyCenterDashboardFragment extends SafetyCenterFragment {
setPreferencesFromResource(R.xml.safety_center_dashboard, rootKey);
if (getArguments() != null) {
- mSessionId =
- getArguments()
- .getLong(Constants.EXTRA_SESSION_ID, Constants.INVALID_SESSION_ID);
mIsQuickSettingsFragment =
getArguments().getBoolean(QUICK_SETTINGS_SAFETY_CENTER_FRAGMENT, false);
}
@@ -146,7 +141,7 @@ public final class SafetyCenterDashboardFragment extends SafetyCenterFragment {
@Override
public void configureInteractionLogger() {
InteractionLogger logger = getSafetyCenterViewModel().getInteractionLogger();
- logger.setSessionId(mSessionId);
+ logger.setSessionId(getSafetyCenterSessionId());
logger.setViewType(mIsQuickSettingsFragment ? ViewType.QUICK_SETTINGS : ViewType.FULL);
Intent intent = requireActivity().getIntent();
@@ -227,7 +222,8 @@ public final class SafetyCenterDashboardFragment extends SafetyCenterFragment {
if (SafetyCenterUiFlags.getShowSubpages() && group != null) {
mEntriesGroup.addPreference(
- new SafetyHomepageEntryPreference(context, group, mSessionId));
+ new SafetyHomepageEntryPreference(
+ context, group, getSafetyCenterSessionId()));
} else if (entry != null) {
addTopLevelEntry(context, entry, isFirstElement, isLastElement);
} else if (group != null) {
diff --git a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterFragment.kt b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterFragment.kt
index 358c790cd..9ff8bee1a 100644
--- a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterFragment.kt
+++ b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterFragment.kt
@@ -25,6 +25,8 @@ import androidx.lifecycle.ViewModelProvider
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceScreen
import androidx.recyclerview.widget.RecyclerView
+import com.android.permissioncontroller.Constants.EXTRA_SESSION_ID
+import com.android.permissioncontroller.Constants.INVALID_SESSION_ID
import com.android.permissioncontroller.safetycenter.SafetyCenterConstants.QUICK_SETTINGS_SAFETY_CENTER_FRAGMENT
import com.android.permissioncontroller.safetycenter.ui.ParsedSafetyCenterIntent.Companion.toSafetyCenterIntent
import com.android.permissioncontroller.safetycenter.ui.model.LiveSafetyCenterViewModelFactory
@@ -39,6 +41,7 @@ abstract class SafetyCenterFragment : PreferenceFragmentCompat() {
lateinit var safetyCenterViewModel: SafetyCenterViewModel
lateinit var sameTaskSourceIds: List<String>
lateinit var collapsableIssuesCardHelper: CollapsableIssuesCardHelper
+ var safetyCenterSessionId = INVALID_SESSION_ID
private val highlightManager = PreferenceHighlightManager(this)
override fun onCreate(savedInstanceState: Bundle?) {
@@ -72,6 +75,7 @@ abstract class SafetyCenterFragment : PreferenceFragmentCompat() {
SafetyCenterResourcesContext(requireContext())
.getStringByName("config_same_task_safety_source_ids")
.split(",")
+ safetyCenterSessionId = requireArguments().getLong(EXTRA_SESSION_ID, INVALID_SESSION_ID)
safetyCenterViewModel =
ViewModelProvider(
diff --git a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterSubpageFragment.kt b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterSubpageFragment.kt
index 6e13b6d29..8625e1959 100644
--- a/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterSubpageFragment.kt
+++ b/PermissionController/src/com/android/permissioncontroller/safetycenter/ui/SafetyCenterSubpageFragment.kt
@@ -22,9 +22,8 @@ import android.safetycenter.SafetyCenterEntryGroup
import android.util.Log
import androidx.annotation.RequiresApi
import androidx.preference.PreferenceGroup
-import com.android.permissioncontroller.Constants
+import com.android.permissioncontroller.Constants.EXTRA_SESSION_ID
import com.android.permissioncontroller.R
-import com.android.permissioncontroller.permission.utils.Utils
import com.android.permissioncontroller.safetycenter.ui.SafetyBrandChipPreference.Companion.closeSubpage
import com.android.permissioncontroller.safetycenter.ui.model.SafetyCenterUiData
import com.android.safetycenter.resources.SafetyCenterResourcesContext
@@ -40,13 +39,11 @@ class SafetyCenterSubpageFragment : SafetyCenterFragment() {
private lateinit var subpageIssueGroup: PreferenceGroup
private lateinit var subpageEntryGroup: PreferenceGroup
private lateinit var subpageFooter: FooterPreference
- private var sessionId = Constants.INVALID_SESSION_ID
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
super.onCreatePreferences(savedInstanceState, rootKey)
setPreferencesFromResource(R.xml.safety_center_subpage, rootKey)
sourceGroupId = requireArguments().getString(SOURCE_GROUP_ID_KEY)!!
- sessionId = Utils.getOrGenerateSessionId(requireActivity().getIntent())
subpageBrandChip = getPreferenceScreen().findPreference(BRAND_CHIP_KEY)!!
subpageIllustration = getPreferenceScreen().findPreference(ILLUSTRATION_KEY)!!
@@ -54,7 +51,7 @@ class SafetyCenterSubpageFragment : SafetyCenterFragment() {
subpageEntryGroup = getPreferenceScreen().findPreference(ENTRY_GROUP_KEY)!!
subpageFooter = getPreferenceScreen().findPreference(FOOTER_KEY)!!
- subpageBrandChip.setupListener(requireActivity(), sessionId)
+ subpageBrandChip.setupListener(requireActivity(), safetyCenterSessionId)
setupIllustration()
setupFooter()
@@ -63,7 +60,7 @@ class SafetyCenterSubpageFragment : SafetyCenterFragment() {
override fun configureInteractionLogger() {
val logger = safetyCenterViewModel.interactionLogger
- logger.sessionId = sessionId
+ logger.sessionId = safetyCenterSessionId
logger.navigationSource = NavigationSource.fromIntent(requireActivity().getIntent())
logger.viewType = ViewType.SUBPAGE
logger.groupId = sourceGroupId
@@ -79,7 +76,7 @@ class SafetyCenterSubpageFragment : SafetyCenterFragment() {
val entryGroup = uiData?.getMatchingGroup(sourceGroupId)
if (entryGroup == null) {
Log.w(TAG, "$sourceGroupId doesn't match any of the existing SafetySourcesGroup IDs")
- closeSubpage(requireActivity(), requireContext(), sessionId)
+ closeSubpage(requireActivity(), requireContext(), safetyCenterSessionId)
return
}
@@ -167,8 +164,9 @@ class SafetyCenterSubpageFragment : SafetyCenterFragment() {
/** Creates an instance of SafetyCenterSubpageFragment with the arguments set */
@JvmStatic
- fun newInstance(groupId: String): SafetyCenterSubpageFragment {
+ fun newInstance(sessionId: Long, groupId: String): SafetyCenterSubpageFragment {
val args = Bundle()
+ args.putLong(EXTRA_SESSION_ID, sessionId)
args.putString(SOURCE_GROUP_ID_KEY, groupId)
val subpageFragment = SafetyCenterSubpageFragment()
diff --git a/tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/PrivacySubpageTest.kt b/tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/PrivacySubpageTest.kt
index 7196567e0..da1c859e5 100644
--- a/tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/PrivacySubpageTest.kt
+++ b/tests/functional/safetycenter/singleuser/src/android/safetycenter/functional/ui/PrivacySubpageTest.kt
@@ -34,7 +34,7 @@ import com.android.safetycenter.testing.SafetyCenterFlags
import com.android.safetycenter.testing.SafetyCenterFlags.deviceSupportsSafetyCenter
import com.android.safetycenter.testing.SafetyCenterTestConfigs
import com.android.safetycenter.testing.SafetyCenterTestConfigs.Companion.PRIVACY_SOURCE_ID_1
-import com.android.safetycenter.testing.SafetyCenterTestConfigs.Companion.PRIVACY_SOURCE_ID_2
+import com.android.safetycenter.testing.SafetyCenterTestConfigs.Companion.SOURCE_ID_1
import com.android.safetycenter.testing.SafetyCenterTestHelper
import com.android.safetycenter.testing.SafetySourceTestData
import com.android.safetycenter.testing.UiTestHelper.MORE_ISSUES_LABEL
@@ -162,7 +162,7 @@ class PrivacySubpageTest {
val firstSourceData = safetySourceTestData.criticalWithIssueWithAttributionTitle
val secondSourceData = safetySourceTestData.informationWithIssueWithAttributionTitle
safetyCenterTestHelper.setData(PRIVACY_SOURCE_ID_1, firstSourceData)
- safetyCenterTestHelper.setData(PRIVACY_SOURCE_ID_2, secondSourceData)
+ safetyCenterTestHelper.setData(SOURCE_ID_1, secondSourceData)
val extras = Bundle()
extras.putString(EXTRA_SAFETY_SOURCES_GROUP_ID, config.safetySourcesGroups.first().id)
diff --git a/tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterTestConfigs.kt b/tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterTestConfigs.kt
index 4d3a7f0fe..de4cf7094 100644
--- a/tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterTestConfigs.kt
+++ b/tests/utils/safetycenter/java/com/android/safetycenter/testing/SafetyCenterTestConfigs.kt
@@ -262,8 +262,8 @@ class SafetyCenterTestConfigs(private val context: Context) {
/**
* A simple [SafetyCenterConfig] for testing the Privacy subpage. Note that this config contains
- * the [PRIVACY_SOURCE_ID_1] and [PRIVACY_SOURCE_ID_2] sources that are part of the generic
- * category, and the [SOURCE_ID_1] that is part of the data category.
+ * the [PRIVACY_SOURCE_ID_1] source that is part of the generic category, and the [SOURCE_ID_1]
+ * that is part of the data category.
*/
val privacySubpageConfig: SafetyCenterConfig
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
@@ -272,7 +272,6 @@ class SafetyCenterTestConfigs(private val context: Context) {
.addSafetySourcesGroup(
safetySourcesGroupBuilder(ANDROID_PRIVACY_SOURCES_GROUP_ID)
.addSafetySource(dynamicSafetySource(PRIVACY_SOURCE_ID_1))
- .addSafetySource(dynamicSafetySource(PRIVACY_SOURCE_ID_2))
.addSafetySource(dynamicSafetySource(SOURCE_ID_1))
.build()
)
@@ -280,8 +279,8 @@ class SafetyCenterTestConfigs(private val context: Context) {
/**
* A simple [SafetyCenterConfig] without data sources for testing the Privacy subpage. Note that
- * this config contains only [PRIVACY_SOURCE_ID_1] and [PRIVACY_SOURCE_ID_2] sources that are
- * part of the generic category. Hence it doesn't have any data category sources.
+ * this config contains only [PRIVACY_SOURCE_ID_1] source that is part of the generic category.
+ * Hence it doesn't have any data category sources.
*/
val privacySubpageWithoutDataSourcesConfig: SafetyCenterConfig
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
@@ -290,7 +289,6 @@ class SafetyCenterTestConfigs(private val context: Context) {
.addSafetySourcesGroup(
safetySourcesGroupBuilder(ANDROID_PRIVACY_SOURCES_GROUP_ID)
.addSafetySource(dynamicSafetySource(PRIVACY_SOURCE_ID_1))
- .addSafetySource(dynamicSafetySource(PRIVACY_SOURCE_ID_2))
.build()
)
.build()
@@ -855,12 +853,12 @@ class SafetyCenterTestConfigs(private val context: Context) {
/** ID of a source provided by [summaryTestConfig]. */
const val SOURCE_ID_7 = "test_source_id_7"
- /** ID of a source provided by [privacySubpageConfig]. */
+ /**
+ * ID of a source provided by [privacySubpageConfig] and
+ * [privacySubpageWithoutDataSourcesConfig].
+ */
const val PRIVACY_SOURCE_ID_1 = "AndroidPermissionUsage"
- /** ID of a source provided by [privacySubpageConfig]. */
- const val PRIVACY_SOURCE_ID_2 = "AndroidPrivacyAppDataSharingUpdates"
-
/**
* ID of a [SafetySourcesGroup] provided by [multipleSourcesConfig], containing two sources
* of ids [SOURCE_ID_1] and [SOURCE_ID_2].
@@ -1031,8 +1029,8 @@ class SafetyCenterTestConfigs(private val context: Context) {
const val ANDROID_LOCK_SCREEN_SOURCES_GROUP_ID = "AndroidLockScreenSources"
/**
- * ID of a [SafetySourcesGroup] provided by [privacySubpageConfig], to replicate the privacy
- * sources group.
+ * ID of a [SafetySourcesGroup] provided by [privacySubpageConfig] and
+ * [privacySubpageWithoutDataSourcesConfig], to replicate the privacy sources group.
*/
const val ANDROID_PRIVACY_SOURCES_GROUP_ID = "AndroidPrivacySources"
}