lineage-sdk internal: Add LightsCapabilities

*) Moved lights capabilities from frameworks/base
   NotificationManager to the lineage-sdk.

*) Add device has a battery light LIGHTS_BATTERY_LED capability.

Adapted from the original frameworks/base commits:

   Author: Ricardo Cerqueira <android@cerqueira.org>
   Date:   Thu Nov 10 12:15:00 2016 +0000

       NotificationManager: Concentrate LED light capabilities in a single location

       We have a bunch of individual boolean toggles for various LED behaviors
       and combinations, which end up getting used as a similarly sprawling bunch
       of getResource() calls across various locations. And they keep piling up...

       So... create a new overlayable bit field of LED capabilities,
       config_deviceLightCapabilities, where we can throw everything
       and expand in the future. Remove the obsolete overlays so that
       everyone uses the new overlay moving forward.

       Change-Id: I7d627914b058861048071fc15776031c4152157f

   Author: Adrian DC <radian.dc@gmail.com>
   Date:   Sat Oct 14 23:08:47 2017 +0200

       fw: Rebrand to LineageOS and cleanup for Android Oreo

       Change-Id: If7468759925d1636adad1c253d68b5adbc6dfb26

Change-Id: Ib14badcc0a2ad165610dd7d0e90388170e1cd548
This commit is contained in:
Sam Mortimer
2017-10-17 21:02:15 -07:00
parent 814a9f5fa3
commit cef20e4e1f
2 changed files with 53 additions and 2 deletions

View File

@@ -96,9 +96,10 @@
LIGHTS_PULSATING_LED = 8
LIGHTS_SEGMENTED_BATTERY_LED = 16
LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS = 32
LIGHTS_BATTERY_LED = 64
For example, a device support pulsating, RGB notification and
battery LEDs would set this config to 11. -->
For example, a device with notification and battery lights that supports
pulsating and RGB control would set this config to 75. -->
<integer name="config_deviceLightCapabilities">8</integer>
<!-- Default, comma-delimited, quick settings tiles. See QSConstants.java for a list of all available tiles -->

View File

@@ -0,0 +1,50 @@
/**
* Copyright (C) 2017 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lineageos.internal.notification;
import android.content.Context;
public final class LightsCapabilities {
// Device has a color adjustable notification light.
public static final int LIGHTS_RGB_NOTIFICATION_LED = 1;
// Device has a color adjustable battery light.
public static final int LIGHTS_RGB_BATTERY_LED = 2;
// Deprecated
// public static final int LIGHTS_MULTIPLE_NOTIFICATION_LED = 4;
// The notification light has adjustable pulsing capability.
public static final int LIGHTS_PULSATING_LED = 8;
// Device has a multi-segment battery light that is able to
// use the light brightness value to determine how many
// segments to show (in order to represent battery level).
public static final int LIGHTS_SEGMENTED_BATTERY_LED = 16;
// The notification light supports adjustable brightness.
public static final int LIGHTS_ADJUSTABLE_NOTIFICATION_LED_BRIGHTNESS = 32;
// Device has a battery light.
public static final int LIGHTS_BATTERY_LED = 64;
public static boolean supports(Context context, final int capability) {
final int capabilities = context.getResources().getInteger(
org.lineageos.platform.internal.R.integer.config_deviceLightCapabilities);
return (capabilities & capability) != 0;
}
}