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

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

Snap for 7498377 from 8e4f478f to sc-release

Change-Id: Iebe319fc969c21ebc404369a4ce3d5e2f1cae1d4
parents 3dd391fc 8e4f478f
Loading
Loading
Loading
Loading
+296 −237

File changed.

Preview size limit exceeded, changes collapsed.

+2 −10
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.ApplicationInfoFlags;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetManager;
import android.content.res.CompatResources;
@@ -2462,7 +2461,7 @@ class ContextImpl extends Context {
    public Context createApplicationContext(ApplicationInfo application, int flags)
            throws NameNotFoundException {
        LoadedApk pi = mMainThread.getPackageInfo(application, mResources.getCompatibilityInfo(),
                flags | CONTEXT_REGISTER_PACKAGE);
                flags | CONTEXT_REGISTER_PACKAGE, false);
        if (pi != null) {
            ContextImpl c = new ContextImpl(this, mMainThread, pi, ContextParams.EMPTY,
                    mAttributionSource.getAttributionTag(),
@@ -2494,13 +2493,6 @@ class ContextImpl extends Context {
    @Override
    public Context createPackageContextAsUser(String packageName, int flags, UserHandle user)
            throws NameNotFoundException {
        return createPackageContextAsUser(packageName, flags, user, 0 /* packageFlags */);
    }

    @Override
    public Context createPackageContextAsUser(
            @NonNull String packageName, @CreatePackageOptions int flags, @NonNull UserHandle user,
            @ApplicationInfoFlags int packageFlags) throws PackageManager.NameNotFoundException {
        if (packageName.equals("system") || packageName.equals("android")) {
            // The system resources are loaded in every application, so we can safely copy
            // the context without reloading Resources.
@@ -2511,7 +2503,7 @@ class ContextImpl extends Context {
        }

        LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(),
                flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier(), packageFlags);
                flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier());
        if (pi != null) {
            ContextImpl c = new ContextImpl(this, mMainThread, pi, mParams,
                    mAttributionSource.getAttributionTag(),
+3 −4
Original line number Diff line number Diff line
@@ -6344,11 +6344,10 @@ public class Notification implements Parcelable
            ApplicationInfo applicationInfo = n.extras.getParcelable(
                    EXTRA_BUILDER_APPLICATION_INFO);
            Context builderContext;
            if (applicationInfo != null && applicationInfo.packageName != null) {
            if (applicationInfo != null) {
                try {
                    builderContext = context.createPackageContextAsUser(applicationInfo.packageName,
                            Context.CONTEXT_RESTRICTED,
                            UserHandle.getUserHandleForUid(applicationInfo.uid));
                    builderContext = context.createApplicationContext(applicationInfo,
                            Context.CONTEXT_RESTRICTED);
                } catch (NameNotFoundException e) {
                    Log.e(TAG, "ApplicationInfo " + applicationInfo + " not found");
                    builderContext = context;  // try with our context
+38 −5
Original line number Diff line number Diff line
@@ -97,6 +97,12 @@ public class ResourcesManager {
     */
    private int mResDisplayId = DEFAULT_DISPLAY;

    /**
     * ApplicationInfo changes that need to be applied to Resources when the next configuration
     * change occurs.
     */
    private ArrayList<ApplicationInfo> mPendingAppInfoUpdates;

    /**
     * A mapping of ResourceImpls and their configurations. These are heavy weight objects
     * which should be reused as much as possible.
@@ -988,7 +994,7 @@ public class ResourcesManager {
     * @param classLoader The classloader to use for the Resources object.
     *                    If null, {@link ClassLoader#getSystemClassLoader()} is used.
     * @return A Resources object that gets updated when
     *         {@link #applyConfigurationToResourcesLocked(Configuration, CompatibilityInfo)}
     *         {@link #applyConfigurationToResources(Configuration, CompatibilityInfo)}
     *         is called.
     */
    @Nullable
@@ -1115,8 +1121,8 @@ public class ResourcesManager {
    /**
     * Updates an Activity's Resources object with overrideConfig. The Resources object
     * that was previously returned by {@link #getResources(IBinder, String, String[], String[],
     * String[], Integer, Configuration, CompatibilityInfo, ClassLoader, List)} is still valid and
     * will have the updated configuration.
     * String[], String[], Integer, Configuration, CompatibilityInfo, ClassLoader, List)} is still
     * valid and will have the updated configuration.
     *
     * @param activityToken The Activity token.
     * @param overrideConfig The configuration override to update.
@@ -1267,6 +1273,22 @@ public class ResourcesManager {
        return newKey;
    }

    public void updatePendingAppInfoUpdates(@NonNull ApplicationInfo appInfo) {
        synchronized (mLock) {
            if (mPendingAppInfoUpdates == null) {
                mPendingAppInfoUpdates = new ArrayList<>();
            }
            // Clear previous app info changes for the package to prevent multiple ResourcesImpl
            // recreations when only the last recreation will be used.
            for (int i = mPendingAppInfoUpdates.size() - 1; i >= 0; i--) {
                if (appInfo.sourceDir.equals(mPendingAppInfoUpdates.get(i).sourceDir)) {
                    mPendingAppInfoUpdates.remove(i);
                }
            }
            mPendingAppInfoUpdates.add(appInfo);
        }
    }

    public final boolean applyConfigurationToResources(@NonNull Configuration config,
            @Nullable CompatibilityInfo compat) {
        return applyConfigurationToResources(config, compat, null /* adjustments */);
@@ -1280,7 +1302,18 @@ public class ResourcesManager {
                Trace.traceBegin(Trace.TRACE_TAG_RESOURCES,
                        "ResourcesManager#applyConfigurationToResources");

                if (!mResConfiguration.isOtherSeqNewer(config) && compat == null) {
                final boolean assetsUpdated = mPendingAppInfoUpdates != null
                        && config.assetsSeq > mResConfiguration.assetsSeq;
                if (assetsUpdated) {
                    for (int i = 0, n = mPendingAppInfoUpdates.size(); i < n; i++) {
                        final ApplicationInfo appInfo = mPendingAppInfoUpdates.get(i);
                        applyNewResourceDirs(appInfo, new String[]{appInfo.sourceDir});
                    }
                    mPendingAppInfoUpdates = null;
                }

                if (!assetsUpdated && !mResConfiguration.isOtherSeqNewer(config)
                        && compat == null) {
                    if (DEBUG || DEBUG_CONFIGURATION) {
                        Slog.v(TAG, "Skipping new config: curSeq="
                                + mResConfiguration.seq + ", newSeq=" + config.seq);
@@ -1320,7 +1353,7 @@ public class ResourcesManager {
                    }
                }

                return changes != 0;
                return assetsUpdated || changes != 0;
            } finally {
                Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
            }
+3 −5
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Parcelable;
import android.os.UserHandle;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Pair;
@@ -719,10 +718,9 @@ public class AppWidgetHostView extends FrameLayout {
    protected Context getRemoteContext() {
        try {
            // Return if cloned successfully, otherwise default
            final ApplicationInfo info = mInfo.providerInfo.applicationInfo;
            Context newContext = mContext.createPackageContextAsUser(info.packageName,
                    Context.CONTEXT_RESTRICTED,
                    UserHandle.getUserHandleForUid(info.uid));
            Context newContext = mContext.createApplicationContext(
                    mInfo.providerInfo.applicationInfo,
                    Context.CONTEXT_RESTRICTED);
            if (mColorResources != null) {
                mColorResources.apply(newContext);
            }
Loading