1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ondevicepersonalization.services.policyengine.policy 18 19 import com.android.libraries.pcc.chronicle.api.policy.StorageMedium 20 import com.android.libraries.pcc.chronicle.api.policy.UsageType 21 import com.android.libraries.pcc.chronicle.api.policy.builder.policy 22 import com.android.ondevicepersonalization.services.policyengine.data.USER_DATA_GENERATED_DTD 23 import com.android.ondevicepersonalization.services.policyengine.policy.rules.UserOptsInLimitedAdsTracking 24 import com.android.ondevicepersonalization.services.policyengine.policy.rules.UnicornAccount 25 import com.android.libraries.pcc.chronicle.api.policy.contextrules.and 26 import com.android.libraries.pcc.chronicle.api.policy.contextrules.not 27 28 import java.time.Duration 29 30 /** This module encapsulates all data ingress policies for ODA. */ 31 class DataIngressPolicy { 32 companion object { 33 // NPA (No Personalized Ads) policy for user and vendor data in ODA 34 @JvmField 35 val NPA_DATA_POLICY = policy( 36 name = "npaPolicy", 37 egressType = "None", <lambda>null38 ) { 39 description = 40 """ 41 Policy that grant on-device data to ad vendors if no NPA flag is set. 42 """ 43 .trimIndent() 44 target(USER_DATA_GENERATED_DTD, Duration.ofDays(30)) { 45 retention(medium = StorageMedium.RAM, encryptionRequired = false) 46 "timestampSec" {rawUsage(UsageType.ANY)} 47 "timezoneUtcOffsetMins" {rawUsage(UsageType.ANY)} 48 "orientation" {rawUsage(UsageType.ANY)} 49 "availableStorageMB" {rawUsage(UsageType.ANY)} 50 "batteryPercentage" {rawUsage(UsageType.ANY)} 51 "carrier" {rawUsage(UsageType.ANY)} 52 "dataNetworkType" {rawUsage(UsageType.ANY)} 53 "appInfos" { 54 "packageName" {rawUsage(UsageType.ANY)} 55 "installed" {rawUsage(UsageType.ANY)} 56 } 57 } 58 59 allowedContext = not(UnicornAccount) and not(UserOptsInLimitedAdsTracking) 60 } 61 } 62 } 63