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

Commit 44b3507f authored by Jackeagle's avatar Jackeagle
Browse files

Merge branch '1387devices-a14-otter-fix-missed-call-led' into 'a14'

lineage-sdk: Fix missed call LED color settings support

See merge request !124
parents 2c72fece 9cb635b7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public class LedValues {
            int red   = ((mColor >> 16) & 0xFF) * mBrightness / 255;
            int green = ((mColor >>  8) & 0xFF) * mBrightness / 255;
            int blue  = (mColor & 0xFF) * mBrightness / 255;
            mColor = (red << 16) | (green << 8) | blue;
            mColor = (mColor & 0xFF000000) | (red << 16) | (green << 8) | blue;
            mBrightness = 255;
        }
    }
+43 −3
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public final class LineageNotificationLights {
    private boolean mScreenOnEnabled;
    private boolean mZenAllowLights;
    private boolean mNotificationLedEnabled;
    private boolean mCustomLedValuesEnabled;
    private int mNotificationLedBrightnessLevel;
    private int mNotificationLedBrightnessLevelZen;
    private int mDefaultNotificationColor;
@@ -165,7 +166,45 @@ public final class LineageNotificationLights {
    }

    private LedValues getLedValuesForPackageName(String packageName) {
        return mNotificationPulseCustomLedValues.get(mapPackage(packageName));
        final String mappedPackage = mapPackage(packageName);

        // Only check dedicated settings if custom LED values are enabled
        if (mCustomLedValuesEnabled) {
            // Check for phone app specific settings first
            if ("com.android.phone".equals(mappedPackage) || "com.android.dialer".equals(mappedPackage)) {
                final ContentResolver resolver = mContext.getContentResolver();
                final int callColor = LineageSettings.System.getIntForUser(resolver,
                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_COLOR, 0, UserHandle.USER_CURRENT);
                final int callLedOn = LineageSettings.System.getIntForUser(resolver,
                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_ON, mDefaultNotificationLedOn, UserHandle.USER_CURRENT);
                final int callLedOff = LineageSettings.System.getIntForUser(resolver,
                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CALL_LED_OFF, mDefaultNotificationLedOff, UserHandle.USER_CURRENT);

                if (callColor != 0) {
                    return new LedValues(callColor, callLedOn, callLedOff);
                }
            }

            // Check for voicemail app specific settings
            if (mappedPackage.contains("voicemail") || mappedPackage.contains("vvm")) {
                final ContentResolver resolver = mContext.getContentResolver();
                final int vmailColor = LineageSettings.System.getIntForUser(resolver,
                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_COLOR, 0, UserHandle.USER_CURRENT);
                final int vmailLedOn = LineageSettings.System.getIntForUser(resolver,
                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_ON, mDefaultNotificationLedOn, UserHandle.USER_CURRENT);
                final int vmailLedOff = LineageSettings.System.getIntForUser(resolver,
                        LineageSettings.System.NOTIFICATION_LIGHT_PULSE_VMAIL_LED_OFF, mDefaultNotificationLedOff, UserHandle.USER_CURRENT);

                if (vmailColor != 0) {
                    return new LedValues(vmailColor, vmailLedOn, vmailLedOff);
                }
            }

            return mNotificationPulseCustomLedValues.get(mappedPackage);
        }

        // When custom values are disabled, return null to use default behavior
        return null;
    }

    private int generateLedColorForPackageName(String packageName) {
@@ -452,9 +491,10 @@ public final class LineageNotificationLights {

            // LED custom notification colors
            mNotificationPulseCustomLedValues.clear();
            if (LineageSettings.System.getIntForUser(resolver,
            mCustomLedValuesEnabled = LineageSettings.System.getIntForUser(resolver,
                    LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_ENABLE, 0,
                    UserHandle.USER_CURRENT) != 0) {
                    UserHandle.USER_CURRENT) != 0;
            if (mCustomLedValuesEnabled) {
                parseNotificationPulseCustomValuesString(LineageSettings.System.getStringForUser(
                        resolver, LineageSettings.System.NOTIFICATION_LIGHT_PULSE_CUSTOM_VALUES,
                        UserHandle.USER_CURRENT));