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

Commit 2770170e authored by Saumya Pathak's avatar Saumya Pathak Committed by Android (Google) Code Review
Browse files

Merge "Show a separate tab for the Private Space" into main

parents 589c129f 6efc455f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6184,6 +6184,8 @@
    <string name="account_settings_menu_auto_sync_personal">Auto-sync personal data</string>
    <!--  Title for menu option to enable global auto-sync of work account data [CHAR LIMIT=30] -->
    <string name="account_settings_menu_auto_sync_work">Auto-sync work data</string>
    <!--  Title for menu option to enable global auto-sync of private account data [CHAR LIMIT=30] -->
    <string name="account_settings_menu_auto_sync_private">Auto-sync private data</string>
    <!-- Title for option to change data usage cycle day. [CHAR LIMIT=32] -->
    <string name="data_usage_change_cycle">Change cycle\u2026</string>
+66 −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"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="user_and_account_settings_screen"
    android:title="@string/account_dashboard_title"
    settings:keywords="@string/keywords_accounts">

    <PreferenceCategory
        android:key="passwords_category"
        android:order="10"
        android:persistent="false"
        android:title="@string/autofill_passwords"
        settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
        settings:keywords="@string/autofill_keywords" />

    <PreferenceCategory
        android:key="default_service_category"
        android:order="20"
        android:title="@string/autofill_app">

        <com.android.settings.widget.GearPreference
            android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
            android:key="default_autofill_private"
            android:title="@string/autofill_app"
            settings:keywords="@string/autofill_keywords">
            <extra
                android:name="for_work"
                android:value="false" />
        </com.android.settings.widget.GearPreference>
    </PreferenceCategory>

    <PreferenceCategory
        android:key="dashboard_tile_placeholder"
        android:order="130"/>

    <SwitchPreference
        android:key="auto_sync_account_data"
        android:title="@string/auto_sync_account_title"
        android:summary="@string/auto_sync_account_summary"
        android:order="200"
        settings:allowDividerAbove="true"/>

    <SwitchPreference
        android:key="auto_sync_private_account_data"
        android:title="@string/account_settings_menu_auto_sync_private"
        android:summary="@string/auto_sync_account_summary"
        android:order="210"/>

</PreferenceScreen>
+67 −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"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:key="user_and_account_settings_screen"
    android:title="@string/account_dashboard_title"
    settings:keywords="@string/keywords_accounts">

    <PreferenceCategory
        android:key="default_service_category"
        android:order="10"
        android:title="@string/credman_chosen_app_title">

        <com.android.settings.widget.GearPreference
            android:fragment="com.android.settings.applications.credentials.DefaultCombinedPickerPrivate"
            android:key="default_credman_autofill_private"
            android:title="@string/credman_chosen_app_title"
            settings:searchable="false">
            settings:keywords="@string/credman_autofill_keywords">
            <extra
                android:name="for_work"
                android:value="false" />
        </com.android.settings.widget.GearPreference>
    </PreferenceCategory>

    <PreferenceCategory
        android:key="credman_category"
        android:order="20"
        android:persistent="false"
        android:title="@string/credman_credentials"
        settings:controller="com.android.settings.applications.credentials.CredentialManagerPreferenceController"
        settings:keywords="@string/credman_keywords" />

    <PreferenceCategory
        android:key="dashboard_tile_placeholder"
        android:order="130"/>

    <SwitchPreference
        android:key="auto_sync_account_data"
        android:title="@string/auto_sync_account_title"
        android:summary="@string/auto_sync_account_summary"
        android:order="200"
        settings:allowDividerAbove="true"/>

    <SwitchPreference
        android:key="auto_sync_private_account_data"
        android:title="@string/account_settings_menu_auto_sync_private"
        android:summary="@string/auto_sync_account_summary"
        android:order="210"/>

</PreferenceScreen>
 No newline at end of file
+55 −10
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@ package com.android.settings;

import static android.content.Intent.EXTRA_USER;
import static android.content.Intent.EXTRA_USER_ID;
import static android.os.UserManager.USER_TYPE_FULL_SYSTEM;
import static android.os.UserManager.USER_TYPE_PROFILE_MANAGED;
import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;

@@ -63,6 +66,7 @@ import android.os.BatteryManager;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.Flags;
import android.os.IBinder;
import android.os.INetworkManagementService;
import android.os.RemoteException;
@@ -111,6 +115,7 @@ import com.android.internal.util.ArrayUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.dashboard.profileselector.ProfileFragmentBridge;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment.ProfileType;
import com.android.settings.password.ChooseLockSettingsHelper;
import com.android.settingslib.widget.ActionBarShadowController;
import com.android.settingslib.widget.AdaptiveIcon;
@@ -118,6 +123,7 @@ import com.android.settingslib.widget.AdaptiveIcon;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;

public final class Utils extends com.android.settingslib.Utils {
@@ -440,6 +446,38 @@ public final class Utils extends com.android.settingslib.Utils {
        return null;
    }

    /**
     * Returns the profile of userType of the current user or {@code null} if none is found or a
     * profile exists, but it is disabled.
     */
    @Nullable
    public static UserHandle getProfileOfType(
            @NonNull UserManager userManager, @ProfileType int userType) {
        final List<UserHandle> userProfiles = userManager.getUserProfiles();
        String umUserType = getUmUserType(userType);
        for (UserHandle profile : userProfiles) {
            if (profile.getIdentifier() == UserHandle.myUserId()) {
                continue;
            }
            final UserInfo userInfo = userManager.getUserInfo(profile.getIdentifier());
            if (Objects.equals(umUserType, userInfo.userType)) {
                return profile;
            }
        }
        return null;
    }

    private static String getUmUserType(@ProfileType int userType) throws IllegalArgumentException {
        if (userType == ProfileType.WORK) {
            return USER_TYPE_PROFILE_MANAGED;
        } else if (userType == ProfileType.PRIVATE) {
            return USER_TYPE_PROFILE_PRIVATE;
        } else if (userType == ProfileType.PERSONAL) {
            return USER_TYPE_FULL_SYSTEM;
        }
        throw new IllegalArgumentException("Cannot get user type for ALL types");
    }

    /**
     * Returns the managed profile of the current user or {@code null} if none is found. Unlike
     * {@link #getManagedProfile} this method returns enabled and disabled managed profiles.
@@ -479,15 +517,20 @@ public final class Utils extends com.android.settingslib.Utils {
        return UserHandle.USER_NULL;
    }

    /** Returns user ID of current user, throws IllegalStateException if it's not available. */
    public static int getCurrentUserId(UserManager userManager, boolean isWorkProfile)
            throws IllegalStateException {
        if (isWorkProfile) {
            final UserHandle managedUserHandle = getManagedProfile(userManager);
            if (managedUserHandle == null) {
                throw new IllegalStateException("Work profile user ID is not available.");
    /**
     * Returns user ID of the user of specified type under the current context, throws
     * IllegalStateException if it's not available.
     */
    public static int getCurrentUserIdOfType(
            @NonNull UserManager userManager,
            @ProfileType int userType) throws IllegalStateException {
        if (userType != ProfileType.PERSONAL) {
            final UserHandle userHandle = getProfileOfType(userManager, userType);
            if (userHandle == null) {
                throw new IllegalStateException("User ID of requested profile type is not "
                        + "available.");
            }
            return managedUserHandle.getIdentifier();
            return userHandle.getIdentifier();
        }
        return UserHandle.myUserId();
    }
@@ -1223,8 +1266,10 @@ public final class Utils extends com.android.settingslib.Utils {
        List<UserHandle> profiles = userManager.getUserProfiles();
        for (UserHandle userHandle : profiles) {
            UserProperties userProperties = userManager.getUserProperties(userHandle);
            if (userProperties.getShowInSettings()
                    == UserProperties.SHOW_IN_SETTINGS_SEPARATE) {
            if (userProperties.getShowInSettings() == UserProperties.SHOW_IN_SETTINGS_SEPARATE) {
                if (Flags.allowPrivateProfile() && userProperties.getHideInSettingsInQuietMode()) {
                    return !userManager.isQuietModeEnabled(userHandle);
                }
                return true;
            }
        }
+6 −0
Original line number Diff line number Diff line
@@ -31,14 +31,17 @@ import com.android.settings.R;
import com.android.settings.applications.autofill.PasswordsPreferenceController;
import com.android.settings.applications.credentials.CredentialManagerPreferenceController;
import com.android.settings.applications.credentials.DefaultCombinedPreferenceController;
import com.android.settings.applications.credentials.DefaultPrivateCombinedPreferenceController;
import com.android.settings.applications.credentials.DefaultWorkCombinedPreferenceController;
import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
import com.android.settings.applications.defaultapps.DefaultPrivateAutofillPreferenceController;
import com.android.settings.applications.defaultapps.DefaultWorkAutofillPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.users.AutoSyncDataPreferenceController;
import com.android.settings.users.AutoSyncPersonalDataPreferenceController;
import com.android.settings.users.AutoSyncPrivateDataPreferenceController;
import com.android.settings.users.AutoSyncWorkDataPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
@@ -111,9 +114,11 @@ public class AccountDashboardFragment extends DashboardFragment {
        if (CredentialManager.isServiceEnabled(context)) {
            controllers.add(new DefaultCombinedPreferenceController(context));
            controllers.add(new DefaultWorkCombinedPreferenceController(context));
            controllers.add(new DefaultPrivateCombinedPreferenceController(context));
        } else {
            controllers.add(new DefaultAutofillPreferenceController(context));
            controllers.add(new DefaultWorkAutofillPreferenceController(context));
            controllers.add(new DefaultPrivateAutofillPreferenceController(context));
        }
    }

@@ -132,6 +137,7 @@ public class AccountDashboardFragment extends DashboardFragment {
        controllers.add(new AutoSyncDataPreferenceController(context, parent));
        controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
        controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
        controllers.add(new AutoSyncPrivateDataPreferenceController(context, parent));
    }

    private static int getPreferenceLayoutResId(Context context) {
Loading