Skip to content
Permalink
Browse files

blade2: sync with skate

  • Loading branch information
Dazzozo committed Feb 18, 2013
1 parent 14bbe65 commit 28701a3f57a98b0bd8e5ddbb65d688b98b3f2963
@@ -5,34 +5,17 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class CrescentPartsStartup extends BroadcastReceiver
{
private void writeValue(String parameter, int value) {
try {
FileOutputStream fos = new FileOutputStream(new File(parameter));
fos.write(String.valueOf(value).getBytes());
fos.flush();
fos.getFD().sync();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onReceive(final Context context, final Intent bootintent) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

@Override
public void onReceive(final Context context, final Intent bootintent) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// USB charging
if(prefs.getBoolean("usb_charging", true))
writeValue("/sys/module/msm_battery/parameters/usb_chg_enable", 1);
else
writeValue("/sys/module/msm_battery/parameters/usb_chg_enable", 0);
}
// USB charging
if(prefs.getBoolean("usb_charging", true))
Utils.writeValue("/sys/module/msm_battery/parameters/usb_chg_enable", 1);
else
Utils.writeValue("/sys/module/msm_battery/parameters/usb_chg_enable", 0);
}
}
@@ -7,42 +7,21 @@
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class DeviceSettings extends PreferenceActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

addPreferencesFromResource(R.xml.crescentparts);
}

private void writeValue(String parameter, int value) {
try {
FileOutputStream fos = new FileOutputStream(new File(parameter));
fos.write(String.valueOf(value).getBytes());
fos.flush();
fos.getFD().sync();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void onPause() {
super.onPause();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
// USB charging
if(prefs.getBoolean("usb_charging", true))
writeValue("/sys/module/msm_battery/parameters/usb_chg_enable", 1);
else
writeValue("/sys/module/msm_battery/parameters/usb_chg_enable", 0);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.crescentparts);
}

@Override
public void onPause() {
super.onPause();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
// USB charging
if(prefs.getBoolean("usb_charging", true))
Utils.writeValue("/sys/module/msm_battery/parameters/usb_chg_enable", 1);
else
Utils.writeValue("/sys/module/msm_battery/parameters/usb_chg_enable", 0);
}
}
@@ -0,0 +1,44 @@
package com.cyanogenmod.settings.device;

import android.util.Log;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.SyncFailedException;

public class Utils
{
private static final String TAG = "CrescentParts";

public static void writeValue(String parameter, int value) {
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File(parameter));
fos.write(String.valueOf(value).getBytes());
fos.flush();
// fos.getFD().sync();
} catch (FileNotFoundException ex) {
Log.w(TAG, "file " + parameter + " not found: " + ex);
} catch (SyncFailedException ex) {
Log.w(TAG, "file " + parameter + " sync failed: " + ex);
} catch (IOException ex) {
Log.w(TAG, "IOException trying to sync " + parameter + ": " + ex);
} catch (RuntimeException ex) {
Log.w(TAG, "exception while syncing file: ", ex);
} finally {
if (fos != null) {
try {
Log.w(TAG, "file " + parameter + ": " + value);
fos.close();
} catch (IOException ex) {
Log.w(TAG, "IOException while closing synced file: ", ex);
} catch (RuntimeException ex) {
Log.w(TAG, "exception while closing file: ", ex);
}
}
}
}
}
@@ -12,10 +12,20 @@ on boot

# Setup boostpulse
write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ondemand

chown system system /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
chown system system /sys/devices/system/cpu/cpufreq/ondemand/boostpulse
chown system system /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
chown system system /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy
chown system system /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
chown system system /sys/devices/system/cpu/cpufreq/ondemand/down_differential

chmod 0666 /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
chmod 0666 /sys/devices/system/cpu/cpufreq/ondemand/boostpulse
chmod 0666 /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
chmod 0666 /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy
chmod 0666 /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
chmod 0666 /sys/devices/system/cpu/cpufreq/ondemand/down_differential

# cpufreq configurations
write /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate 500000

0 comments on commit 28701a3

Please sign in to comment.
You can’t perform that action at this time.