blob: 6f9c05c8836692ffbc5f58e58c0be45fd6554c2c [file] [log] [blame]
Chris Wren4b171362014-01-13 17:39:02 -05001/*
2 * Copyright (C) 2014 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 com.android.launcher3;
18
19import android.app.backup.BackupDataInputStream;
20import android.app.backup.SharedPreferencesBackupHelper;
21import android.content.Context;
Chris Wren50c8f422014-01-15 16:10:39 -050022import android.util.Log;
Chris Wren4b171362014-01-13 17:39:02 -050023
24public class LauncherPreferencesBackupHelper extends SharedPreferencesBackupHelper {
25
Chris Wren50c8f422014-01-15 16:10:39 -050026 private static final String TAG = "LauncherPreferencesBackupHelper";
27 private static final boolean VERBOSE = LauncherBackupAgentHelper.VERBOSE;
28
Chris Wren4b171362014-01-13 17:39:02 -050029 private final boolean mRestoreEnabled;
30
31 public LauncherPreferencesBackupHelper(Context context, String sharedPreferencesKey,
32 boolean restoreEnabled) {
33 super(context, sharedPreferencesKey);
34 mRestoreEnabled = restoreEnabled;
35 }
36
37 @Override
38 public void restoreEntity(BackupDataInputStream data) {
39 if (mRestoreEnabled) {
Chris Wren50c8f422014-01-15 16:10:39 -050040 if (VERBOSE) Log.v(TAG, "restoring preferences");
Chris Wren4b171362014-01-13 17:39:02 -050041 super.restoreEntity(data);
42 }
43 }
44}