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

Commit 45880f2b authored by Nishith  Khanna's avatar Nishith Khanna
Browse files

Merge remote-tracking branch 'origin/lineage-19.1' into v1-s

parents d69cb696 d42ec4c0
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.content.pm.ActivityInfo.FLAG_SUPPORTS_PICTURE_IN_PICTURE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_BAD_MANIFEST;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_ONLY_COREAPP_ALLOWED;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_RESOURCES_ARSC_COMPRESSED;
import static android.content.pm.PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION;
@@ -905,6 +906,13 @@ public class ParsingPackageUtils {
            );
        }

        if (ParsedPermissionUtils.declareDuplicatePermission(pkg)) {
            return input.error(
                    INSTALL_PARSE_FAILED_MANIFEST_MALFORMED,
                    "Declare duplicate permissions with different protection levels or group."
            );
        }

        convertNewPermissions(pkg);

        convertSplitPermissions(pkg);
+49 −0
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.content.pm.parsing.result.ParseResult;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.ArrayMap;
import android.util.EventLog;
import android.util.Slog;

import com.android.internal.R;
@@ -32,6 +34,8 @@ import com.android.internal.R;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.List;
import java.util.Objects;

/** @hide */
public class ParsedPermissionUtils {
@@ -233,4 +237,49 @@ public class ParsedPermissionUtils {
        return ComponentParseUtils.parseAllMetaData(pkg, res, parser, tag, permissionGroup,
                input);
    }

    /**
     * Determines if a duplicate permission is malformed .i.e. defines different protection level
     * or group
     */
    private static boolean isMalformedDuplicate(ParsedPermission p1, ParsedPermission p2) {
        // Since a permission tree is also added as a permission with normal protection
        // level, we need to skip if the parsedPermission is a permission tree.
        if (p1 == null || p2 == null || p1.isTree() || p2.isTree()) {
            return false;
        }

        if (p1.getProtectionLevel() != p2.getProtectionLevel()) {
            return true;
        }
        if (!Objects.equals(p1.getGroup(), p2.getGroup())) {
            return true;
        }

        return false;
    }

    /**
     * @return {@code true} if the package declares malformed duplicate permissions.
     *
     */
    public static boolean declareDuplicatePermission(@NonNull ParsingPackage pkg) {
        final List<ParsedPermission> permissions = pkg.getPermissions();
        final int size = permissions.size();
        if (size > 0) {
            final ArrayMap<String, ParsedPermission> checkDuplicatePerm = new ArrayMap<>(size);
            for (int i = 0; i < size; i++) {
                final ParsedPermission parsedPermission = permissions.get(i);
                final String name = parsedPermission.getName();
                final ParsedPermission perm = checkDuplicatePerm.get(name);
                if (isMalformedDuplicate(parsedPermission, perm)) {
                    // Fix for b/213323615
                    EventLog.writeEvent(0x534e4554, "213323615");
                    return true;
                }
                checkDuplicatePerm.put(name, parsedPermission);
            }
        }
        return false;
    }
}
+11 −8
Original line number Diff line number Diff line
@@ -1240,23 +1240,26 @@ public class VolumeDialogImpl implements VolumeDialog,
                == BluetoothProfile.STATE_CONNECTED;
    }

    private boolean isMediaControllerAvailable(MediaController mediaController) {
        return mediaController != null && !TextUtils.isEmpty(mediaController.getPackageName());
    }

    public void initSettingsH() {
        if (mSettingsView != null) {
            mSettingsView.setVisibility(mDeviceProvisionedController.isCurrentUserSetup()
                    && mActivityManager.getLockTaskModeState() == LOCK_TASK_MODE_NONE
                    && isBluetoothA2dpConnected()
                    && (isMediaControllerAvailable(getActiveLocalMediaController())
                            || isBluetoothA2dpConnected())
                    ? VISIBLE : GONE);
        }
        if (mSettingsIcon != null) {
            mSettingsIcon.setOnClickListener(v -> {
                Events.writeEvent(Events.EVENT_SETTINGS_CLICK);
                final MediaController mediaController = getActiveLocalMediaController();
                String packageName =
                        mediaController != null
                                && !TextUtils.isEmpty(mediaController.getPackageName())
                String packageName = isMediaControllerAvailable(mediaController)
                        ? mediaController.getPackageName()
                        : "";
                mMediaOutputDialogFactory.create(packageName, false, mDialogView);
                mMediaOutputDialogFactory.create(packageName, true, mDialogView);
                dismissH(DISMISS_REASON_SETTINGS_CLICKED);
            });
        }
@@ -1587,13 +1590,13 @@ public class VolumeDialogImpl implements VolumeDialog,
                    mIsAnimatingDismiss = false;

                    hideRingerDrawer();
                    mController.notifyVisible(false);
                }, 50));
        if (!shouldSlideInVolumeTray()) {
            animator.translationX(getTranslationForPanelLocation() * mDialogView.getWidth() / 2.0f);
        }
        animator.start();
        checkODICaptionsTooltip(true);
        mController.notifyVisible(false);
        synchronized (mSafetyWarningLock) {
            if (mSafetyWarning != null) {
                if (D.BUG) Log.d(TAG, "SafetyWarning dismissed");
+17 −40
Original line number Diff line number Diff line
@@ -433,14 +433,6 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    // PowerManager.BRIGHTNESS_INVALID_FLOAT when there's no temporary adjustment set.
    private float mTemporaryAutoBrightnessAdjustment;

    // Whether reduce bright colors (rbc) has been turned on, or a change in strength has been
    // requested. We want to retain the current backlight level when rbc is toggled, since rbc
    // additionally makes the screen appear dimmer using screen colors rather than backlight levels,
    // and therefore we don't actually want to compensate for this by then in/decreasing the
    // backlight when toggling this feature.
    // This should be false during system start up.
    private boolean mPendingRbcOnOrChanged = false;

    // Whether auto brightness is applied one shot when screen is turned on
    private boolean mAutoBrightnessOneShot;

@@ -583,35 +575,29 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                @Override
                public void onReduceBrightColorsActivationChanged(boolean activated,
                        boolean userInitiated) {
                    applyReduceBrightColorsSplineAdjustment(
                            /* rbcStrengthChanged= */ false, activated);
                    applyReduceBrightColorsSplineAdjustment();

                }

                @Override
                public void onReduceBrightColorsStrengthChanged(int strength) {
                    applyReduceBrightColorsSplineAdjustment(
                            /* rbcStrengthChanged= */ true, /* justActivated= */ false);
                    applyReduceBrightColorsSplineAdjustment();
                }
            });
            if (active) {
                applyReduceBrightColorsSplineAdjustment(
                        /* rbcStrengthChanged= */ false,  /* justActivated= */ false);
                applyReduceBrightColorsSplineAdjustment();
            }
        } else {
            mCdsi = null;
        }
    }

    private void applyReduceBrightColorsSplineAdjustment(
            boolean rbcStrengthChanged, boolean justActivated) {
        final int strengthChanged = rbcStrengthChanged ? 1 : 0;
        final int activated = justActivated ? 1 : 0;
        mHandler.obtainMessage(MSG_UPDATE_RBC, strengthChanged, activated).sendToTarget();
    private void applyReduceBrightColorsSplineAdjustment() {
        mHandler.obtainMessage(MSG_UPDATE_RBC).sendToTarget();
        sendUpdatePowerState();
    }

    private void handleRbcChanged(boolean strengthChanged, boolean justActivated) {
    private void handleRbcChanged() {
        if (mBrightnessMapper == null) {
            Log.w(TAG, "No brightness mapping available to recalculate splines");
            return;
@@ -623,13 +609,13 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
        }
        mBrightnessMapper.recalculateSplines(mCdsi.isReduceBrightColorsActivated(), adjustedNits);

        mPendingRbcOnOrChanged = strengthChanged || justActivated;

        // Reset model if strength changed OR rbc is turned off
        if ((strengthChanged || !justActivated) && mAutomaticBrightnessController != null) {
        // If rbc is turned on, off or there is a change in strength, we want to reset the short
        // term model. Since the nits range at which brightness now operates has changed due to
        // RBC/strength change, any short term model based on the previous range should be
        // invalidated.
        mAutomaticBrightnessController.resetShortTermModel();
    }
    }

    /**
     * Returns true if the proximity sensor screen-off function is available.
@@ -977,8 +963,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call

    private void reloadReduceBrightColours() {
        if (mCdsi != null && mCdsi.isReduceBrightColorsActivated()) {
            applyReduceBrightColorsSplineAdjustment(
                    /* rbcStrengthChanged= */ false, /* justActivated= */ false);
            applyReduceBrightColorsSplineAdjustment();
        }
    }

@@ -2155,23 +2140,17 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
    }

    // We want to return true if the user has set the screen brightness.
    // If they have just turned RBC on (and therefore added that interaction to the curve),
    // or changed the brightness another way, then we should return true.
    // RBC on, off, and intensity changes will return false.
    // Slider interactions whilst in RBC will return true, just as when in non-rbc.
    private boolean updateUserSetScreenBrightness() {
        final boolean treatAsIfUserChanged = mPendingRbcOnOrChanged;
        if (treatAsIfUserChanged && !Float.isNaN(mCurrentScreenBrightnessSetting)) {
            mLastUserSetScreenBrightness = mCurrentScreenBrightnessSetting;
        }
        mPendingRbcOnOrChanged = false;

        if ((Float.isNaN(mPendingScreenBrightnessSetting)
                || mPendingScreenBrightnessSetting < 0.0f)) {
            return treatAsIfUserChanged;
            return false;
        }
        if (mCurrentScreenBrightnessSetting == mPendingScreenBrightnessSetting) {
            mPendingScreenBrightnessSetting = PowerManager.BRIGHTNESS_INVALID_FLOAT;
            mTemporaryScreenBrightness = PowerManager.BRIGHTNESS_INVALID_FLOAT;
            return treatAsIfUserChanged;
            return false;
        }
        setCurrentScreenBrightness(mPendingScreenBrightnessSetting);
        mLastUserSetScreenBrightness = mPendingScreenBrightnessSetting;
@@ -2515,9 +2494,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
                    break;

                case MSG_UPDATE_RBC:
                    final int strengthChanged = msg.arg1;
                    final int justActivated = msg.arg2;
                    handleRbcChanged(strengthChanged == 1, justActivated == 1);
                    handleRbcChanged();
                    break;
            }
        }
+1 −1
Original line number Diff line number Diff line
@@ -1520,7 +1520,7 @@ public class UsbDeviceManager implements ActivityTaskManagerInternal.ScreenObser

        public void setTrustRestrictUsb() {
            final int restrictUsb = LineageSettings.Global.getInt(mContentResolver,
                    LineageSettings.Global.TRUST_RESTRICT_USB, 1);
                    LineageSettings.Global.TRUST_RESTRICT_USB, 0);
            // Effective immediately, ejects any connected USB devices.
            // If the restriction is set to "only when locked", only execute once USB is
            // disconnected and keyguard is showing, to avoid ejecting connected devices