Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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.internal.backup; |
| 18 | |
Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame^] | 19 | import android.content.pm.PackageInfo; |
Christopher Tate | e10be80 | 2009-05-07 17:22:16 -0700 | [diff] [blame] | 20 | import android.os.ParcelFileDescriptor; |
| 21 | |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 22 | /** {@hide} */ |
| 23 | interface IBackupTransport { |
Christopher Tate | e10be80 | 2009-05-07 17:22:16 -0700 | [diff] [blame] | 24 | /* STOPSHIP - don't ship with this comment in place |
| 25 | Things the transport interface has to do: |
| 26 | 1. set up the connection to the destination |
| 27 | - set up encryption |
| 28 | - for Google cloud, log in using the user's gaia credential or whatever |
Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame^] | 29 | - for adb, just set up the all-in-one destination file |
Christopher Tate | e10be80 | 2009-05-07 17:22:16 -0700 | [diff] [blame] | 30 | 2. send each app's backup transaction |
| 31 | - parse the data file for key/value pointers etc |
| 32 | - send key/blobsize set to the Google cloud, get back quota ok/rejected response |
| 33 | - sd/adb doesn't preflight; no per-app quota |
| 34 | - app's entire change is essentially atomic |
| 35 | - cloud transaction encrypts then sends each key/value pair separately; we already |
| 36 | parsed the data when preflighting so we don't have to again here |
| 37 | - sd target streams raw data into encryption envelope then to sd? |
| 38 | 3. shut down connection to destination |
| 39 | - cloud: tear down connection etc |
Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame^] | 40 | - adb: close the file |
Christopher Tate | e10be80 | 2009-05-07 17:22:16 -0700 | [diff] [blame] | 41 | */ |
| 42 | /** |
| 43 | * Establish a connection to the back-end data repository, if necessary. If the transport |
| 44 | * needs to initialize state that is not tied to individual applications' backup operations, |
| 45 | * this is where it should be done. |
| 46 | * |
| 47 | * @return Zero on success; a nonzero error code on failure. |
| 48 | */ |
| 49 | int startSession(); |
| 50 | |
| 51 | /** |
| 52 | * Send one application's data to the backup destination. |
| 53 | * |
Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame^] | 54 | * @param package The identity of the application whose data is being backed up. This |
| 55 | * specifically includes the signature list for the package. |
Christopher Tate | e10be80 | 2009-05-07 17:22:16 -0700 | [diff] [blame] | 56 | * @param data The data stream that resulted from invoking the application's |
Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame^] | 57 | * BackupService.doBackup() method. This may be a pipe rather than a file on |
| 58 | * persistent media, so it may not be seekable. |
Christopher Tate | e10be80 | 2009-05-07 17:22:16 -0700 | [diff] [blame] | 59 | * @return Zero on success; a nonzero error code on failure. |
| 60 | */ |
Christopher Tate | 7b88128 | 2009-06-07 13:52:37 -0700 | [diff] [blame^] | 61 | int performBackup(in PackageInfo packageInfo, in ParcelFileDescriptor data); |
Christopher Tate | e10be80 | 2009-05-07 17:22:16 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * Terminate the backup session, closing files, freeing memory, and cleaning up whatever |
| 65 | * other state the transport required. |
| 66 | * |
| 67 | * @return Zero on success; a nonzero error code on failure. Even on failure, the session |
| 68 | * is torn down and must be restarted if another backup is attempted. |
| 69 | */ |
| 70 | int endSession(); |
Christopher Tate | 487529a | 2009-04-29 14:03:25 -0700 | [diff] [blame] | 71 | } |