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

Commit ed463102 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Optimize the Parcel read/write of common window data" into sc-dev

parents 287b9cb0 b293d933
Loading
Loading
Loading
Loading
+11 −14
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
     * TODO: Investigate combining with {@link #mAppBounds}. Can the latter be a product of the
     * former?
     */
    private Rect mBounds = new Rect();
    private final Rect mBounds = new Rect();

    /**
     * {@link android.graphics.Rect} defining app bounds. The dimensions override usages of
@@ -71,7 +71,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
     * The maximum {@link Rect} bounds that an app can expect. It is used to report value of
     * {@link WindowManager#getMaximumWindowMetrics()}.
     */
    private Rect mMaxBounds = new Rect();
    private final Rect mMaxBounds = new Rect();

    /**
     * The current rotation of this window container relative to the default
@@ -240,9 +240,9 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(mBounds, flags);
        dest.writeParcelable(mAppBounds, flags);
        dest.writeParcelable(mMaxBounds, flags);
        mBounds.writeToParcel(dest, flags);
        dest.writeTypedObject(mAppBounds, flags);
        mMaxBounds.writeToParcel(dest, flags);
        dest.writeInt(mWindowingMode);
        dest.writeInt(mActivityType);
        dest.writeInt(mAlwaysOnTop);
@@ -250,10 +250,11 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
        dest.writeInt(mDisplayWindowingMode);
    }

    private void readFromParcel(Parcel source) {
        mBounds = source.readParcelable(Rect.class.getClassLoader());
        mAppBounds = source.readParcelable(Rect.class.getClassLoader());
        mMaxBounds = source.readParcelable(Rect.class.getClassLoader());
    /** @hide */
    public void readFromParcel(@NonNull Parcel source) {
        mBounds.readFromParcel(source);
        mAppBounds = source.readTypedObject(Rect.CREATOR);
        mMaxBounds.readFromParcel(source);
        mWindowingMode = source.readInt();
        mActivityType = source.readInt();
        mAlwaysOnTop = source.readInt();
@@ -693,9 +694,7 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
        }
        protoOutputStream.write(WINDOWING_MODE, mWindowingMode);
        protoOutputStream.write(ACTIVITY_TYPE, mActivityType);
        if (mBounds != null) {
        mBounds.dumpDebug(protoOutputStream, BOUNDS);
        }
        mMaxBounds.dumpDebug(protoOutputStream, MAX_BOUNDS);
        protoOutputStream.end(token);
    }
@@ -719,11 +718,9 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
                        mAppBounds.readFromProto(proto, APP_BOUNDS);
                        break;
                    case (int) BOUNDS:
                        mBounds = new Rect();
                        mBounds.readFromProto(proto, BOUNDS);
                        break;
                    case (int) MAX_BOUNDS:
                        mMaxBounds = new Rect();
                        mMaxBounds.readFromProto(proto, MAX_BOUNDS);
                        break;
                    case (int) WINDOWING_MODE:
+4 −4
Original line number Diff line number Diff line
@@ -1956,7 +1956,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        dest.writeInt(mnc);

        fixUpLocaleList();
        dest.writeParcelable(mLocaleList, flags);
        dest.writeTypedObject(mLocaleList, flags);

        if(userSetLocale) {
            dest.writeInt(1);
@@ -1980,7 +1980,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        dest.writeInt(compatScreenWidthDp);
        dest.writeInt(compatScreenHeightDp);
        dest.writeInt(compatSmallestScreenWidthDp);
        dest.writeValue(windowConfiguration);
        windowConfiguration.writeToParcel(dest, flags);
        dest.writeInt(assetsSeq);
        dest.writeInt(seq);
        dest.writeInt(fontWeightAdjustment);
@@ -1991,7 +1991,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        mcc = source.readInt();
        mnc = source.readInt();

        mLocaleList = source.readParcelable(LocaleList.class.getClassLoader());
        mLocaleList = source.readTypedObject(LocaleList.CREATOR);
        locale = mLocaleList.get(0);

        userSetLocale = (source.readInt()==1);
@@ -2012,7 +2012,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        compatScreenWidthDp = source.readInt();
        compatScreenHeightDp = source.readInt();
        compatSmallestScreenWidthDp = source.readInt();
        windowConfiguration.setTo((WindowConfiguration) source.readValue(null));
        windowConfiguration.readFromParcel(source);
        assetsSeq = source.readInt();
        seq = source.readInt();
        fontWeightAdjustment = source.readInt();
+9 −9
Original line number Diff line number Diff line
@@ -33,9 +33,9 @@ import java.io.PrintWriter;
 */
public class MergedConfiguration implements Parcelable {

    private Configuration mGlobalConfig = new Configuration();
    private Configuration mOverrideConfig = new Configuration();
    private Configuration mMergedConfig = new Configuration();
    private final Configuration mGlobalConfig = new Configuration();
    private final Configuration mOverrideConfig = new Configuration();
    private final Configuration mMergedConfig = new Configuration();

    public MergedConfiguration() {
    }
@@ -59,15 +59,15 @@ public class MergedConfiguration implements Parcelable {

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(mGlobalConfig, flags);
        dest.writeParcelable(mOverrideConfig, flags);
        dest.writeParcelable(mMergedConfig, flags);
        mGlobalConfig.writeToParcel(dest, flags);
        mOverrideConfig.writeToParcel(dest, flags);
        mMergedConfig.writeToParcel(dest, flags);
    }

    public void readFromParcel(Parcel source) {
        mGlobalConfig = source.readParcelable(Configuration.class.getClassLoader());
        mOverrideConfig = source.readParcelable(Configuration.class.getClassLoader());
        mMergedConfig = source.readParcelable(Configuration.class.getClassLoader());
        mGlobalConfig.readFromParcel(source);
        mOverrideConfig.readFromParcel(source);
        mMergedConfig.readFromParcel(source);
    }

    @Override
+2 −11
Original line number Diff line number Diff line
@@ -261,11 +261,7 @@ public class InsetsSource implements Parcelable {

    public InsetsSource(Parcel in) {
        mType = in.readInt();
        if (in.readInt() != 0) {
        mFrame = Rect.CREATOR.createFromParcel(in);
        } else {
            mFrame = null;
        }
        if (in.readInt() != 0) {
            mVisibleFrame = Rect.CREATOR.createFromParcel(in);
        } else {
@@ -282,12 +278,7 @@ public class InsetsSource implements Parcelable {
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mType);
        if (mFrame != null) {
            dest.writeInt(1);
        mFrame.writeToParcel(dest, 0);
        } else {
            dest.writeInt(0);
        }
        if (mVisibleFrame != null) {
            dest.writeInt(1);
            mVisibleFrame.writeToParcel(dest, 0);
+4 −4
Original line number Diff line number Diff line
@@ -77,8 +77,8 @@ public class InsetsSourceControl implements Parcelable {

    public InsetsSourceControl(Parcel in) {
        mType = in.readInt();
        mLeash = in.readParcelable(null /* loader */);
        mSurfacePosition = in.readParcelable(null /* loader */);
        mLeash = in.readTypedObject(SurfaceControl.CREATOR);
        mSurfacePosition = in.readTypedObject(Point.CREATOR);
        mSkipAnimationOnce = in.readBoolean();
    }

@@ -119,8 +119,8 @@ public class InsetsSourceControl implements Parcelable {
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mType);
        dest.writeParcelable(mLeash, 0 /* flags*/);
        dest.writeParcelable(mSurfacePosition, 0 /* flags*/);
        dest.writeTypedObject(mLeash, 0 /* parcelableFlags */);
        dest.writeTypedObject(mSurfacePosition, 0 /* parcelableFlags */);
        dest.writeBoolean(mSkipAnimationOnce);
    }

Loading