1 /* 2 * Copyright (C) 2019 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.documentsui; 18 19 import androidx.annotation.IntDef; 20 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 24 /** 25 * All constants are based on the enums in 26 * frameworks/base/core/proto/android/stats/docsui/docsui_enums.proto. 27 */ 28 public class MetricConsts { 29 30 // Codes representing different root types. 31 public static final int ROOT_UNKNOWN = 0; 32 public static final int ROOT_NONE = 1; 33 public static final int ROOT_OTHER_DOCS_PROVIDER = 2; 34 public static final int ROOT_AUDIO = 3; 35 public static final int ROOT_DEVICE_STORAGE = 4; 36 public static final int ROOT_DOWNLOADS = 5; 37 public static final int ROOT_HOME = 6; 38 public static final int ROOT_IMAGES = 7; 39 public static final int ROOT_RECENTS = 8; 40 public static final int ROOT_VIDEOS = 9; 41 public static final int ROOT_MTP = 10; 42 public static final int ROOT_THIRD_PARTY_APP = 11; 43 public static final int ROOT_DOCUMENTS = 12; 44 45 @IntDef(flag = true, value = { 46 ROOT_UNKNOWN, 47 ROOT_NONE, 48 ROOT_OTHER_DOCS_PROVIDER, 49 ROOT_AUDIO, 50 ROOT_DEVICE_STORAGE, 51 ROOT_DOWNLOADS, 52 ROOT_HOME, 53 ROOT_IMAGES, 54 ROOT_RECENTS, 55 ROOT_VIDEOS, 56 ROOT_MTP, 57 ROOT_THIRD_PARTY_APP, 58 ROOT_DOCUMENTS 59 }) 60 @Retention(RetentionPolicy.SOURCE) 61 public @interface Root { 62 } 63 64 // Codes representing different mime types. 65 static final int MIME_UNKNOWN = 0; 66 static final int MIME_NONE = 1; // null mime 67 static final int MIME_ANY = 2; // */* 68 static final int MIME_APPLICATION = 3; // application/* 69 static final int MIME_AUDIO = 4; // audio/* 70 static final int MIME_IMAGE = 5; // image/* 71 static final int MIME_MESSAGE = 6; // message/* 72 static final int MIME_MULTIPART = 7; // multipart/* 73 static final int MIME_TEXT = 8; // text/* 74 static final int MIME_VIDEO = 9; // video/* 75 static final int MIME_OTHER = 10; // anything not enumerated below 76 77 @IntDef(flag = true, value = { 78 MIME_UNKNOWN, 79 MIME_NONE, 80 MIME_ANY, 81 MIME_APPLICATION, 82 MIME_AUDIO, 83 MIME_IMAGE, 84 MIME_MESSAGE, 85 MIME_MULTIPART, 86 MIME_TEXT, 87 MIME_VIDEO, 88 MIME_OTHER 89 }) 90 @Retention(RetentionPolicy.SOURCE) 91 public @interface Mime { 92 } 93 94 public static final int UNKNOWN_SCOPE = 0; 95 public static final int FILES_SCOPE = 1; 96 public static final int PICKER_SCOPE = 2; 97 98 // Codes representing different scopes(FILE/PICKER mode). 99 @IntDef({UNKNOWN_SCOPE, FILES_SCOPE, PICKER_SCOPE}) 100 @Retention(RetentionPolicy.SOURCE) 101 public @interface ContextScope { 102 } 103 104 // Codes representing different kinds of file operations. 105 static final int FILEOP_UNKNOWN = 0; 106 static final int FILEOP_OTHER = 1; // any file operation not listed below 107 static final int FILEOP_COPY = 2; 108 static final int FILEOP_COPY_INTRA_PROVIDER = 3; // Copy within a provider 109 static final int FILEOP_COPY_SYSTEM_PROVIDER = 4; // Copy to a system provider. 110 static final int FILEOP_COPY_EXTERNAL_PROVIDER = 5; // Copy to a 3rd-party provider. 111 static final int FILEOP_MOVE = 6; 112 static final int FILEOP_MOVE_INTRA_PROVIDER = 7; // Move within a provider. 113 static final int FILEOP_MOVE_SYSTEM_PROVIDER = 8; // Move to a system provider. 114 static final int FILEOP_MOVE_EXTERNAL_PROVIDER = 9; // Move to a 3rd-party provider. 115 static final int FILEOP_DELETE = 10; 116 static final int FILEOP_RENAME = 11; 117 static final int FILEOP_CREATE_DIR = 12; 118 static final int FILEOP_OTHER_ERROR = 13; 119 static final int FILEOP_DELETE_ERROR = 14; 120 static final int FILEOP_MOVE_ERROR = 15; 121 static final int FILEOP_COPY_ERROR = 16; 122 static final int FILEOP_RENAME_ERROR = 17; 123 static final int FILEOP_CREATE_DIR_ERROR = 18; 124 static final int FILEOP_COMPRESS_INTRA_PROVIDER = 19; // Compres within a provider 125 static final int FILEOP_COMPRESS_SYSTEM_PROVIDER = 20; // Compress to a system provider. 126 static final int FILEOP_COMPRESS_EXTERNAL_PROVIDER = 21; // Compress to a 3rd-party provider. 127 static final int FILEOP_EXTRACT_INTRA_PROVIDER = 22; // Extract within a provider 128 static final int FILEOP_EXTRACT_SYSTEM_PROVIDER = 23; // Extract to a system provider. 129 static final int FILEOP_EXTRACT_EXTERNAL_PROVIDER = 24; // Extract to a 3rd-party provider. 130 static final int FILEOP_COMPRESS_ERROR = 25; 131 static final int FILEOP_EXTRACT_ERROR = 26; 132 133 @IntDef(flag = true, value = { 134 FILEOP_UNKNOWN, 135 FILEOP_OTHER, 136 FILEOP_COPY, 137 FILEOP_COPY_INTRA_PROVIDER, 138 FILEOP_COPY_SYSTEM_PROVIDER, 139 FILEOP_COPY_EXTERNAL_PROVIDER, 140 FILEOP_MOVE, 141 FILEOP_MOVE_INTRA_PROVIDER, 142 FILEOP_MOVE_SYSTEM_PROVIDER, 143 FILEOP_MOVE_EXTERNAL_PROVIDER, 144 FILEOP_DELETE, 145 FILEOP_RENAME, 146 FILEOP_CREATE_DIR, 147 FILEOP_OTHER_ERROR, 148 FILEOP_DELETE_ERROR, 149 FILEOP_MOVE_ERROR, 150 FILEOP_COPY_ERROR, 151 FILEOP_RENAME_ERROR, 152 FILEOP_CREATE_DIR_ERROR, 153 FILEOP_COMPRESS_INTRA_PROVIDER, 154 FILEOP_COMPRESS_SYSTEM_PROVIDER, 155 FILEOP_COMPRESS_EXTERNAL_PROVIDER, 156 FILEOP_EXTRACT_INTRA_PROVIDER, 157 FILEOP_EXTRACT_SYSTEM_PROVIDER, 158 FILEOP_EXTRACT_EXTERNAL_PROVIDER, 159 FILEOP_COMPRESS_ERROR, 160 FILEOP_EXTRACT_ERROR 161 }) 162 @Retention(RetentionPolicy.SOURCE) 163 public @interface FileOp { 164 } 165 166 // Codes representing different provider types. Used for sorting file operations when logging. 167 static final int PROVIDER_INTRA = 0; 168 static final int PROVIDER_SYSTEM = 1; 169 static final int PROVIDER_EXTERNAL = 2; 170 171 @IntDef(flag = false, value = { 172 PROVIDER_INTRA, 173 PROVIDER_SYSTEM, 174 PROVIDER_EXTERNAL 175 }) 176 @Retention(RetentionPolicy.SOURCE) 177 public @interface Provider { 178 } 179 180 // Codes representing different types of sub-fileops. 181 public static final int SUBFILEOP_UNKNOWN = 0; 182 public static final int SUBFILEOP_QUERY_DOCUMENT = 1; 183 public static final int SUBFILEOP_QUERY_CHILDREN = 2; 184 public static final int SUBFILEOP_OPEN_FILE = 3; 185 public static final int SUBFILEOP_READ_FILE = 4; 186 public static final int SUBFILEOP_CREATE_DOCUMENT = 5; 187 public static final int SUBFILEOP_WRITE_FILE = 6; 188 public static final int SUBFILEOP_DELETE_DOCUMENT = 7; 189 public static final int SUBFILEOP_OBTAIN_STREAM_TYPE = 8; 190 public static final int SUBFILEOP_QUICK_MOVE = 9; 191 public static final int SUBFILEOP_QUICK_COPY = 10; 192 193 @IntDef(flag = false, value = { 194 SUBFILEOP_UNKNOWN, 195 SUBFILEOP_QUERY_DOCUMENT, 196 SUBFILEOP_QUERY_CHILDREN, 197 SUBFILEOP_OPEN_FILE, 198 SUBFILEOP_READ_FILE, 199 SUBFILEOP_CREATE_DOCUMENT, 200 SUBFILEOP_WRITE_FILE, 201 SUBFILEOP_DELETE_DOCUMENT, 202 SUBFILEOP_OBTAIN_STREAM_TYPE, 203 SUBFILEOP_QUICK_MOVE, 204 SUBFILEOP_QUICK_COPY 205 }) 206 @Retention(RetentionPolicy.SOURCE) 207 public @interface SubFileOp { 208 } 209 210 // Codes representing different user actions 211 public static final int USER_ACTION_UNKNOWN = 0; 212 public static final int USER_ACTION_OTHER = 1; 213 public static final int USER_ACTION_GRID = 2; 214 public static final int USER_ACTION_LIST = 3; 215 public static final int USER_ACTION_SORT_NAME = 4; 216 public static final int USER_ACTION_SORT_DATE = 5; 217 public static final int USER_ACTION_SORT_SIZE = 6; 218 public static final int USER_ACTION_SORT_TYPE = 7; 219 public static final int USER_ACTION_SEARCH = 8; 220 public static final int USER_ACTION_SHOW_SIZE = 9; 221 public static final int USER_ACTION_HIDE_SIZE = 10; 222 public static final int USER_ACTION_SETTINGS = 11; 223 public static final int USER_ACTION_COPY_TO = 12; 224 public static final int USER_ACTION_MOVE_TO = 13; 225 public static final int USER_ACTION_DELETE = 14; 226 public static final int USER_ACTION_RENAME = 15; 227 public static final int USER_ACTION_CREATE_DIR = 16; 228 public static final int USER_ACTION_SELECT_ALL = 17; 229 public static final int USER_ACTION_SHARE = 18; 230 public static final int USER_ACTION_OPEN = 19; 231 public static final int USER_ACTION_SHOW_ADVANCED = 20; 232 public static final int USER_ACTION_HIDE_ADVANCED = 21; 233 public static final int USER_ACTION_NEW_WINDOW = 22; 234 public static final int USER_ACTION_PASTE_CLIPBOARD = 23; 235 public static final int USER_ACTION_COPY_CLIPBOARD = 24; 236 public static final int USER_ACTION_DRAG_N_DROP = 25; 237 public static final int USER_ACTION_DRAG_N_DROP_MULTI_WINDOW = 26; 238 public static final int USER_ACTION_CUT_CLIPBOARD = 27; 239 public static final int USER_ACTION_COMPRESS = 28; 240 public static final int USER_ACTION_EXTRACT_TO = 29; 241 public static final int USER_ACTION_VIEW_IN_APPLICATION = 30; 242 public static final int USER_ACTION_INSPECTOR = 31; 243 public static final int USER_ACTION_SEARCH_CHIP = 32; 244 public static final int USER_ACTION_SEARCH_HISTORY = 33; 245 public static final int USER_ACTION_SHOW_HIDDEN_FILES = 34; 246 public static final int USER_ACTION_HIDE_HIDDEN_FILES = 35; 247 248 @IntDef(flag = false, value = { 249 USER_ACTION_UNKNOWN, 250 USER_ACTION_OTHER, 251 USER_ACTION_GRID, 252 USER_ACTION_LIST, 253 USER_ACTION_SORT_NAME, 254 USER_ACTION_SORT_DATE, 255 USER_ACTION_SORT_SIZE, 256 USER_ACTION_SORT_TYPE, 257 USER_ACTION_SEARCH, 258 USER_ACTION_SHOW_SIZE, 259 USER_ACTION_HIDE_SIZE, 260 USER_ACTION_SETTINGS, 261 USER_ACTION_COPY_TO, 262 USER_ACTION_MOVE_TO, 263 USER_ACTION_DELETE, 264 USER_ACTION_RENAME, 265 USER_ACTION_CREATE_DIR, 266 USER_ACTION_SELECT_ALL, 267 USER_ACTION_SHARE, 268 USER_ACTION_OPEN, 269 USER_ACTION_SHOW_ADVANCED, 270 USER_ACTION_HIDE_ADVANCED, 271 USER_ACTION_NEW_WINDOW, 272 USER_ACTION_PASTE_CLIPBOARD, 273 USER_ACTION_COPY_CLIPBOARD, 274 USER_ACTION_DRAG_N_DROP, 275 USER_ACTION_DRAG_N_DROP_MULTI_WINDOW, 276 USER_ACTION_CUT_CLIPBOARD, 277 USER_ACTION_COMPRESS, 278 USER_ACTION_EXTRACT_TO, 279 USER_ACTION_VIEW_IN_APPLICATION, 280 USER_ACTION_INSPECTOR, 281 USER_ACTION_SEARCH_CHIP, 282 USER_ACTION_SEARCH_HISTORY, 283 USER_ACTION_SHOW_HIDDEN_FILES, 284 USER_ACTION_HIDE_HIDDEN_FILES 285 }) 286 @Retention(RetentionPolicy.SOURCE) 287 public @interface UserAction { 288 } 289 290 // Codes representing different approaches to copy/move a document. OPMODE_PROVIDER indicates 291 // it's an optimized operation provided by providers; OPMODE_CONVERTED means it's converted from 292 // a virtual file; and OPMODE_CONVENTIONAL means it's byte copied. 293 public static final int OPMODE_UNKNOWN = 0; 294 public static final int OPMODE_PROVIDER = 1; 295 public static final int OPMODE_CONVERTED = 2; 296 public static final int OPMODE_CONVENTIONAL = 3; 297 298 @IntDef({OPMODE_UNKNOWN, OPMODE_PROVIDER, OPMODE_CONVERTED, OPMODE_CONVENTIONAL}) 299 @Retention(RetentionPolicy.SOURCE) 300 public @interface FileOpMode { 301 } 302 303 // Codes representing different menu actions. 304 static final int ACTION_UNKNOWN = 0; 305 static final int ACTION_OPEN = 1; 306 static final int ACTION_CREATE = 2; 307 static final int ACTION_GET_CONTENT = 3; 308 static final int ACTION_OPEN_TREE = 4; 309 static final int ACTION_PICK_COPY_DESTINATION = 5; 310 static final int ACTION_BROWSE = 6; 311 static final int ACTION_OTHER = 7; 312 313 @IntDef(flag = true, value = { 314 ACTION_UNKNOWN, 315 ACTION_OPEN, 316 ACTION_CREATE, 317 ACTION_GET_CONTENT, 318 ACTION_OPEN_TREE, 319 ACTION_PICK_COPY_DESTINATION, 320 ACTION_BROWSE, 321 ACTION_OTHER 322 }) 323 @Retention(RetentionPolicy.SOURCE) 324 public @interface MetricsAction { 325 } 326 327 public static final int AUTH_UNKNOWN = 0; 328 public static final int AUTH_OTHER = 1; 329 public static final int AUTH_MEDIA = 2; 330 public static final int AUTH_STORAGE_INTERNAL = 3; 331 public static final int AUTH_STORAGE_EXTERNAL = 4; 332 public static final int AUTH_DOWNLOADS = 5; 333 public static final int AUTH_MTP = 6; 334 335 @IntDef(flag = true, value = { 336 AUTH_UNKNOWN, 337 AUTH_OTHER, 338 AUTH_MEDIA, 339 AUTH_STORAGE_INTERNAL, 340 AUTH_STORAGE_EXTERNAL, 341 AUTH_DOWNLOADS, 342 AUTH_MTP 343 }) 344 @Retention(RetentionPolicy.SOURCE) 345 public @interface MetricsAuth { 346 } 347 348 // Types for logInvalidScopedAccessRequest 349 public static final int SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS = 1; 350 public static final int SCOPED_DIRECTORY_ACCESS_INVALID_DIRECTORY = 2; 351 public static final int SCOPED_DIRECTORY_ACCESS_ERROR = 3; 352 public static final int SCOPED_DIRECTORY_ACCESS_DEPRECATED = 4; 353 354 @IntDef(value = { 355 SCOPED_DIRECTORY_ACCESS_INVALID_ARGUMENTS, 356 SCOPED_DIRECTORY_ACCESS_INVALID_DIRECTORY, 357 SCOPED_DIRECTORY_ACCESS_ERROR, 358 SCOPED_DIRECTORY_ACCESS_DEPRECATED 359 }) 360 @Retention(RetentionPolicy.SOURCE) 361 public @interface InvalidScopedAccess { 362 } 363 364 // Codes representing different search types 365 public static final int TYPE_UNKNOWN = 0; 366 public static final int TYPE_CHIP_IMAGES = 1; 367 public static final int TYPE_CHIP_AUDIOS = 2; 368 public static final int TYPE_CHIP_VIDEOS = 3; 369 public static final int TYPE_CHIP_DOCS = 4; 370 public static final int TYPE_SEARCH_HISTORY = 5; 371 public static final int TYPE_SEARCH_STRING = 6; 372 public static final int TYPE_CHIP_LARGE_FILES = 7; 373 public static final int TYPE_CHIP_FROM_THIS_WEEK = 8; 374 375 @IntDef(flag = true, value = { 376 TYPE_UNKNOWN, 377 TYPE_CHIP_IMAGES, 378 TYPE_CHIP_AUDIOS, 379 TYPE_CHIP_VIDEOS, 380 TYPE_CHIP_DOCS, 381 TYPE_SEARCH_HISTORY, 382 TYPE_SEARCH_STRING, 383 TYPE_CHIP_LARGE_FILES, 384 TYPE_CHIP_FROM_THIS_WEEK 385 }) 386 @Retention(RetentionPolicy.SOURCE) 387 public @interface SearchType {} 388 389 // Codes representing different search types 390 public static final int SEARCH_UNKNOWN = 0; 391 public static final int SEARCH_KEYWORD = 1; 392 public static final int SEARCH_CHIPS = 2; 393 public static final int SEARCH_KEYWORD_N_CHIPS = 3; 394 395 @IntDef(flag = true, value = { 396 SEARCH_UNKNOWN, 397 SEARCH_KEYWORD, 398 SEARCH_CHIPS, 399 SEARCH_KEYWORD_N_CHIPS 400 }) 401 @Retention(RetentionPolicy.SOURCE) 402 public @interface SearchMode {} 403 }