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 4931630
Showing
12 changed files
with
202 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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</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 @@ | ||
/BRANCH_TODO | ||
/bin/* |
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>WifiLock</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,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.elsdoerfer.wifilock" | ||
android:versionCode="1" | ||
android:versionName="1.0.0"> | ||
<application android:icon="@drawable/icon" android:label="@string/app_name"> | ||
<activity android:name=".ToggleActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/Theme"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<service android:name=".WifiLockService"/> | ||
</application> | ||
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission> | ||
</manifest> |
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,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="fill_parent" | ||
android:layout_height="fill_parent" | ||
android:theme="@style/Theme" | ||
> | ||
</FrameLayout> |
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,3 @@ | ||
<resources> | ||
<drawable name="transparent_background">#00000000</drawable> | ||
</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,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
|
||
<string name="app_name">WifiLock</string> | ||
<string name="service_enabled">WifiLock is now ENABLED, and your wifi connection will remain active at all times.</string> | ||
<string name="service_disabled">WifiLock is now DISABLED, and your wifi may be shutoff when sleeping to conserve battery power.</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,7 @@ | ||
<resources> | ||
<style name="Theme"> | ||
<item name="android:windowBackground">@drawable/transparent_background</item> | ||
<item name="android:windowNoTitle">true</item> | ||
<item name="android:windowIsFloating">true</item> | ||
</style> | ||
</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,28 @@ | ||
/* AUTO-GENERATED FILE. DO NOT MODIFY. | ||
* | ||
* This class was automatically generated by the | ||
* aapt tool from the resource data it found. It | ||
* should not be modified by hand. | ||
*/ | ||
|
||
package com.elsdoerfer.wifilock; | ||
|
||
public final class R { | ||
public static final class attr { | ||
} | ||
public static final class drawable { | ||
public static final int icon=0x7f020000; | ||
public static final int transparent_background=0x7f020001; | ||
} | ||
public static final class layout { | ||
public static final int main=0x7f030000; | ||
} | ||
public static final class string { | ||
public static final int app_name=0x7f040000; | ||
public static final int service_disabled=0x7f040002; | ||
public static final int service_enabled=0x7f040001; | ||
} | ||
public static final class style { | ||
public static final int Theme=0x7f050000; | ||
} | ||
} |
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 @@ | ||
package com.elsdoerfer.wifilock; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
|
||
public class ToggleActivity extends Activity { | ||
|
||
static private String LOG_TAG = "WifiLock.Toggle"; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
final Intent svc = new Intent(this, WifiLockService.class); | ||
|
||
if (WifiLockService.serviceRunning) { | ||
Log.d(LOG_TAG, "before stopService"); | ||
stopService(svc); | ||
Log.d(LOG_TAG, "after stopService"); | ||
} | ||
else{ | ||
Log.d(LOG_TAG, "before startService"); | ||
startService(svc); | ||
Log.d(LOG_TAG, "after startService"); | ||
} | ||
|
||
this.finish(); | ||
} | ||
} |
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,59 @@ | ||
package com.elsdoerfer.wifilock; | ||
|
||
import android.app.Service; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.net.wifi.WifiManager; | ||
import android.os.IBinder; | ||
import android.util.Log; | ||
import android.widget.Toast; | ||
|
||
public class WifiLockService extends Service { | ||
|
||
/** | ||
* Global state of this service. Is checked by the | ||
* toggle activity to determine whether to start or | ||
* stop the service. | ||
*/ | ||
static public boolean serviceRunning = false; | ||
|
||
/** | ||
* The WifiLock the service holds while running. | ||
*/ | ||
protected WifiManager.WifiLock lock = null; | ||
|
||
static private String LOG_TAG = "WifiLock.Service"; | ||
|
||
public WifiLockService() {} | ||
|
||
@Override | ||
public IBinder onBind(Intent intent) { return null; } | ||
|
||
@Override | ||
public void onCreate() { | ||
Log.v(LOG_TAG, "WifiLock service about to be created"); | ||
super.onCreate(); | ||
|
||
WifiManager manager = (WifiManager) getSystemService(Context.WIFI_SERVICE); | ||
lock = manager.createWifiLock("com.elsdoerfer.wifilock"); | ||
lock.acquire(); | ||
serviceRunning = true; | ||
|
||
Toast.makeText(this, R.string.service_enabled, Toast.LENGTH_LONG).show(); | ||
|
||
Log.v(LOG_TAG, "WifiLock service creation completed"); | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
Log.v(LOG_TAG, "WifiLock service about to shutdown"); | ||
|
||
serviceRunning = false; | ||
lock.release(); | ||
Toast.makeText(this, R.string.service_disabled, Toast.LENGTH_LONG).show(); | ||
|
||
super.onDestroy(); | ||
Log.v(LOG_TAG, "WifiLock service shutdown completed"); | ||
} | ||
|
||
} |