|
@@ -0,0 +1,66 @@
|
|
|
+package me.yoqi.screenfilter;
|
|
|
+
|
|
|
+import android.app.Notification;
|
|
|
+import android.app.NotificationManager;
|
|
|
+import android.app.Service;
|
|
|
+import android.content.Intent;
|
|
|
+import android.os.Binder;
|
|
|
+import android.os.IBinder;
|
|
|
+import android.util.Log;
|
|
|
+
|
|
|
+public class FilterService extends Service {
|
|
|
+
|
|
|
+ private final IBinder binder = new LocalBinder();
|
|
|
+
|
|
|
+ public IBinder onBind(Intent paramIntent) {
|
|
|
+ return this.binder;
|
|
|
+ }
|
|
|
+
|
|
|
+// public void onCreate() {
|
|
|
+// super.onCreate();
|
|
|
+// Log.d("FilterService", "onCreate");
|
|
|
+// Notification localNotification = ScreenFilterActivity.getNotification(getBaseContext());
|
|
|
+// try {
|
|
|
+// getClass().getMethod("startForeground", new Class[] { Integer.TYPE, Notification.class }).invoke(this,
|
|
|
+// new Object[] { Integer.valueOf(1), localNotification });
|
|
|
+// return;
|
|
|
+// } catch (Exception localException) {
|
|
|
+// Log.w("ScreenFilter", "Error calling startForeground", localException);
|
|
|
+// setForegroundBackwardsCompat(true);
|
|
|
+// ((NotificationManager) getSystemService("notification")).notify(1, localNotification);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// public void onDestroy() {
|
|
|
+// super.onDestroy();
|
|
|
+// Log.d("FilterService", "onDestroy");
|
|
|
+// setForegroundBackwardsCompat(false);
|
|
|
+// ScreenFilterActivity.hideNotification(getBaseContext());
|
|
|
+// }
|
|
|
+//
|
|
|
+// public void onStart(Intent paramIntent, int paramInt) {
|
|
|
+// super.onStart(paramIntent, paramInt);
|
|
|
+// Log.d("FilterService", "onStart");
|
|
|
+// }
|
|
|
+//
|
|
|
+// void setForegroundBackwardsCompat(boolean paramBoolean) {
|
|
|
+// try {
|
|
|
+// getClass().getMethod("setForeground", new Class[] { Boolean.class }).invoke(this,
|
|
|
+// new Object[] { Boolean.valueOf(paramBoolean) });
|
|
|
+// return;
|
|
|
+// } catch (Exception localException) {
|
|
|
+// Log.w("ScreenFilter", "Error calling setForeground", localException);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+ public class LocalBinder extends Binder {
|
|
|
+ public LocalBinder() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ FilterService getService() {
|
|
|
+ return FilterService.this;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|