Merge "Don't log on each call when hibernation not enabled" into sc-mainline-prod
This commit is contained in:
committed by
Android (Google) Code Review
commit
e11730100c
@@ -208,7 +208,7 @@ public final class AppHibernationService extends SystemService {
|
||||
*/
|
||||
boolean isHibernatingForUser(String packageName, int userId) {
|
||||
String methodName = "isHibernatingForUser";
|
||||
if (!checkHibernationEnabled(methodName)) {
|
||||
if (!sIsServiceEnabled) {
|
||||
return false;
|
||||
}
|
||||
getContext().enforceCallingOrSelfPermission(
|
||||
@@ -237,7 +237,7 @@ public final class AppHibernationService extends SystemService {
|
||||
* @param packageName package to check
|
||||
*/
|
||||
boolean isHibernatingGlobally(String packageName) {
|
||||
if (!checkHibernationEnabled("isHibernatingGlobally")) {
|
||||
if (!sIsServiceEnabled) {
|
||||
return false;
|
||||
}
|
||||
getContext().enforceCallingOrSelfPermission(
|
||||
@@ -263,7 +263,7 @@ public final class AppHibernationService extends SystemService {
|
||||
*/
|
||||
void setHibernatingForUser(String packageName, int userId, boolean isHibernating) {
|
||||
String methodName = "setHibernatingForUser";
|
||||
if (!checkHibernationEnabled(methodName)) {
|
||||
if (!sIsServiceEnabled) {
|
||||
return;
|
||||
}
|
||||
getContext().enforceCallingOrSelfPermission(
|
||||
@@ -313,7 +313,7 @@ public final class AppHibernationService extends SystemService {
|
||||
* @param isHibernating new hibernation state
|
||||
*/
|
||||
void setHibernatingGlobally(String packageName, boolean isHibernating) {
|
||||
if (!checkHibernationEnabled("setHibernatingGlobally")) {
|
||||
if (!sIsServiceEnabled) {
|
||||
return;
|
||||
}
|
||||
getContext().enforceCallingOrSelfPermission(
|
||||
@@ -344,7 +344,7 @@ public final class AppHibernationService extends SystemService {
|
||||
@NonNull List<String> getHibernatingPackagesForUser(int userId) {
|
||||
ArrayList<String> hibernatingPackages = new ArrayList<>();
|
||||
String methodName = "getHibernatingPackagesForUser";
|
||||
if (!checkHibernationEnabled(methodName)) {
|
||||
if (!sIsServiceEnabled) {
|
||||
return hibernatingPackages;
|
||||
}
|
||||
getContext().enforceCallingOrSelfPermission(
|
||||
@@ -640,6 +640,7 @@ public final class AppHibernationService extends SystemService {
|
||||
for (String key : properties.getKeyset()) {
|
||||
if (TextUtils.equals(KEY_APP_HIBERNATION_ENABLED, key)) {
|
||||
sIsServiceEnabled = isDeviceConfigAppHibernationEnabled();
|
||||
Slog.d(TAG, "App hibernation changed to enabled=" + sIsServiceEnabled);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -676,13 +677,6 @@ public final class AppHibernationService extends SystemService {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkHibernationEnabled(String methodName) {
|
||||
if (!sIsServiceEnabled) {
|
||||
Slog.w(TAG, String.format("Attempted to call %s on unsupported device.", methodName));
|
||||
}
|
||||
return sIsServiceEnabled;
|
||||
}
|
||||
|
||||
private void dump(PrintWriter pw) {
|
||||
// Check usage stats permission since hibernation indirectly informs usage.
|
||||
if (!DumpUtils.checkDumpAndUsageStatsPermission(getContext(), TAG, pw)) return;
|
||||
|
||||
Reference in New Issue
Block a user