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

Commit 3b5b5367 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Update sync exemptions log to include restriction level." into tm-dev...

Merge "Update sync exemptions log to include restriction level." into tm-dev am: 2b4f92c6 am: fbb58309

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18438448



Change-Id: I619b9ac0f98d7ce345f395336e41441086e14759
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 88647406 fbb58309
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
import android.app.ActivityManager.RestrictionLevel;
import android.app.ActivityManagerInternal;
import android.app.AppGlobals;
import android.app.AppOpsManager;
@@ -52,6 +53,7 @@ import android.content.pm.ProviderInfo;
import android.database.IContentObserver;
import android.database.sqlite.SQLiteException;
import android.net.Uri;
import android.os.AppBackgroundRestrictionsInfo;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
@@ -1544,7 +1546,8 @@ public final class ContentService extends IContentService.Stub {
        }
        if (procState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND || isUidActive) {
            FrameworkStatsLog.write(FrameworkStatsLog.SYNC_EXEMPTION_OCCURRED,
                    callingUid, getProcStateForStatsd(procState), isUidActive);
                    callingUid, getProcStateForStatsd(procState), isUidActive,
                    getRestrictionLevelForStatsd(ami.getRestrictionLevel(callingUid)));
            return ContentResolver.SYNC_EXEMPTION_PROMOTE_BUCKET;
        }
        return ContentResolver.SYNC_EXEMPTION_NONE;
@@ -1599,6 +1602,27 @@ public final class ContentService extends IContentService.Stub {
        }
    }

    private int getRestrictionLevelForStatsd(@RestrictionLevel int level) {
        switch (level) {
            case ActivityManager.RESTRICTION_LEVEL_UNKNOWN:
                return AppBackgroundRestrictionsInfo.LEVEL_UNKNOWN;
            case ActivityManager.RESTRICTION_LEVEL_UNRESTRICTED:
                return AppBackgroundRestrictionsInfo.LEVEL_UNRESTRICTED;
            case ActivityManager.RESTRICTION_LEVEL_EXEMPTED:
                return AppBackgroundRestrictionsInfo.LEVEL_EXEMPTED;
            case ActivityManager.RESTRICTION_LEVEL_ADAPTIVE_BUCKET:
                return AppBackgroundRestrictionsInfo.LEVEL_ADAPTIVE_BUCKET;
            case ActivityManager.RESTRICTION_LEVEL_RESTRICTED_BUCKET:
                return AppBackgroundRestrictionsInfo.LEVEL_RESTRICTED_BUCKET;
            case ActivityManager.RESTRICTION_LEVEL_BACKGROUND_RESTRICTED:
                return AppBackgroundRestrictionsInfo.LEVEL_BACKGROUND_RESTRICTED;
            case ActivityManager.RESTRICTION_LEVEL_HIBERNATION:
                return AppBackgroundRestrictionsInfo.LEVEL_HIBERNATION;
            default:
                return AppBackgroundRestrictionsInfo.LEVEL_UNKNOWN;
        }
    }

    /** {@hide} */
    @VisibleForTesting
    public static final class ObserverNode {