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

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

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

Merge cherrypicks of ['googleplex-android-review.googlesource.com/25027409', 'googleplex-android-review.googlesource.com/25165839', 'googleplex-android-review.googlesource.com/25224776', 'googleplex-android-review.googlesource.com/25246670', 'googleplex-android-review.googlesource.com/25097160', 'googleplex-android-review.googlesource.com/25272315', 'googleplex-android-review.googlesource.com/25253990', 'googleplex-android-review.googlesource.com/25235458', 'googleplex-android-review.googlesource.com/25291109', 'googleplex-android-review.googlesource.com/25373704'] into udc-qpr1-release.

Change-Id: I61c48eba58624dd4cd9bd15af71120164dd47abe
parents 6ff78c36 8d20cf7a
Loading
Loading
Loading
Loading
+58 −4
Original line number Diff line number Diff line
@@ -127,6 +127,7 @@ import android.os.GraphicsEnvironment;
import android.os.Handler;
import android.os.HandlerExecutor;
import android.os.IBinder;
import android.os.IBinderCallback;
import android.os.ICancellationSignal;
import android.os.LocaleList;
import android.os.Looper;
@@ -359,6 +360,15 @@ public final class ActivityThread extends ClientTransactionHandler
    /** Maps from activity token to the pending override configuration. */
    @GuardedBy("mPendingOverrideConfigs")
    private final ArrayMap<IBinder, Configuration> mPendingOverrideConfigs = new ArrayMap<>();

    /**
     * A queue of pending ApplicationInfo updates. In case when we get a concurrent update
     * this queue allows us to only apply the latest object, and it can be applied on demand
     * instead of waiting for the handler thread to reach the scheduled callback.
     */
    @GuardedBy("mResourcesManager")
    private final ArrayMap<String, ApplicationInfo> mPendingAppInfoUpdates = new ArrayMap<>();

    /** The activities to be truly destroyed (not include relaunch). */
    final Map<IBinder, ClientTransactionItem> mActivitiesToBeDestroyed =
            Collections.synchronizedMap(new ArrayMap<IBinder, ClientTransactionItem>());
@@ -1260,9 +1270,19 @@ public final class ActivityThread extends ClientTransactionHandler
        }

        public void scheduleApplicationInfoChanged(ApplicationInfo ai) {
            synchronized (mResourcesManager) {
                var oldAi = mPendingAppInfoUpdates.put(ai.packageName, ai);
                if (oldAi != null && oldAi.createTimestamp > ai.createTimestamp) {
                    Slog.w(TAG, "Skipping application info changed for obsolete AI with TS "
                            + ai.createTimestamp + " < already pending TS "
                            + oldAi.createTimestamp);
                    mPendingAppInfoUpdates.put(ai.packageName, oldAi);
                    return;
                }
            }
            mResourcesManager.appendPendingAppInfoUpdate(new String[]{ai.sourceDir}, ai);
            mH.removeMessages(H.APPLICATION_INFO_CHANGED, ai);
            sendMessage(H.APPLICATION_INFO_CHANGED, ai);
            mH.removeMessages(H.APPLICATION_INFO_CHANGED, ai.packageName);
            sendMessage(H.APPLICATION_INFO_CHANGED, ai.packageName);
        }

        public void updateTimeZone() {
@@ -2437,7 +2457,7 @@ public final class ActivityThread extends ClientTransactionHandler
                    break;
                }
                case APPLICATION_INFO_CHANGED:
                    handleApplicationInfoChanged((ApplicationInfo) msg.obj);
                    applyPendingApplicationInfoChanges((String) msg.obj);
                    break;
                case RUN_ISOLATED_ENTRY_POINT:
                    handleRunIsolatedEntryPoint((String) ((SomeArgs) msg.obj).arg1,
@@ -3922,7 +3942,8 @@ public final class ActivityThread extends ClientTransactionHandler
            mProfiler.startProfiling();
        }

        // Make sure we are running with the most recent config.
        // Make sure we are running with the most recent config and resource paths.
        applyPendingApplicationInfoChanges(r.activityInfo.packageName);
        mConfigurationController.handleConfigurationChanged(null, null);
        updateDeviceIdForNonUIContexts(deviceId);

@@ -6248,6 +6269,17 @@ public final class ActivityThread extends ClientTransactionHandler
        r.mLastReportedWindowingMode = newWindowingMode;
    }

    private void applyPendingApplicationInfoChanges(String packageName) {
        final ApplicationInfo ai;
        synchronized (mResourcesManager) {
            ai = mPendingAppInfoUpdates.remove(packageName);
        }
        if (ai == null) {
            return;
        }
        handleApplicationInfoChanged(ai);
    }

    /**
     * Updates the application info.
     *
@@ -6273,6 +6305,16 @@ public final class ActivityThread extends ClientTransactionHandler
            apk = ref != null ? ref.get() : null;
            ref = mResourcePackages.get(ai.packageName);
            resApk = ref != null ? ref.get() : null;
            for (ActivityClientRecord ar : mActivities.values()) {
                if (ar.activityInfo.applicationInfo.packageName.equals(ai.packageName)) {
                    ar.activityInfo.applicationInfo = ai;
                    if (apk != null || resApk != null) {
                        ar.packageInfo = apk != null ? apk : resApk;
                    } else {
                        apk = ar.packageInfo;
                    }
                }
            }
        }

        if (apk != null) {
@@ -7055,6 +7097,18 @@ public final class ActivityThread extends ClientTransactionHandler
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }

        // Set binder transaction callback after finishing bindApplication
        Binder.setTransactionCallback(new IBinderCallback() {
            @Override
            public void onTransactionError(int pid, int code, int flags, int err) {
                try {
                    mgr.frozenBinderTransactionDetected(pid, code, flags, err);
                } catch (RemoteException ex) {
                    throw ex.rethrowFromSystemServer();
                }
            }
        });
    }

    @UnsupportedAppUsage
+36 −0
Original line number Diff line number Diff line
@@ -460,6 +460,33 @@ public final class ApplicationExitInfo implements Parcelable {
     */
    public static final int SUBREASON_SDK_SANDBOX_NOT_NEEDED = 28;

    /**
     * The process was killed because the binder proxy limit for system server was exceeded.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_EXCESSIVE_BINDER_OBJECTS = 29;

    /**
     * The process was killed by the [kernel] Out-of-memory (OOM) killer; this
     * would be set only when the reason is {@link #REASON_LOW_MEMORY}.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_OOM_KILL = 30;

    /**
     * The process was killed because its async kernel binder buffer is running out
     * while being frozen.
     * this would be set only when the reason is {@link #REASON_FREEZER}.
     *
     * For internal use only.
     * @hide
     */
    public static final int SUBREASON_FREEZER_BINDER_ASYNC_FULL = 31;

    // If there is any OEM code which involves additional app kill reasons, it should
    // be categorized in {@link #REASON_OTHER}, with subreason code starting from 1000.

@@ -635,6 +662,9 @@ public final class ApplicationExitInfo implements Parcelable {
        SUBREASON_KILL_BACKGROUND,
        SUBREASON_PACKAGE_UPDATE,
        SUBREASON_UNDELIVERED_BROADCAST,
        SUBREASON_EXCESSIVE_BINDER_OBJECTS,
        SUBREASON_OOM_KILL,
        SUBREASON_FREEZER_BINDER_ASYNC_FULL,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface SubReason {}
@@ -1360,6 +1390,12 @@ public final class ApplicationExitInfo implements Parcelable {
                return "PACKAGE UPDATE";
            case SUBREASON_UNDELIVERED_BROADCAST:
                return "UNDELIVERED BROADCAST";
            case SUBREASON_EXCESSIVE_BINDER_OBJECTS:
                return "EXCESSIVE BINDER OBJECTS";
            case SUBREASON_OOM_KILL:
                return "OOM KILL";
            case SUBREASON_FREEZER_BINDER_ASYNC_FULL:
                return "FREEZER BINDER ASYNC FULL";
            default:
                return "UNKNOWN";
        }
+10 −0
Original line number Diff line number Diff line
@@ -924,4 +924,14 @@ interface IActivityManager {
    void unregisterUidFrozenStateChangedCallback(in IUidFrozenStateChangedCallback callback);
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)")
    int[] getUidFrozenState(in int[] uids);

    /**
     * Notify AMS about binder transactions to frozen apps.
     *
     * @param debugPid The binder transaction sender
     * @param code The binder transaction code
     * @param flags The binder transaction flags
     * @param err The binder transaction error
     */
    oneway void frozenBinderTransactionDetected(int debugPid, int code, int flags, int err);
}
+11 −2
Original line number Diff line number Diff line
@@ -343,7 +343,9 @@ public final class LoadedApk {
     */
    public void updateApplicationInfo(@NonNull ApplicationInfo aInfo,
            @Nullable List<String> oldPaths) {
        setApplicationInfo(aInfo);
        if (!setApplicationInfo(aInfo)) {
            return;
        }

        final List<String> newPaths = new ArrayList<>();
        makePaths(mActivityThread, aInfo, newPaths);
@@ -388,7 +390,13 @@ public final class LoadedApk {
        mAppComponentFactory = createAppFactory(aInfo, mDefaultClassLoader);
    }

    private void setApplicationInfo(ApplicationInfo aInfo) {
    private boolean setApplicationInfo(ApplicationInfo aInfo) {
        if (mApplicationInfo != null && mApplicationInfo.createTimestamp > aInfo.createTimestamp) {
            Slog.w(TAG, "New application info for package " + aInfo.packageName
                    + " is out of date with TS " + aInfo.createTimestamp + " < the current TS "
                    + mApplicationInfo.createTimestamp);
            return false;
        }
        final int myUid = Process.myUid();
        aInfo = adjustNativeLibraryPaths(aInfo);
        mApplicationInfo = aInfo;
@@ -411,6 +419,7 @@ public final class LoadedApk {
        if (aInfo.requestsIsolatedSplitLoading() && !ArrayUtils.isEmpty(mSplitNames)) {
            mSplitLoader = new SplitDependencyLoaderImpl(aInfo.splitDependencies);
        }
        return true;
    }

    void setSdkSandboxStorage(@Nullable String sdkSandboxClientAppVolumeUuid,
+26 −0
Original line number Diff line number Diff line
@@ -642,6 +642,32 @@ public class Binder implements IBinder {
     */
    public static final native void blockUntilThreadAvailable();


    /**
     * TODO (b/308179628): Move this to libbinder for non-Java usages.
     */
    private static IBinderCallback sBinderCallback = null;

    /**
     * Set callback function for unexpected binder transaction errors.
     *
     * @hide
     */
    public static final void setTransactionCallback(IBinderCallback callback) {
        sBinderCallback = callback;
    }

    /**
     * Execute the callback function if it's already set.
     *
     * @hide
     */
    public static final void transactionCallback(int pid, int code, int flags, int err) {
        if (sBinderCallback != null) {
            sBinderCallback.onTransactionError(pid, code, flags, err);
        }
    }

    /**
     * Default constructor just initializes the object.
     *
Loading