Merge "Add some TestAPIs for replacing some @hide API usages in ExtServices's test" into sc-dev
This commit is contained in:
@@ -657,6 +657,16 @@ package android.app.usage {
|
||||
ctor public UsageStats();
|
||||
}
|
||||
|
||||
public static final class UsageStats.Builder {
|
||||
ctor public UsageStats.Builder();
|
||||
method @NonNull public android.app.usage.UsageStats build();
|
||||
method @NonNull public android.app.usage.UsageStats.Builder setFirstTimeStamp(long);
|
||||
method @NonNull public android.app.usage.UsageStats.Builder setLastTimeStamp(long);
|
||||
method @NonNull public android.app.usage.UsageStats.Builder setLastTimeUsed(long);
|
||||
method @NonNull public android.app.usage.UsageStats.Builder setPackageName(@Nullable String);
|
||||
method @NonNull public android.app.usage.UsageStats.Builder setTotalTimeInForeground(long);
|
||||
}
|
||||
|
||||
public final class UsageStatsManager {
|
||||
method public void forceUsageSourceSettingRead();
|
||||
}
|
||||
@@ -1902,6 +1912,16 @@ package android.os.storage {
|
||||
method public String getPath();
|
||||
}
|
||||
|
||||
public static final class StorageVolume.Builder {
|
||||
ctor public StorageVolume.Builder(@NonNull String, @NonNull java.io.File, @NonNull String, @NonNull android.os.UserHandle, @NonNull String);
|
||||
method @NonNull public android.os.storage.StorageVolume build();
|
||||
method @NonNull public android.os.storage.StorageVolume.Builder setEmulated(boolean);
|
||||
method @NonNull public android.os.storage.StorageVolume.Builder setPrimary(boolean);
|
||||
method @NonNull public android.os.storage.StorageVolume.Builder setRemovable(boolean);
|
||||
method @NonNull public android.os.storage.StorageVolume.Builder setStorageUuid(@Nullable java.util.UUID);
|
||||
method @NonNull public android.os.storage.StorageVolume.Builder setUuid(@Nullable String);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.os.strictmode {
|
||||
|
||||
@@ -31,6 +31,8 @@ import static android.app.usage.UsageEvents.Event.ROLLOVER_FOREGROUND_SERVICE;
|
||||
import static android.app.usage.UsageEvents.Event.USER_INTERACTION;
|
||||
|
||||
import android.annotation.CurrentTimeMillisLong;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
@@ -760,4 +762,48 @@ public final class UsageStats implements Parcelable {
|
||||
return new UsageStats[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
// This class is used by the mainline test suite, so we have to keep these APIs around across
|
||||
// releases. Consider making this class public to help external developers to write tests as
|
||||
// well.
|
||||
@TestApi
|
||||
public static final class Builder {
|
||||
private final UsageStats mUsageStats = new UsageStats();
|
||||
|
||||
@NonNull
|
||||
public UsageStats build() {
|
||||
return mUsageStats;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setPackageName(@Nullable String packageName) {
|
||||
mUsageStats.mPackageName = packageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setFirstTimeStamp(long firstTimeStamp) {
|
||||
mUsageStats.mBeginTimeStamp = firstTimeStamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setLastTimeStamp(long lastTimeStamp) {
|
||||
mUsageStats.mEndTimeStamp = lastTimeStamp;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setTotalTimeInForeground(long totalTimeInForeground) {
|
||||
mUsageStats.mTotalTimeInForeground = totalTimeInForeground;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setLastTimeUsed(long lastTimeUsed) {
|
||||
mUsageStats.mLastTimeUsed = lastTimeUsed;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static android.annotation.SystemApi.Client.MODULE_LIBRARIES;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.TestApi;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
@@ -551,4 +552,82 @@ public final class StorageVolume implements Parcelable {
|
||||
parcel.writeString8(mFsUuid);
|
||||
parcel.writeString8(mState);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
// This class is used by the mainline test suite, so we have to keep these APIs around across
|
||||
// releases. Consider making this class public to help external developers to write tests as
|
||||
// well.
|
||||
@TestApi
|
||||
public static final class Builder {
|
||||
private String mId;
|
||||
private File mPath;
|
||||
private String mDescription;
|
||||
private boolean mPrimary;
|
||||
private boolean mRemovable;
|
||||
private boolean mEmulated;
|
||||
private UserHandle mOwner;
|
||||
private UUID mStorageUuid;
|
||||
private String mUuid;
|
||||
private String mState;
|
||||
|
||||
@SuppressLint("StreamFiles")
|
||||
public Builder(
|
||||
@NonNull String id, @NonNull File path, @NonNull String description,
|
||||
@NonNull UserHandle owner, @NonNull String state) {
|
||||
mId = id;
|
||||
mPath = path;
|
||||
mDescription = description;
|
||||
mOwner = owner;
|
||||
mState = state;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setStorageUuid(@Nullable UUID storageUuid) {
|
||||
mStorageUuid = storageUuid;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setUuid(@Nullable String uuid) {
|
||||
mUuid = uuid;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setPrimary(boolean primary) {
|
||||
mPrimary = primary;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setRemovable(boolean removable) {
|
||||
mRemovable = removable;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder setEmulated(boolean emulated) {
|
||||
mEmulated = emulated;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public StorageVolume build() {
|
||||
return new StorageVolume(
|
||||
mId,
|
||||
mPath,
|
||||
/* internalPath= */ mPath,
|
||||
mDescription,
|
||||
mPrimary,
|
||||
mRemovable,
|
||||
mEmulated,
|
||||
/* allowMassStorage= */ false,
|
||||
/* maxFileSize= */ 0,
|
||||
mOwner,
|
||||
mStorageUuid,
|
||||
mUuid,
|
||||
mState);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user