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

Commit c751bbd8 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12970832 from 61e7f37b to 25Q2-release

Change-Id: Ib3bd7e2432726e620f1d8489a3a33bda09e9350f
parents d0266888 61e7f37b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -12769,6 +12769,13 @@
    <!-- Title for a toggle that enables freeform windows. Freeform windows enables users to freely arrange and resize overlapping apps. [CHAR LIMIT=50] -->
    <string name="enable_desktop_mode">Enable freeform windows</string>
    <!-- Title for a toggle that enables desktop experience features. This includes desktop view and connected displays. [CHAR LIMIT=50] -->
    <string name="enable_desktop_experience_features">Enable desktop experience features</string>
    <!-- Summary for a toggle that enables desktop experience features when the device itself can show the desktop (but it is not available without the developer option). [CHAR LIMIT=NONE] -->
    <string name="enable_desktop_experience_features_summary_with_desktop">Enable Desktop View on the device and on secondary displays.</string>
    <!-- Summary for a toggle that enables desktop experience features when desktop views don't need to be enable. [CHAR LIMIT=NONE] -->
    <string name="enable_desktop_experience_features_summary_without_desktop">Enable Desktop View on secondary displays.</string>
    <!-- Title for a toggle that enables freeform windows on secondary display. Freeform windows enables users to freely arrange and resize overlapping apps. [CHAR LIMIT=50] -->
    <string name="enable_desktop_mode_on_secondary_display">Enable freeform windows on secondary display</string>
+4 −0
Original line number Diff line number Diff line
@@ -755,6 +755,10 @@
            android:key="enable_freeform_support"
            android:title="@string/enable_freeform_support" />

        <SwitchPreferenceCompat
            android:key="override_desktop_experience_features"
            android:title="@string/enable_desktop_experience_features"/>

        <SwitchPreferenceCompat
            android:key="force_desktop_mode_on_external_displays"
            android:title="@string/enable_desktop_mode_on_secondary_display"/>
+1 −1
Original line number Diff line number Diff line
@@ -147,7 +147,7 @@ public class RestrictedPreferenceHelper {
                && android.security.Flags.extendEcmToAllSettings()) {
            preference.checkEcmRestrictionAndSetDisabled(
                    AppOpsManager.OPSTR_BIND_ACCESSIBILITY_SERVICE,
                    preference.getPackageName());
                    preference.getPackageName(), serviceEnabled);
            if (preference.isDisabledByEcm()) {
                serviceAllowed = false;
            }
+109 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.development;

import static android.provider.Settings.Global.DEVELOPMENT_OVERRIDE_DESKTOP_EXPERIENCE_FEATURES;
import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_OFF;
import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_ON;
import static android.window.DesktopModeFlags.ToggleOverride.OVERRIDE_UNSET;
import static android.window.DesktopModeFlags.ToggleOverride.fromSetting;

import android.content.Context;
import android.provider.Settings;
import android.window.DesktopModeFlags;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;

import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;

public class DesktopExperiencePreferenceController extends DeveloperOptionsPreferenceController
        implements Preference.OnPreferenceChangeListener,
        PreferenceControllerMixin, RebootConfirmationDialogHost {
    private static final String OVERRIDE_DESKTOP_EXPERIENCE_FEATURES_KEY =
            "override_desktop_experience_features";

    @Nullable
    private final DevelopmentSettingsDashboardFragment mFragment;

    public DesktopExperiencePreferenceController(
            Context context, @Nullable DevelopmentSettingsDashboardFragment fragment) {
        super(context);
        mFragment = fragment;
    }

    @Override
    public boolean isAvailable() {
        return DesktopModeStatus.canShowDesktopExperienceDevOption(mContext);
    }

    @Override
    public String getPreferenceKey() {
        return OVERRIDE_DESKTOP_EXPERIENCE_FEATURES_KEY;
    }

    @Override
    public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
        final boolean isEnabled = (Boolean) newValue;
        Settings.Global.putInt(mContext.getContentResolver(),
                DEVELOPMENT_OVERRIDE_DESKTOP_EXPERIENCE_FEATURES,
                isEnabled ? OVERRIDE_ON.getSetting() : OVERRIDE_OFF.getSetting());
        if (mFragment != null) {
            RebootConfirmationDialogFragment.show(
                    mFragment, R.string.reboot_dialog_override_desktop_mode, this);
        }
        return true;
    }

    @Override
    public void updateState(Preference preference) {
        super.updateState(preference);
        // Use overridden state, if not present, then use default state
        final int overrideInt = Settings.Global.getInt(mContext.getContentResolver(),
                DEVELOPMENT_OVERRIDE_DESKTOP_EXPERIENCE_FEATURES, OVERRIDE_UNSET.getSetting());
        final DesktopModeFlags.ToggleOverride toggleOverride = fromSetting(overrideInt,
                OVERRIDE_UNSET);
        final boolean shouldDevOptionBeEnabled = switch (toggleOverride) {
            case OVERRIDE_OFF, OVERRIDE_UNSET -> false;
            case OVERRIDE_ON -> true;
        };
        ((TwoStatePreference) mPreference).setChecked(shouldDevOptionBeEnabled);
    }

    @Override
    protected void onDeveloperOptionsSwitchDisabled() {
        super.onDeveloperOptionsSwitchDisabled();
        Settings.Global.putInt(mContext.getContentResolver(),
                DEVELOPMENT_OVERRIDE_DESKTOP_EXPERIENCE_FEATURES, OVERRIDE_UNSET.getSetting());
    }

    @Override
    public CharSequence getSummary() {
        if (DesktopModeStatus.isDeviceEligibleForDesktopMode(mContext)
                && !DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODE.isTrue()) {
            return mContext.getString(
                    R.string.enable_desktop_experience_features_summary_with_desktop);
        }
        return mContext.getString(
                R.string.enable_desktop_experience_features_summary_without_desktop);
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ public class DesktopModePreferenceController extends DeveloperOptionsPreferenceC

    @Override
    public boolean isAvailable() {
        return DesktopModeStatus.canShowDesktopModeDevOption(mContext);
        return DesktopModeStatus.canShowDesktopModeDevOption(mContext)
                && !DesktopModeStatus.canShowDesktopExperienceDevOption(mContext);
    }

    @Override
Loading