Skip to content
Browse files

Merge "Notification light(LED) settings: package mapping" into ics

  • Loading branch information...
2 parents 5f30cf4 + e8cb9f6 commit 5482c3cf0319f5dc7ae66c59533d1d31ef829b3b @cyanogen cyanogen committed with Gerrit Code Review Apr 16, 2012
Showing with 29 additions and 5 deletions.
  1. +8 −0 core/res/res/values/arrays.xml
  2. +21 −5 services/java/com/android/server/NotificationManagerService.java
View
8 core/res/res/values/arrays.xml
@@ -526,4 +526,12 @@
<item>bootloader</item>
</string-array>
+ <!-- Do not translate. Defines the mapping of notification package names
+ from the actual triggering package to the user selectable package.
+ E.g. GTalk notifications come via Google Services Framework
+ Format: [triggering package]|[user package] -->
+ <string-array name="notification_light_package_mapping" translatable="false">
+ <item>com.google.android.gsf|com.google.android.talk</item>
+ </string-array>
+
</resources>
View
26 services/java/com/android/server/NotificationManagerService.java
@@ -66,6 +66,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Calendar;
+import java.util.Map;
/** {@hide} */
public class NotificationManagerService extends INotificationManager.Stub
@@ -106,12 +107,13 @@
private NotificationRecord mVibrateNotification;
private Vibrator mVibrator = new Vibrator();
- // for enabling and disabling notification pulse behavior
+ // for enabling and disabling notification pulse behaviour
private boolean mScreenOn = true;
private boolean mWasScreenOn = false;
private boolean mInCall = false;
private boolean mNotificationPulseEnabled;
private HashMap<String, NotificationLedValues> mNotificationPulseCustomLedValues;
+ private Map<String, String> mPackageNameMappings;
private final ArrayList<NotificationRecord> mNotificationList =
new ArrayList<NotificationRecord>();
@@ -516,6 +518,13 @@ public void update() {
mNotificationPulseCustomLedValues = new HashMap<String, NotificationLedValues>();
+ mPackageNameMappings = new HashMap<String, String>();
+ for(String mapping : resources.getStringArray(
+ com.android.internal.R.array.notification_light_package_mapping)) {
+ String[] map = mapping.split("\\|");
+ mPackageNameMappings.put(map[0], map[1]);
+ }
+
// Don't start allowing notifications until the setup wizard has run once.
// After that, including subsequent boots, init with notifications turned on.
// This works on the first boot because the setup wizard will toggle this
@@ -1233,9 +1242,9 @@ private void updateLightsLocked()
int ledOffMS;
NotificationLedValues ledValues = getLedValuesForNotification(mLedNotification);
if (ledValues != null) {
- ledARGB = ledValues.color;
- ledOnMS = ledValues.onMS;
- ledOffMS = ledValues.offMS;
+ ledARGB = ledValues.color != 0 ? ledValues.color : mDefaultNotificationColor;
+ ledOnMS = ledValues.onMS >= 0 ? ledValues.onMS : mDefaultNotificationLedOn;
+ ledOffMS = ledValues.offMS >= 0 ? ledValues.offMS : mDefaultNotificationLedOn;
} else {
if ((mLedNotification.notification.defaults & Notification.DEFAULT_LIGHTS) != 0) {
ledARGB = mDefaultNotificationColor;
@@ -1286,7 +1295,14 @@ private void parseNotificationPulseCustomValuesString(String customLedValuesStri
}
private NotificationLedValues getLedValuesForNotification(NotificationRecord ledNotification) {
- return mNotificationPulseCustomLedValues.get(ledNotification.pkg);
+ return mNotificationPulseCustomLedValues.get(mapPackage(ledNotification.pkg));
+ }
+
+ private String mapPackage(String pkg) {
+ if(!mPackageNameMappings.containsKey(pkg)) {
+ return pkg;
+ }
+ return mPackageNameMappings.get(pkg);
}
// lock on mNotificationList

0 comments on commit 5482c3c

Please sign in to comment.
Something went wrong with that request. Please try again.