summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BoardConfig.mk4
-rw-r--r--GNexusParts/Android.mk15
-rw-r--r--GNexusParts/AndroidManifest.xml31
-rw-r--r--GNexusParts/res/drawable/color_tuning_preview.xml9
-rwxr-xr-xGNexusParts/res/drawable/ic_launcher_cmdevicesettings.pngbin0 -> 8207 bytes
-rw-r--r--GNexusParts/res/layout/preference_dialog_color_tuning.xml92
-rw-r--r--GNexusParts/res/layout/preference_dialog_gamma_tuning.xml92
-rwxr-xr-xGNexusParts/res/layout/top.xml5
-rw-r--r--GNexusParts/res/values-ja/strings.xml23
-rw-r--r--GNexusParts/res/values/strings.xml23
-rwxr-xr-xGNexusParts/res/xml/display_preferences.xml15
-rw-r--r--GNexusParts/res/xml/general_preferences.xml10
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java215
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java159
-rwxr-xr-xGNexusParts/src/com/cyanogenmod/settings/device/DisplayFragmentActivity.java50
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java211
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/GeneralFragmentActivity.java66
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/Hspa.java57
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/Startup.java18
-rw-r--r--GNexusParts/src/com/cyanogenmod/settings/device/Utils.java149
-rwxr-xr-xaudio/audio_hw.c7
-rwxr-xr-xinit.tuna.rc3
-rw-r--r--kernelbin3918788 -> 3072968 bytes
-rw-r--r--recovery_keys.c41
24 files changed, 1292 insertions, 3 deletions
diff --git a/BoardConfig.mk b/BoardConfig.mk
index b1a43ac..f1ba83e 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -77,3 +77,7 @@ BOARD_HAVE_BLUETOOTH_BCM := true
BOARD_LIB_DUMPSTATE := libdumpstate.tuna
BOARD_USES_SECURE_SERVICES := true
+
+BOARD_HAS_NO_SELECT_BUTTON := true
+BOARD_CUSTOM_RECOVERY_KEYMAPPING := ../../device/samsung/tuna/recovery_keys.c
+BOARD_USE_CUSTOM_RECOVERY_FONT := \"roboto_15x24.h\" \ No newline at end of file
diff --git a/GNexusParts/Android.mk b/GNexusParts/Android.mk
new file mode 100644
index 0000000..e934402
--- /dev/null
+++ b/GNexusParts/Android.mk
@@ -0,0 +1,15 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := GNexusParts
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/GNexusParts/AndroidManifest.xml b/GNexusParts/AndroidManifest.xml
new file mode 100644
index 0000000..12b1009
--- /dev/null
+++ b/GNexusParts/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.cyanogenmod.settings.device"
+ android:sharedUserId="android.uid.system" >
+
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+ <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
+
+ <application android:label="@string/app_name" >
+ <activity
+ android:name="com.cyanogenmod.settings.device.DeviceSettings"
+ android:icon="@drawable/ic_launcher_cmdevicesettings"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="com.cyanogenmod.action.LAUNCH_DEVICE_SETTINGS" />
+ <action android:name="android.intent.action.MAIN" />
+ </intent-filter>
+ </activity>
+
+ <receiver android:name=".Startup" >
+ <intent-filter android:priority="100" >
+ <action android:name="android.intent.action.BOOT_COMPLETED" />
+ </intent-filter>
+ </receiver>
+
+ <activity android:name=".GeneralFragmentActivity" />
+ <activity android:name=".DisplayFragmentActivity" />
+ <activity android:name=".SoundFragmentActivity" />
+ </application>
+
+</manifest>
diff --git a/GNexusParts/res/drawable/color_tuning_preview.xml b/GNexusParts/res/drawable/color_tuning_preview.xml
new file mode 100644
index 0000000..2d83c10
--- /dev/null
+++ b/GNexusParts/res/drawable/color_tuning_preview.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <gradient
+ android:angle="0"
+ android:startColor="#000000"
+ android:endColor="#FFFFFF" />
+</shape> \ No newline at end of file
diff --git a/GNexusParts/res/drawable/ic_launcher_cmdevicesettings.png b/GNexusParts/res/drawable/ic_launcher_cmdevicesettings.png
new file mode 100755
index 0000000..66de9c3
--- /dev/null
+++ b/GNexusParts/res/drawable/ic_launcher_cmdevicesettings.png
Binary files differ
diff --git a/GNexusParts/res/layout/preference_dialog_color_tuning.xml b/GNexusParts/res/layout/preference_dialog_color_tuning.xml
new file mode 100644
index 0000000..6154982
--- /dev/null
+++ b/GNexusParts/res/layout/preference_dialog_color_tuning.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:paddingBottom="20dip">
+
+ <TextView android:id="@+id/color_red_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/color_red_title"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <TextView android:id="@+id/color_red_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <SeekBar android:id="@+id/color_red_seekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/color_red_text"
+ android:paddingTop="2dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ <TextView android:id="@+id/color_green_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/color_red_seekbar"
+ android:text="@string/color_green_title"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <TextView android:id="@+id/color_green_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/color_red_seekbar"
+ android:layout_alignParentRight="true"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <SeekBar android:id="@+id/color_green_seekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/color_green_text"
+ android:paddingTop="2dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ <TextView android:id="@+id/color_blue_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/color_green_seekbar"
+ android:text="@string/color_blue_title"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <TextView android:id="@+id/color_blue_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/color_green_seekbar"
+ android:layout_alignParentRight="true"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <SeekBar android:id="@+id/color_blue_seekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/color_blue_text"
+ android:paddingTop="2dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ <ImageView android:src="@drawable/color_tuning_preview"
+ android:layout_width="match_parent"
+ android:layout_height="40dip"
+ android:layout_below="@id/color_blue_seekbar"
+ android:paddingTop="20dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ </RelativeLayout>
+</ScrollView> \ No newline at end of file
diff --git a/GNexusParts/res/layout/preference_dialog_gamma_tuning.xml b/GNexusParts/res/layout/preference_dialog_gamma_tuning.xml
new file mode 100644
index 0000000..3ece54b
--- /dev/null
+++ b/GNexusParts/res/layout/preference_dialog_gamma_tuning.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:paddingBottom="20dip">
+
+ <TextView android:id="@+id/gamma_red_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/color_red_title"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <TextView android:id="@+id/gamma_red_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentRight="true"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <SeekBar android:id="@+id/gamma_red_seekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/gamma_red_text"
+ android:paddingTop="2dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ <TextView android:id="@+id/gamma_green_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/gamma_red_seekbar"
+ android:text="@string/color_green_title"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <TextView android:id="@+id/gamma_green_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/gamma_red_seekbar"
+ android:layout_alignParentRight="true"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <SeekBar android:id="@+id/gamma_green_seekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/gamma_green_text"
+ android:paddingTop="2dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ <TextView android:id="@+id/gamma_blue_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/gamma_green_seekbar"
+ android:text="@string/color_blue_title"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <TextView android:id="@+id/gamma_blue_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/gamma_green_seekbar"
+ android:layout_alignParentRight="true"
+ android:paddingTop="10dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+ <SeekBar android:id="@+id/gamma_blue_seekbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/gamma_blue_text"
+ android:paddingTop="2dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ <ImageView android:src="@drawable/color_tuning_preview"
+ android:layout_width="match_parent"
+ android:layout_height="40dip"
+ android:layout_below="@id/gamma_blue_seekbar"
+ android:paddingTop="20dip"
+ android:paddingLeft="20dip"
+ android:paddingRight="20dip" />
+
+ </RelativeLayout>
+</ScrollView> \ No newline at end of file
diff --git a/GNexusParts/res/layout/top.xml b/GNexusParts/res/layout/top.xml
new file mode 100755
index 0000000..744b568
--- /dev/null
+++ b/GNexusParts/res/layout/top.xml
@@ -0,0 +1,5 @@
+<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/viewPager"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
diff --git a/GNexusParts/res/values-ja/strings.xml b/GNexusParts/res/values-ja/strings.xml
new file mode 100644
index 0000000..357a2d8
--- /dev/null
+++ b/GNexusParts/res/values-ja/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy Nexus 設定</string>
+
+ <!-- Page Headers -->
+ <string name="general_title">一般</string>
+ <string name="display_title">ディスプレイ</string>
+
+ <string name="category_cpu_title">CPU</string>
+ <string name="category_screen_title">WM8994設定 ( voodoo )</string>
+ <string name="color_tuning_title_head">カラーマルチプライヤチューニング</string>
+ <string name="color_tuning_summary_head">画面の色味を調整する</string>
+ <string name="gamma_tuning_title_head">カラーガンマ調整</string>
+ <string name="gamma_tuning_summary_head">カラーガンマ値を調整する</string>
+ <string name="color_red_title">赤</string>
+ <string name="color_green_title">緑</string>
+ <string name="color_blue_title">青</string>
+
+ <string name="category_radio_title">ラジオ</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">HSDPA/HSUPAを有効にする</string>
+
+</resources>
diff --git a/GNexusParts/res/values/strings.xml b/GNexusParts/res/values/strings.xml
new file mode 100644
index 0000000..b629e90
--- /dev/null
+++ b/GNexusParts/res/values/strings.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy Nexus Settings</string>
+
+ <!-- Page Headers -->
+ <string name="general_title">GENERAL</string>
+ <string name="display_title">DISPLAY</string>
+
+ <string name="category_cpu_title">CPU</string>
+ <string name="category_screen_title">WM8994 Settings ( voodoo )</string>
+ <string name="color_tuning_title_head">Color Multipliers Tuning</string>
+ <string name="color_tuning_summary_head">Calibrate multipliers screen color</string>
+ <string name="gamma_tuning_title_head">Color Gamma Tuning</string>
+ <string name="gamma_tuning_summary_head">Calibrate gamma color correction</string>
+ <string name="color_red_title">Red</string>
+ <string name="color_green_title">Green</string>
+ <string name="color_blue_title">Blue</string>
+
+ <string name="category_radio_title">Radio</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">Enable HSDPA/HSUPA</string>
+
+</resources>
diff --git a/GNexusParts/res/xml/display_preferences.xml b/GNexusParts/res/xml/display_preferences.xml
new file mode 100755
index 0000000..9772b20
--- /dev/null
+++ b/GNexusParts/res/xml/display_preferences.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/app_name">
+
+ <!-- Color tuning -->
+ <com.cyanogenmod.settings.device.ColorTuningPreference
+ android:key="color_tuning"
+ android:title="@string/color_tuning_title_head"
+ android:summary="@string/color_tuning_summary_head" />
+ <com.cyanogenmod.settings.device.GammaTuningPreference
+ android:key="gamma_tuning"
+ android:title="@string/gamma_tuning_title_head"
+ android:summary="@string/gamma_tuning_summary_head" />
+
+</PreferenceScreen>
diff --git a/GNexusParts/res/xml/general_preferences.xml b/GNexusParts/res/xml/general_preferences.xml
new file mode 100644
index 0000000..fc07c42
--- /dev/null
+++ b/GNexusParts/res/xml/general_preferences.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+
+ <!-- General settings -->
+ <PreferenceCategory android:key="category_cpu"
+ android:title="@string/category_cpu_title">
+
+ </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java b/GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java
new file mode 100644
index 0000000..085cae7
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/ColorTuningPreference.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.preference.DialogPreference;
+import android.preference.PreferenceManager;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.SeekBar;
+import android.widget.TextView;
+import android.util.Log;
+
+/**
+ * Special preference type that allows configuration of both the ring volume and
+ * notification volume.
+ */
+public class ColorTuningPreference extends DialogPreference {
+
+ private static final String TAG = "COLOR...";
+
+ enum Colors {
+ RED, GREEN, BLUE
+ };
+
+ private static final int[] SEEKBAR_ID = new int[] {
+ R.id.color_red_seekbar, R.id.color_green_seekbar, R.id.color_blue_seekbar
+ };
+
+ private static final int[] VALUE_DISPLAY_ID = new int[] {
+ R.id.color_red_value, R.id.color_green_value, R.id.color_blue_value
+ };
+
+ private static final String[] FILE_PATH = new String[] {
+ "/sys/class/misc/samoled_color/red_multiplier",
+ "/sys/class/misc/samoled_color/green_multiplier",
+ "/sys/class/misc/samoled_color/blue_multiplier"
+ };
+
+ private ColorSeekBar mSeekBars[] = new ColorSeekBar[3];
+
+ // Align MAX_VALUE with Voodoo Control settings
+ private static final int MAX_VALUE = Integer.MAX_VALUE - 2;
+
+ // Track instances to know when to restore original color
+ // (when the orientation changes, a new dialog is created before the old one
+ // is destroyed)
+ private static int sInstances = 0;
+
+ public ColorTuningPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ setDialogLayoutResource(R.layout.preference_dialog_color_tuning);
+ }
+
+ @Override
+ protected void onBindDialogView(View view) {
+ super.onBindDialogView(view);
+
+ sInstances++;
+
+ for (int i = 0; i < SEEKBAR_ID.length; i++) {
+ SeekBar seekBar = (SeekBar) view.findViewById(SEEKBAR_ID[i]);
+ TextView valueDisplay = (TextView) view.findViewById(VALUE_DISPLAY_ID[i]);
+ mSeekBars[i] = new ColorSeekBar(seekBar, valueDisplay, FILE_PATH[i]);
+ }
+ }
+
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ super.onDialogClosed(positiveResult);
+
+ sInstances--;
+
+ if (positiveResult) {
+ for (ColorSeekBar csb : mSeekBars) {
+ csb.save();
+ }
+ } else if (sInstances == 0) {
+ for (ColorSeekBar csb : mSeekBars) {
+ csb.reset();
+ }
+ }
+ }
+
+ /**
+ * Restore screen color tuning from SharedPreferences. (Write to kernel.)
+ *
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ int iValue, iValue2;
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ for (String filePath : FILE_PATH) {
+ String sDefaultValue = Utils.readOneLine(filePath);
+ Log.d(TAG,"INIT: " + sDefaultValue);
+ try {
+ iValue2 = Integer.parseInt(sDefaultValue);
+ } catch (NumberFormatException e) {
+ iValue2 = MAX_VALUE;
+ }
+ try {
+ iValue = sharedPrefs.getInt(filePath, iValue2);
+ Log.d(TAG, "restore: iValue: " + iValue + " File: " + filePath);
+ } catch (NumberFormatException e) {
+ iValue = iValue2;
+ Log.e(TAG, "restore ERROR: iValue: " + iValue + " File: " + filePath);
+ }
+ Utils.writeColor(filePath, (int) iValue);
+ }
+ }
+
+ /**
+ * Check whether the running kernel supports color tuning or not.
+ *
+ * @return Whether color tuning is supported or not
+ */
+ public static boolean isSupported() {
+ boolean supported = true;
+ for (String filePath : FILE_PATH) {
+ if (!Utils.fileExists(filePath)) {
+ supported = false;
+ }
+ }
+
+ return supported;
+ }
+
+ class ColorSeekBar implements SeekBar.OnSeekBarChangeListener {
+
+ private String mFilePath;
+
+ private int mOriginal;
+
+ private SeekBar mSeekBar;
+
+ private TextView mValueDisplay;
+
+ public ColorSeekBar(SeekBar seekBar, TextView valueDisplay, String filePath) {
+ int iValue;
+
+ mSeekBar = seekBar;
+ mValueDisplay = valueDisplay;
+ mFilePath = filePath;
+
+ SharedPreferences sharedPreferences = getSharedPreferences();
+
+ // Read original value
+ if (Utils.fileExists(mFilePath)) {
+ String sDefaultValue = Utils.readOneLine(mFilePath);
+ iValue = (int) (Long.valueOf(sDefaultValue) / 2);
+ } else {
+ iValue = sharedPreferences.getInt(mFilePath, MAX_VALUE);
+ }
+ mOriginal = iValue;
+
+ mSeekBar.setMax(MAX_VALUE);
+ reset();
+ mSeekBar.setOnSeekBarChangeListener(this);
+ }
+
+ public void reset() {
+ mSeekBar.setProgress(mOriginal);
+ updateValue(mOriginal);
+ }
+
+ public void save() {
+ Editor editor = getEditor();
+ editor.putInt(mFilePath, mSeekBar.getProgress());
+ editor.commit();
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ Utils.writeColor(mFilePath, progress);
+ updateValue(progress);
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+
+ private void updateValue(int progress) {
+ mValueDisplay.setText(String.format("%.10f", (double) progress / MAX_VALUE));
+ }
+
+ }
+
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java b/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
new file mode 100644
index 0000000..e131654
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.app.ActionBar;
+import android.app.ActionBar.Tab;
+import android.app.ActionBar.TabListener;
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.support.v13.app.FragmentPagerAdapter;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.view.ViewPager;
+
+import com.cyanogenmod.settings.device.R;
+
+import java.util.ArrayList;
+
+public class DeviceSettings extends Activity {
+
+ public static final String SHARED_PREFERENCES_BASENAME = "com.cyanogenmod.settings.device";
+ public static final String ACTION_UPDATE_PREFERENCES = "com.cyanogenmod.settings.device.UPDATE";
+ public static final String KEY_COLOR_TUNING = "color_tuning";
+ public static final String KEY_GAMMA_TUNING = "gamma_tuning";
+ public static final String KEY_CATEGORY_RADIO = "category_radio";
+ public static final String KEY_HSPA = "hspa";
+
+ ViewPager mViewPager;
+ TabsAdapter mTabsAdapter;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mViewPager = new ViewPager(this);
+ mViewPager.setId(R.id.viewPager);
+ setContentView(mViewPager);
+
+ final ActionBar bar = getActionBar();
+ bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
+ bar.setTitle(R.string.app_name);
+
+ mTabsAdapter = new TabsAdapter(this, mViewPager);
+ mTabsAdapter.addTab(bar.newTab().setText(R.string.display_title),
+ DisplayFragmentActivity.class, null);
+ mTabsAdapter.addTab(bar.newTab().setText(R.string.general_title),
+ GeneralFragmentActivity.class, null);
+
+ if (savedInstanceState != null) {
+ bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
+ }
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putInt("tab", getActionBar().getSelectedNavigationIndex());
+ }
+
+ public static class TabsAdapter extends FragmentPagerAdapter
+ implements ActionBar.TabListener, ViewPager.OnPageChangeListener {
+ private final Context mContext;
+ private final ActionBar mActionBar;
+ private final ViewPager mViewPager;
+ private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
+
+ static final class TabInfo {
+ private final Class<?> clss;
+ private final Bundle args;
+
+ TabInfo(Class<?> _class, Bundle _args) {
+ clss = _class;
+ args = _args;
+ }
+ }
+
+ public TabsAdapter(Activity activity, ViewPager pager) {
+ super(activity.getFragmentManager());
+ mContext = activity;
+ mActionBar = activity.getActionBar();
+ mViewPager = pager;
+ mViewPager.setAdapter(this);
+ mViewPager.setOnPageChangeListener(this);
+ }
+
+ public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) {
+ TabInfo info = new TabInfo(clss, args);
+ tab.setTag(info);
+ tab.setTabListener(this);
+ mTabs.add(info);
+ mActionBar.addTab(tab);
+ notifyDataSetChanged();
+ }
+
+ @Override
+ public int getCount() {
+ return mTabs.size();
+ }
+
+ @Override
+ public Fragment getItem(int position) {
+ TabInfo info = mTabs.get(position);
+ return Fragment.instantiate(mContext, info.clss.getName(), info.args);
+ }
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ mActionBar.setSelectedNavigationItem(position);
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+ }
+
+ @Override
+ public void onTabSelected(Tab tab, FragmentTransaction ft) {
+ Object tag = tab.getTag();
+ for (int i=0; i<mTabs.size(); i++) {
+ if (mTabs.get(i) == tag) {
+ mViewPager.setCurrentItem(i);
+ }
+ }
+ }
+
+ @Override
+ public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+ }
+
+ @Override
+ public void onTabReselected(Tab tab, FragmentTransaction ft) {
+ }
+ }
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/DisplayFragmentActivity.java b/GNexusParts/src/com/cyanogenmod/settings/device/DisplayFragmentActivity.java
new file mode 100755
index 0000000..b2ae578
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/DisplayFragmentActivity.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.cyanogenmod.settings.device.R;
+
+public class DisplayFragmentActivity extends PreferenceFragment {
+
+ private ColorTuningPreference mColorTuning;
+ private GammaTuningPreference mGammaTuning;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.display_preferences);
+
+ mColorTuning = (ColorTuningPreference) findPreference(DeviceSettings.KEY_COLOR_TUNING);
+ mColorTuning.setEnabled(ColorTuningPreference.isSupported());
+
+ mGammaTuning = (GammaTuningPreference) findPreference(DeviceSettings.KEY_GAMMA_TUNING);
+ mGammaTuning.setEnabled(GammaTuningPreference.isSupported());
+ }
+
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java b/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java
new file mode 100644
index 0000000..bfbc62e
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/GammaTuningPreference.java
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.preference.DialogPreference;
+import android.preference.PreferenceManager;
+import android.util.AttributeSet;
+import android.view.View;
+import android.widget.SeekBar;
+import android.widget.TextView;
+
+/**
+ * Special preference type that allows configuration of both the ring volume and
+ * notification volume.
+ */
+public class GammaTuningPreference extends DialogPreference {
+
+ private static final String TAG = "GAMMA...";
+
+ enum Colors {
+ RED, GREEN, BLUE
+ };
+
+ private static final int[] SEEKBAR_ID = new int[] {
+ R.id.gamma_red_seekbar, R.id.gamma_green_seekbar, R.id.gamma_blue_seekbar
+ };
+
+ private static final int[] VALUE_DISPLAY_ID = new int[] {
+ R.id.gamma_red_value, R.id.gamma_green_value, R.id.gamma_blue_value
+ };
+
+ private static final String[] FILE_PATH = new String[] {
+ "/sys/class/misc/samoled_color/red_v1_offset",
+ "/sys/class/misc/samoled_color/green_v1_offset",
+ "/sys/class/misc/samoled_color/blue_v1_offset"
+ };
+
+ private GammaSeekBar mSeekBars[] = new GammaSeekBar[3];
+
+ private static final int MAX_VALUE = 80;
+
+ private static final int OFFSET_VALUE = 0;
+
+ // Track instances to know when to restore original color
+ // (when the orientation changes, a new dialog is created before the old one
+ // is destroyed)
+ private static int sInstances = 0;
+
+ public GammaTuningPreference(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ setDialogLayoutResource(R.layout.preference_dialog_gamma_tuning);
+ }
+
+ @Override
+ protected void onBindDialogView(View view) {
+ super.onBindDialogView(view);
+
+ sInstances++;
+
+ for (int i = 0; i < SEEKBAR_ID.length; i++) {
+ SeekBar seekBar = (SeekBar) view.findViewById(SEEKBAR_ID[i]);
+ TextView valueDisplay = (TextView) view.findViewById(VALUE_DISPLAY_ID[i]);
+ mSeekBars[i] = new GammaSeekBar(seekBar, valueDisplay, FILE_PATH[i]);
+ }
+ }
+
+ @Override
+ protected void onDialogClosed(boolean positiveResult) {
+ super.onDialogClosed(positiveResult);
+
+ sInstances--;
+
+ if (positiveResult) {
+ for (GammaSeekBar csb : mSeekBars) {
+ csb.save();
+ }
+ } else if (sInstances == 0) {
+ for (GammaSeekBar csb : mSeekBars) {
+ csb.reset();
+ }
+ }
+ }
+
+ /**
+ * Restore screen color tuning from SharedPreferences. (Write to kernel.)
+ *
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ for (String filePath : FILE_PATH) {
+ String sDefaultValue = Utils.readOneLine(filePath);
+ int iValue = sharedPrefs.getInt(filePath, Integer.valueOf(sDefaultValue));
+ Utils.writeValue(filePath, String.valueOf((long) iValue));
+ }
+ }
+
+ /**
+ * Check whether the running kernel supports color tuning or not.
+ *
+ * @return Whether color tuning is supported or not
+ */
+ public static boolean isSupported() {
+ boolean supported = true;
+ for (String filePath : FILE_PATH) {
+ if (!Utils.fileExists(filePath)) {
+ supported = false;
+ }
+ }
+
+ return supported;
+ }
+
+ class GammaSeekBar implements SeekBar.OnSeekBarChangeListener {
+
+ private String mFilePath;
+
+ private int mOriginal;
+
+ private SeekBar mSeekBar;
+
+ private TextView mValueDisplay;
+
+ public GammaSeekBar(SeekBar seekBar, TextView valueDisplay, String filePath) {
+ int iValue;
+
+ mSeekBar = seekBar;
+ mValueDisplay = valueDisplay;
+ mFilePath = filePath;
+
+ SharedPreferences sharedPreferences = getSharedPreferences();
+
+ // Read original value
+ if (Utils.fileExists(mFilePath)) {
+ String sDefaultValue = Utils.readOneLine(mFilePath);
+ iValue = Integer.valueOf(sDefaultValue);
+ } else {
+ iValue = MAX_VALUE - OFFSET_VALUE;
+ }
+ mOriginal = iValue;
+
+ mSeekBar.setMax(MAX_VALUE);
+ reset();
+ mSeekBar.setOnSeekBarChangeListener(this);
+ }
+
+ public void reset() {
+ int iValue;
+
+ iValue = mOriginal + OFFSET_VALUE;
+ mSeekBar.setProgress(iValue);
+ updateValue(mOriginal);
+ }
+
+ public void save() {
+ int iValue;
+
+ iValue = mSeekBar.getProgress() - OFFSET_VALUE;
+ Editor editor = getEditor();
+ editor.putInt(mFilePath, iValue);
+ editor.commit();
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ int iValue;
+
+ iValue = progress - OFFSET_VALUE;
+ Utils.writeValue(mFilePath, String.valueOf((long) iValue));
+ updateValue(iValue);
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ // Do nothing
+ }
+
+ private void updateValue(int progress) {
+ mValueDisplay.setText(String.format("%d", (int) progress));
+ }
+
+ }
+
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/GeneralFragmentActivity.java b/GNexusParts/src/com/cyanogenmod/settings/device/GeneralFragmentActivity.java
new file mode 100644
index 0000000..ca1b155
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/GeneralFragmentActivity.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.PreferenceScreen;
+import android.util.Log;
+
+import com.cyanogenmod.settings.device.R;
+
+public class GeneralFragmentActivity extends PreferenceFragment {
+
+ private static final String PREF_ENABLED = "1";
+ private static final String TAG = "GNexusParts_General";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.general_preferences);
+
+ PreferenceScreen prefSet = getPreferenceScreen();
+
+ }
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+
+ String boxValue;
+ String key = preference.getKey();
+
+ Log.w(TAG, "key: " + key);
+
+ return true;
+ }
+
+ public static boolean isSupported(String FILE) {
+ return Utils.fileExists(FILE);
+ }
+
+ public static void restore(Context context) {
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ }
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/Hspa.java b/GNexusParts/src/com/cyanogenmod/settings/device/Hspa.java
new file mode 100644
index 0000000..cc47307
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/Hspa.java
@@ -0,0 +1,57 @@
+package com.cyanogenmod.settings.device;
+
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.SystemProperties;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class Hspa implements OnPreferenceChangeListener {
+
+ private static final String APK_FILE = "/system/app/SamsungServiceMode.apk";
+ private static final String HSPA_PROP = "ro.gnexusparts.rild.hspa";
+ private static final String HSPA_PROP_ENABLED = "1";
+
+ private Context mCtx;
+
+ public Hspa(Context context) {
+ mCtx = context;
+ }
+
+ public static boolean isSupported() {
+ String mHspa = SystemProperties.get(HSPA_PROP,"0");
+ if (mHspa.equals(HSPA_PROP_ENABLED)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Restore HSPA setting from SharedPreferences. (Write to kernel.)
+ * @param context The context to read the SharedPreferences from
+ */
+ public static void restore(Context context) {
+ if (!isSupported()) {
+ return;
+ }
+
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ sendIntent(context, sharedPrefs.getString(DeviceSettings.KEY_HSPA, "23"));
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ sendIntent(mCtx, (String) newValue);
+ return true;
+ }
+
+ private static void sendIntent(Context context, String value) {
+ Intent i = new Intent("com.cyanogenmod.SamsungServiceMode.EXECUTE");
+ i.putExtra("sub_type", 20); // HSPA Setting
+ i.putExtra("data", value);
+ context.sendBroadcast(i);
+ }
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/Startup.java b/GNexusParts/src/com/cyanogenmod/settings/device/Startup.java
new file mode 100644
index 0000000..302e951
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/Startup.java
@@ -0,0 +1,18 @@
+package com.cyanogenmod.settings.device;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class Startup extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(final Context context, final Intent bootintent) {
+ ColorTuningPreference.restore(context);
+ GammaTuningPreference.restore(context);
+ GeneralFragmentActivity.restore(context);
+ if (Hspa.isSupported()) {
+ Hspa.restore(context);
+ }
+ }
+}
diff --git a/GNexusParts/src/com/cyanogenmod/settings/device/Utils.java b/GNexusParts/src/com/cyanogenmod/settings/device/Utils.java
new file mode 100644
index 0000000..dbf2947
--- /dev/null
+++ b/GNexusParts/src/com/cyanogenmod/settings/device/Utils.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2011 The CyanogenMod Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cyanogenmod.settings.device;
+
+import android.util.Log;
+
+import java.io.BufferedReader;
+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 = "GNexusParts_Utils";
+ private static final String TAG_READ = "GNexusParts_Utils_Read";
+ private static final String TAG_WRITE = "GNexusParts_Utils_Write";
+
+ /**
+ * Write a string value to the specified file.
+ *
+ * @param filename The filename
+ * @param value The value
+ */
+ public static void writeValue(String filename, String value) {
+ FileOutputStream fos = null;
+ try {
+ fos = new FileOutputStream(new File(filename), false);
+ fos.write(value.getBytes());
+ fos.flush();
+ // fos.getFD().sync();
+ } catch (FileNotFoundException ex) {
+ Log.w(TAG, "file " + filename + " not found: " + ex);
+ } catch (SyncFailedException ex) {
+ Log.w(TAG, "file " + filename + " sync failed: " + ex);
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException trying to sync " + filename + ": " + ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while syncing file: ", ex);
+ } finally {
+ if (fos != null) {
+ try {
+ Log.w(TAG_WRITE, "file " + filename + ": " + 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);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Write a string value to the specified file.
+ *
+ * @param filename The filename
+ * @param value The value
+ */
+ public static void writeValue(String filename, Boolean value) {
+ FileOutputStream fos = null;
+ String sEnvia;
+ try {
+ fos = new FileOutputStream(new File(filename), false);
+ if (value)
+ sEnvia = "1";
+ else
+ sEnvia = "0";
+ fos.write(sEnvia.getBytes());
+ fos.flush();
+ // fos.getFD().sync();
+ } catch (FileNotFoundException ex) {
+ Log.w(TAG, "file " + filename + " not found: " + ex);
+ } catch (SyncFailedException ex) {
+ Log.w(TAG, "file " + filename + " sync failed: " + ex);
+ } catch (IOException ex) {
+ Log.w(TAG, "IOException trying to sync " + filename + ": " + ex);
+ } catch (RuntimeException ex) {
+ Log.w(TAG, "exception while syncing file: ", ex);
+ } finally {
+ if (fos != null) {
+ try {
+ Log.w(TAG_WRITE, "file " + filename + ": " + 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);
+ }
+ }
+ }
+ }
+
+ /**
+ * Write the "color value" to the specified file. The value is scaled from
+ * an integer to an unsigned integer by multiplying by 2.
+ *
+ * @param filename The filename
+ * @param value The value of max value Integer.MAX
+ */
+ public static void writeColor(String filename, int value) {
+ writeValue(filename, String.valueOf((long) value * 2));
+ }
+
+ /**
+ * Check if the specified file exists.
+ *
+ * @param filename The filename
+ * @return Whether the file exists or not
+ */
+ public static boolean fileExists(String filename) {
+ return new File(filename).exists();
+ }
+
+ // Read value from sysfs interface
+ public static String readOneLine(String sFile) {
+ BufferedReader brBuffer;
+ String sLine = null;
+
+ try {
+ brBuffer = new BufferedReader(new FileReader(sFile), 512);
+ try {
+ sLine = brBuffer.readLine();
+ } finally {
+ Log.w(TAG_READ, "file " + sFile + ": " + sLine);
+ brBuffer.close();
+ }
+ } catch (Exception e) {
+ Log.e(TAG_READ, "IO Exception when reading /sys/ file", e);
+ }
+ return sLine;
+ }
+}
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 850a1b1..310bce7 100755
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -1,4 +1,5 @@
/*
+ * Portions Copyright (C) 2012 VMware, Inc. All Rights Reserved.
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -182,8 +183,8 @@
#define VOICE_CALL_HEADSET_MIC_VOLUME 8
/* use-case specific output volumes */
-#define NORMAL_SPEAKER_VOLUME_TORO 4
-#define NORMAL_SPEAKER_VOLUME_MAGURO 2
+#define NORMAL_SPEAKER_VOLUME_TORO 9
+#define NORMAL_SPEAKER_VOLUME_MAGURO 7
#define NORMAL_HEADSET_VOLUME_TORO -12
#define NORMAL_HEADSET_VOLUME_MAGURO -12
#define NORMAL_HEADPHONE_VOLUME_TORO -6 /* allow louder output for headphones */
@@ -192,7 +193,7 @@
#define NORMAL_EARPIECE_VOLUME_MAGURO -2
#define VOICE_CALL_SPEAKER_VOLUME_TORO 9
-#define VOICE_CALL_SPEAKER_VOLUME_MAGURO 6
+#define VOICE_CALL_SPEAKER_VOLUME_MAGURO 7
#define VOICE_CALL_HEADSET_VOLUME_TORO -6
#define VOICE_CALL_HEADSET_VOLUME_MAGURO 0
#define VOICE_CALL_EARPIECE_VOLUME_TORO 2
diff --git a/init.tuna.rc b/init.tuna.rc
index 70f1cbe..129aa3f 100755
--- a/init.tuna.rc
+++ b/init.tuna.rc
@@ -83,6 +83,9 @@ on fs
# add symlink for HDCP key
symlink /factory/hdcp.keys /system/vendor/firmware/hdcp.keys
+# allow to modify Wifi power behaviour in terms of battery/speed at sleep time
+ chown root system sys/module/bcmdhd/parameters/uiFastWifi
+
# nfc
setprop ro.nfc.port "COM4"
chmod 0600 /dev/ttyO3
diff --git a/kernel b/kernel
index c10bd3f..a960b5f 100644
--- a/kernel
+++ b/kernel
Binary files differ
diff --git a/recovery_keys.c b/recovery_keys.c
new file mode 100644
index 0000000..013c169
--- /dev/null
+++ b/recovery_keys.c
@@ -0,0 +1,41 @@
+#include <linux/input.h>
+
+#include "recovery_ui.h"
+#include "common.h"
+#include "extendedcommands.h"
+
+
+int device_toggle_display(volatile char* key_pressed, int key_code) {
+ int alt = key_pressed[KEY_LEFTALT] || key_pressed[KEY_RIGHTALT];
+ if (alt && key_code == KEY_L)
+ return 1;
+ // allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off
+ if (ui_get_showing_back_button()) {
+ return 0;
+ //return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END);
+ }
+ return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END);
+}
+
+int device_handle_key(int key_code, int visible) {
+ if (visible) {
+ switch (key_code) {
+ case KEY_VOLUMEDOWN:
+ return HIGHLIGHT_DOWN;
+
+ case KEY_VOLUMEUP:
+ return HIGHLIGHT_UP;
+
+ case KEY_POWER:
+ if (ui_get_showing_back_button()) {
+ return SELECT_ITEM;
+ }
+ if (!get_allow_toggle_display())
+ return GO_BACK;
+ break;
+ return SELECT_ITEM;
+ }
+ }
+
+ return NO_ACTION;
+}