Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
blade2: sync with skate
  • Loading branch information
Daz Jones committed Feb 18, 2013
1 parent 14bbe65 commit 28701a3
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 63 deletions.
35 changes: 9 additions & 26 deletions CrescentParts/src/com/cyanogenmod/settings/device/CrescentPartsStartup.java 100755 → 100644
Expand Up @@ -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);
}
}
53 changes: 16 additions & 37 deletions CrescentParts/src/com/cyanogenmod/settings/device/DeviceSettings.java 100755 → 100644
Expand Up @@ -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);
}
}
44 changes: 44 additions & 0 deletions CrescentParts/src/com/cyanogenmod/settings/device/Utils.java
@@ -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);
}
}
}
}
}
10 changes: 10 additions & 0 deletions ramdisk/init.blade2.rc
Expand Up @@ -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
Expand Down

0 comments on commit 28701a3

Please sign in to comment.