Permalink
Browse files

converted tabs to spaces for better formatting

  • Loading branch information...
1 parent 72a3e60 commit 5a22ff1f1a85537619b3cf5c9fde2ad63c7ea4fb Mark Murphy committed Oct 22, 2011
View
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.commonsware.cwac.wakeful"
- android:versionCode="1"
- android:versionName="1.0">
+ package="com.commonsware.cwac.wakeful"
+ android:versionCode="1"
+ android:versionName="1.0">
</manifest>
View
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.commonsware.cwac.wakeful.demo" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="6"/>
- <supports-screens android:largeScreens="false" android:normalScreens="true" android:smallScreens="false"/>
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
- <uses-permission android:name="android.permission.WAKE_LOCK"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
- <application android:label="@string/app_name">
- <receiver android:name=".OnBootReceiver">
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED"/>
- </intent-filter>
- </receiver>
- <receiver android:name=".OnAlarmReceiver">
- </receiver>
- <service android:name=".AppService">
- </service>
- </application>
+ <supports-screens android:largeScreens="false" android:normalScreens="true" android:smallScreens="false"/>
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
+ <uses-permission android:name="android.permission.WAKE_LOCK"/>
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <application android:label="@string/app_name">
+ <receiver android:name=".OnBootReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.BOOT_COMPLETED"/>
+ </intent-filter>
+ </receiver>
+ <receiver android:name=".OnAlarmReceiver">
+ </receiver>
+ <service android:name=".AppService">
+ </service>
+ </application>
</manifest>
@@ -1,15 +1,15 @@
/***
- Copyright (c) 2009 CommonsWare, LLC
-
- 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.
+ Copyright (c) 2009 CommonsWare, LLC
+
+ 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.commonsware.cwac.wakeful.demo;
@@ -25,25 +25,25 @@
import com.commonsware.cwac.wakeful.WakefulIntentService;
public class AppService extends WakefulIntentService {
- public AppService() {
- super("AppService");
- }
+ public AppService() {
+ super("AppService");
+ }
- @Override
- protected void doWakefulWork(Intent intent) {
- File log=new File(Environment.getExternalStorageDirectory(),
- "AlarmLog.txt");
-
- try {
- BufferedWriter out=new BufferedWriter(new FileWriter(log.getAbsolutePath(),
- log.exists()));
-
- out.write(new Date().toString());
- out.write("\n");
- out.close();
- }
- catch (IOException e) {
- Log.e("AppService", "Exception appending to log file", e);
- }
- }
+ @Override
+ protected void doWakefulWork(Intent intent) {
+ File log=new File(Environment.getExternalStorageDirectory(),
+ "AlarmLog.txt");
+
+ try {
+ BufferedWriter out=new BufferedWriter(new FileWriter(log.getAbsolutePath(),
+ log.exists()));
+
+ out.write(new Date().toString());
+ out.write("\n");
+ out.close();
+ }
+ catch (IOException e) {
+ Log.e("AppService", "Exception appending to log file", e);
+ }
+ }
}
@@ -1,15 +1,15 @@
/***
- Copyright (c) 2009 CommonsWare, LLC
-
- 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.
+ Copyright (c) 2009 CommonsWare, LLC
+
+ 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.commonsware.cwac.wakeful.demo;
@@ -21,8 +21,8 @@
import com.commonsware.cwac.wakeful.WakefulIntentService;
public class OnAlarmReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- WakefulIntentService.sendWakefulWork(context, AppService.class);
- }
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ WakefulIntentService.sendWakefulWork(context, AppService.class);
+ }
}
@@ -1,15 +1,15 @@
/***
- Copyright (c) 2009 CommonsWare, LLC
-
- 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.
+ Copyright (c) 2009 CommonsWare, LLC
+
+ 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.commonsware.cwac.wakeful.demo;
@@ -22,18 +22,18 @@
import android.os.SystemClock;
public class OnBootReceiver extends BroadcastReceiver {
- private static final int PERIOD=300000; // 5 minutes
-
- @Override
- public void onReceive(Context context, Intent intent) {
- AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
- Intent i=new Intent(context, OnAlarmReceiver.class);
- PendingIntent pi=PendingIntent.getBroadcast(context, 0,
- i, 0);
-
- mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
- SystemClock.elapsedRealtime()+60000,
- PERIOD,
- pi);
- }
+ private static final int PERIOD=300000; // 5 minutes
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
+ Intent i=new Intent(context, OnAlarmReceiver.class);
+ PendingIntent pi=PendingIntent.getBroadcast(context, 0,
+ i, 0);
+
+ mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ SystemClock.elapsedRealtime()+60000,
+ PERIOD,
+ pi);
+ }
}
@@ -1,15 +1,15 @@
/***
- Copyright (c) 2009 CommonsWare, LLC
-
- 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.
+ Copyright (c) 2009 CommonsWare, LLC
+
+ 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.commonsware.cwac.wakeful;
@@ -20,55 +20,55 @@
import android.os.PowerManager;
abstract public class WakefulIntentService extends IntentService {
- abstract protected void doWakefulWork(Intent intent);
-
- private static final String LOCK_NAME_STATIC="com.commonsware.cwac.wakeful.WakefulIntentService";
- private static volatile PowerManager.WakeLock lockStatic=null;
-
- synchronized private static PowerManager.WakeLock getLock(Context context) {
- if (lockStatic==null) {
- PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
-
- lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
- LOCK_NAME_STATIC);
- lockStatic.setReferenceCounted(true);
- }
-
- return(lockStatic);
- }
-
- public static void sendWakefulWork(Context ctxt, Intent i) {
- getLock(ctxt.getApplicationContext()).acquire();
- ctxt.startService(i);
- }
-
- public static void sendWakefulWork(Context ctxt, Class<?> clsService) {
- sendWakefulWork(ctxt, new Intent(ctxt, clsService));
- }
-
- public WakefulIntentService(String name) {
- super(name);
- setIntentRedelivery(true);
- }
-
- @Override
+ abstract protected void doWakefulWork(Intent intent);
+
+ private static final String LOCK_NAME_STATIC="com.commonsware.cwac.wakeful.WakefulIntentService";
+ private static volatile PowerManager.WakeLock lockStatic=null;
+
+ synchronized private static PowerManager.WakeLock getLock(Context context) {
+ if (lockStatic==null) {
+ PowerManager mgr=(PowerManager)context.getSystemService(Context.POWER_SERVICE);
+
+ lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+ LOCK_NAME_STATIC);
+ lockStatic.setReferenceCounted(true);
+ }
+
+ return(lockStatic);
+ }
+
+ public static void sendWakefulWork(Context ctxt, Intent i) {
+ getLock(ctxt.getApplicationContext()).acquire();
+ ctxt.startService(i);
+ }
+
+ public static void sendWakefulWork(Context ctxt, Class<?> clsService) {
+ sendWakefulWork(ctxt, new Intent(ctxt, clsService));
+ }
+
+ public WakefulIntentService(String name) {
+ super(name);
+ setIntentRedelivery(true);
+ }
+
+ @Override
public int onStartCommand(Intent intent, int flags, int startId) {
- if ((flags & START_FLAG_REDELIVERY)!=0) { // if crash restart...
- getLock(this.getApplicationContext()).acquire(); // ...then quick grab the lock
- }
+ if ((flags & START_FLAG_REDELIVERY)!=0) { // if crash restart...
+ getLock(this.getApplicationContext()).acquire(); // ...then quick grab the lock
+ }
- super.onStartCommand(intent, flags, startId);
-
- return(START_REDELIVER_INTENT);
- }
-
- @Override
- final protected void onHandleIntent(Intent intent) {
- try {
- doWakefulWork(intent);
- }
- finally {
- getLock(this.getApplicationContext()).release();
- }
- }
+ super.onStartCommand(intent, flags, startId);
+
+ return(START_REDELIVER_INTENT);
+ }
+
+ @Override
+ final protected void onHandleIntent(Intent intent) {
+ try {
+ doWakefulWork(intent);
+ }
+ finally {
+ getLock(this.getApplicationContext()).release();
+ }
+ }
}

0 comments on commit 5a22ff1

Please sign in to comment.