blob: a91aded1abf6be366ef066ec04c11eaee9791053 [file] [log] [blame]
Stefanotb1f573d2017-01-27 12:03:53 +00001/*
2 * Copyright (C) 2017 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
17package android.app.backup;
18
19import android.annotation.SystemApi;
20import android.os.Bundle;
21
22/**
23 * Callback class for receiving important events during backup/restore operations.
24 * Events consist mostly of errors and exceptions, giving detailed reason on why a restore/backup
25 * failed or any time BackupManager makes an important decision.
26 * On the other hand {@link BackupObserver} will give a failure/success view without
27 * getting into details why. This callback runs on the thread it was called on because it can get
28 * a bit spammy.
29 * These callbacks will run on the binder thread.
30 *
31 * @hide
32 */
33@SystemApi
34public class BackupManagerMonitor {
35
36 // Logging constants for BackupManagerMonitor
37 public static final int LOG_EVENT_CATEGORY_TRANSPORT = 1;
38 public static final int LOG_EVENT_CATEGORY_AGENT = 2;
39 public static final int LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY = 3;
40 /** string : the package name */
41 public static final String EXTRA_LOG_EVENT_PACKAGE_NAME =
42 "android.app.backup.extra.LOG_EVENT_PACKAGE_NAME";
Dianne Hackborn3accca02013-09-20 09:32:11 -070043 /** int : the versionCode of the package named by EXTRA_LOG_EVENT_PACKAGE_NAME
44 * @deprecated Use {@link #EXTRA_LOG_EVENT_PACKAGE_LONG_VERSION} */
45 @Deprecated
Stefanotb1f573d2017-01-27 12:03:53 +000046 public static final String EXTRA_LOG_EVENT_PACKAGE_VERSION =
47 "android.app.backup.extra.LOG_EVENT_PACKAGE_VERSION";
Dianne Hackborn3accca02013-09-20 09:32:11 -070048 /** long : the full versionCode of the package named by EXTRA_LOG_EVENT_PACKAGE_NAME */
49 public static final String EXTRA_LOG_EVENT_PACKAGE_LONG_VERSION =
50 "android.app.backup.extra.LOG_EVENT_PACKAGE_FULL_VERSION";
Stefanotb1f573d2017-01-27 12:03:53 +000051 /** int : the id of the log message, will be a unique identifier */
52 public static final String EXTRA_LOG_EVENT_ID = "android.app.backup.extra.LOG_EVENT_ID";
53 /**
54 * int : category will be one of
55 * { LOG_EVENT_CATEGORY_TRANSPORT,
56 * LOG_EVENT_CATEGORY_AGENT,
57 * LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY}.
58 */
59 public static final String EXTRA_LOG_EVENT_CATEGORY =
60 "android.app.backup.extra.LOG_EVENT_CATEGORY";
61
Anton Philippovdeb244d2017-02-21 23:25:31 +000062
Stefanot28154962017-02-21 10:48:18 +000063 /**
Anton Philippovdeb244d2017-02-21 23:25:31 +000064 * boolean: when we have an event with id LOG_EVENT_ID_KEY_VALUE_BACKUP_CANCEL we record if
65 * the call was to cancel backup of all packages
66 */
67 public static final String EXTRA_LOG_CANCEL_ALL = "android.app.backup.extra.LOG_CANCEL_ALL";
68
69 /**
70 * string: when we have an event with id LOG_EVENT_ID_ILLEGAL_KEY we send the key that was used
71 * by the app
72 */
73 public static final String EXTRA_LOG_ILLEGAL_KEY = "android.app.backup.extra.LOG_ILLEGAL_KEY";
74
75 /**
76 * long: when we have an event with id LOG_EVENT_ID_ERROR_PREFLIGHT we send the error code that
77 * was returned by the transport during preflight
78 */
79 public static final String EXTRA_LOG_PREFLIGHT_ERROR =
80 "android.app.backup.extra.LOG_PREFLIGHT_ERROR";
81
82 /**
83 * string: when we have an event with id LOG_EVENT_ID_EXCEPTION_FULL_BACKUP we send the
84 * exception's stacktrace
85 */
86 public static final String EXTRA_LOG_EXCEPTION_FULL_BACKUP =
87 "android.app.backup.extra.LOG_EXCEPTION_FULL_BACKUP";
88
89 /**
90 * int: when we have an event with id LOG_EVENT_ID_RESTORE_VERSION_HIGHER we send the
91 * restore package version
92 */
93 public static final String EXTRA_LOG_RESTORE_VERSION =
94 "android.app.backup.extra.LOG_RESTORE_VERSION";
95
96 /**
97 * boolean: when we have an event with id LOG_EVENT_ID_RESTORE_VERSION_HIGHER we record if
98 * ApplicationInfo.FLAG_RESTORE_ANY_VERSION flag is set
99 */
100 public static final String EXTRA_LOG_RESTORE_ANYWAY =
101 "android.app.backup.extra.LOG_RESTORE_ANYWAY";
102
103
104 /**
105 * boolean: when we have an event with id LOG_EVENT_ID_APK_NOT_INSTALLED we record if
106 * the policy allows to install apks provided with the dataset
107 */
108 public static final String EXTRA_LOG_POLICY_ALLOW_APKS =
109 "android.app.backup.extra.LOG_POLICY_ALLOW_APKS";
110
111
112 /**
113 * string: when we have an event with id LOG_EVENT_ID_EXPECTED_DIFFERENT_PACKAGE we record the
114 * package name provided in the restore manifest
115 */
116 public static final String EXTRA_LOG_MANIFEST_PACKAGE_NAME =
117 "android.app.backup.extra.LOG_MANIFEST_PACKAGE_NAME";
118
119 /**
120 * string: when we have an event with id LOG_EVENT_ID_WIDGET_METADATA_MISMATCH we record the
121 * package name provided in the widget metadata
122 */
123 public static final String EXTRA_LOG_WIDGET_PACKAGE_NAME =
124 "android.app.backup.extra.LOG_WIDGET_PACKAGE_NAME";
125
126 /**
127 * int: when we have event of id LOG_EVENT_ID_VERSION_OF_BACKUP_OLDER we send the version
Stefanot28154962017-02-21 10:48:18 +0000128 * of the backup.
129 */
Anton Philippovdeb244d2017-02-21 23:25:31 +0000130 public static final String EXTRA_LOG_OLD_VERSION = "android.app.backup.extra.LOG_OLD_VERSION";
Stefanot28154962017-02-21 10:48:18 +0000131
Stefanotb1f573d2017-01-27 12:03:53 +0000132 // TODO complete this list with all log messages. And document properly.
Anton Philippovdeb244d2017-02-21 23:25:31 +0000133 public static final int LOG_EVENT_ID_FULL_BACKUP_CANCEL = 4;
134 public static final int LOG_EVENT_ID_ILLEGAL_KEY = 5;
135 public static final int LOG_EVENT_ID_NO_DATA_TO_SEND = 7;
136 public static final int LOG_EVENT_ID_PACKAGE_INELIGIBLE = 9;
137 public static final int LOG_EVENT_ID_PACKAGE_KEY_VALUE_PARTICIPANT = 10;
138 public static final int LOG_EVENT_ID_PACKAGE_STOPPED = 11;
Stefanot28154962017-02-21 10:48:18 +0000139 public static final int LOG_EVENT_ID_PACKAGE_NOT_FOUND = 12;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000140 public static final int LOG_EVENT_ID_BACKUP_DISABLED = 13;
141 public static final int LOG_EVENT_ID_DEVICE_NOT_PROVISIONED = 14;
Stefanot28154962017-02-21 10:48:18 +0000142 public static final int LOG_EVENT_ID_PACKAGE_TRANSPORT_NOT_PRESENT = 15;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000143 public static final int LOG_EVENT_ID_ERROR_PREFLIGHT = 16;
144 public static final int LOG_EVENT_ID_QUOTA_HIT_PREFLIGHT = 18;
145 public static final int LOG_EVENT_ID_EXCEPTION_FULL_BACKUP = 19;
146 public static final int LOG_EVENT_ID_KEY_VALUE_BACKUP_CANCEL = 21;
Stefanot28154962017-02-21 10:48:18 +0000147 public static final int LOG_EVENT_ID_NO_RESTORE_METADATA_AVAILABLE = 22;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000148 public static final int LOG_EVENT_ID_NO_PM_METADATA_RECEIVED = 23;
149 public static final int LOG_EVENT_ID_PM_AGENT_HAS_NO_METADATA = 24;
150 public static final int LOG_EVENT_ID_LOST_TRANSPORT = 25;
Stefanot28154962017-02-21 10:48:18 +0000151 public static final int LOG_EVENT_ID_PACKAGE_NOT_PRESENT = 26;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000152 public static final int LOG_EVENT_ID_RESTORE_VERSION_HIGHER = 27;
Stefanot28154962017-02-21 10:48:18 +0000153 public static final int LOG_EVENT_ID_APP_HAS_NO_AGENT = 28;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000154 public static final int LOG_EVENT_ID_SIGNATURE_MISMATCH = 29;
Stefanot28154962017-02-21 10:48:18 +0000155 public static final int LOG_EVENT_ID_CANT_FIND_AGENT = 30;
Stefanotf4e237c2017-02-06 21:14:05 +0000156 public static final int LOG_EVENT_ID_KEY_VALUE_RESTORE_TIMEOUT = 31;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000157 public static final int LOG_EVENT_ID_RESTORE_ANY_VERSION = 34;
158 public static final int LOG_EVENT_ID_VERSIONS_MATCH = 35;
Stefanot28154962017-02-21 10:48:18 +0000159 public static final int LOG_EVENT_ID_VERSION_OF_BACKUP_OLDER = 36;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000160 public static final int LOG_EVENT_ID_FULL_RESTORE_SIGNATURE_MISMATCH = 37;
161 public static final int LOG_EVENT_ID_SYSTEM_APP_NO_AGENT = 38;
162 public static final int LOG_EVENT_ID_FULL_RESTORE_ALLOW_BACKUP_FALSE = 39;
163 public static final int LOG_EVENT_ID_APK_NOT_INSTALLED = 40;
164 public static final int LOG_EVENT_ID_CANNOT_RESTORE_WITHOUT_APK = 41;
165 public static final int LOG_EVENT_ID_MISSING_SIGNATURE = 42;
166 public static final int LOG_EVENT_ID_EXPECTED_DIFFERENT_PACKAGE = 43;
167 public static final int LOG_EVENT_ID_UNKNOWN_VERSION = 44;
Stefanotf4e237c2017-02-06 21:14:05 +0000168 public static final int LOG_EVENT_ID_FULL_RESTORE_TIMEOUT = 45;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000169 public static final int LOG_EVENT_ID_CORRUPT_MANIFEST = 46;
170 public static final int LOG_EVENT_ID_WIDGET_METADATA_MISMATCH = 47;
171 public static final int LOG_EVENT_ID_WIDGET_UNKNOWN_VERSION = 48;
Stefanotb1f573d2017-01-27 12:03:53 +0000172 public static final int LOG_EVENT_ID_NO_PACKAGES = 49;
Anton Philippovdeb244d2017-02-21 23:25:31 +0000173 public static final int LOG_EVENT_ID_TRANSPORT_IS_NULL = 50;
Stefanotb1f573d2017-01-27 12:03:53 +0000174
Oscar Keyf5b99ad2018-01-23 13:53:29 +0000175 /**
176 * The transport returned {@link BackupTransport#TRANSPORT_NON_INCREMENTAL_BACKUP_REQUIRED}.
177 * @hide
178 */
179 public static final int LOG_EVENT_ID_TRANSPORT_NON_INCREMENTAL_BACKUP_REQUIRED = 51;
180
Stefanotb1f573d2017-01-27 12:03:53 +0000181
182
Stefanot28154962017-02-21 10:48:18 +0000183
184
Stefanotb1f573d2017-01-27 12:03:53 +0000185 /**
186 * This method will be called each time something important happens on BackupManager.
187 *
188 * @param event bundle will contain data about event:
189 * - event id, not optional, a unique identifier for each event.
190 * - package name, optional, the current package we're backing up/restoring if applicable.
191 * - package version, optional, the current package version we're backing up/restoring
192 * if applicable.
193 * - category of event, not optional, one of
194 * { LOG_EVENT_CATEGORY_TRANSPORT,
195 * LOG_EVENT_CATEGORY_AGENT,
196 * LOG_EVENT_CATEGORY_BACKUP_MANAGER_POLICY}
197 *
198 */
199 public void onEvent(Bundle event) {
200 }
201}