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

Commit 86432e46 authored by Wes Garner's avatar Wes Garner Committed by Steve Kondik
Browse files

CMParts: Allow CompCache size to be set by user - via % of total RAM

Use % instead of a set size - per suggestion from Cyanogen
Fix to integer instead of decimal being passed around - props to Nameless
Handle older versions changing enabled CC to Default CC size (25%)
Enable PerformanceSettings dialog to view new CC setup
Final cleanup and fix default values / bash arithmetic

Change-Id: Ib9b1a0c0ec07a591413c592690a1705d35e97408

German translation - Matthias Büchner
French translation - Sébastien Vaucher
parent 3ae1c295
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -71,6 +71,15 @@
    <item>30 Minuten</item>
  </string-array>

  <string-array name="pref_compcache_size_entries">
    <item>Ausgeschaltet</item>
    <item>5% des gesamten RAM</item>
    <item>15%</item>
    <item>25% (Standard)</item>
    <item>35%</item>
    <item>45%</item>
  </string-array>

  <string-array name="entries_light_filter_window">
    <item>10 Sekunden</item>
    <item>20 Sekunden</item>
+9 −0
Original line number Diff line number Diff line
@@ -83,6 +83,15 @@
        <item>30m</item>
    </string-array>

    <string-array name="pref_compcache_size_entries">
        <item>Désactivé</item>
        <item>5% de la RAM totale</item>
        <item>15%</item>
        <item>25% (par défaut)</item>
        <item>35%</item>
        <item>45%</item>
    </string-array>

    <string-array name="entries_light_filter_reset">
        <item>Désactivé</item>
        <item>400 lux</item>
+14 −0
Original line number Diff line number Diff line
@@ -164,6 +164,20 @@
        <item>1800000</item>
    </string-array>

    <string-array name="pref_compcache_size_entries">
        <item>Disabled</item>
        <item>15%</item>
        <item>25% (default)</item>
        <item>35%</item>
    </string-array>

    <string-array name="pref_compcache_size_values" translatable="false">
        <item>0</item>
        <item>15</item>
        <item>25</item>
        <item>35</item>
    </string-array>

    <string-array name="entries_light_filter_window">
        <item>10 s</item>
        <item>20 s</item>
+3 −2
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <CheckBoxPreference android:key="pref_compcache"
        android:title="@string/pref_compcache_title" android:summary="@string/pref_compcache_summary" />
    <ListPreference android:key="pref_compcache_size" android:dialogTitle="@string/pref_compcache_title"
        android:title="@string/pref_compcache_title" android:summary="@string/pref_compcache_summary"
        android:entries="@array/pref_compcache_size_entries" android:entryValues="@array/pref_compcache_size_values" />

    <CheckBoxPreference android:key="pref_jit_mode"
        android:title="@string/pref_jit_mode_title" android:summary="@string/pref_jit_mode_summary" />
+41 −34
Original line number Diff line number Diff line
@@ -20,9 +20,11 @@ import java.io.File;
 */
public class PerformanceSettingsActivity extends PreferenceActivity implements Preference.OnPreferenceChangeListener {

    private static final String COMPCACHE_PREF = "pref_compcache";
    private static final String COMPCACHE_PREF = "pref_compcache_size";

    private static final String COMPCACHE_PROP = "persist.service.compcache";
    private static final String COMPCACHE_PERSIST_PROP = "persist.service.compcache";

    private static final String COMPCACHE_DEFAULT = "25";

    private static final String JIT_PREF = "pref_jit_mode";

@@ -56,7 +58,7 @@ public class PerformanceSettingsActivity extends PreferenceActivity implements P

    private static final int LOCK_MMS_DEFAULT = 1;

    private CheckBoxPreference mCompcachePref;
    private ListPreference mCompcachePref;

    private CheckBoxPreference mJitPref;

@@ -72,6 +74,7 @@ public class PerformanceSettingsActivity extends PreferenceActivity implements P

    private int swapAvailable = -1;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -80,10 +83,12 @@ public class PerformanceSettingsActivity extends PreferenceActivity implements P
        addPreferencesFromResource(R.xml.performance_settings);

        PreferenceScreen prefSet = getPreferenceScreen();
        
        mCompcachePref = (CheckBoxPreference) prefSet.findPreference(COMPCACHE_PREF);
        mCompcachePref = (ListPreference) prefSet.findPreference(COMPCACHE_PREF);
        if (isSwapAvailable()) {
            mCompcachePref.setChecked(SystemProperties.getBoolean(COMPCACHE_PROP, false));
	    if (SystemProperties.get(COMPCACHE_PERSIST_PROP) == "1")
                SystemProperties.set(COMPCACHE_PERSIST_PROP, COMPCACHE_DEFAULT);
            mCompcachePref.setValue(SystemProperties.get(COMPCACHE_PERSIST_PROP, COMPCACHE_DEFAULT));
            mCompcachePref.setOnPreferenceChangeListener(this);
        } else {
            prefSet.removePreference(mCompcachePref);
        }
@@ -122,14 +127,8 @@ public class PerformanceSettingsActivity extends PreferenceActivity implements P

        alertDialog.show();
    }
    
    @Override
    public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
        if (preference == mCompcachePref) {
            SystemProperties.set(COMPCACHE_PROP, mCompcachePref.isChecked() ? "1" : "0");
            return true;
        }
        
	if (preference == mJitPref) {
            SystemProperties.set(JIT_PERSIST_PROP,
                    mJitPref.isChecked() ? JIT_ENABLED : JIT_DISABLED);
@@ -164,6 +163,14 @@ public class PerformanceSettingsActivity extends PreferenceActivity implements P
                return true;
            }
        }

        if (preference == mCompcachePref) {
            if (newValue != null) {
                SystemProperties.set(COMPCACHE_PERSIST_PROP, (String)newValue);
                return true;
	    }
        }

        return false;
    }