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