Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5482c3cf authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

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

parents 5f30cf46 e8cb9f65
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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>
+21 −5
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import java.util.ArrayList;
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 @@ public class NotificationManagerService extends INotificationManager.Stub
    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 class NotificationManagerService extends INotificationManager.Stub

        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 @@ public class NotificationManagerService extends INotificationManager.Stub
            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 @@ public class NotificationManagerService extends INotificationManager.Stub
    }

    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