Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50e4741b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add auto lock preference inside private space settings" into main

parents 4df36e65 099ae329
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1483,4 +1483,18 @@
        <item>2</item>
    </string-array>

    <!-- Entries for private space auto lock option -->
    <string-array name="private_space_auto_lock_options">
        <item>@string/private_space_auto_lock_every_time</item>
        <item>@string/private_space_auto_lock_after_inactivity</item>
        <item>@string/private_space_auto_lock_never</item>
    </string-array>

    <!-- Values for private space auto lock option -->
    <string-array name="private_space_auto_lock_options_values" translatable="false">
        <item>0</item>
        <item>1</item>
        <item>2</item>
    </string-array>

</resources>
+13 −1
Original line number Diff line number Diff line
@@ -1237,10 +1237,22 @@
    <string name="private_space_face_unlock_title">Face Unlock for Private Space</string>
    <!-- Biometric category title - biometric options for unlocking the device. [CHAR LIMIT=50] -->
    <string name="private_space_category_ways_to_unlock">Ways to unlock</string>
    <!-- Summary for one lock when device screen lock is used as private profile lock. [CHAR LIMIT=60] -->
    <!-- Summary for one lock when device screen lock is used as private profile lock. [CHAR LIMIT=40] -->
    <string name="private_space_screen_lock_summary">Same as device screen lock</string>
    <!-- Dialog message to choose a new lock for Private Space. [CHAR LIMIT=50] -->
    <string name="private_space_new_lock_title">Choose a new lock for Private Space?</string>
    <!-- Title for the preference for auto lock private space. [CHAR LIMIT=40] -->
    <string name="private_space_auto_lock_title">Lock automatically</string>
    <!-- Title for private space auto lock settings page. [CHAR LIMIT=50] -->
    <string name="private_space_auto_lock_page_title">Lock private space automatically</string>
    <!-- Description for private space auto lock settings page. [CHAR LIMIT=NONE] -->
    <string name="private_space_auto_lock_page_summary">You can lock your private space automatically if you haven\’t used your device for a period of time</string>
    <!-- Configure auto lock: Value for auto lock configuration to lock private space every time device locks. [CHAR LIMIT=40] -->
    <string name="private_space_auto_lock_every_time">Every time device locks</string>
    <!-- Configure auto lock: Value for auto lock configuration to lock private space after 5 minutes of inactivity. [CHAR LIMIT=40] -->
    <string name="private_space_auto_lock_after_inactivity">After 5 minutes of inactivity</string>
    <!-- Configure auto lock: Value for auto lock configuration to never lock private space. [CHAR LIMIT=20] -->
    <string name="private_space_auto_lock_never">Never</string>
    <!-- Title for the preference to hide Private Space. [CHAR LIMIT=60] -->
    <string name="private_space_hide_title">Hide when locked</string>
    <!-- Title for the hide Private Space setting. [CHAR LIMIT=60] -->
+20 −0
Original line number Diff line number Diff line
<?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.
  -->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:title="@string/private_space_auto_lock_page_title"/>
+7 −0
Original line number Diff line number Diff line
@@ -36,6 +36,13 @@
    <PreferenceCategory
        android:title="@string/security_header">

        <Preference
            android:key="private_space_auto_lock"
            android:title="@string/private_space_auto_lock_title"
            android:fragment="com.android.settings.privatespace.autolock.AutoLockSettingsFragment"
            settings:controller="com.android.settings.privatespace.autolock.AutoLockPreferenceController"
            settings:searchable="false" />

        <Preference
            android:key="private_space_use_one_lock"
            android:title="@string/private_space_lock_title"
+31 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.settings.privatespace;

import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
import static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT;
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK;
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK_NEVER;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;

import android.app.ActivityManager;
@@ -46,7 +48,6 @@ import java.util.List;
/** A class to help with the creation / deletion of Private Space */
public class PrivateSpaceMaintainer {
    private static final String TAG = "PrivateSpaceMaintainer";

    @GuardedBy("this")
    private static PrivateSpaceMaintainer sPrivateSpaceMaintainer;

@@ -59,6 +60,9 @@ public class PrivateSpaceMaintainer {
    /** This is the default value for the hide private space entry point settings. */
    public static final int HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL = 0;
    public static final int HIDE_PRIVATE_SPACE_ENTRY_POINT_ENABLED_VAL = 1;
    /** Default value for private space auto lock settings. */
    @Settings.Secure.PrivateSpaceAutoLockOption
    public static final int PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL = PRIVATE_SPACE_AUTO_LOCK_NEVER;

    public enum ErrorDeletingPrivateSpace {
            DELETE_PS_ERROR_NONE,
@@ -223,6 +227,14 @@ public class PrivateSpaceMaintainer {
        Settings.Secure.putInt(mContext.getContentResolver(), HIDE_PRIVATESPACE_ENTRY_POINT, value);
    }

    /** Sets the setting for private space auto lock option. */
    public void setPrivateSpaceAutoLockSetting(
            @Settings.Secure.PrivateSpaceAutoLockOption int value) {
        if (isPrivateSpaceAutoLockSupported()) {
            Settings.Secure.putInt(mContext.getContentResolver(), PRIVATE_SPACE_AUTO_LOCK, value);
        }
    }

    /** @return the setting to show PS entry point. */
    public int getHidePrivateSpaceEntryPointSetting() {
        return Settings.Secure.getInt(
@@ -231,6 +243,18 @@ public class PrivateSpaceMaintainer {
                HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
    }

    /** @return the setting for PS auto lock option. */
    @Settings.Secure.PrivateSpaceAutoLockOption
    public int getPrivateSpaceAutoLockSetting() {
        if (isPrivateSpaceAutoLockSupported()) {
            return Settings.Secure.getInt(
                    mContext.getContentResolver(),
                    PRIVATE_SPACE_AUTO_LOCK,
                    PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
        }
        return PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL;
    }

    /**
     * Returns true if private space exists and quiet mode is successfully enabled, otherwise
     * returns false
@@ -264,6 +288,7 @@ public class PrivateSpaceMaintainer {

    private void resetPrivateSpaceSettings() {
        setHidePrivateSpaceEntryPointSetting(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
        setPrivateSpaceAutoLockSetting(PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
    }

    /**
@@ -275,4 +300,9 @@ public class PrivateSpaceMaintainer {
        Settings.Secure.putIntForUser(mContext.getContentResolver(), USER_SETUP_COMPLETE,
                1, mUserHandle.getIdentifier());
    }

    private boolean isPrivateSpaceAutoLockSupported() {
        return android.os.Flags.allowPrivateProfile()
                && android.multiuser.Flags.supportAutolockForPrivateSpace();
    }
}
Loading