Start private space setup when there is no private space set

This change handles as below based on if private space already exists on device:
1. If PS doesn't exist then start the setup flow which shows a PS education screen. On setup button creates the private space.
2. If PS already exists on device then display PS settings page.

Bug: 299069146
Test: atest PrivateSpaceSettingsAuthenticatorTest
Change-Id: I46bdbaeb0210fd5b41a426f852e3f455b62c1c29
This commit is contained in:
josephpv
2023-10-05 21:42:43 +00:00
committed by Joseph Vincent
parent 1ef91389e2
commit ee5e1ceb03
14 changed files with 578 additions and 15 deletions

View File

@@ -4991,6 +4991,11 @@
</intent-filter>
</provider>
<activity
android:name=".privatespace.PrivateSpaceSetupActivity"
android:theme="@style/GlifV3Theme.Light"
android:exported="false" />
<activity android:name=".privatespace.PrivateSpaceAuthenticationActivity"
android:theme="@*android:style/Theme.DeviceDefault.Settings.Dialog.NoActionBar"
android:exported="false"/>

View File

@@ -0,0 +1,27 @@
<!--
~ Copyright (C) 2023 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M420,600L540,600L517,471Q537,461 548.5,442Q560,423 560,400Q560,367 536.5,343.5Q513,320 480,320Q447,320 423.5,343.5Q400,367 400,400Q400,423 411.5,442Q423,461 443,471L420,600ZM480,880Q341,845 250.5,720.5Q160,596 160,444L160,200L480,80L800,200L800,444Q800,596 709.5,720.5Q619,845 480,880ZM480,796Q584,763 652,664Q720,565 720,444L720,255L480,165L240,255L240,444Q240,565 308,664Q376,763 480,796ZM480,480Q480,480 480,480Q480,480 480,480L480,480L480,480L480,480L480,480Q480,480 480,480Q480,480 480,480Z"/>
</vector>

View File

@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="364dp"
android:height="265dp"
android:viewportWidth="364"
android:viewportHeight="265">
<group>
<clip-path
android:pathData="M0,0h364v265h-364z"/>
<path
android:pathData="M339.42,265H24.58C11.07,265 0,253.67 0,239.84V25.19C0,11.33 11.07,0 24.58,0H339.52C352.93,0 364,11.33 364,25.16V239.94C364,253.67 352.93,265 339.42,265Z"
android:fillColor="#000000"/>
<path
android:pathData="M247.65,93.87V85.83C247.65,84.73 246.73,83.82 245.61,83.82V41.94C245.61,36.42 241.02,32 235.5,32H142.1C136.49,32 132,36.52 132,41.94V233.67C132,239.2 136.59,243.62 142.1,243.62H235.5C241.12,243.62 245.61,239.1 245.61,233.67V135.85C246.73,135.85 247.65,134.95 247.65,133.84V113.86C247.65,112.75 246.73,111.85 245.61,111.85V95.88C246.84,95.88 247.65,94.97 247.65,93.87ZM243.67,233.67C243.67,238.09 240,241.71 235.5,241.71H142.1C137.61,241.71 133.94,238.09 133.94,233.67V41.94C133.94,37.52 137.61,33.91 142.1,33.91H235.5C240,33.91 243.67,37.52 243.67,41.94V233.67Z"
android:fillColor="#DADCE0"/>
<path
android:pathData="M151.68,46.76L225.5,46.76A7.38,7.38 0,0 1,232.89 54.15L232.89,54.15A7.38,7.38 0,0 1,225.5 61.53L151.68,61.53A7.38,7.38 0,0 1,144.3 54.15L144.3,54.15A7.38,7.38 0,0 1,151.68 46.76z"
android:fillColor="#444746"/>
<path
android:pathData="M147.42,187.02L228.54,187.02A8.04,8.04 0,0 1,236.58 195.06L236.58,226.97A8.04,8.04 0,0 1,228.54 235L147.42,235A8.04,8.04 0,0 1,139.38 226.97L139.38,195.06A8.04,8.04 0,0 1,147.42 187.02z"
android:fillColor="#1F1F1F"/>
<path
android:pathData="M154.15,77.52m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M177.52,77.52m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M200.9,77.52m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M224.27,77.52m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M154.15,99.67m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M154.15,121.81m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M154.15,143.96m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M154.15,166.11m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M177.52,99.67m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M177.52,121.81m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M177.52,143.96m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M177.52,166.11m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M200.9,99.67m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M200.9,121.81m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M200.9,143.96m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M200.9,166.11m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M224.27,99.67m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M224.27,121.81m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M224.27,143.96m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M224.27,166.11m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#D9D9D9"
android:fillAlpha="0.4"/>
<path
android:pathData="M154.15,199.32m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#0B57D0"/>
<path
android:pathData="M154.15,220.24m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#0B57D0"/>
<path
android:pathData="M177.52,199.32m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#0B57D0"/>
<path
android:pathData="M177.52,220.24m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#0B57D0"/>
<path
android:pathData="M200.9,199.32m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#0B57D0"/>
<path
android:pathData="M200.9,220.24m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#0B57D0"/>
<path
android:pathData="M224.27,199.32m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#0B57D0"/>
<path
android:pathData="M224.27,220.24m-7.38,0a7.38,7.38 0,1 1,14.76 0a7.38,7.38 0,1 1,-14.76 0"
android:fillColor="#0B57D0"/>
</group>
</vector>

View File

@@ -0,0 +1,101 @@
<!--
~ Copyright (C) 2023 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.
-->
<com.google.android.setupdesign.GlifLayout
xmlns:aapt="http://schemas.android.com/aapt"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ps_education_screen"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:sucHeaderText="@string/privatespace_setup_title"
app:sudDescriptionText="@string/privatespace_hide_apps_summary"
android:icon="@drawable/ic_privatespace_icon">
<ScrollView
android:id="@+id/main_clear_scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/sud_layout_icon_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/placeholder_image"
style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_height="wrap_content"
android:src="@drawable/privatespace_placeholder_image"/>
<TextView
style="@style/PrivateSpaceSetupSubHeaderStyle"
android:text="@string/privatespace_how_title"/>
<RelativeLayout
style="@style/PrivateSpaceSetupBulletPointLayoutStyle"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/appsIcon"
style="@style/PrivateSpaceBulletPointIconStyle"
android:src="@drawable/ic_apps" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
android:layout_toRightOf="@+id/appsIcon"
android:text="@string/privatespace_access_bottom_text"/>
</RelativeLayout>
<RelativeLayout
style="@style/PrivateSpaceSetupBulletPointLayoutStyle">
<ImageView
android:id="@+id/lockIcon"
style="@style/PrivateSpaceBulletPointIconStyle"
android:src="@drawable/ic_lock_closed" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
android:layout_toRightOf="@+id/lockIcon"
android:text="@string/privatespace_protected_lock_text"/>
</RelativeLayout>
<RelativeLayout
style="@style/PrivateSpaceSetupBulletPointLayoutStyle">
<ImageView
android:id="@+id/bellIcon"
style="@style/PrivateSpaceBulletPointIconStyle"
android:src="@drawable/ic_notifications" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
android:layout_toRightOf="@+id/bellIcon"
android:text="@string/privatespace_hidden_notifications_text"/>
</RelativeLayout>
<Space
android:layout_width="wrap_content"
android:layout_height="16dp"/>
<RelativeLayout
style="@style/PrivateSpaceSetupBulletPointLayoutStyle">
<ImageView
android:id="@+id/infoIcon"
style="@style/PrivateSpaceBulletPointIconStyle"
android:layout_width="18dp"
android:layout_height="18dp"
android:src="@drawable/ic_info_outline_24dp" />
<TextView
style="@style/PrivateSpaceBulletPointTextFontStyle"
android:textSize = "14sp"
android:layout_toRightOf="@+id/infoIcon"
android:text="@string/privatespace_apps_permission_text"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</com.google.android.setupdesign.GlifLayout>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MergeRootFrame">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/ps_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true" />
</FrameLayout>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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.
-->
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/privatespace_main_context_nav"
app:startDestination="@id/ps_education_fragment">
<fragment android:id="@+id/ps_education_fragment"
android:name="com.android.settings.privatespace.PrivateSpaceEducation"
android:label="fragment_ps_education"/>
</navigation>

View File

@@ -1239,6 +1239,24 @@
<string name="no_device_lock_action_label">Set screen lock</string>
<!-- Action label to cancel Alert dialog when no screen lock is set [CHAR LIMIT=30] -->
<string name="no_device_lock_cancel">Cancel</string>
<!-- Action label to cancel Private Space Setup flow [CHAR LIMIT=50] -->
<string name="privatespace_cancel_label">Cancel</string>
<!-- Label for Private Space setup button to create Private Space [CHAR LIMIT=50] -->
<string name="privatespace_setup_button_label">Set up</string>
<!-- Title for Private Space setup education screen. [CHAR LIMIT=60] -->
<string name="privatespace_setup_title">Set up Private Space</string>
<!-- Summary for the Private Space setup education screen. [CHAR LIMIT=NONE] -->
<string name="privatespace_hide_apps_summary">Hide private apps in a secure space that only you can access</string>
<!-- Text shown in Private Space setup screen which explains how the Private Space works [CHAR LIMIT=NONE] -->
<string name="privatespace_how_title">How it works</string>
<!-- Text shown in Private Space setup screen which explains Private Space can be accessed from bottom of all apps list. [CHAR LIMIT=NONE] -->
<string name="privatespace_access_bottom_text">You can access Private Space from the bottom of your apps list</string>
<!-- Text shown in Private Space setup screen which explains Private Space apps are protected by a lock. [CHAR LIMIT=NONE] -->
<string name="privatespace_protected_lock_text">Apps in Private Space are protected by a lock</string>
<!-- Text shown in Private Space setup screen which explains notifications from Private Space apps will not be shown when Private Space is locked. [CHAR LIMIT=NONE] -->
<string name="privatespace_hidden_notifications_text">Notifications from apps in Private Space are hidden when it\'s locked</string>
<!-- Text shown in Private Space setup screen which explains that the permissions granted to Private Space apps will not be shown in settings when Private Space is locked. [CHAR LIMIT=NONE] -->
<string name="privatespace_apps_permission_text">Private Space apps won\'t appear in permission manager, privacy dashboard, and other settings when Private Space is locked</string>
<!-- Text shown when "Add fingerprint" button is disabled -->
<string name="fingerprint_add_max">You can add up to <xliff:g id="count" example="5">%d</xliff:g> fingerprints</string>

View File

@@ -944,4 +944,40 @@
<item name="android:fontFamily">google-sans-text</item>
</style>
<style name="PrivateSpaceSetupTextFontStyle">
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:fontFamily">google-sans-text</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="PrivateSpaceSetupSubHeaderStyle" parent="@style/PrivateSpaceSetupTextFontStyle">
<item name="android:paddingLeft">24dp</item>
<item name="android:paddingRight">24dp</item>
<item name="android:paddingTop">20dp</item>
<item name="android:paddingBottom">8dp</item>
<item name="android:textSize">14sp</item>
</style>
<style name="PrivateSpaceSetupBulletPointLayoutStyle">
<item name="android:paddingLeft">24dp</item>
<item name="android:paddingRight">24dp</item>
<item name="android:paddingTop">16dp</item>
<item name="android:paddingBottom">16dp</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="PrivateSpaceBulletPointTextFontStyle" parent="@style/PrivateSpaceSetupTextFontStyle">
<item name="android:paddingLeft">16dp</item>
<item name="android:textSize">16sp</item>
</style>
<style name="PrivateSpaceBulletPointIconStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:layout_alignParentTop">true</item>
</style>
</resources>

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2023 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.
-->
<ItemGroup
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Item
android:enabled="false"
android:icon="@drawable/ic_apps"
android:title="@string/privatespace_access_bottom_text"
app:sudIconTint="?android:attr/textColorSecondary"/>
<Item
android:enabled="false"
android:icon="@drawable/ic_lock_24dp"
android:title="@string/privatespace_protected_lock_text"
app:sudIconTint="?android:attr/textColorSecondary"/>
<Item
android:enabled="false"
android:icon="@drawable/ic_notifications"
android:title="@string/privatespace_hidden_notifications_text"
app:sudIconTint="?android:attr/textColorSecondary"/>
</ItemGroup>

View File

@@ -92,20 +92,24 @@ public class PrivateSpaceAuthenticationActivity extends FragmentActivity {
}
}
/** Show private space settings page on device lock authentications */
/** Starts private space setup flow or the PS settings page on device lock authentication */
@VisibleForTesting
public void onLockAuthentication(Context context) {
new SubSettingLauncher(context)
.setDestination(PrivateSpaceDashboardFragment.class.getName())
.setTransitionType(
SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
.setSourceMetricsCategory(SettingsEnums.PRIVATE_SPACE_SETTINGS)
.launch();
if (mPrivateSpaceMaintainer.doesPrivateSpaceExist()) {
new SubSettingLauncher(context)
.setDestination(PrivateSpaceDashboardFragment.class.getName())
.setTransitionType(
SettingsTransitionHelper.TransitionType.TRANSITION_SLIDE)
.setSourceMetricsCategory(SettingsEnums.PRIVATE_SPACE_SETTINGS)
.launch();
} else {
startActivity(new Intent(context, PrivateSpaceSetupActivity.class));
}
}
@VisibleForTesting
public void setPrivateSpaceMaintainer(Injector injector) {
mPrivateSpaceMaintainer = injector.injectPrivateSpaceMaintainer(getApplicationContext());
mPrivateSpaceMaintainer = injector.injectPrivateSpaceMaintainer(this);
}
private void promptToSetDeviceLock() {

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2023 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.settings.privatespace;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.android.settings.R;
import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupcompat.template.FooterButton;
import com.google.android.setupdesign.GlifLayout;
/** Fragment educating about the usage of Private Space. */
public class PrivateSpaceEducation extends Fragment {
@Override
public View onCreateView(
LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
GlifLayout rootView =
(GlifLayout)
inflater.inflate(R.layout.privatespace_education_screen, container, false);
final FooterBarMixin mixin = rootView.getMixin(FooterBarMixin.class);
mixin.setPrimaryButton(
new FooterButton.Builder(getContext())
.setText(R.string.privatespace_setup_button_label)
.setListener(onSetup())
.setButtonType(FooterButton.ButtonType.NEXT)
.setTheme(com.google.android.setupdesign.R.style.SudGlifButton_Primary)
.build());
mixin.getPrimaryButtonView().setFilterTouchesWhenObscured(true);
mixin.setSecondaryButton(
new FooterButton.Builder(getContext())
.setText(R.string.privatespace_cancel_label)
.setListener(onCancel())
.setButtonType(FooterButton.ButtonType.CANCEL)
.setTheme(
com.google.android.setupdesign.R.style
.Base_TextAppearance_AppCompat_Widget_Button)
.build());
mixin.getSecondaryButtonView().setFilterTouchesWhenObscured(true);
return rootView;
}
private View.OnClickListener onSetup() {
return v -> {
if (PrivateSpaceMaintainer.getInstance(getContext()).createPrivateSpace()) {
finishActivity();
}
};
}
private View.OnClickListener onCancel() {
return v -> {
finishActivity();
};
}
private void finishActivity() {
Activity activity = getActivity();
if (activity != null) {
activity.finish();
}
}
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2023 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.settings.privatespace;
import android.os.Bundle;
import androidx.fragment.app.FragmentActivity;
import androidx.navigation.fragment.NavHostFragment;
import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.google.android.setupdesign.util.ThemeHelper;
public class PrivateSpaceSetupActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
ThemeHelper.trySetDynamicColor(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.privatespace_setup_root);
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager()
.findFragmentById(R.id.ps_nav_host_fragment);
navHostFragment.getNavController().setGraph(R.navigation.privatespace_main_context_nav);
}
}

View File

@@ -16,14 +16,13 @@
package com.android.settings.privatespace;
import static com.android.settings.privatespace.PrivateSpaceSafetySource.SAFETY_SOURCE_ID;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
@@ -86,13 +85,17 @@ public class PrivateSpaceAuthenticationActivityTest {
mPrivateSpaceAuthenticationActivity.setPrivateSpaceMaintainer(injector);
}
/** Tests that on lock authentication Private space settings is launched. */
/** Tests that when Private does not exist setup flow is started. */
//TODO(b/307729746) Plan to add more tests for complete setup flow
@Test
@RequiresFlagsEnabled(Flags.FLAG_ALLOW_PRIVATE_PROFILE)
public void deviceSecurePrivateSpaceExists() {
public void whenPrivateProfileDoesNotExist_triggersSetupFlow() {
when(mPrivateSpaceMaintainer.doesPrivateSpaceExist()).thenReturn(false);
final ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
mPrivateSpaceAuthenticationActivity.onLockAuthentication(mContext);
verify(mPrivateSpaceAuthenticationActivity).startActivity(intentCaptor.capture());
assertThat(intentCaptor.getValue().getIdentifier()).isEqualTo(SAFETY_SOURCE_ID);
assertThat(intentCaptor.getValue().getComponent().getClassName())
.isEqualTo(PrivateSpaceSetupActivity.class.getName());
}
}

View File

@@ -138,7 +138,9 @@ public class PrivateSpaceSafetySourceTest {
any(), eq(SAFETY_SOURCE_ID), captor.capture(), eq(EVENT_TYPE_DEVICE_REBOOTED));
SafetySourceData safetySourceData = captor.getValue();
SafetySourceStatus safetySourceStatus = safetySourceData.getStatus();
assertThat(safetySourceStatus.getPendingIntent().getIntent()
.equals(PrivateSpaceAuthenticationActivity.class));
assertThat(safetySourceStatus.getPendingIntent().getIntent().getComponent().getClassName())
.isEqualTo(PrivateSpaceAuthenticationActivity.class.getName());
assertThat(safetySourceStatus.getPendingIntent().getIntent().getIdentifier())
.isEqualTo(SAFETY_SOURCE_ID);
}
}