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.permission.safetylabel; 18 19 import static java.lang.annotation.RetentionPolicy.SOURCE; 20 21 import android.annotation.IntDef; 22 23 import java.lang.annotation.Retention; 24 import java.util.Arrays; 25 import java.util.Collections; 26 import java.util.HashSet; 27 import java.util.Set; 28 29 /** 30 * Constants for determining valid {@link Integer} data usage purposes for usage within 31 * {@link DataType} 32 */ 33 public class DataPurposeConstants { 34 35 /** List of valid data usage purposes */ 36 @Retention(SOURCE) 37 @IntDef( 38 prefix = "PURPOSE_", 39 value = { 40 PURPOSE_APP_FUNCTIONALITY, 41 PURPOSE_ANALYTICS, 42 PURPOSE_DEVELOPER_COMMUNICATIONS, 43 PURPOSE_FRAUD_PREVENTION_SECURITY, 44 PURPOSE_ADVERTISING, 45 PURPOSE_PERSONALIZATION, 46 PURPOSE_ACCOUNT_MANAGEMENT, 47 }) 48 public @interface Purpose {} 49 50 public static final int PURPOSE_APP_FUNCTIONALITY = 1; 51 public static final int PURPOSE_ANALYTICS = 2; 52 public static final int PURPOSE_DEVELOPER_COMMUNICATIONS = 3; 53 public static final int PURPOSE_FRAUD_PREVENTION_SECURITY = 4; 54 public static final int PURPOSE_ADVERTISING = 5; 55 public static final int PURPOSE_PERSONALIZATION = 6; 56 public static final int PURPOSE_ACCOUNT_MANAGEMENT = 7; 57 // RESERVED/DEPRECATED = 8 58 // RESERVED/DEPRECATED = 9 59 60 /** {@link Set} of valid {@link Integer} purposes */ 61 @Purpose 62 public static final Set<Integer> VALID_PURPOSES = 63 Collections.unmodifiableSet( 64 new HashSet<>( 65 Arrays.asList( 66 PURPOSE_APP_FUNCTIONALITY, 67 PURPOSE_ANALYTICS, 68 PURPOSE_DEVELOPER_COMMUNICATIONS, 69 PURPOSE_FRAUD_PREVENTION_SECURITY, 70 PURPOSE_ADVERTISING, 71 PURPOSE_PERSONALIZATION, 72 PURPOSE_ACCOUNT_MANAGEMENT))); 73 74 /** Returns {@link Set} of valid {@link Integer} purpose */ 75 @Purpose getValidPurposes()76 public static Set<Integer> getValidPurposes() { 77 return VALID_PURPOSES; 78 } 79 } 80