Merge Android 24Q2 Release (ab/11526283) to aosp-main-future

Bug: 337098550
Merged-In: I96574a79eba581db95d387f0d9c9fde2e004c41c
Change-Id: Ib9f2c742f8aa72651ef9eca80a716dd94b9041ea
This commit is contained in:
Xin Li
2024-05-23 14:12:07 -07:00
1413 changed files with 69959 additions and 31812 deletions

View File

@@ -16,12 +16,12 @@
package com.android.settings.development;
import static com.android.window.flags.Flags.predictiveBackSystemAnimations;
import static com.android.window.flags.Flags.predictiveBackSystemAnims;
import android.annotation.Nullable;
import android.content.Context;
import android.provider.Settings;
import androidx.annotation.Nullable;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;
@@ -57,7 +57,7 @@ public class BackAnimationPreferenceController extends DeveloperOptionsPreferenc
@Override
public boolean isAvailable() {
return !predictiveBackSystemAnimations();
return !predictiveBackSystemAnims();
}
@Override

View File

@@ -0,0 +1,139 @@
/*
* Copyright 2024 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 android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothStatusCodes;
import android.content.Context;
import android.os.SystemProperties;
import android.sysprop.BluetoothProperties;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
/**
* Preference controller to control Bluetooth LE audio mode
*/
public class BluetoothLeAudioModePreferenceController
extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String PREFERENCE_KEY = "bluetooth_leaudio_mode";
static final String LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY =
"persist.bluetooth.leaudio_dynamic_switcher.mode";
@Nullable private final DevelopmentSettingsDashboardFragment mFragment;
private final String[] mListValues;
private final String[] mListSummaries;
@VisibleForTesting
@Nullable String mNewMode;
@VisibleForTesting
BluetoothAdapter mBluetoothAdapter;
boolean mChanged = false;
public BluetoothLeAudioModePreferenceController(@NonNull Context context,
@Nullable DevelopmentSettingsDashboardFragment fragment) {
super(context);
mFragment = fragment;
mBluetoothAdapter = context.getSystemService(BluetoothManager.class).getAdapter();
mListValues = context.getResources().getStringArray(R.array.bluetooth_leaudio_mode_values);
mListSummaries = context.getResources().getStringArray(R.array.bluetooth_leaudio_mode);
}
@Override
@NonNull public String getPreferenceKey() {
return PREFERENCE_KEY;
}
@Override
public boolean isAvailable() {
return BluetoothProperties.isProfileBapBroadcastSourceEnabled().orElse(false);
}
@Override
public boolean onPreferenceChange(@NonNull Preference preference, Object newValue) {
if (mFragment == null) {
return false;
}
BluetoothRebootDialog.show(mFragment);
mChanged = true;
mNewMode = newValue.toString();
return false;
}
@Override
public void updateState(@NonNull Preference preference) {
if (mBluetoothAdapter == null) {
return;
}
if (mBluetoothAdapter.isLeAudioBroadcastSourceSupported()
== BluetoothStatusCodes.FEATURE_SUPPORTED) {
SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "broadcast");
} else if (mBluetoothAdapter.isLeAudioSupported()
== BluetoothStatusCodes.FEATURE_SUPPORTED) {
SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "unicast");
} else {
SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, "disabled");
}
final String currentValue = SystemProperties.get(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY);
int index = 0;
for (int i = 0; i < mListValues.length; i++) {
if (TextUtils.equals(currentValue, mListValues[i])) {
index = i;
break;
}
}
final ListPreference listPreference = (ListPreference) preference;
listPreference.setValue(mListValues[index]);
listPreference.setSummary(mListSummaries[index]);
}
/**
* Called when the RebootDialog confirm is clicked.
*/
public void onRebootDialogConfirmed() {
if (!mChanged) {
return;
}
SystemProperties.set(LE_AUDIO_DYNAMIC_SWITCHER_MODE_PROPERTY, mNewMode);
}
/**
* Called when the RebootDialog cancel is clicked.
*/
public void onRebootDialogCanceled() {
mChanged = false;
}
}

View File

@@ -21,6 +21,7 @@ import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothStatusCodes;
import android.content.Context;
import android.os.SystemProperties;
import android.sysprop.BluetoothProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
@@ -64,6 +65,12 @@ public class BluetoothLeAudioPreferenceController
return PREFERENCE_KEY;
}
@Override
public boolean isAvailable() {
return BluetoothProperties.isProfileBapUnicastClientEnabled().orElse(false)
&& !BluetoothProperties.isProfileBapBroadcastSourceEnabled().orElse(false);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
BluetoothRebootDialog.show(mFragment);

View File

@@ -235,7 +235,14 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
return;
}
Context context = requireContext();
if (!DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context)) {
UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);
if (!um.isAdminUser()) {
Toast.makeText(context, R.string.dev_settings_available_to_admin_only_warning,
Toast.LENGTH_SHORT)
.show();
finish();
} else if (!DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context)) {
Toast.makeText(context, R.string.dev_settings_disabled_warning, Toast.LENGTH_SHORT)
.show();
finish();
@@ -456,6 +463,11 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
getDevelopmentOptionsController(
BluetoothLeAudioPreferenceController.class);
leAudioFeatureController.onRebootDialogConfirmed();
final BluetoothLeAudioModePreferenceController leAudioModeController =
getDevelopmentOptionsController(
BluetoothLeAudioModePreferenceController.class);
leAudioModeController.onRebootDialogConfirmed();
}
@Override
@@ -473,6 +485,11 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
getDevelopmentOptionsController(
BluetoothLeAudioPreferenceController.class);
leAudioFeatureController.onRebootDialogCanceled();
final BluetoothLeAudioModePreferenceController leAudioModeController =
getDevelopmentOptionsController(
BluetoothLeAudioModePreferenceController.class);
leAudioModeController.onRebootDialogCanceled();
}
@Override
@@ -681,12 +698,12 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new BluetoothAvrcpVersionPreferenceController(context));
controllers.add(new BluetoothMapVersionPreferenceController(context));
controllers.add(new BluetoothLeAudioPreferenceController(context, fragment));
controllers.add(new BluetoothLeAudioModePreferenceController(context, fragment));
controllers.add(new BluetoothLeAudioDeviceDetailsPreferenceController(context));
controllers.add(new BluetoothLeAudioAllowListPreferenceController(context, fragment));
controllers.add(new BluetoothA2dpHwOffloadPreferenceController(context, fragment));
controllers.add(new BluetoothLeAudioHwOffloadPreferenceController(context, fragment));
controllers.add(new BluetoothMaxConnectedAudioDevicesPreferenceController(context));
controllers.add(new NfcStackDebugLogPreferenceController(context));
controllers.add(new NfcSnoopLogPreferenceController(context, fragment));
controllers.add(new NfcVerboseVendorLogPreferenceController(context, fragment));
controllers.add(new ShowTapsPreferenceController(context));
@@ -707,6 +724,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
controllers.add(new HardwareLayersUpdatesPreferenceController(context));
controllers.add(new DebugGpuOverdrawPreferenceController(context));
controllers.add(new DebugNonRectClipOperationsPreferenceController(context));
controllers.add(new GameDefaultFrameRatePreferenceController(context));
controllers.add(new ForceDarkPreferenceController(context));
controllers.add(new EnableBlursPreferenceController(context));
controllers.add(new ForceMSAAPreferenceController(context));
@@ -765,6 +783,7 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
context, context.getSystemService(UiModeManager.class)));
controllers.add(new ForceEnableNotesRolePreferenceController(context));
controllers.add(new GrammaticalGenderPreferenceController(context));
controllers.add(new SensitiveContentProtectionPreferenceController(context));
return controllers;
}

View File

@@ -0,0 +1,66 @@
/*
* 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.development;
import android.annotation.NonNull;
import android.os.SystemProperties;
/**
* Wrapper interface to access {@link SystemProperties}.
*
* @hide
*/
public interface DevelopmentSystemPropertiesWrapper {
/**
* Get the String value for the given {@code key}.
*
* @param key the key to lookup
* @param def the default value in case the property is not set or empty
* @return if the {@code key} isn't found, return {@code def} if it isn't null, or an empty
* string otherwise
*/
@NonNull
String get(@NonNull String key, @NonNull String def);
/**
* Set the value for the given {@code key} to {@code val}.
*
* @throws IllegalArgumentException if the {@code val} exceeds 91 characters
* @throws RuntimeException if the property cannot be set, for example, if it was blocked by
* SELinux. libc will log the underlying reason.
*/
void set(@NonNull String key, @NonNull String val);
/**
* Get the Integer value for the given {@code key}.
*
* @param key the key to lookup
* @param def the default value in case the property is not set or empty
* @return if the {@code key} isn't found, return {@code def} if it isn't null, not parsable
* or an empty string otherwise
*/
@NonNull
int getInt(@NonNull String key, @NonNull int def);
/**
* Get the boolean value for the given {@code key}.
*
* @param key the key to lookup
* @param def the default value in case the property is not set or empty
* @return if the {@code key} isn't found, return {@code def}.
*/
boolean getBoolean(@NonNull String key, @NonNull boolean def);
}

View File

@@ -29,6 +29,8 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.applications.ProcessStatsSummary;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
public class DisableDevSettingsDialogFragment extends InstrumentedDialogFragment
@@ -42,7 +44,7 @@ public class DisableDevSettingsDialogFragment extends InstrumentedDialogFragment
return dialog;
}
public static void show(DevelopmentSettingsDashboardFragment host) {
public static void show(SettingsPreferenceFragment host) {
final DisableDevSettingsDialogFragment dialog = new DisableDevSettingsDialogFragment();
dialog.setTargetFragment(host, 0 /* requestCode */);
// We need to handle data changes and switch state based on which button user clicks,
@@ -75,18 +77,31 @@ public class DisableDevSettingsDialogFragment extends InstrumentedDialogFragment
@Override
public void onClick(DialogInterface dialog, int which) {
Fragment fragment = getTargetFragment();
if (!(fragment instanceof DevelopmentSettingsDashboardFragment)){
if (!(fragment instanceof DevelopmentSettingsDashboardFragment)
&& !(fragment instanceof ProcessStatsSummary)) {
Log.e(TAG, "getTargetFragment return unexpected type");
}
final DevelopmentSettingsDashboardFragment host =
(DevelopmentSettingsDashboardFragment) fragment;
if (which == DialogInterface.BUTTON_POSITIVE) {
host.onDisableDevelopmentOptionsConfirmed();
PowerManager pm = getContext().getSystemService(PowerManager.class);
pm.reboot(null);
} else {
host.onDisableDevelopmentOptionsRejected();
if (fragment instanceof DevelopmentSettingsDashboardFragment) {
final DevelopmentSettingsDashboardFragment host =
(DevelopmentSettingsDashboardFragment) fragment;
if (which == DialogInterface.BUTTON_POSITIVE) {
host.onDisableDevelopmentOptionsConfirmed();
PowerManager pm = getContext().getSystemService(PowerManager.class);
pm.reboot(null);
} else {
host.onDisableDevelopmentOptionsRejected();
}
} else if (fragment instanceof ProcessStatsSummary) {
final ProcessStatsSummary host =
(ProcessStatsSummary) fragment;
if (which == DialogInterface.BUTTON_POSITIVE) {
host.onRebootDialogConfirmed();
PowerManager pm = getContext().getSystemService(PowerManager.class);
pm.reboot(null);
} else {
host.onRebootDialogCanceled();
}
}
}
}

View File

@@ -16,13 +16,13 @@
package com.android.settings.development;
import android.annotation.Nullable;
import android.content.Context;
import android.hardware.dumpstate.V1_0.IDumpstateDevice;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;

View File

@@ -17,6 +17,7 @@
package com.android.settings.development;
import static com.android.internal.display.RefreshRateSettingsUtils.DEFAULT_REFRESH_RATE;
import static com.android.internal.display.RefreshRateSettingsUtils.findHighestRefreshRateAmongAllDisplays;
import static com.android.internal.display.RefreshRateSettingsUtils.findHighestRefreshRateForDefaultDisplay;
import android.content.Context;
@@ -28,6 +29,7 @@ import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.TwoStatePreference;
import com.android.server.display.feature.flags.Flags;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
@@ -46,7 +48,9 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
public ForcePeakRefreshRatePreferenceController(Context context) {
super(context);
mPeakRefreshRate = findHighestRefreshRateForDefaultDisplay(context);
mPeakRefreshRate = Flags.backUpSmoothDisplayAndForcePeakRefreshRate()
? findHighestRefreshRateAmongAllDisplays(context)
: findHighestRefreshRateForDefaultDisplay(context);
Log.d(TAG, "DEFAULT_REFRESH_RATE : " + DEFAULT_REFRESH_RATE
+ " mPeakRefreshRate : " + mPeakRefreshRate);
}
@@ -95,7 +99,9 @@ public class ForcePeakRefreshRatePreferenceController extends DeveloperOptionsPr
@VisibleForTesting
void forcePeakRefreshRate(boolean enable) {
final float peakRefreshRate = enable ? Float.POSITIVE_INFINITY : NO_CONFIG;
final float valueIfEnabled = Flags.backUpSmoothDisplayAndForcePeakRefreshRate()
? Float.POSITIVE_INFINITY : mPeakRefreshRate;
final float peakRefreshRate = enable ? valueIfEnabled : NO_CONFIG;
Settings.System.putFloat(mContext.getContentResolver(),
Settings.System.MIN_REFRESH_RATE, peakRefreshRate);
}

View File

@@ -0,0 +1,146 @@
/*
* 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.development;
import android.app.IGameManagerService;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;
import com.android.settings.R;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.flags.Flags;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class GameDefaultFrameRatePreferenceController extends DeveloperOptionsPreferenceController
implements Preference.OnPreferenceChangeListener, PreferenceControllerMixin {
private static final String TAG = "GameDefFrameRatePrefCtr";
private static final String DISABLE_GAME_DEFAULT_FRAME_RATE_KEY =
"disable_game_default_frame_rate";
private final IGameManagerService mGameManagerService;
static final String PROPERTY_DEBUG_GFX_GAME_DEFAULT_FRAME_RATE_DISABLED =
"debug.graphics.game_default_frame_rate.disabled";
private final DevelopmentSystemPropertiesWrapper mSysProps;
private int mGameDefaultFrameRateValue;
@VisibleForTesting
static class Injector {
public DevelopmentSystemPropertiesWrapper createSystemPropertiesWrapper() {
return new DevelopmentSystemPropertiesWrapper() {
@Override
public String get(String key, String def) {
return SystemProperties.get(key, def);
}
@Override
public boolean getBoolean(String key, boolean def) {
return SystemProperties.getBoolean(key, def);
}
@Override
public int getInt(String key, int def) {
return SystemProperties.getInt(key, def);
}
@Override
public void set(String key, String val) {
SystemProperties.set(key, val);
}
};
}
}
public GameDefaultFrameRatePreferenceController(Context context) {
super(context);
mGameManagerService = IGameManagerService.Stub.asInterface(
ServiceManager.getService(Context.GAME_SERVICE));
mSysProps = new Injector().createSystemPropertiesWrapper();
mGameDefaultFrameRateValue = mSysProps.getInt(
"ro.surface_flinger.game_default_frame_rate_override", 60);
}
@VisibleForTesting
GameDefaultFrameRatePreferenceController(Context context,
IGameManagerService gameManagerService,
Injector injector) {
super(context);
mGameManagerService = gameManagerService;
mSysProps = injector.createSystemPropertiesWrapper();
}
@Override
public String getPreferenceKey() {
return DISABLE_GAME_DEFAULT_FRAME_RATE_KEY;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isDisabled = (Boolean) newValue;
try {
mGameManagerService.toggleGameDefaultFrameRate(!isDisabled);
updateGameDefaultPreferenceSetting();
} catch (RemoteException e) {
// intentional no-op
}
return true;
}
private void updateGameDefaultPreferenceSetting() {
final boolean isDisabled =
mSysProps.getBoolean(PROPERTY_DEBUG_GFX_GAME_DEFAULT_FRAME_RATE_DISABLED,
false);
((TwoStatePreference) mPreference).setChecked(isDisabled);
mPreference.setSummary(mContext.getString(
R.string.disable_game_default_frame_rate_summary,
mGameDefaultFrameRateValue));
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
updateGameDefaultPreferenceSetting();
}
@Override
public boolean isAvailable() {
return Flags.developmentGameDefaultFrameRate();
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
final TwoStatePreference preference = (TwoStatePreference) mPreference;
if (preference.isChecked()) {
// When the developer option is disabled, we should set everything
// to off, that is, enabling game default frame rate.
try {
mGameManagerService.toggleGameDefaultFrameRate(true);
} catch (RemoteException e) {
// intentional no-op
}
}
preference.setChecked(false);
}
}

View File

@@ -17,6 +17,8 @@
package com.android.settings.development;
import android.content.Context;
import android.os.Flags;
import android.provider.Settings;
import android.text.format.Formatter;
import androidx.annotation.VisibleForTesting;
@@ -65,9 +67,13 @@ public class MemoryUsagePreferenceController extends DeveloperOptionsPreferenceC
(long) memInfo.realUsedRam);
final String totalResult = Formatter.formatShortFileSize(mContext,
(long) memInfo.realTotalRam);
ThreadUtils.postOnMainThread(
() -> mPreference.setSummary(mContext.getString(R.string.memory_summary,
usedResult, totalResult)));
boolean displayMemorySummary = !Flags.removeAppProfilerPssCollection();
displayMemorySummary |= Settings.Global.getInt(mContext.getContentResolver(),
Settings.Global.FORCE_ENABLE_PSS_PROFILING, 0) == 1;
String summary = displayMemorySummary
? mContext.getString(R.string.memory_summary, usedResult, totalResult)
: mContext.getString(R.string.pss_profiling_disabled);
ThreadUtils.postOnMainThread(() -> mPreference.setSummary(summary));
});
}

View File

@@ -1,82 +0,0 @@
/*
* Copyright (C) 2021 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 android.content.Context;
import android.os.SystemProperties;
import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.TwoStatePreference;
import com.android.settings.core.PreferenceControllerMixin;
import com.android.settingslib.development.DeveloperOptionsPreferenceController;
public class NfcStackDebugLogPreferenceController extends
DeveloperOptionsPreferenceController implements Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
private static final String NFC_STACK_DEBUGLOG_ENABLED_KEY =
"nfc_stack_debuglog_enabled";
@VisibleForTesting
static final String NFC_STACK_DEBUGLOG_ENABLED_PROPERTY =
"persist.nfc.debug_enabled";
public NfcStackDebugLogPreferenceController(Context context) {
super(context);
}
@Override
public String getPreferenceKey() {
return NFC_STACK_DEBUGLOG_ENABLED_KEY;
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean isEnabled = (Boolean) newValue;
try {
SystemProperties.set(NFC_STACK_DEBUGLOG_ENABLED_PROPERTY,
isEnabled ? "true" : "false");
} catch (RuntimeException e) {
Log.e(TAG, "Fail to set nfc system property: " + e.getMessage());
}
return true;
}
@Override
public void updateState(Preference preference) {
try {
final boolean isEnabled = SystemProperties.getBoolean(
NFC_STACK_DEBUGLOG_ENABLED_PROPERTY, false /* default */);
((TwoStatePreference) mPreference).setChecked(isEnabled);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to get nfc system property: " + e.getMessage());
}
}
@Override
protected void onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled();
try {
SystemProperties.set(NFC_STACK_DEBUGLOG_ENABLED_PROPERTY, "false");
((TwoStatePreference) mPreference).setChecked(false);
} catch (RuntimeException e) {
Log.e(TAG, "Fail to set nfc system property: " + e.getMessage());
}
}
}

View File

@@ -1,3 +1,9 @@
# GameDefaultFrameRatePreferenceController
per-file GameDefaultFrameRatePreferenceController.java=file:platform/frameworks/base:/GAME_MANAGER_OWNERS
# SensitiveContentProtectionPreferenceController
per-file SensitiveContentProtectionPreferenceController.kt=file:platform/frameworks/base:/core/java/android/permission/OWNERS
# ShowHdrSdrRatioPreferenceController
per-file ShowHdrSdrRatioPreferenceController.java=file:platform/frameworks/native:/services/surfaceflinger/OWNERS

View File

@@ -0,0 +1,81 @@
/*
* Copyright (C) 2024 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 android.content.Context
import android.permission.flags.Flags.sensitiveNotificationAppProtection
import android.provider.Settings
import android.view.flags.Flags.sensitiveContentAppProtection
import androidx.annotation.VisibleForTesting
import androidx.preference.Preference
import androidx.preference.TwoStatePreference
import com.android.server.notification.Flags.screenshareNotificationHiding
import com.android.settings.core.PreferenceControllerMixin
import com.android.settingslib.development.DeveloperOptionsPreferenceController
class SensitiveContentProtectionPreferenceController(val context: Context) :
DeveloperOptionsPreferenceController(context),
Preference.OnPreferenceChangeListener,
PreferenceControllerMixin {
override fun getPreferenceKey(): String =
DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS_KEY
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
val isEnabled = newValue as Boolean
Settings.Global.putInt(
mContext.getContentResolver(),
Settings.Global.DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS,
if (isEnabled) SETTING_VALUE_ON else SETTING_VALUE_OFF
)
return true
}
override fun updateState(preference: Preference?) {
val mode = Settings.Global.getInt(
mContext.getContentResolver(),
Settings.Global.DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS,
0)
(mPreference as TwoStatePreference).isChecked = mode != SETTING_VALUE_OFF
}
// Overriding as public, kotlin tests can not invoke a protected method
public override fun onDeveloperOptionsSwitchDisabled() {
super.onDeveloperOptionsSwitchDisabled()
Settings.Global.putInt(
mContext.getContentResolver(),
Settings.Global.DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS,
SETTING_VALUE_OFF
)
(mPreference as TwoStatePreference).isChecked = false
}
override fun isAvailable(): Boolean {
return sensitiveNotificationAppProtection() || screenshareNotificationHiding()
|| sensitiveContentAppProtection()
}
companion object {
private const val DISABLE_SCREEN_SHARE_PROTECTIONS_FOR_APPS_AND_NOTIFICATIONS_KEY =
"disable_screen_share_protections_for_apps_and_notifications"
@VisibleForTesting
val SETTING_VALUE_ON = 1
@VisibleForTesting
val SETTING_VALUE_OFF = 0
}
}

View File

@@ -14,9 +14,11 @@
* limitations under the License.
*/
package com.android.settings.development.graphicsdriver;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.SystemProperties;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* Wrapper interface to access {@link SystemProperties}.
*

View File

@@ -15,7 +15,6 @@
*/
package com.android.settings.development.tare;
import android.annotation.Nullable;
import android.app.Fragment;
import android.app.tare.EconomyManager;
import android.content.res.Resources;
@@ -26,6 +25,8 @@ import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import androidx.annotation.Nullable;
import com.android.settings.R;
/**

View File

@@ -15,7 +15,6 @@
*/
package com.android.settings.development.tare;
import android.annotation.Nullable;
import android.app.Fragment;
import android.app.tare.EconomyManager;
import android.content.res.Resources;
@@ -26,6 +25,8 @@ import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import androidx.annotation.Nullable;
import com.android.settings.R;
/**

View File

@@ -25,7 +25,6 @@ import static android.app.tare.EconomyManager.parseCreditValue;
import static android.provider.Settings.Global.TARE_ALARM_MANAGER_CONSTANTS;
import static android.provider.Settings.Global.TARE_JOB_SCHEDULER_CONSTANTS;
import android.annotation.NonNull;
import android.app.tare.EconomyManager;
import android.content.ContentResolver;
import android.content.Context;
@@ -40,6 +39,8 @@ import android.util.ArraySet;
import android.util.KeyValueListParser;
import android.util.Slog;
import androidx.annotation.NonNull;
import com.android.settings.R;
/**

View File

@@ -18,7 +18,6 @@ package com.android.settings.development.tare;
import static android.app.tare.EconomyManager.CAKE_IN_ARC;
import android.annotation.NonNull;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
@@ -33,6 +32,8 @@ import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import androidx.annotation.NonNull;
import com.android.settings.R;
import com.android.settings.Utils;

View File

@@ -18,7 +18,6 @@ package com.android.settings.development.tare;
import static android.app.tare.EconomyManager.CAKE_IN_ARC;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.View;
@@ -26,6 +25,8 @@ import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.android.settings.R;
/**