Skip to content

Instantly share code, notes, and snippets.

@CedricGatay
Created August 16, 2010 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CedricGatay/527087 to your computer and use it in GitHub Desktop.
Save CedricGatay/527087 to your computer and use it in GitHub Desktop.
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index c335b02..2bad6dc 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -26,22 +26,22 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.database.Cursor;
import android.media.AudioManager;
import android.net.Uri;
import android.os.IBinder;
import android.os.SystemClock;
import android.preference.PreferenceManager;
-import android.provider.Settings;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.PhoneLookup;
+import android.provider.Settings;
import android.telephony.PhoneNumberUtils;
import android.telephony.ServiceState;
import android.text.TextUtils;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;
-
import com.android.internal.telephony.Call;
import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.CallerInfoAsyncQuery;
@@ -49,6 +49,9 @@ import com.android.internal.telephony.Connection;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneBase;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
/**
* NotificationManager-related utility code for the Phone app.
*/
@@ -365,9 +368,10 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
* Configures a Notification to emit the blinky green message-waiting/
* missed-call signal.
*/
- private static void configureLedNotification(Notification note) {
- note.flags |= Notification.FLAG_SHOW_LIGHTS;
- note.defaults |= Notification.DEFAULT_LIGHTS;
+ private void configureLedNotification(Notification note) {
+// note.flags |= Notification.FLAG_SHOW_LIGHTS;
+// note.defaults |= Notification.DEFAULT_LIGHTS;
+ mLiquidLEDHack.setLEDEnabled(true);
}
/**
@@ -428,8 +432,10 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
// reset the number of missed calls to 0.
mNumberMissedCalls = 0;
mNotificationMgr.cancel(MISSED_CALL_NOTIFICATION);
+ mLiquidLEDHack.setLEDEnabled(false);
}
+
void notifySpeakerphone() {
if (mSpeakerphoneIcon == null) {
mSpeakerphoneIcon = mStatusBar.addIcon("speakerphone",
@@ -968,4 +974,36 @@ public class NotificationMgr implements CallerInfoAsyncQuery.OnQueryCompleteList
private void log(String msg) {
Log.d(LOG_TAG, msg);
}
+
+ private final class LiquidCallLEDHack{
+ private static final String TAG = "LiquidCallLEDHack";
+ private static final String LED_FILE = "/sys/class/leds2/call";
+
+ public boolean getLEDEnabled() {
+ try {
+ FileInputStream fis = new FileInputStream(LED_FILE);
+ int result = fis.read();
+ fis.close();
+ return (result != '0');
+ } catch (Exception e) {
+ Log.e(TAG, "setLEDEnabled failed", e);
+ return false;
+ }
+ }
+
+ public void setLEDEnabled(boolean on) {
+ try {
+ FileOutputStream fos = new FileOutputStream(LED_FILE);
+ byte[] bytes = new byte[2];
+ bytes[0] = (byte)(on ? '3' : '0');
+ bytes[1] = '\n';
+ fos.write(bytes);
+ fos.close();
+ } catch (Exception e) {
+ Log.e(TAG, "setLEDEnabled failed", e);
+ }
+ }
+ }
+
+ private LiquidCallLEDHack mLiquidLEDHack = new LiquidCallLEDHack();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment