1 /* 2 * Copyright (C) 2022 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 18 package com.android.systemui.keyguard.domain.backup 19 20 import android.app.backup.BackupDataInputStream 21 import android.app.backup.SharedPreferencesBackupHelper 22 import android.content.Context 23 import android.util.Log 24 import com.android.app.tracing.traceSection 25 import com.android.systemui.keyguard.data.quickaffordance.KeyguardQuickAffordanceSelectionManager 26 import com.android.systemui.settings.UserFileManagerImpl 27 28 /** Handles backup & restore for keyguard quick affordances. */ 29 class KeyguardQuickAffordanceBackupHelper( 30 private val context: Context, 31 userId: Int, 32 ) : 33 SharedPreferencesBackupHelper( 34 context, 35 UserFileManagerImpl.createFile( 36 userId = userId, 37 fileName = KeyguardQuickAffordanceSelectionManager.FILE_NAME, 38 ) 39 .getPath() 40 ) { 41 restoreEntitynull42 override fun restoreEntity(data: BackupDataInputStream?) { 43 Log.d(TAG, "Starting restore for ${data?.key} for user ${context.userId}") 44 traceSection("$TAG File restore: ${data?.key}") { 45 super.restoreEntity(data) 46 } 47 Log.d(TAG, "Finished restore for ${data?.key} for user ${context.userId}") 48 } 49 50 companion object { 51 private const val TAG = "KeyguardQuickAffordanceBackupHelper" 52 } 53 } 54