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

Commit 4aacd713 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Collect historical appops by feature

This
- pipes through the featureId from AppOpsService to HistoricalRegistry
- changes the file format of historical app ops by adding the feature-id
  tag. This will make us loose all previously collected app-ops. This is
  ok as we never shipped a device with historical app-ops enabled
- Adds a new layer to the HistoricalOps hierarchy. For backwards
  compatibility it is possible to go directly from package to op. In this
  case a combined HistoricalOp object is generated on the fly.
- It is possible to filter historical ops requests by featureId.
  Unfortunately a 'null' featureId is a valid ID. Hence there is now a
  dedicated mask of paramters to filter for (@HistoricalOpsRequestFilter).
- Fixes the equals methods of HistoricalOp by implementing an equals
  method for LongSparseLongArray

Test: atest CtsAppOpsTestCases AppOpsServiceTest
Bug: 136595429
Change-Id: I92c41e8ae2cd471051c2d628d49a3ad6a5a66330
parent 03f00fc5
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -413,6 +413,16 @@ package android.app {
    field public static final int UID_STATE_TOP = 200; // 0xc8
  }
  public static final class AppOpsManager.HistoricalFeatureOps implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public String getFeatureId();
    method @Nullable public android.app.AppOpsManager.HistoricalOp getOp(@NonNull String);
    method @NonNull public android.app.AppOpsManager.HistoricalOp getOpAt(@IntRange(from=0) int);
    method @IntRange(from=0) public int getOpCount();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.HistoricalFeatureOps> CREATOR;
  }
  public static final class AppOpsManager.HistoricalOp implements android.os.Parcelable {
    method public int describeContents();
    method public long getAccessCount(int, int, int);
@@ -446,6 +456,7 @@ package android.app {
  public static final class AppOpsManager.HistoricalOpsRequest.Builder {
    ctor public AppOpsManager.HistoricalOpsRequest.Builder(long, long);
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest build();
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setFeatureId(@Nullable String);
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setFlags(int);
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setOpNames(@Nullable java.util.List<java.lang.String>);
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setPackageName(@Nullable String);
@@ -454,6 +465,9 @@ package android.app {
  public static final class AppOpsManager.HistoricalPackageOps implements android.os.Parcelable {
    method public int describeContents();
    method @IntRange(from=0) public int getFeatureCount();
    method @Nullable public android.app.AppOpsManager.HistoricalFeatureOps getFeatureOps(@NonNull String);
    method @NonNull public android.app.AppOpsManager.HistoricalFeatureOps getFeatureOpsAt(@IntRange(from=0) int);
    method @Nullable public android.app.AppOpsManager.HistoricalOp getOp(@NonNull String);
    method @NonNull public android.app.AppOpsManager.HistoricalOp getOpAt(@IntRange(from=0) int);
    method @IntRange(from=0) public int getOpCount();
+17 −3
Original line number Diff line number Diff line
@@ -244,6 +244,16 @@ package android.app {
    field public static final int UID_STATE_TOP = 200; // 0xc8
  }

  public static final class AppOpsManager.HistoricalFeatureOps implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public String getFeatureId();
    method @Nullable public android.app.AppOpsManager.HistoricalOp getOp(@NonNull String);
    method @NonNull public android.app.AppOpsManager.HistoricalOp getOpAt(@IntRange(from=0) int);
    method @IntRange(from=0) public int getOpCount();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.HistoricalFeatureOps> CREATOR;
  }

  public static final class AppOpsManager.HistoricalOp implements android.os.Parcelable {
    method public int describeContents();
    method public long getAccessCount(int, int, int);
@@ -268,9 +278,9 @@ package android.app {
    method @IntRange(from=0) public int getUidCount();
    method @Nullable public android.app.AppOpsManager.HistoricalUidOps getUidOps(int);
    method @NonNull public android.app.AppOpsManager.HistoricalUidOps getUidOpsAt(@IntRange(from=0) int);
    method public void increaseAccessCount(int, int, @NonNull String, int, int, long);
    method public void increaseAccessDuration(int, int, @NonNull String, int, int, long);
    method public void increaseRejectCount(int, int, @NonNull String, int, int, long);
    method public void increaseAccessCount(int, int, @NonNull String, @Nullable String, int, int, long);
    method public void increaseAccessDuration(int, int, @NonNull String, @Nullable String, int, int, long);
    method public void increaseRejectCount(int, int, @NonNull String, @Nullable String, int, int, long);
    method public void offsetBeginAndEndTime(long);
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.AppOpsManager.HistoricalOps> CREATOR;
@@ -282,6 +292,7 @@ package android.app {
  public static final class AppOpsManager.HistoricalOpsRequest.Builder {
    ctor public AppOpsManager.HistoricalOpsRequest.Builder(long, long);
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest build();
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setFeatureId(@Nullable String);
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setFlags(int);
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setOpNames(@Nullable java.util.List<java.lang.String>);
    method @NonNull public android.app.AppOpsManager.HistoricalOpsRequest.Builder setPackageName(@Nullable String);
@@ -290,6 +301,9 @@ package android.app {

  public static final class AppOpsManager.HistoricalPackageOps implements android.os.Parcelable {
    method public int describeContents();
    method @IntRange(from=0) public int getFeatureCount();
    method @Nullable public android.app.AppOpsManager.HistoricalFeatureOps getFeatureOps(@NonNull String);
    method @NonNull public android.app.AppOpsManager.HistoricalFeatureOps getFeatureOpsAt(@IntRange(from=0) int);
    method @Nullable public android.app.AppOpsManager.HistoricalOp getOp(@NonNull String);
    method @NonNull public android.app.AppOpsManager.HistoricalOp getOpAt(@IntRange(from=0) int);
    method @IntRange(from=0) public int getOpCount();
Loading