Merge "Removed AppUsageLimit#isGroupLimit API."

This commit is contained in:
Varun Shah
2019-01-28 23:53:01 +00:00
committed by Android (Google) Code Review
5 changed files with 7 additions and 62 deletions

View File

@@ -287,19 +287,14 @@ public abstract class UsageStatsManagerInternal {
/** A class which is used to share the usage limit data for an app or a group of apps. */
public static class AppUsageLimitData {
private final boolean mGroupLimit;
private final long mTotalUsageLimit;
private final long mUsageRemaining;
public AppUsageLimitData(boolean groupLimit, long totalUsageLimit, long usageRemaining) {
this.mGroupLimit = groupLimit;
public AppUsageLimitData(long totalUsageLimit, long usageRemaining) {
this.mTotalUsageLimit = totalUsageLimit;
this.mUsageRemaining = usageRemaining;
}
public boolean isGroupLimit() {
return mGroupLimit;
}
public long getTotalUsageLimit() {
return mTotalUsageLimit;
}

View File

@@ -1658,34 +1658,22 @@ public class LauncherApps {
* A class that encapsulates information about the usage limit set for an app or
* a group of apps.
*
* <p>The launcher can query specifics about the usage limit such as if it is a group limit,
* how much usage time the limit has, and how much of the total usage time is remaining
* via the APIs available in this class.
* <p>The launcher can query specifics about the usage limit such as how much usage time
* the limit has and how much of the total usage time is remaining via the APIs available
* in this class.
*
* @see #getAppUsageLimit(String, UserHandle)
*/
public static final class AppUsageLimit implements Parcelable {
private final boolean mGroupLimit;
private final long mTotalUsageLimit;
private final long mUsageRemaining;
/** @hide */
public AppUsageLimit(boolean groupLimit, long totalUsageLimit, long usageRemaining) {
this.mGroupLimit = groupLimit;
public AppUsageLimit(long totalUsageLimit, long usageRemaining) {
this.mTotalUsageLimit = totalUsageLimit;
this.mUsageRemaining = usageRemaining;
}
/**
* Returns whether this limit refers to a group of apps.
*
* @return {@code TRUE} if the limit refers to a group of apps, {@code FALSE} otherwise.
* @hide
*/
public boolean isGroupLimit() {
return mGroupLimit;
}
/**
* Returns the total usage limit in milliseconds set for an app or a group of apps.
*
@@ -1706,7 +1694,6 @@ public class LauncherApps {
}
private AppUsageLimit(Parcel source) {
mGroupLimit = source.readBoolean();
mTotalUsageLimit = source.readLong();
mUsageRemaining = source.readLong();
}
@@ -1730,7 +1717,6 @@ public class LauncherApps {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeBoolean(mGroupLimit);
dest.writeLong(mTotalUsageLimit);
dest.writeLong(mUsageRemaining);
}

View File

@@ -696,7 +696,7 @@ public class LauncherAppsService extends SystemService {
return null;
}
return new LauncherApps.AppUsageLimit(
data.isGroupLimit(), data.getTotalUsageLimit(), data.getUsageRemaining());
data.getTotalUsageLimit(), data.getUsageRemaining());
}
private void ensureShortcutPermission(@NonNull String callingPackage) {

View File

@@ -964,26 +964,6 @@ public class AppTimeLimitControllerTests {
assertFalse(hasAppUsageObserver(UID, OBS_ID1));
}
/** Verify app usage limit observer added correctly reports it being a group limit */
@Test
public void testAppUsageLimitObserver_IsGroupLimit() {
addAppUsageLimitObserver(OBS_ID1, GROUP1, TIME_30_MIN);
AppTimeLimitController.AppUsageLimitGroup group = getAppUsageLimitObserver(UID, OBS_ID1);
assertNotNull("Observer wasn't added", group);
assertTrue("Observer didn't correctly report being a group limit",
group.isGroupLimit());
}
/** Verify app usage limit observer added correctly reports it being not a group limit */
@Test
public void testAppUsageLimitObserver_IsNotGroupLimit() {
addAppUsageLimitObserver(OBS_ID1, new String[]{PKG_PROD}, TIME_30_MIN);
AppTimeLimitController.AppUsageLimitGroup group = getAppUsageLimitObserver(UID, OBS_ID1);
assertNotNull("Observer wasn't added", group);
assertFalse("Observer didn't correctly report not being a group limit",
group.isGroupLimit());
}
/** Verify app usage limit observer added correctly reports its total usage limit */
@Test
public void testAppUsageLimitObserver_GetTotalUsageLimit() {

View File

@@ -510,12 +510,9 @@ public class AppTimeLimitController {
}
class AppUsageLimitGroup extends UsageGroup {
private boolean mGroupLimit;
public AppUsageLimitGroup(UserData user, ObserverAppData observerApp, int observerId,
String[] observed, long timeLimitMs, PendingIntent limitReachedCallback) {
super(user, observerApp, observerId, observed, timeLimitMs, limitReachedCallback);
mGroupLimit = observed.length > 1;
}
@Override
@@ -528,11 +525,6 @@ public class AppTimeLimitController {
}
}
@GuardedBy("mLock")
boolean isGroupLimit() {
return mGroupLimit;
}
@GuardedBy("mLock")
long getTotaUsageLimit() {
return mTimeLimitMs;
@@ -547,14 +539,6 @@ public class AppTimeLimitController {
return mTimeLimitMs - mUsageTimeMs;
}
}
@Override
@GuardedBy("mLock")
void dump(PrintWriter pw) {
super.dump(pw);
pw.print(" groupLimit=");
pw.print(mGroupLimit);
}
}
@@ -692,7 +676,7 @@ public class AppTimeLimitController {
smallestGroup = otherGroup;
}
}
return new UsageStatsManagerInternal.AppUsageLimitData(smallestGroup.isGroupLimit(),
return new UsageStatsManagerInternal.AppUsageLimitData(
smallestGroup.getTotaUsageLimit(), smallestGroup.getUsageRemaining());
}
}