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

Commit bd7a5bbf authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7592383 from 7a3cb23b to sc-release

Change-Id: I7e08be9cdff1cd33ba6ff1f0ce9a022dfce34d0e
parents e898e566 7a3cb23b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2603,7 +2603,7 @@ public class AlarmManagerService extends SystemService {
            final int uid = mPackageManagerInternal.getPackageUid(packageName, 0, userId);
            if (callingUid != uid && !UserHandle.isCore(callingUid)) {
                throw new SecurityException("Uid " + callingUid
                        + " cannot query hasScheduleExactAlarm for uid " + uid);
                        + " cannot query hasScheduleExactAlarm for package " + packageName);
            }
            return (uid > 0) ? hasScheduleExactAlarmInternal(packageName, uid) : false;
        }
+4 −0
Original line number Diff line number Diff line
@@ -1025,6 +1025,10 @@ public final class BluetoothA2dp implements BluetoothProfile {
    public boolean setBufferLengthMillis(@BluetoothCodecConfig.SourceCodecType int codec,
            int value) {
        if (VDBG) log("setBufferLengthMillis(" + codec + ", " + value + ")");
        if (value < 0) {
            Log.e(TAG, "Trying to set audio buffer length to a negative value: " + value);
            return false;
        }
        try {
            final IBluetoothA2dp service = getService();
            if (service != null && isEnabled()) {
+4 −2
Original line number Diff line number Diff line
@@ -776,8 +776,10 @@ public abstract class WallpaperService extends Service {
                WallpaperColors color = colors.get(i);
                RectF area = regions.get(i);
                if (color == null || area == null) {
                    Log.wtf(TAG, "notifyLocalColorsChanged null values. color: "
                    if (DEBUG) {
                        Log.e(TAG, "notifyLocalColorsChanged null values. color: "
                                + color + " area " + area);
                    }
                    continue;
                }
                try {
+33 −57
Original line number Diff line number Diff line
@@ -16,11 +16,9 @@

package com.android.internal.display;

import android.annotation.NonNull;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.hardware.display.BrightnessInfo;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.net.Uri;
@@ -63,10 +61,10 @@ public class BrightnessSynchronizer {
                    updateBrightnessFloatFromInt(msg.arg1);
                    break;
                case MSG_UPDATE_INT:
                    updateBrightnessIntFromFloat((BrightnessInfo) msg.obj);
                    updateBrightnessIntFromFloat(Float.intBitsToFloat(msg.arg1));
                    break;
                case MSG_UPDATE_BOTH:
                    updateBoth((BrightnessInfo) msg.obj, Float.intBitsToFloat(msg.arg1));
                    updateBoth(Float.intBitsToFloat(msg.arg1));
                    break;
                default:
                    super.handleMessage(msg);
@@ -97,11 +95,11 @@ public class BrightnessSynchronizer {
        brightnessSyncObserver = new BrightnessSyncObserver();
        brightnessSyncObserver.startObserving();

        final BrightnessInfo brightnessInfo = getBrightnessInfo();
        final float currentFloatBrightness = getScreenBrightnessFloat();
        final int currentIntBrightness = getScreenBrightnessInt(mContext);

        if (brightnessInfo != null && !Float.isNaN(brightnessInfo.brightness)) {
            updateBrightnessIntFromFloat(brightnessInfo);
        if (!Float.isNaN(currentFloatBrightness)) {
            updateBrightnessIntFromFloat(currentFloatBrightness);
        } else if (currentIntBrightness != -1) {
            updateBrightnessFloatFromInt(currentIntBrightness);
        } else {
@@ -114,52 +112,45 @@ public class BrightnessSynchronizer {

    /**
     * Converts between the int brightness system and the float brightness system.
     *
     * @param brightnessInt The int brightness value to convert.
     */
    public static float brightnessIntToFloat(int brightnessInt) {
        return brightnessIntToFloat(brightnessInt, null);
    }

    private static float brightnessIntToFloat(int brightnessInt, BrightnessInfo info) {
        if (brightnessInt == PowerManager.BRIGHTNESS_OFF) {
            return PowerManager.BRIGHTNESS_OFF_FLOAT;
        } else if (brightnessInt == PowerManager.BRIGHTNESS_INVALID) {
            return PowerManager.BRIGHTNESS_INVALID_FLOAT;
        } else {
            final float minFloat = info != null
                    ? info.brightnessMinimum : PowerManager.BRIGHTNESS_MIN;
            final float maxFloat = info != null
                    ? info.brightnessMaximum : PowerManager.BRIGHTNESS_MAX;
            final float minFloat = PowerManager.BRIGHTNESS_MIN;
            final float maxFloat = PowerManager.BRIGHTNESS_MAX;
            final float minInt = PowerManager.BRIGHTNESS_OFF + 1;
            final float maxInt = PowerManager.BRIGHTNESS_ON;
            return MathUtils.constrainedMap(minFloat, maxFloat, minInt, maxInt, brightnessInt);
        }
    }

    /**
     * Converts between the float brightness system and the int brightness system.
     */
    public static int brightnessFloatToInt(float brightnessFloat) {
        return Math.round(brightnessFloatToIntRange(brightnessFloat));
    }

    /**
     * Translates specified value from the float brightness system to the int brightness system,
     * given the min/max of each range. Accounts for special values such as OFF and invalid values.
     * Value returned as a float primitive (to preserve precision), but is a value within the
     * int-system range.
     *
     * @param brightnessFloat The float brightness value to convert.
     * @param info Brightness information to use in the conversion.
     */
    public static int brightnessFloatToInt(float brightnessFloat, BrightnessInfo info) {
    public static float brightnessFloatToIntRange(float brightnessFloat) {
        if (floatEquals(brightnessFloat, PowerManager.BRIGHTNESS_OFF_FLOAT)) {
            return PowerManager.BRIGHTNESS_OFF;
        } else if (Float.isNaN(brightnessFloat)) {
            return PowerManager.BRIGHTNESS_INVALID;
        } else {
            final float minFloat = info != null
                    ? info.brightnessMinimum : PowerManager.BRIGHTNESS_MIN;
            final float maxFloat = info != null
                    ? info.brightnessMaximum : PowerManager.BRIGHTNESS_MAX;
            final float minFloat = PowerManager.BRIGHTNESS_MIN;
            final float maxFloat = PowerManager.BRIGHTNESS_MAX;
            final float minInt = PowerManager.BRIGHTNESS_OFF + 1;
            final float maxInt = PowerManager.BRIGHTNESS_ON;
            return Math.round(MathUtils.constrainedMap(minInt, maxInt, minFloat, maxFloat,
                    brightnessFloat));
            return MathUtils.constrainedMap(minInt, maxInt, minFloat, maxFloat, brightnessFloat);
        }
    }

@@ -194,37 +185,35 @@ public class BrightnessSynchronizer {
     * @param value Brightness value as int to store in the float setting.
     */
    private void updateBrightnessFloatFromInt(int value) {
        final BrightnessInfo info = getBrightnessInfo();
        if (brightnessFloatToInt(mPreferredSettingValue, info) == value) {
        if (brightnessFloatToInt(mPreferredSettingValue) == value) {
            return;
        }

        mPreferredSettingValue = brightnessIntToFloat(value, info);
        mPreferredSettingValue = brightnessIntToFloat(value);
        final int newBrightnessAsIntBits = Float.floatToIntBits(mPreferredSettingValue);
        mHandler.removeMessages(MSG_UPDATE_BOTH);
        mHandler.obtainMessage(MSG_UPDATE_BOTH, newBrightnessAsIntBits, 0).sendToTarget();
    }

    /**
     * Updates the settings from the specified {@link BrightnessInfo}. This is called whenever the
     * float brightness changed from DisplayManager. mPreferredSettingValue holds the most recently
     * updated brightness value as a float that we would like the display to be set to.
     * Updates the settings based on a passed in float value. This is called whenever the float
     * setting changes. mPreferredSettingValue holds the most recently updated brightness value
     * as a float that we would like the display to be set to.
     *
     * We then schedule an update to both the int and float settings, but, remove all the other
     * messages to update all, to prevent us getting stuck in a loop.
     *
     * @param brightnessInfo Current brightness information
     * @param value Brightness setting as float to store in int setting.
     */
    private void updateBrightnessIntFromFloat(@NonNull BrightnessInfo brightnessInfo) {
        final float value = brightnessInfo.brightness;
    private void updateBrightnessIntFromFloat(float value) {
        if (floatEquals(mPreferredSettingValue, value)) {
            return;
        }

        mPreferredSettingValue = value;
        final int newBrightnessAsIntBits = Float.floatToIntBits(mPreferredSettingValue);
        mHandler.removeMessages(MSG_UPDATE_BOTH);
        mHandler.obtainMessage(MSG_UPDATE_BOTH, Float.floatToIntBits(value), 0, brightnessInfo)
                .sendToTarget();
        mHandler.obtainMessage(MSG_UPDATE_BOTH, newBrightnessAsIntBits, 0).sendToTarget();
    }


@@ -233,24 +222,16 @@ public class BrightnessSynchronizer {
     * mDisplayManager.setBrightness automatically checks for changes
     * Settings.System.putIntForUser needs to be checked, to prevent an extra callback to this class
     *
     * @param brightnessInfo Brightness information, takes precedent over newBrightnessFloat
     * @param newBrightnessFloat Brightness setting as float to store in both settings
     */
    private void updateBoth(BrightnessInfo brightnessInfo, float newBrightnessFloat) {
        int newBrightnessInt = brightnessFloatToInt(newBrightnessFloat, brightnessInfo);
    private void updateBoth(float newBrightnessFloat) {
        int newBrightnessInt = brightnessFloatToInt(newBrightnessFloat);
        mDisplayManager.setBrightness(Display.DEFAULT_DISPLAY, newBrightnessFloat);
        if (getScreenBrightnessInt(mContext) != newBrightnessInt) {
            Settings.System.putIntForUser(mContext.getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS, newBrightnessInt, UserHandle.USER_CURRENT);
        }
    }

    private BrightnessInfo getBrightnessInfo() {
        final Display display = mDisplayManager.getDisplay(Display.DEFAULT_DISPLAY);
        if (display != null) {
            return display.getBrightnessInfo();
        }
        return null;
    }

    /**
@@ -282,15 +263,10 @@ public class BrightnessSynchronizer {

            @Override
            public void onDisplayChanged(int displayId) {
                if (displayId != Display.DEFAULT_DISPLAY) {
                    return;
                }

                final BrightnessInfo info = getBrightnessInfo();
                if (info != null) {
                float currentFloat = getScreenBrightnessFloat();
                int toSend = Float.floatToIntBits(currentFloat);
                mHandler.removeMessages(MSG_UPDATE_INT);
                    mHandler.obtainMessage(MSG_UPDATE_INT, info).sendToTarget();
                }
                mHandler.obtainMessage(MSG_UPDATE_INT, toSend, 0).sendToTarget();
            }
        };

+9 −3
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.util.EventLog;
import android.util.Log;

import com.android.internal.annotations.GuardedBy;
@@ -601,9 +602,14 @@ public class AndroidFuture<T> extends CompletableFuture<T> implements Parcelable
        String messageWithStackTrace = message + '\n' + stackTrace;
        Throwable throwable;
        try {
            Class<?> clazz = Class.forName(className);
            Class<?> clazz = Class.forName(className, true, Parcelable.class.getClassLoader());
            if (Throwable.class.isAssignableFrom(clazz)) {
                Constructor<?> constructor = clazz.getConstructor(String.class);
                throwable = (Throwable) constructor.newInstance(messageWithStackTrace);
            } else {
                android.util.EventLog.writeEvent(0x534e4554, "186530450", -1, "");
                throwable = new RuntimeException(className + ": " + messageWithStackTrace);
            }
        } catch (Throwable t) {
            throwable = new RuntimeException(className + ": " + messageWithStackTrace);
            throwable.addSuppressed(t);
Loading