Merge changes from topic "wv-dev-opt" into main

* changes:
  Add feature flag for force L3 dev option
  Add Widevine developer option to settings
This commit is contained in:
Treehugger Robot
2023-11-14 22:54:03 +00:00
committed by Android (Google) Code Review
7 changed files with 192 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}
};
}