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.server.am; 18 19 import android.app.backup.BackupAnnotations.BackupDestination; 20 import android.content.pm.ApplicationInfo; 21 22 /** @hide */ 23 final class BackupRecord { 24 // backup/restore modes 25 public static final int BACKUP_NORMAL = 0; 26 public static final int BACKUP_FULL = 1; 27 public static final int RESTORE = 2; 28 public static final int RESTORE_FULL = 3; 29 30 String stringName; // cached toString() output 31 final ApplicationInfo appInfo; // information about BackupAgent's app 32 final int userId; // user for which backup is performed 33 final int backupMode; // full backup / incremental / restore 34 @BackupDestination final int backupDestination; // see BackupAnnotations#BackupDestination 35 ProcessRecord app; // where this agent is running or null 36 37 // ----- Implementation ----- 38 BackupRecord(ApplicationInfo _appInfo, int _backupMode, int _userId, int _backupDestination)39 BackupRecord(ApplicationInfo _appInfo, int _backupMode, int _userId, int _backupDestination) { 40 appInfo = _appInfo; 41 backupMode = _backupMode; 42 userId = _userId; 43 backupDestination = _backupDestination; 44 } 45 toString()46 public String toString() { 47 if (stringName != null) { 48 return stringName; 49 } 50 StringBuilder sb = new StringBuilder(128); 51 sb.append("BackupRecord{") 52 .append(Integer.toHexString(System.identityHashCode(this))) 53 .append(' ').append(appInfo.packageName) 54 .append(' ').append(appInfo.name) 55 .append(' ').append(appInfo.backupAgentName).append('}'); 56 return stringName = sb.toString(); 57 } 58 } 59