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

Commit b957a742 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'brightness' into mnc-dev

* changes:
  Add code to collect data about auto-brightness adjustments.
  Add float support to binary event log.
parents 46fc1101 a576b4d3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34006,6 +34006,7 @@ package android.util {
    method public static void readEvents(int[], java.util.Collection<android.util.EventLog.Event>) throws java.io.IOException;
    method public static int writeEvent(int, int);
    method public static int writeEvent(int, long);
    method public static int writeEvent(int, float);
    method public static int writeEvent(int, java.lang.String);
    method public static int writeEvent(int, java.lang.Object...);
  }
+1 −0
Original line number Diff line number Diff line
@@ -36208,6 +36208,7 @@ package android.util {
    method public static void readEvents(int[], java.util.Collection<android.util.EventLog.Event>) throws java.io.IOException;
    method public static int writeEvent(int, int);
    method public static int writeEvent(int, long);
    method public static int writeEvent(int, float);
    method public static int writeEvent(int, java.lang.String);
    method public static int writeEvent(int, java.lang.Object...);
  }
+7 −0
Original line number Diff line number Diff line
@@ -182,6 +182,10 @@ public abstract class DisplayManagerInternal {
        // The screen auto-brightness adjustment factor in the range -1 (dimmer) to 1 (brighter).
        public float screenAutoBrightnessAdjustment;

        // Set to true if screenBrightness and screenAutoBrightnessAdjustment were both
        // set by the user as opposed to being programmatically controlled by apps.
        public boolean brightnessSetByUser;

        // If true, enables automatic brightness control.
        public boolean useAutoBrightness;

@@ -229,6 +233,7 @@ public abstract class DisplayManagerInternal {
            useProximitySensor = other.useProximitySensor;
            screenBrightness = other.screenBrightness;
            screenAutoBrightnessAdjustment = other.screenAutoBrightnessAdjustment;
            brightnessSetByUser = other.brightnessSetByUser;
            useAutoBrightness = other.useAutoBrightness;
            blockScreenOn = other.blockScreenOn;
            lowPowerMode = other.lowPowerMode;
@@ -249,6 +254,7 @@ public abstract class DisplayManagerInternal {
                    && useProximitySensor == other.useProximitySensor
                    && screenBrightness == other.screenBrightness
                    && screenAutoBrightnessAdjustment == other.screenAutoBrightnessAdjustment
                    && brightnessSetByUser == other.brightnessSetByUser
                    && useAutoBrightness == other.useAutoBrightness
                    && blockScreenOn == other.blockScreenOn
                    && lowPowerMode == other.lowPowerMode
@@ -268,6 +274,7 @@ public abstract class DisplayManagerInternal {
                    + ", useProximitySensor=" + useProximitySensor
                    + ", screenBrightness=" + screenBrightness
                    + ", screenAutoBrightnessAdjustment=" + screenAutoBrightnessAdjustment
                    + ", brightnessSetByUser=" + brightnessSetByUser
                    + ", useAutoBrightness=" + useAutoBrightness
                    + ", blockScreenOn=" + blockScreenOn
                    + ", lowPowerMode=" + lowPowerMode
+15 −3
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class EventLog {
        private static final byte LONG_TYPE   = 1;
        private static final byte STRING_TYPE = 2;
        private static final byte LIST_TYPE   = 3;
        private static final byte FLOAT_TYPE = 4;

        /** @param data containing event, read from the system */
        /*package*/ Event(byte[] data) {
@@ -106,7 +107,7 @@ public class EventLog {
            return mBuffer.getInt(offset);
        }

        /** @return one of Integer, Long, String, null, or Object[] of same. */
        /** @return one of Integer, Long, Float, String, null, or Object[] of same. */
        public synchronized Object getData() {
            try {
                int offset = mBuffer.getShort(HEADER_SIZE_OFFSET);
@@ -130,10 +131,13 @@ public class EventLog {
            byte type = mBuffer.get();
            switch (type) {
            case INT_TYPE:
                return (Integer) mBuffer.getInt();
                return mBuffer.getInt();

            case LONG_TYPE:
                return (Long) mBuffer.getLong();
                return mBuffer.getLong();

            case FLOAT_TYPE:
                return mBuffer.getFloat();

            case STRING_TYPE:
                try {
@@ -177,6 +181,14 @@ public class EventLog {
     */
    public static native int writeEvent(int tag, long value);

    /**
     * Record an event log message.
     * @param tag The event type tag code
     * @param value A value to log
     * @return The number of bytes written
     */
    public static native int writeEvent(int tag, float value);

    /**
     * Record an event log message.
     * @param tag The event type tag code
+23 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@ static jfieldID gIntegerValueID;
static jclass gLongClass;
static jfieldID gLongValueID;

static jclass gFloatClass;
static jfieldID gFloatValueID;

static jclass gStringClass;

/*
@@ -64,6 +67,17 @@ static jint android_util_EventLog_writeEvent_Long(JNIEnv* env UNUSED,
    return android_btWriteLog(tag, EVENT_TYPE_LONG, &value, sizeof(value));
}

/*
 * In class android.util.EventLog:
 *  static native int writeEvent(long tag, float value)
 */
static jint android_util_EventLog_writeEvent_Float(JNIEnv* env UNUSED,
                                                  jobject clazz UNUSED,
                                                  jint tag, jfloat value)
{
    return android_btWriteLog(tag, EVENT_TYPE_FLOAT, &value, sizeof(value));
}

/*
 * In class android.util.EventLog:
 *  static native int writeEvent(int tag, String value)
@@ -128,6 +142,12 @@ static jint android_util_EventLog_writeEvent_Array(JNIEnv* env, jobject clazz,
            buf[pos++] = EVENT_TYPE_LONG;
            memcpy(&buf[pos], &longVal, sizeof(longVal));
            pos += sizeof(longVal);
        } else if (env->IsInstanceOf(item, gFloatClass)) {
            jfloat floatVal = env->GetFloatField(item, gFloatValueID);
            if (pos + 1 + sizeof(floatVal) > max) break;
            buf[pos++] = EVENT_TYPE_FLOAT;
            memcpy(&buf[pos], &floatVal, sizeof(floatVal));
            pos += sizeof(floatVal);
        } else {
            jniThrowException(env,
                    "java/lang/IllegalArgumentException",
@@ -233,6 +253,7 @@ static JNINativeMethod gRegisterMethods[] = {
    /* name, signature, funcPtr */
    { "writeEvent", "(II)I", (void*) android_util_EventLog_writeEvent_Integer },
    { "writeEvent", "(IJ)I", (void*) android_util_EventLog_writeEvent_Long },
    { "writeEvent", "(IF)I", (void*) android_util_EventLog_writeEvent_Float },
    { "writeEvent",
      "(ILjava/lang/String;)I",
      (void*) android_util_EventLog_writeEvent_String
@@ -251,6 +272,7 @@ static struct { const char *name; jclass *clazz; } gClasses[] = {
    { "android/util/EventLog$Event", &gEventClass },
    { "java/lang/Integer", &gIntegerClass },
    { "java/lang/Long", &gLongClass },
    { "java/lang/Float", &gFloatClass },
    { "java/lang/String", &gStringClass },
    { "java/util/Collection", &gCollectionClass },
};
@@ -258,6 +280,7 @@ static struct { const char *name; jclass *clazz; } gClasses[] = {
static struct { jclass *c; const char *name, *ft; jfieldID *id; } gFields[] = {
    { &gIntegerClass, "value", "I", &gIntegerValueID },
    { &gLongClass, "value", "J", &gLongValueID },
    { &gFloatClass, "value", "F", &gFloatValueID },
};

static struct { jclass *c; const char *name, *mt; jmethodID *id; } gMethods[] = {
Loading