diff --git a/Android.bp b/Android.bp
index 97b235d3ab9..0777aa77440 100644
--- a/Android.bp
+++ b/Android.bp
@@ -84,6 +84,7 @@ android_library {
// Settings dependencies
"FingerprintManagerInteractor",
+ "MediaDrmSettingsFlagsLib",
"Settings-change-ids",
"SettingsLib",
"SettingsLibActivityEmbedding",
diff --git a/aconfig/Android.bp b/aconfig/Android.bp
index eb9a6b4155b..37b03bafb14 100644
--- a/aconfig/Android.bp
+++ b/aconfig/Android.bp
@@ -25,3 +25,14 @@ java_aconfig_library {
name: "factory_reset_flags_lib",
aconfig_declarations: "factory_reset_flags",
}
+
+aconfig_declarations {
+ name: "media_drm_flags",
+ package: "com.android.settings.media_drm",
+ srcs: ["media_drm/*.aconfig"],
+}
+
+java_aconfig_library {
+ name: "MediaDrmSettingsFlagsLib",
+ aconfig_declarations: "media_drm_flags",
+}
\ No newline at end of file
diff --git a/aconfig/media_drm/settings_mediadrm_flag_declarations.aconfig b/aconfig/media_drm/settings_mediadrm_flag_declarations.aconfig
new file mode 100644
index 00000000000..06d75f1e34c
--- /dev/null
+++ b/aconfig/media_drm/settings_mediadrm_flag_declarations.aconfig
@@ -0,0 +1,8 @@
+package: "com.android.settings.media_drm"
+
+flag {
+ name: "force_l3_enabled"
+ namespace: "media_drm"
+ description: "Feature flag of forcing L3"
+ bug: "301669353"
+}
\ No newline at end of file
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index f890984f34b..f0a288181a9 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -619,6 +619,11 @@
android:title="@string/transcode_settings_title"
android:fragment="com.android.settings.development.transcode.TranscodeSettingsFragment" />
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/android/settings/development/widevine/ForceL3FallbackPreferenceController.java b/src/com/android/settings/development/widevine/ForceL3FallbackPreferenceController.java
new file mode 100644
index 00000000000..78468c19f5f
--- /dev/null
+++ b/src/com/android/settings/development/widevine/ForceL3FallbackPreferenceController.java
@@ -0,0 +1,80 @@
+/*
+* 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.widevine;
+
+import android.content.Context;
+import android.sysprop.WidevineProperties;
+import android.util.Log;
+
+import androidx.preference.Preference;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+import com.android.settingslib.development.DevelopmentSettingsEnabler;
+import com.android.settings.media_drm.Flags;
+
+/**
+ * The controller (in the Media Widevine settings) enforces L3 security level
+* of Widevine CDM.
+*/
+public class ForceL3FallbackPreferenceController extends TogglePreferenceController {
+ private static final String TAG = "ForceL3FallbackPreferenceController";
+
+ public ForceL3FallbackPreferenceController(Context context, String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return WidevineProperties.forcel3_enabled().orElse(false);
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ WidevineProperties.forcel3_enabled(isChecked);
+ return true;
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ if (Flags.forceL3Enabled()) {
+ preference.setEnabled(true);
+ Log.i(TAG, "forceL3Enabled is on");
+ } else {
+ preference.setEnabled(false);
+ // In case of flag rollback, the controller should be unchecked.
+ WidevineProperties.forcel3_enabled(false);
+ Log.i(TAG, "forceL3Enabled is off");
+ }
+ super.updateState(preference);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)) {
+ return AVAILABLE;
+ } else {
+ return CONDITIONALLY_UNAVAILABLE;
+ }
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_system;
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/development/widevine/WidevineSettingsFragment.java b/src/com/android/settings/development/widevine/WidevineSettingsFragment.java
new file mode 100644
index 00000000000..058aa40e44b
--- /dev/null
+++ b/src/com/android/settings/development/widevine/WidevineSettingsFragment.java
@@ -0,0 +1,58 @@
+/*
+* 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.widevine;
+
+import android.app.settings.SettingsEnums;
+import android.content.Context;
+
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settingslib.development.DevelopmentSettingsEnabler;
+import com.android.settingslib.search.SearchIndexable;
+
+/**
+ * Fragment for native widevine settings in Developer options.
+*/
+@SearchIndexable
+public class WidevineSettingsFragment extends DashboardFragment {
+ private static final String TAG = "WidevineSettings";
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.widevine_settings;
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.WIDEVINE_SETTINGS;
+ }
+
+ public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider(R.xml.widevine_settings) {
+
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
+ }
+ };
+}
\ No newline at end of file