summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2012-06-16 14:37:55 +0200
committerDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2012-06-16 14:37:55 +0200
commitfabb781b25fdb90ffaf70fd359fea7ca3e014956 (patch)
tree7baf35ecf19bc07e2d43c14a773d5011aae7e595
parente794169ae3ab7c6002373aaf48a827cf6a5583f4 (diff)
downloaddevice_samsung_i9300-fabb781b25fdb90ffaf70fd359fea7ca3e014956.zip
device_samsung_i9300-fabb781b25fdb90ffaf70fd359fea7ca3e014956.tar.gz
device_samsung_i9300-fabb781b25fdb90ffaf70fd359fea7ca3e014956.tar.bz2
added device specific settings
-rw-r--r--DeviceSettings/Android.mk15
-rw-r--r--DeviceSettings/AndroidManifest.xml30
-rwxr-xr-xDeviceSettings/res/drawable/ic_launcher_cmdevicesettings.pngbin0 -> 8207 bytes
-rwxr-xr-xDeviceSettings/res/layout/top.xml5
-rw-r--r--DeviceSettings/res/values-de/arrays.xml17
-rw-r--r--DeviceSettings/res/values-de/strings.xml13
-rw-r--r--DeviceSettings/res/values/arrays.xml31
-rw-r--r--DeviceSettings/res/values/strings.xml13
-rw-r--r--DeviceSettings/res/xml/haptic_preferences.xml13
-rw-r--r--DeviceSettings/res/xml/radio_preferences.xml12
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java145
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java66
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java67
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java66
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java32
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java79
-rw-r--r--DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java59
-rw-r--r--galaxys3_base.mk1
-rwxr-xr-xinit.smdk4x12.rc4
19 files changed, 667 insertions, 1 deletions
diff --git a/DeviceSettings/Android.mk b/DeviceSettings/Android.mk
new file mode 100644
index 0000000..12c8de5
--- /dev/null
+++ b/DeviceSettings/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 := GalaxyS3Settings
+LOCAL_CERTIFICATE := platform
+
+include $(BUILD_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/DeviceSettings/AndroidManifest.xml b/DeviceSettings/AndroidManifest.xml
new file mode 100644
index 0000000..d658983
--- /dev/null
+++ b/DeviceSettings/AndroidManifest.xml
@@ -0,0 +1,30 @@
+<?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=".mDNIeFragmentActivity" />
+ <activity android:name=".RadioFragmentActivity" />
+
+ </application>
+</manifest>
diff --git a/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png b/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png
new file mode 100755
index 0000000..66de9c3
--- /dev/null
+++ b/DeviceSettings/res/drawable/ic_launcher_cmdevicesettings.png
Binary files differ
diff --git a/DeviceSettings/res/layout/top.xml b/DeviceSettings/res/layout/top.xml
new file mode 100755
index 0000000..744b568
--- /dev/null
+++ b/DeviceSettings/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/DeviceSettings/res/values-de/arrays.xml b/DeviceSettings/res/values-de/arrays.xml
new file mode 100644
index 0000000..f3e59cb
--- /dev/null
+++ b/DeviceSettings/res/values-de/arrays.xml
@@ -0,0 +1,17 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Standard)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>Nur UMTS</item>
+ <item>Nur HSDPA</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+</resources>
diff --git a/DeviceSettings/res/values-de/strings.xml b/DeviceSettings/res/values-de/strings.xml
new file mode 100644
index 0000000..db6c767
--- /dev/null
+++ b/DeviceSettings/res/values-de/strings.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy S III Einstellungen</string>
+
+ <string name="category_haptic_title">Haptik</string>
+ <string name="vibrator_subcat_title">Vibrator</string>
+ <string name="vibrator_intensity_title_head">Vibrator Intensität</string>
+ <string name="vibrator_intensity_summary_head">Setze Vibrator Intensität</string>
+
+ <string name="category_radio_title">Mobilfunk</string>
+ <string name="hspa_title_head">HSPA</string>
+ <string name="hspa_summary_head">Aktiviere HSDPA/HSUPA</string>
+</resources>
diff --git a/DeviceSettings/res/values/arrays.xml b/DeviceSettings/res/values/arrays.xml
new file mode 100644
index 0000000..25792a7
--- /dev/null
+++ b/DeviceSettings/res/values/arrays.xml
@@ -0,0 +1,31 @@
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+
+ <string-array name="vibrator_intensity_entries">
+ <item>0%</item>
+ <item>25%</item>
+ <item>50% (Default)</item>
+ <item>75%</item>
+ <item>100%</item>
+ </string-array>
+
+ <string-array name="vibrator_intensity_entries_values" translatable="false">
+ <item>0</item>
+ <item>25</item>
+ <item>50</item>
+ <item>75</item>
+ <item>100</item>
+ </string-array>
+
+ <string-array name="hspa_entries">
+ <item>UMTS Only</item>
+ <item>HSDPA Only</item>
+ <item>HSDPA + HSUPA</item>
+ </string-array>
+
+ <string-array name="hspa_entries_values" translatable="false">
+ <item>21</item>
+ <item>22</item>
+ <item>23</item>
+ </string-array>
+
+</resources>
diff --git a/DeviceSettings/res/values/strings.xml b/DeviceSettings/res/values/strings.xml
new file mode 100644
index 0000000..8f3e9b4
--- /dev/null
+++ b/DeviceSettings/res/values/strings.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">Galaxy S III Settings</string>
+
+ <string name="category_haptic_title">Haptic</string>
+ <string name="vibrator_subcat_title">Vibrator</string>
+ <string name="vibrator_intensity_title_head">Vibrator Intensity</string>
+ <string name="vibrator_intensity_summary_head">Set vibrator intensity</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/DeviceSettings/res/xml/haptic_preferences.xml b/DeviceSettings/res/xml/haptic_preferences.xml
new file mode 100644
index 0000000..31c0e21
--- /dev/null
+++ b/DeviceSettings/res/xml/haptic_preferences.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory
+ android:title="@string/vibrator_subcat_title">
+ <com.cyanogenmod.settings.device.VibratorIntensity
+ android:key="vibrator_intensity"
+ android:title="@string/vibrator_intensity_title_head"
+ android:summary="@string/vibrator_intensity_summary_head"
+ android:entries="@array/vibrator_intensity_entries"
+ android:entryValues="@array/vibrator_intensity_entries_values"
+ android:defaultValue="50" />
+ </PreferenceCategory>
+</PreferenceScreen>
diff --git a/DeviceSettings/res/xml/radio_preferences.xml b/DeviceSettings/res/xml/radio_preferences.xml
new file mode 100644
index 0000000..c173db7
--- /dev/null
+++ b/DeviceSettings/res/xml/radio_preferences.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Hspa modes -->
+ <com.cyanogenmod.settings.device.Hspa
+ android:key="hspa"
+ android:title="@string/hspa_title_head"
+ android:summary="@string/hspa_summary_head"
+ android:entries="@array/hspa_entries"
+ android:entryValues="@array/hspa_entries_values"
+ android:defaultValue="23" />
+
+</PreferenceScreen>
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
new file mode 100644
index 0000000..c3b7d99
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/DeviceSettings.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012 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.Activity;
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.support.v13.app.FragmentPagerAdapter;
+import android.support.v4.view.ViewPager;
+
+import com.cyanogenmod.settings.device.R;
+
+import java.util.ArrayList;
+
+public class DeviceSettings extends FragmentActivity {
+
+ 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_HSPA = "hspa";
+ public static final String KEY_VIBRATOR_INTENSITY = "vibrator_intensity";
+
+ 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.category_radio_title),
+ RadioFragmentActivity.class, null);
+ mTabsAdapter.addTab(bar.newTab().setText(R.string.category_haptic_title),
+ HapticFragmentActivity.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);
+ }
+
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ }
+
+ public void onPageSelected(int position) {
+ mActionBar.setSelectedNavigationItem(position);
+ }
+
+ public void onPageScrollStateChanged(int state) {
+ }
+
+ 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);
+ }
+ }
+ }
+
+ public void onTabUnselected(Tab tab, FragmentTransaction ft) {
+ }
+
+ public void onTabReselected(Tab tab, FragmentTransaction ft) {
+ }
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
new file mode 100644
index 0000000..527e931
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/HapticFragmentActivity.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 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 HapticFragmentActivity extends PreferenceFragment {
+
+ private static final String PREF_ENABLED = "1";
+ private static final String TAG = "GalaxyS3Parts_General";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.haptic_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/DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java
new file mode 100644
index 0000000..f19eff7
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Hspa.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 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.Intent;
+import android.content.SharedPreferences;
+import android.util.AttributeSet;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class Hspa extends ListPreference implements OnPreferenceChangeListener {
+
+ private static final String FILE = "/system/app/SamsungServiceMode.apk";
+ private Context mCtx;
+
+ public Hspa(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ mCtx = context;
+ }
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * 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"));
+ }
+
+ 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/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java
new file mode 100644
index 0000000..4d830b8
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/RadioFragmentActivity.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2012 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 RadioFragmentActivity extends PreferenceFragment {
+
+ private static final String PREF_ENABLED = "1";
+ private static final String TAG = "GalaxyS2Parts_General";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.radio_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/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
new file mode 100644
index 0000000..5073489
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Startup.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2012 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.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+public class Startup extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(final Context context, final Intent bootintent) {
+ HapticFragmentActivity.restore(context);
+ Hspa.restore(context);
+ RadioFragmentActivity.restore(context);
+ VibratorIntensity.restore(context);
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
new file mode 100644
index 0000000..9d4176c
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/Utils.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2012 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 java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Context;
+
+public class Utils {
+
+ /**
+ * Write a string value to the specified file.
+ * @param filename The filename
+ * @param value The value
+ */
+ public static void writeValue(String filename, String value) {
+ try {
+ FileOutputStream fos = new FileOutputStream(new File(filename));
+ fos.write(value.getBytes());
+ fos.flush();
+ fos.getFD().sync();
+ fos.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 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();
+ }
+
+
+ public static void showDialog(Context ctx, String title, String message) {
+ final AlertDialog alertDialog = new AlertDialog.Builder(ctx).create();
+ alertDialog.setTitle(title);
+ alertDialog.setMessage(message);
+ alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ alertDialog.dismiss();
+ }
+ });
+ alertDialog.show();
+ }
+}
diff --git a/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java
new file mode 100644
index 0000000..7a809a5
--- /dev/null
+++ b/DeviceSettings/src/com/cyanogenmod/settings/device/VibratorIntensity.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 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 java.io.IOException;
+import android.content.Context;
+import android.util.AttributeSet;
+import android.content.SharedPreferences;
+import android.preference.Preference;
+import android.preference.ListPreference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceManager;
+
+public class VibratorIntensity extends ListPreference implements OnPreferenceChangeListener {
+
+ public VibratorIntensity(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ this.setOnPreferenceChangeListener(this);
+ }
+
+ private static final String FILE = "/sys/vibrator/pwm_val";
+
+ public static boolean isSupported() {
+ return Utils.fileExists(FILE);
+ }
+
+ /**
+ * Restore vibrator intensity 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);
+ Utils.writeValue(FILE, sharedPrefs.getString(DeviceSettings.KEY_VIBRATOR_INTENSITY, "50"));
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ Utils.writeValue(FILE, (String) newValue);
+ return true;
+ }
+
+}
diff --git a/galaxys3_base.mk b/galaxys3_base.mk
index 682990f..5360cf5 100644
--- a/galaxys3_base.mk
+++ b/galaxys3_base.mk
@@ -66,6 +66,7 @@ PRODUCT_PACKAGES := \
camera.exynos4 \
Camera \
com.android.future.usb.accessory \
+ GalaxyS3Settings \
SamsungServiceMode \
Torch
diff --git a/init.smdk4x12.rc b/init.smdk4x12.rc
index af3777c..fab7594 100755
--- a/init.smdk4x12.rc
+++ b/init.smdk4x12.rc
@@ -96,9 +96,11 @@ on post-fs-data
chmod 0600 /dev/pn544
chown nfc nfc /dev/pn544
-# Vibetonz
+# Vibrator
chmod 0660 /dev/tspdrv
chown root shell /dev/tspdrv
+ chmod 0660 /sys/vibrator/pwm_val
+ chown system system /sys/vibrator/pwm_val
# Permissions for LCD
chown system radio /sys/class/lcd/panel/lcd_power