Use canAddPrivateProfile() to enable PS delete from Reset

This change adds canAddPrivateProfile() check to enable/disable
Private space delete controller in Reset options.

Matches the availability to delete private space from reset
options with the conditions used to show the private space entry point.

In Settings Reset options preference to delete private space will be
shown only when private space creation is allowed on the device or if
private space already exists on the device.

Bug: 330396315
Test: ResetOptionsDeletePrivateSpaceControllerTest
Change-Id: I63232556f7927aeb07b73e8732bbb8b1d2423456
This commit is contained in:
josephpv
2024-04-02 12:38:19 +00:00
committed by Joseph Vincent
parent bc48abe0bd
commit 4e32375f3d
5 changed files with 90 additions and 7 deletions

View File

@@ -59,10 +59,9 @@ public class ResetOptionsDeletePrivateSpaceController extends BasePreferenceCont
@Override
public int getAvailabilityStatus() {
// TODO(b/330396315) : use canAddPrivateProfile() to check if private space is supported
// on the device
return android.multiuser.Flags.enablePrivateSpaceFeatures()
&& android.multiuser.Flags.deletePrivateSpaceFromReset()
&& isPrivateSpaceEntryPointEnabled()
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@@ -107,6 +106,11 @@ public class ResetOptionsDeletePrivateSpaceController extends BasePreferenceCont
return mHostFragment.getFragmentManager();
}
@VisibleForTesting
boolean isPrivateSpaceEntryPointEnabled() {
return PrivateSpaceMaintainer.getInstance(mContext).isPrivateSpaceEntryPointEnabled();
}
/* Dialog shown when deleting private space from Reset Options. */
public static class DeletePrivateSpaceDialogFragment extends InstrumentedDialogFragment {
private static final String TAG = "PrivateSpaceResetFrag";