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

Commit 87ca7017 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Tweak development settings to report system property changes.

Uses the new IBinder hack to tell all registered system services
about the property change.  This should get most processes of
interest...  some of them many times over, even.

This implementation does the broadcast for every debug property
change, though currently the only ones handling it are the
trace and layout bounds debugging properties.

Change-Id: Ibe3a10a40184751b8b2ed00021a224182d8f3f30
parent 48c72676
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Bundle;
@@ -49,6 +50,7 @@ import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.HardwareRenderer;
import android.view.IWindowManager;
@@ -103,6 +105,7 @@ public class DevelopmentSettings extends PreferenceFragment
    private Switch mEnabledSwitch;
    private boolean mLastEnabledState;
    private boolean mHaveDebugSettings;
    private boolean mDontPokeProperties;

    private CheckBoxPreference mEnableAdb;
    private CheckBoxPreference mKeepScreenOn;
@@ -327,6 +330,7 @@ public class DevelopmentSettings extends PreferenceFragment
    }

    private void resetDangerousOptions() {
        mDontPokeProperties = true;
        for (int i=0; i<mResetCbPrefs.size(); i++) {
            CheckBoxPreference cb = mResetCbPrefs.get(i);
            if (cb.isChecked()) {
@@ -342,6 +346,8 @@ public class DevelopmentSettings extends PreferenceFragment
        writeAppProcessLimitOptions(null);
        mHaveDebugSettings = false;
        updateAllOptions();
        mDontPokeProperties = false;
        pokeSystemProperties();
    }

    private void updateHdcpValues() {
@@ -526,6 +532,7 @@ public class DevelopmentSettings extends PreferenceFragment
    
    private void writeHardwareUiOptions() {
        SystemProperties.set(HARDWARE_UI_PROPERTY, mForceHardwareUi.isChecked() ? "true" : "false");
        pokeSystemProperties();
    }

    private void updateTrackFrameTimeOptions() {
@@ -536,6 +543,7 @@ public class DevelopmentSettings extends PreferenceFragment
    private void writeTrackFrameTimeOptions() {
        SystemProperties.set(HardwareRenderer.PROFILE_PROPERTY,
                mTrackFrameTime.isChecked() ? "true" : "false");
        pokeSystemProperties();
    }

    private void updateShowHwScreenUpdatesOptions() {
@@ -546,6 +554,7 @@ public class DevelopmentSettings extends PreferenceFragment
    private void writeShowHwScreenUpdatesOptions() {
        SystemProperties.set(HardwareRenderer.DEBUG_DIRTY_REGIONS_PROPERTY,
                mShowHwScreenUpdates.isChecked() ? "true" : "false");
        pokeSystemProperties();
    }

    private void updateDebugLayoutOptions() {
@@ -556,6 +565,7 @@ public class DevelopmentSettings extends PreferenceFragment
    private void writeDebugLayoutOptions() {
        SystemProperties.set(View.DEBUG_LAYOUT_PROPERTY,
                mDebugLayout.isChecked() ? "true" : "false");
        pokeSystemProperties();
    }

    private void updateCpuUsageOptions() {
@@ -705,6 +715,7 @@ public class DevelopmentSettings extends PreferenceFragment
    private void writeEnableTracesOptions(long value) {
        SystemProperties.set(Trace.PROPERTY_TRACE_TAG_ENABLEFLAGS,
                "0x" + Long.toString(value, 16));
        pokeSystemProperties();
    }

    @Override
@@ -817,6 +828,7 @@ public class DevelopmentSettings extends PreferenceFragment
        if (HDCP_CHECKING_KEY.equals(preference.getKey())) {
            SystemProperties.set(HDCP_CHECKING_PROPERTY, newValue.toString());
            updateHdcpValues();
            pokeSystemProperties();
            return true;
        } else if (preference == mWindowAnimationScale) {
            writeAnimationScaleOption(0, mWindowAnimationScale, newValue);
@@ -892,4 +904,34 @@ public class DevelopmentSettings extends PreferenceFragment
        dismissDialogs();
        super.onDestroy();
    }

    void pokeSystemProperties() {
        if (!mDontPokeProperties) {
            (new SystemPropPoker()).execute();
        }
    }

    static class SystemPropPoker extends AsyncTask<Void, Void, Void> {
        @Override
        protected Void doInBackground(Void... params) {
            String[] services;
            try {
                services = ServiceManager.listServices();
            } catch (RemoteException e) {
                return null;
            }
            for (String service : services) {
                IBinder obj = ServiceManager.checkService(service);
                if (obj != null) {
                    Parcel data = Parcel.obtain();
                    try {
                        obj.transact(IBinder.SYSPROPS_TRANSACTION, data, null, 0);
                    } catch (RemoteException e) {
                    }
                    data.recycle();
                }
            }
            return null;
        }
    }
}