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

Commit a1d9b440 authored by /e/ robot's avatar /e/ robot
Browse files

Merge remote-tracking branch 'origin/lineage-16.0' into v1-pie

parents 61d838f2 31664aa5
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -88,6 +88,12 @@ public class Account implements Parcelable {
    public Account(Parcel in) {
        this.name = in.readString();
        this.type = in.readString();
        if (TextUtils.isEmpty(name)) {
            throw new android.os.BadParcelableException("the name must not be empty: " + name);
        }
        if (TextUtils.isEmpty(type)) {
            throw new android.os.BadParcelableException("the type must not be empty: " + type);
        }
        this.accessId = in.readString();
        if (accessId != null) {
            synchronized (sAccessedAccounts) {
+31 −6
Original line number Diff line number Diff line
@@ -16,16 +16,23 @@
package android.accounts;

import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.LinearLayout;
import android.view.View;
import android.view.LayoutInflater;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.internal.R;

import java.io.IOException;
@@ -42,11 +49,15 @@ public class GrantCredentialsPermissionActivity extends Activity implements View
    private Account mAccount;
    private String mAuthTokenType;
    private int mUid;
    private int mCallingUid;
    private Bundle mResultBundle = null;
    protected LayoutInflater mInflater;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addPrivateFlags(
                android.view.WindowManager.LayoutParams
                        .PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS);
        setContentView(R.layout.grant_credentials_permission);
        setTitle(R.string.grant_permissions_header_text);

@@ -74,6 +85,20 @@ public class GrantCredentialsPermissionActivity extends Activity implements View
            return;
        }

        try {
            IBinder activityToken = getActivityToken();
            mCallingUid = ActivityManager.getService().getLaunchedFromUid(activityToken);
        } catch (RemoteException re) {
            // Couldn't figure out caller details
            Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re);
        }

        if (!UserHandle.isSameApp(mCallingUid, Process.SYSTEM_UID) && mCallingUid != mUid) {
            setResult(Activity.RESULT_CANCELED);
            finish();
            return;
        }

        String accountTypeLabel;
        try {
            accountTypeLabel = getAccountLabel(mAccount);
+0 −5
Original line number Diff line number Diff line
@@ -152,10 +152,6 @@ public abstract class SliceProvider extends ContentProvider {
     * @hide
     */
    public static final String EXTRA_PKG = "pkg";
    /**
     * @hide
     */
    public static final String EXTRA_PROVIDER_PKG = "provider_pkg";
    /**
     * @hide
     */
@@ -519,7 +515,6 @@ public abstract class SliceProvider extends ContentProvider {
                "com.android.systemui.SlicePermissionActivity"));
        intent.putExtra(EXTRA_BIND_URI, sliceUri);
        intent.putExtra(EXTRA_PKG, callingPackage);
        intent.putExtra(EXTRA_PROVIDER_PKG, context.getPackageName());
        // Unique pending intent.
        intent.setData(sliceUri.buildUpon().appendQueryParameter("package", callingPackage)
                .build());
+28 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ package com.android.systemui;

import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS;

import android.annotation.Nullable;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.slice.SliceManager;
@@ -28,6 +29,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
import android.text.BidiFormatter;
import android.util.EventLog;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.TextView;
@@ -49,10 +51,12 @@ public class SlicePermissionActivity extends Activity implements OnClickListener

        mUri = getIntent().getParcelableExtra(SliceProvider.EXTRA_BIND_URI);
        mCallingPkg = getIntent().getStringExtra(SliceProvider.EXTRA_PKG);
        mProviderPkg = getIntent().getStringExtra(SliceProvider.EXTRA_PROVIDER_PKG);

        try {
            PackageManager pm = getPackageManager();
            mProviderPkg = pm.resolveContentProvider(mUri.getAuthority(),
                    PackageManager.GET_META_DATA).applicationInfo.packageName;
            verifyCallingPkg();
            CharSequence app1 = BidiFormatter.getInstance().unicodeWrap(
                    pm.getApplicationInfo(mCallingPkg, 0).loadSafeLabel(pm).toString());
            CharSequence app2 = BidiFormatter.getInstance().unicodeWrap(
@@ -92,4 +96,27 @@ public class SlicePermissionActivity extends Activity implements OnClickListener
    public void onDismiss(DialogInterface dialog) {
        finish();
    }

    private void verifyCallingPkg() {
        final String providerPkg = getIntent().getStringExtra("provider_pkg");
        if (providerPkg == null || mProviderPkg.equals(providerPkg)) return;
        final String callingPkg = getCallingPkg();
        EventLog.writeEvent(0x534e4554, "159145361", getUid(callingPkg));
    }

    @Nullable
    private String getCallingPkg() {
        final Uri referrer = getReferrer();
        if (referrer == null) return null;
        return referrer.getHost();
    }

    private int getUid(@Nullable final String pkg) {
        if (pkg == null) return -1;
        try {
            return getPackageManager().getApplicationInfo(pkg, 0).uid;
        } catch (NameNotFoundException e) {
        }
        return -1;
    }
}
+48 −37
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ class SaveImageInBackgroundData {
        imageUri = null;
        iconSize = 0;
    }

    void clearContext() {
        context = null;
    }
@@ -407,7 +408,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
            mPublicNotificationBuilder
                    .setContentTitle(r.getString(R.string.screenshot_saved_title))
                    .setContentText(r.getString(R.string.screenshot_saved_text))
                    .setContentIntent(PendingIntent.getActivity(mParams.context, 0, launchIntent, 0))
                    .setContentIntent(PendingIntent.getActivity(mParams.context, 0, launchIntent,
                            PendingIntent.FLAG_IMMUTABLE))
                    .setWhen(now)
                    .setAutoCancel(true)
                    .setColor(context.getColor(
@@ -415,7 +417,8 @@ class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
            mNotificationBuilder
                    .setContentTitle(r.getString(R.string.screenshot_saved_title))
                    .setContentText(r.getString(R.string.screenshot_saved_text))
                .setContentIntent(PendingIntent.getActivity(mParams.context, 0, launchIntent, 0))
                    .setContentIntent(PendingIntent.getActivity(mParams.context, 0, launchIntent,
                            PendingIntent.FLAG_IMMUTABLE))
                    .setWhen(now)
                    .setAutoCancel(true)
                    .setColor(context.getColor(
@@ -522,7 +525,8 @@ class GlobalScreenshot {
        // Inflate the screenshot layout
        mDisplayMatrix = new Matrix();
        mScreenshotLayout = layoutInflater.inflate(R.layout.global_screenshot, null);
        mBackgroundView = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot_background);
        mBackgroundView = (ImageView) mScreenshotLayout.findViewById(
                R.id.global_screenshot_background);
        mScreenshotView = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot);
        mScreenshotFlash = (ImageView) mScreenshotLayout.findViewById(R.id.global_screenshot_flash);
        mScreenshotSelectorView = (ScreenshotSelectorView) mScreenshotLayout.findViewById(
@@ -551,6 +555,7 @@ class GlobalScreenshot {
        mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        mNotificationManager =
            (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        mDisplay = mWindowManager.getDefaultDisplay();
        mDisplayMetrics = new DisplayMetrics();
        mDisplay.getRealMetrics(mDisplayMetrics);
@@ -763,6 +768,7 @@ class GlobalScreenshot {
            }
        });
    }

    private ValueAnimator createScreenshotDropInAnimation() {
        final float flashPeakDurationPct = ((float) (SCREENSHOT_FLASH_TO_PEAK_DURATION)
                / SCREENSHOT_DROP_IN_DURATION);
@@ -803,6 +809,7 @@ class GlobalScreenshot {
                mScreenshotFlash.setAlpha(0f);
                mScreenshotFlash.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(android.animation.Animator animation) {
                mScreenshotFlash.setVisibility(View.GONE);
@@ -824,6 +831,7 @@ class GlobalScreenshot {
        });
        return anim;
    }

    private ValueAnimator createScreenshotDropOutAnimation(int w, int h, boolean statusBarVisible,
            boolean navBarVisible) {
        ValueAnimator anim = ValueAnimator.ofFloat(0f, 1f);
@@ -845,7 +853,8 @@ class GlobalScreenshot {
                public void onAnimationUpdate(ValueAnimator animation) {
                    float t = (Float) animation.getAnimatedValue();
                    float scaleT = (SCREENSHOT_DROP_IN_MIN_SCALE + mBgPaddingScale)
                            - t * (SCREENSHOT_DROP_IN_MIN_SCALE - SCREENSHOT_FAST_DROP_OUT_MIN_SCALE);
                            - t * (SCREENSHOT_DROP_IN_MIN_SCALE
                            - SCREENSHOT_FAST_DROP_OUT_MIN_SCALE);
                    mBackgroundView.setAlpha((1f - t) * BACKGROUND_ALPHA);
                    mScreenshotView.setAlpha(1f - t);
                    mScreenshotView.setScaleX(scaleT);
@@ -872,8 +881,10 @@ class GlobalScreenshot {
            float halfScreenHeight = (h - 2f * mBgPadding) / 2f;
            final float offsetPct = SCREENSHOT_DROP_OUT_MIN_SCALE_OFFSET;
            final PointF finalPos = new PointF(
                -halfScreenWidth + (SCREENSHOT_DROP_OUT_MIN_SCALE + offsetPct) * halfScreenWidth,
                -halfScreenHeight + (SCREENSHOT_DROP_OUT_MIN_SCALE + offsetPct) * halfScreenHeight);
                    -halfScreenWidth
                            + (SCREENSHOT_DROP_OUT_MIN_SCALE + offsetPct) * halfScreenWidth,
                    -halfScreenHeight
                            + (SCREENSHOT_DROP_OUT_MIN_SCALE + offsetPct) * halfScreenHeight);

            // Animate the screenshot to the status bar
            anim.setDuration(SCREENSHOT_DROP_OUT_DURATION);
@@ -918,7 +929,7 @@ class GlobalScreenshot {
                DevicePolicyManager.POLICY_DISABLE_SCREEN_CAPTURE);
        if (intent != null) {
            final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(
                    context, 0, intent, 0, null, UserHandle.CURRENT);
                    context, 0, intent, PendingIntent.FLAG_IMMUTABLE, null, UserHandle.CURRENT);
            b.setContentIntent(pendingIntent);
        }

Loading