forked from arifhn/NSTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0566d4d
Showing
17 changed files
with
708 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="src" path="gen"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> | ||
<classpathentry kind="output" path="bin/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin | ||
gen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>NSTools</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.android.ide.eclipse.adt.ApkBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="mobi.cyann.nstools" | ||
android:versionCode="1" | ||
android:versionName="1.0" > | ||
|
||
<uses-sdk android:minSdkVersion="8" /> | ||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> | ||
|
||
<application | ||
android:icon="@drawable/ic_launcher" | ||
android:label="@string/app_name" > | ||
<activity | ||
android:label="@string/app_name" | ||
android:name="mobi.cyann.nstools.MainActivity" > | ||
<intent-filter > | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name="mobi.cyann.nstools.NSTweakActivity" /> | ||
|
||
<receiver android:name="mobi.cyann.nstools.BootCompleteReceiver"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.BOOT_COMPLETED" /> | ||
</intent-filter> | ||
</receiver> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/system/bin/sh | ||
|
||
# outputfile to save result | ||
OUT_FILE="/data/data/mobi.cyann.nstools/nstweak.prop" | ||
|
||
# empty the file | ||
echo "" > $OUT_FILE | ||
|
||
# bld | ||
STAT=`cat /sys/class/misc/backlightdimmer/enabled` | ||
if [ "$STAT" == "1" ] ; then | ||
echo "bld.status=1" >> $OUT_FILE | ||
echo "bld.delay=`cat /sys/class/misc/backlightdimmer/delay`" >> $OUT_FILE | ||
elif [ "$STAT" == "0" ] ; then | ||
echo "bld.status=0" >> $OUT_FILE | ||
echo "bld.delay=`cat /sys/class/misc/backlightdimmer/delay`" >> $OUT_FILE | ||
else | ||
echo "bld.status=-1" >> $OUT_FILE | ||
echo "bld.delay=0" >> $OUT_FILE | ||
fi | ||
|
||
# screen dimmer | ||
STAT=`cat /sys/class/misc/screendimmer/enabled` | ||
if [ "$STAT" == "1" ] ; then | ||
echo "screendimmer.status=1" >> $OUT_FILE | ||
echo "screendimmer.delay=`cat /sys/class/misc/screendimmer/delay`" >> $OUT_FILE | ||
elif [ "$STAT" == "0" ] ; then | ||
echo "screendimmer.status=0" >> $OUT_FILE | ||
echo "screendimmer.delay=`cat /sys/class/misc/screendimmer/delay`" >> $OUT_FILE | ||
else | ||
echo "screendimmer.status=-1" >> $OUT_FILE | ||
echo "screendimmer.delay=0" >> $OUT_FILE | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-optimizationpasses 5 | ||
-dontusemixedcaseclassnames | ||
-dontskipnonpubliclibraryclasses | ||
-dontpreverify | ||
-verbose | ||
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* | ||
|
||
-keep public class * extends android.app.Activity | ||
-keep public class * extends android.app.Application | ||
-keep public class * extends android.app.Service | ||
-keep public class * extends android.content.BroadcastReceiver | ||
-keep public class * extends android.content.ContentProvider | ||
-keep public class * extends android.app.backup.BackupAgentHelper | ||
-keep public class * extends android.preference.Preference | ||
-keep public class com.android.vending.licensing.ILicensingService | ||
|
||
-keepclasseswithmembernames class * { | ||
native <methods>; | ||
} | ||
|
||
-keepclasseswithmembers class * { | ||
public <init>(android.content.Context, android.util.AttributeSet); | ||
} | ||
|
||
-keepclasseswithmembers class * { | ||
public <init>(android.content.Context, android.util.AttributeSet, int); | ||
} | ||
|
||
-keepclassmembers class * extends android.app.Activity { | ||
public void *(android.view.View); | ||
} | ||
|
||
-keepclassmembers enum * { | ||
public static **[] values(); | ||
public static ** valueOf(java.lang.String); | ||
} | ||
|
||
-keep class * implements android.os.Parcelable { | ||
public static final android.os.Parcelable$Creator *; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file is automatically generated by Android Tools. | ||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||
# | ||
# This file must be checked in Version Control Systems. | ||
# | ||
# To customize properties used by the Ant build system use, | ||
# "ant.properties", and override values to adapt the script to your | ||
# project structure. | ||
|
||
# Project target. | ||
target=android-8 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@android:id/tabhost" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" > | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" > | ||
|
||
<TabWidget | ||
android:id="@android:id/tabs" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" /> | ||
|
||
<FrameLayout | ||
android:id="@android:id/tabcontent" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" /> | ||
</LinearLayout> | ||
|
||
</TabHost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="SCRIPT_DIR">/data/data/mobi.cyann.nstools/scripts/</string> | ||
<string name="SCRIPT_VERSION">1</string> | ||
<string-array name="scripts"> | ||
<item>read_ns_tweak.sh</item> | ||
</string-array> | ||
|
||
<string name="NS_TWEAK_FILE">/data/data/mobi.cyann.nstools/nstweak.prop</string> | ||
<string name="NS_TWEAK_SCRIPT">/data/data/mobi.cyann.nstools/scripts/read_ns_tweak.sh</string> | ||
<string name="NS_TEMP_SCRIPT">/data/data/mobi.cyann.nstools/temp.sh</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">NSTools</string> | ||
<string name="ns_tweak">Nexus-S Tweak</string> | ||
|
||
<string name="bld_tweak">Backlight Dimmer</string> | ||
<string name="key_bld_status">key_bld_status</string> | ||
<string name="key_bld_delay">key_bld_delay</string> | ||
|
||
<string name="screen_dimmer_tweak">Screen Dimmer</string> | ||
<string name="key_screen_dimmer_status">key_screen_dimmer_status</string> | ||
<string name="key_screen_dimmer_delay">key_screen_dimmer_delay</string> | ||
|
||
<string name="label_status">Status: %1$s</string> | ||
<string name="label_delay">Delay: %1$s</string> | ||
<string name="status_on"><b>ON</b></string> | ||
<string name="status_off"><b>OFF</b></string> | ||
<string name="status_not_supported"><i>not supported</i></string> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > | ||
|
||
<PreferenceCategory android:title="@string/bld_tweak" > | ||
|
||
<PreferenceScreen | ||
android:key="@string/key_bld_status" | ||
android:title="@string/label_status" /> | ||
|
||
<EditTextPreference | ||
android:key="@string/key_bld_delay" | ||
android:title="@string/label_delay" /> | ||
</PreferenceCategory> | ||
|
||
<PreferenceCategory android:title="@string/screen_dimmer_tweak" > | ||
|
||
<PreferenceScreen | ||
android:key="@string/key_screen_dimmer_status" | ||
android:title="@string/label_status" /> | ||
|
||
<EditTextPreference | ||
android:key="@string/key_screen_dimmer_delay" | ||
android:title="@string/label_delay" /> | ||
</PreferenceCategory> | ||
|
||
</PreferenceScreen> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package mobi.cyann.nstools; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
/** | ||
* @author arif | ||
* | ||
*/ | ||
public class BootCompleteReceiver extends BroadcastReceiver { | ||
|
||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
context.startService(new Intent(context, OnBootCompleteService.class)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package mobi.cyann.nstools; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import android.app.TabActivity; | ||
import android.content.Intent; | ||
import android.content.res.AssetManager; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.widget.TabHost; | ||
import android.widget.TabHost.TabSpec; | ||
|
||
public class MainActivity extends TabActivity { | ||
private final static String LOG_TAG = "NSTools.MainActivity"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// call extract | ||
extractScripts(); | ||
|
||
setContentView(R.layout.main); | ||
|
||
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost); | ||
|
||
TabSpec tab1 = tabHost.newTabSpec("tid1"); | ||
tab1.setIndicator(getString(R.string.ns_tweak)); | ||
tab1.setContent(new Intent(this, NSTweakActivity.class)); | ||
tabHost.addTab(tab1); | ||
//tabHost.addTab(tab2); | ||
//tabHost.addTab(tab3); | ||
} | ||
|
||
private void copyAsset(String srcPath, String dstPath) throws IOException { | ||
AssetManager assetManager = getApplicationContext().getAssets(); | ||
InputStream is = assetManager.open(srcPath); | ||
FileOutputStream fos = new FileOutputStream(dstPath); | ||
byte[] buffer = new byte[100]; | ||
int n = -1; | ||
do { | ||
n = is.read(buffer); | ||
if(n != -1) { | ||
fos.write(buffer); | ||
} | ||
}while(n != -1); | ||
fos.flush(); | ||
fos.close(); | ||
is.close(); | ||
} | ||
|
||
private void extractScripts() { | ||
String scriptDir = getString(R.string.SCRIPT_DIR); | ||
String scriptVersion = getString(R.string.SCRIPT_VERSION); | ||
|
||
String scriptVersionTagFile = scriptDir + scriptVersion; | ||
// first check script version (in the future we can change SCRIPT_VERSION constant to overwrite existing scripts) | ||
if(!new File(scriptVersionTagFile).exists()) { | ||
try { | ||
// clean old script dir | ||
SysCommand.getInstance().run("rm", "-r", scriptDir); | ||
// create script dir | ||
new File(scriptDir).mkdir(); | ||
// copy all scripts | ||
String[] scripts = getResources().getStringArray(R.array.scripts); | ||
for(String f: scripts) { | ||
copyAsset(f, scriptDir + f); | ||
} | ||
SysCommand.getInstance().run("chmod", "+x", scriptDir + "*"); | ||
// mark script version | ||
FileWriter fw = new FileWriter(scriptVersionTagFile); | ||
fw.write(scriptVersion); | ||
fw.close(); | ||
}catch(IOException e) { | ||
Log.e(LOG_TAG, "failed to extract scripts", e); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.