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

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

Merge cherrypicks of ['googleplex-android-review.googlesource.com/20322502',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/20322502', 'googleplex-android-review.googlesource.com/25124582', 'googleplex-android-review.googlesource.com/26225135', 'googleplex-android-review.googlesource.com/25522017', 'googleplex-android-review.googlesource.com/26460033', 'googleplex-android-review.googlesource.com/26151073', 'googleplex-android-review.googlesource.com/26297402', 'googleplex-android-review.googlesource.com/23400867', 'googleplex-android-review.googlesource.com/26720245', 'googleplex-android-review.googlesource.com/26802222', 'googleplex-android-review.googlesource.com/26766897', 'googleplex-android-review.googlesource.com/26721087', 'googleplex-android-review.googlesource.com/26693133', 'googleplex-android-review.googlesource.com/26802630', 'googleplex-android-review.googlesource.com/26709091'] into security-aosp-sc-v2-release.

Change-Id: Ida420de29481038ddb2f421cfa0fd8c1646ae25c
parents 346a778e cdf39d92
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.os.Parcelable;
import android.os.Process;
import android.permission.PermissionManager;
import android.util.ArraySet;
import android.util.Log;

import com.android.internal.annotations.Immutable;

@@ -86,6 +87,8 @@ import java.util.Set;
 */
@Immutable
public final class AttributionSource implements Parcelable {
    private static final String TAG = "AttributionSource";

    private static final String DESCRIPTOR = "android.content.AttributionSource";

    private static final Binder sDefaultToken = new Binder(DESCRIPTOR);
@@ -153,10 +156,21 @@ public final class AttributionSource implements Parcelable {
    AttributionSource(@NonNull Parcel in) {
        this(AttributionSourceState.CREATOR.createFromParcel(in));

        if (!Binder.isHandlingTransaction()) {
            Log.e(TAG, "Unable to verify calling UID #" + mAttributionSourceState.uid + " PID #"
                    + mAttributionSourceState.pid + " when not handling Binder transaction; "
                    + "clearing.");
            mAttributionSourceState.pid = -1;
            mAttributionSourceState.uid = -1;
            mAttributionSourceState.packageName = null;
            mAttributionSourceState.attributionTag = null;
            mAttributionSourceState.next = null;
        } else {
            // Since we just unpacked this object as part of it transiting a Binder
            // call, this is the perfect time to enforce that its UID and PID can be trusted
            enforceCallingUidAndPid();
        }
    }

    /** @hide */
    public AttributionSource(@NonNull AttributionSourceState attributionSourceState) {
+10 −0
Original line number Diff line number Diff line
@@ -431,6 +431,8 @@ public class ZygoteProcess {
                throw new ZygoteStartFailedEx("Embedded newlines not allowed");
            } else if (arg.indexOf('\r') >= 0) {
                throw new ZygoteStartFailedEx("Embedded carriage returns not allowed");
            } else if (arg.indexOf('\u0000') >= 0) {
                throw new ZygoteStartFailedEx("Embedded nulls not allowed");
            }
        }

@@ -972,6 +974,14 @@ public class ZygoteProcess {
            return true;
        }

        for (/* NonNull */ String s : mApiDenylistExemptions) {
            // indexOf() is intrinsified and faster than contains().
            if (s.indexOf('\n') >= 0 || s.indexOf('\r') >= 0 || s.indexOf('\u0000') >= 0) {
                Slog.e(LOG_TAG, "Failed to set API denylist exemptions: Bad character");
                mApiDenylistExemptions = Collections.emptyList();
                return false;
            }
        }
        try {
            state.mZygoteOutputWriter.write(Integer.toString(mApiDenylistExemptions.size() + 1));
            state.mZygoteOutputWriter.newLine();
+11 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
import android.util.ArraySet;
import android.util.AttributeSet;
@@ -1542,8 +1543,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView

    public ExpandableNotificationRow(Context context, AttributeSet attrs) {
        super(context, attrs);
        mImageResolver = new NotificationInlineImageResolver(context,
                new NotificationInlineImageCache());
        initDimens();
    }

@@ -1572,6 +1571,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
            NotificationGutsManager gutsManager,
            IStatusBarService statusBarService) {
        mEntry = entry;
        mImageResolver = new NotificationInlineImageResolver(userContextForEntry(mContext, entry),
                new NotificationInlineImageCache());
        mAppName = appName;
        if (mMenuRow == null) {
            mMenuRow = new NotificationMenuRow(mContext, peopleNotificationIdentifier);
@@ -1605,6 +1606,14 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
        cacheIsSystemNotification();
    }

    private static Context userContextForEntry(Context base, NotificationEntry entry) {
        if (base.getUserId() == entry.getSbn().getNormalizedUserId()) {
            return base;
        }
        return base.createContextAsUser(
                UserHandle.of(entry.getSbn().getNormalizedUserId()), /* flags= */ 0);
    }

    private void initDimens() {
        mMaxSmallHeightBeforeN = NotificationUtils.getFontScaledHeight(mContext,
                R.dimen.notification_min_height_legacy);
+6 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public class NotificationInlineImageResolver implements ImageResolver {
     * @param imageCache The implementation of internal cache.
     */
    public NotificationInlineImageResolver(Context context, ImageCache imageCache) {
        mContext = context.getApplicationContext();
        mContext = context;
        mImageCache = imageCache;

        if (mImageCache != null) {
@@ -77,6 +77,11 @@ public class NotificationInlineImageResolver implements ImageResolver {
        updateMaxImageSizes();
    }

    @VisibleForTesting
    public Context getContext() {
        return mContext;
    }

    /**
     * Check if this resolver has its internal cache implementation.
     * @return True if has its internal cache, false otherwise.
+22 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@

package com.android.systemui;

import android.annotation.NonNull;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -28,12 +29,15 @@ import android.view.Display;

import com.android.internal.annotations.GuardedBy;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class SysuiTestableContext extends TestableContext {

    @GuardedBy("mRegisteredReceivers")
    private final Set<BroadcastReceiver> mRegisteredReceivers = new ArraySet<>();
    private final Map<UserHandle, Context> mContextForUser = new HashMap<>();

    public SysuiTestableContext(Context base) {
        super(base);
@@ -113,4 +117,22 @@ public class SysuiTestableContext extends TestableContext {
        }
        super.unregisterReceiver(receiver);
    }

    /**
     * Sets a Context object that will be returned as the result of {@link #createContextAsUser}
     * for a specific {@code user}.
     */
    public void prepareCreateContextAsUser(UserHandle user, Context context) {
        mContextForUser.put(user, context);
    }

    @Override
    @NonNull
    public Context createContextAsUser(UserHandle user, int flags) {
        Context userContext = mContextForUser.get(user);
        if (userContext != null) {
            return userContext;
        }
        return super.createContextAsUser(user, flags);
    }
}
Loading