diff options
| author | Michael Wachenschwanz <mwachens@google.com> | 2018-09-07 14:59:25 -0700 |
|---|---|---|
| committer | Michael Wachenschwanz <mwachens@google.com> | 2018-09-28 16:48:23 -0700 |
| commit | c8c26365a4bc237cccb462ef903c837f73833c23 (patch) | |
| tree | 37cd90fe4168c24ea3480b058f079bd52769f36b /core/java/android/app/WindowConfiguration.java | |
| parent | c210031d085b510450c49bf2da0ac7bd9024c4be (diff) | |
Upgrade UsageStatsDatabase from XML to Protobuf
Add the relevant methods to read from ProtoInputStream to
various classes.
Also add some framework to handle version changes in
UsageStatsDatabase. There is some risk of users losing all their current
UsageStats data, if something goes horribly wrong. The debug flag and a
keep backup files flag are temporarily set in UsageStatsDatabase with
this change. They will both be unset in the future before the Q release.
Some rough number on the impact of this change:
Proto file size on disk reduces to ~47% of XML file size :)
Proto file read time reduces to ~55% of XML file read :)
Proto file write time increases ~17% over the XML file write :(
There will be a follow up CL to address the file write time regression
Bug: 111422946
Fixes: 111449927
Test: atest UsageStatsDatabaseTest
Change-Id: I084aea796ed2163c42947d52396a36cc7c5562a2
Diffstat (limited to 'core/java/android/app/WindowConfiguration.java')
| -rw-r--r-- | core/java/android/app/WindowConfiguration.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/java/android/app/WindowConfiguration.java b/core/java/android/app/WindowConfiguration.java index e6fb5dc02ce3..096c7aa44446 100644 --- a/core/java/android/app/WindowConfiguration.java +++ b/core/java/android/app/WindowConfiguration.java @@ -28,9 +28,13 @@ import android.content.res.Configuration; import android.graphics.Rect; import android.os.Parcel; import android.os.Parcelable; +import android.util.proto.ProtoInputStream; import android.util.proto.ProtoOutputStream; +import android.util.proto.WireTypeMismatchException; import android.view.DisplayInfo; +import java.io.IOException; + /** * Class that contains windowing configuration/state for other objects that contain windows directly * or indirectly. E.g. Activities, Task, Displays, ... @@ -511,6 +515,38 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu } /** + * Read from a protocol buffer input stream. + * Protocol buffer message definition at {@link android.app.WindowConfigurationProto} + * + * @param proto Stream to read the WindowConfiguration object from. + * @param fieldId Field Id of the WindowConfiguration as defined in the parent message + * @hide + */ + public void readFromProto(ProtoInputStream proto, long fieldId) + throws IOException, WireTypeMismatchException { + final long token = proto.start(fieldId); + try { + while (proto.nextField() != ProtoInputStream.NO_MORE_FIELDS) { + switch (proto.getFieldNumber()) { + case (int) APP_BOUNDS: + mAppBounds = new Rect(); + mAppBounds.readFromProto(proto, APP_BOUNDS); + break; + case (int) WINDOWING_MODE: + mWindowingMode = proto.readInt(WINDOWING_MODE); + break; + case (int) ACTIVITY_TYPE: + mActivityType = proto.readInt(ACTIVITY_TYPE); + break; + } + } + } finally { + // Let caller handle any exceptions + proto.end(token); + } + } + + /** * Returns true if the activities associated with this window configuration display a shadow * around their border. * @hide |
