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

Commit 2f55e5a9 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Fix various issues in ordering of grouped bindings.

Everything needed to get the CTS tests to work.

Also:

- Change process names to be unique per isolated instance,
  and no longer use isolated uid in proc stats, so we don't
  have a crazy number of process entries there.
- Again move activity manager dumpsys output so we aren't
  spewing less useful stuff at the end where it hides the
  core state about processes.
- Fix protos so that we can read InstrumentationInfo from the
  activity manager protos.  (There was confusion about writing
  protos for a PackageItemInfo vs. an ApplicationInfo.)

Test: atest CtsAppTestCases:ServiceTest\#testActivityServiceBindingLru
Bug: 111434506
Change-Id: I2c86bd1daa582a5c60950173ca12e8ec21b13ead
parent 299a573c
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -1729,8 +1729,11 @@ class ContextImpl extends Context {
            throw new IllegalArgumentException("connection is null");
            throw new IllegalArgumentException("connection is null");
        }
        }
        if (mPackageInfo != null) {
        if (mPackageInfo != null) {
            IServiceConnection sd = mPackageInfo.forgetServiceDispatcher(
            IServiceConnection sd = mPackageInfo.lookupServiceDispatcher(conn, getOuterContext());
                    getOuterContext(), conn);
            if (sd == null) {
                throw new IllegalArgumentException("ServiceConnection not currently bound: "
                        + conn);
            }
            try {
            try {
                ActivityManager.getService().updateServiceGroup(sd, group, importance);
                ActivityManager.getService().updateServiceGroup(sd, group, importance);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
+13 −0
Original line number Original line Diff line number Diff line
@@ -1639,6 +1639,19 @@ public final class LoadedApk {
        }
        }
    }
    }


    @UnsupportedAppUsage
    public IServiceConnection lookupServiceDispatcher(ServiceConnection c,
            Context context) {
        synchronized (mServices) {
            LoadedApk.ServiceDispatcher sd = null;
            ArrayMap<ServiceConnection, LoadedApk.ServiceDispatcher> map = mServices.get(context);
            if (map != null) {
                sd = map.get(c);
            }
            return sd != null ? sd.getIServiceConnection() : null;
        }
    }

    public final IServiceConnection forgetServiceDispatcher(Context context,
    public final IServiceConnection forgetServiceDispatcher(Context context,
            ServiceConnection c) {
            ServiceConnection c) {
        synchronized (mServices) {
        synchronized (mServices) {
+5 −0
Original line number Original line Diff line number Diff line
@@ -3003,6 +3003,11 @@ public abstract class Context {
     * how the process will be managed in some cases based on those flags.  Currently only
     * how the process will be managed in some cases based on those flags.  Currently only
     * works on isolated processes (will be ignored for non-isolated processes).
     * works on isolated processes (will be ignored for non-isolated processes).
     *
     *
     * <p>Note that this call does not take immediate effect, but will be applied the next
     * time the impacted process is adjusted for some other reason.  Typically you would
     * call this before then calling a new {@link #bindIsolatedService} on the service
     * of interest, with that binding causing the process to be shuffled accordingly.</p>
     *
     * @param conn The connection interface previously supplied to bindService().  This
     * @param conn The connection interface previously supplied to bindService().  This
     *             parameter must not be null.
     *             parameter must not be null.
     * @param group A group to put this connection's process in.  Upon calling here, this
     * @param group A group to put this connection's process in.  Upon calling here, this
+1 −1
Original line number Original line Diff line number Diff line
@@ -1303,7 +1303,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    /** {@hide} */
    /** {@hide} */
    public void writeToProto(ProtoOutputStream proto, long fieldId, int dumpFlags) {
    public void writeToProto(ProtoOutputStream proto, long fieldId, int dumpFlags) {
        long token = proto.start(fieldId);
        long token = proto.start(fieldId);
        super.writeToProto(proto, ApplicationInfoProto.PACKAGE);
        super.writeToProto(proto, ApplicationInfoProto.PACKAGE, dumpFlags);
        proto.write(ApplicationInfoProto.PERMISSION, permission);
        proto.write(ApplicationInfoProto.PERMISSION, permission);
        proto.write(ApplicationInfoProto.PROCESS_NAME, processName);
        proto.write(ApplicationInfoProto.PROCESS_NAME, processName);
        proto.write(ApplicationInfoProto.UID, uid);
        proto.write(ApplicationInfoProto.UID, uid);
+5 −5
Original line number Original line Diff line number Diff line
@@ -433,18 +433,18 @@ public class PackageItemInfo {
    /**
    /**
     * @hide
     * @hide
     */
     */
    public void writeToProto(ProtoOutputStream proto, long fieldId) {
    public void writeToProto(ProtoOutputStream proto, long fieldId, int dumpFlags) {
        long token = proto.start(fieldId);
        long token = proto.start(fieldId);
        if (name != null) {
        if (name != null) {
            proto.write(PackageItemInfoProto.NAME, name);
            proto.write(PackageItemInfoProto.NAME, name);
        }
        }
        proto.write(PackageItemInfoProto.PACKAGE_NAME, packageName);
        proto.write(PackageItemInfoProto.PACKAGE_NAME, packageName);
        if (labelRes != 0 || nonLocalizedLabel != null || icon != 0 || banner != 0) {
        proto.write(PackageItemInfoProto.LABEL_RES, labelRes);
        proto.write(PackageItemInfoProto.LABEL_RES, labelRes);
        if (nonLocalizedLabel != null) {
            proto.write(PackageItemInfoProto.NON_LOCALIZED_LABEL, nonLocalizedLabel.toString());
            proto.write(PackageItemInfoProto.NON_LOCALIZED_LABEL, nonLocalizedLabel.toString());
        }
        proto.write(PackageItemInfoProto.ICON, icon);
        proto.write(PackageItemInfoProto.ICON, icon);
        proto.write(PackageItemInfoProto.BANNER, banner);
        proto.write(PackageItemInfoProto.BANNER, banner);
        }
        proto.end(token);
        proto.end(token);
    }
    }


Loading