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 "timeSec" {rawUsage(UsageType.ANY)} 47 "timezone" {rawUsage(UsageType.ANY)} 48 "orientation" {rawUsage(UsageType.ANY)} 49 "availableBytesMB" {rawUsage(UsageType.ANY)} 50 "batteryPct" {rawUsage(UsageType.ANY)} 51 "country" {rawUsage(UsageType.ANY)} 52 "language" {rawUsage(UsageType.ANY)} 53 "carrier" {rawUsage(UsageType.ANY)} 54 "osVersions" { 55 "major" {rawUsage(UsageType.ANY)} 56 "minor" {rawUsage(UsageType.ANY)} 57 "micro" {rawUsage(UsageType.ANY)} 58 } 59 "connectionType" {rawUsage(UsageType.ANY)} 60 "connectionSpeedKbps" {rawUsage(UsageType.ANY)} 61 "networkMetered" {rawUsage(UsageType.ANY)} 62 "deviceMetrics" { 63 "make" {rawUsage(UsageType.ANY)} 64 "model" {rawUsage(UsageType.ANY)} 65 "screenHeightDp" {rawUsage(UsageType.ANY)} 66 "screenWidthDp" {rawUsage(UsageType.ANY)} 67 "xdpi" {rawUsage(UsageType.ANY)} 68 "ydpi" {rawUsage(UsageType.ANY)} 69 "pxRatio" {rawUsage(UsageType.ANY)} 70 } 71 "appInstalledHistory" { 72 "packageName" {rawUsage(UsageType.ANY)} 73 "installed" {rawUsage(UsageType.ANY)} 74 } 75 "appUsageHistory" { 76 "packageName" {rawUsage(UsageType.ANY)} 77 "totalTimeUsedMillis" {rawUsage(UsageType.ANY)} 78 } 79 "currentLocation" { 80 "timeSec" {rawUsage(UsageType.ANY)} 81 "latitude" {rawUsage(UsageType.ANY)} 82 "longitude" {rawUsage(UsageType.ANY)} 83 "locationProvider" {rawUsage(UsageType.ANY)} 84 "preciseLocation" {rawUsage(UsageType.ANY)} 85 } 86 "locationHistory" { 87 "latitude" {rawUsage(UsageType.ANY)} 88 "longitude" {rawUsage(UsageType.ANY)} 89 "durationMillis" {rawUsage(UsageType.ANY)} 90 } 91 } 92 93 allowedContext = not(UnicornAccount) and not(UserOptsInLimitedAdsTracking) 94 } 95 } 96 } 97