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

Commit ce0976cc authored by Amith Yamasani's avatar Amith Yamasani Committed by Android Git Automerger
Browse files

am 2ba97451: am f3b325f5: Debug feature for HDCP compliance testing.

* commit '2ba97451':
  Debug feature for HDCP compliance testing.
parents d6f9c32b 2ba97451
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -533,11 +533,32 @@
        <item>Long</item>
    </string-array>

    <!-- Valeus for the list of long press timeout options. -->
    <!-- Values for the list of long press timeout options. -->
    <string-array name="long_press_timeout_selector_values" translatable="false">
        <item>500</item>
        <item>1000</item>
        <item>1500</item>
    </string-array>

    <!-- Titles for HDCP checking preference. [CHAR LIMIT=35] -->
    <string-array name="hdcp_checking_titles">
        <item>Never check</item>
        <item>Check for DRM content only</item>
        <item>Always check</item>
    </string-array>

    <!-- Values for HDCP checking preference. -->
    <string-array name="hdcp_checking_values" translatable="false" >
        <item>never</item>
        <item>drm-only</item>
        <item>always</item>
    </string-array>

    <!-- Summaries for HDCP checking preference. [CHAR LIMIT=100]-->
    <string-array name="hdcp_checking_summaries" >
        <item>Never use HDCP checking</item>
        <item>Use HDCP checking for DRM content only</item>
        <item>Always use HDCP checking</item>
    </string-array>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -3319,4 +3319,9 @@ found in the list of installed applications.</string>
    <string name="misc_files_selected_count_bytes"><xliff:g id="number" example="3.25MB">%1$s</xliff:g> out of <xliff:g id="total" example="15.25MB">%2$s</xliff:g></string>
    <!--  action to select all [CHAR LIMIT=30] -->
    <string name="select_all">Select All</string>

    <!-- HDCP checking title, used for debug purposes only. [CHAR LIMIT=25] -->
    <string name="hdcp_checking_title">HDCP checking</string>
    <!-- HDCP checking dialog title, used for debug purposes only. [CHAR LIMIT=25] -->
    <string name="hdcp_checking_dialog_title">Set HDCP checking behavior</string>
</resources>
+6 −0
Original line number Diff line number Diff line
@@ -32,4 +32,10 @@
        android:title="@string/allow_mock_location" 
        android:summary="@string/allow_mock_location_summary"/>

    <ListPreference
        android:key="hdcp_checking"
        android:title="@string/hdcp_checking_title"
        android:dialogTitle="@string/hdcp_checking_dialog_title"
        android:entries="@array/hdcp_checking_titles"
        android:entryValues="@array/hdcp_checking_values" />
</PreferenceScreen>
+51 −2
Original line number Diff line number Diff line
@@ -21,22 +21,29 @@ import android.app.Dialog;
import android.content.ContentResolver;
import android.content.DialogInterface;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemProperties;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.preference.CheckBoxPreference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings;

/*
 * Displays preferences for application developers.
 */
public class DevelopmentSettings extends PreferenceFragment
        implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener {
        implements DialogInterface.OnClickListener, DialogInterface.OnDismissListener,
                OnPreferenceChangeListener {

    private static final String ENABLE_ADB = "enable_adb";
    private static final String KEEP_SCREEN_ON = "keep_screen_on";
    private static final String ALLOW_MOCK_LOCATION = "allow_mock_location";
    private static final String HDCP_CHECKING_KEY = "hdcp_checking";
    private static final String HDCP_CHECKING_PROPERTY = "persist.sys.hdcp_checking";

    private CheckBoxPreference mEnableAdb;
    private CheckBoxPreference mKeepScreenOn;
@@ -56,6 +63,18 @@ public class DevelopmentSettings extends PreferenceFragment
        mEnableAdb = (CheckBoxPreference) findPreference(ENABLE_ADB);
        mKeepScreenOn = (CheckBoxPreference) findPreference(KEEP_SCREEN_ON);
        mAllowMockLocation = (CheckBoxPreference) findPreference(ALLOW_MOCK_LOCATION);

        removeHdcpOptionsForProduction();
    }

    private void removeHdcpOptionsForProduction() {
        if ("user".equals(Build.TYPE)) {
            Preference hdcpChecking = findPreference(HDCP_CHECKING_KEY);
            if (hdcpChecking != null) {
                // Remove the preference
                getPreferenceScreen().removePreference(hdcpChecking);
            }
        }
    }

    @Override
@@ -69,6 +88,26 @@ public class DevelopmentSettings extends PreferenceFragment
                Settings.System.STAY_ON_WHILE_PLUGGED_IN, 0) != 0);
        mAllowMockLocation.setChecked(Settings.Secure.getInt(cr,
                Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0);
        updateHdcpValues();
    }

    private void updateHdcpValues() {
        int index = 1; // Defaults to drm-only. Needs to match with R.array.hdcp_checking_values
        ListPreference hdcpChecking = (ListPreference) findPreference(HDCP_CHECKING_KEY);
        if (hdcpChecking != null) {
            String currentValue = SystemProperties.get(HDCP_CHECKING_PROPERTY);
            String[] values = getResources().getStringArray(R.array.hdcp_checking_values);
            String[] summaries = getResources().getStringArray(R.array.hdcp_checking_summaries);
            for (int i = 0; i < values.length; i++) {
                if (currentValue.equals(values[i])) {
                    index = i;
                    break;
                }
            }
            hdcpChecking.setValue(values[index]);
            hdcpChecking.setSummary(summaries[index]);
            hdcpChecking.setOnPreferenceChangeListener(this);
        }
    }

    @Override
@@ -137,4 +176,14 @@ public class DevelopmentSettings extends PreferenceFragment
        dismissDialog();
        super.onDestroy();
    }

    @Override
    public boolean onPreferenceChange(Preference preference, Object newValue) {
        if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
            SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
            updateHdcpValues();
            return true;
        }
        return false;
    }
}