Loading services/core/java/com/android/server/backup/SystemBackupAgent.java +7 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ public class SystemBackupAgent extends BackupAgentHelper { private static final String SYSTEM_GENDER_HELPER = "system_gender"; private static final String DISPLAY_HELPER = "display"; private static final String INPUT_HELPER = "input"; private static final String WEAR_BACKUP_HELPER = "wear"; // These paths must match what the WallpaperManagerService uses. The leaf *_FILENAME // are also used in the full-backup file format, so must not change unless steps are Loading Loading @@ -113,7 +114,7 @@ public class SystemBackupAgent extends BackupAgentHelper { private static final Set<String> sEligibleHelpersForNonSystemUser = SetUtils.union(sEligibleHelpersForProfileUser, Sets.newArraySet(ACCOUNT_MANAGER_HELPER, USAGE_STATS_HELPER, PREFERRED_HELPER, SHORTCUT_MANAGER_HELPER, INPUT_HELPER)); SHORTCUT_MANAGER_HELPER, INPUT_HELPER, WEAR_BACKUP_HELPER)); private int mUserId = UserHandle.USER_SYSTEM; private boolean mIsProfileUser = false; Loading Loading @@ -153,6 +154,11 @@ public class SystemBackupAgent extends BackupAgentHelper { if (com.android.hardware.input.Flags.enableBackupAndRestoreForInputGestures()) { addHelperIfEligibleForUser(INPUT_HELPER, new InputBackupHelper(mUserId)); } // Add Wear helper only if the device is a watch if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) { addHelperIfEligibleForUser(WEAR_BACKUP_HELPER, new WearBackupHelper()); } } @Override Loading services/core/java/com/android/server/backup/WearBackupHelper.java 0 → 100644 +49 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.backup; import android.annotation.Nullable; import android.app.backup.BlobBackupHelper; import com.android.server.LocalServices; /** A {@link android.app.backup.BlobBackupHelper} for Wear */ public class WearBackupHelper extends BlobBackupHelper { private static final int BLOB_VERSION = 1; private static final String KEY_WEAR_BACKUP = "wear"; @Nullable private final WearBackupInternal mWearBackupInternal; public WearBackupHelper() { super(BLOB_VERSION, KEY_WEAR_BACKUP); mWearBackupInternal = LocalServices.getService(WearBackupInternal.class); } @Override protected byte[] getBackupPayload(String key) { return KEY_WEAR_BACKUP.equals(key) && mWearBackupInternal != null ? mWearBackupInternal.getBackupPayload(getLogger()) : null; } @Override protected void applyRestoredPayload(String key, byte[] payload) { if (KEY_WEAR_BACKUP.equals(key) && mWearBackupInternal != null) { mWearBackupInternal.applyRestoredPayload(payload); } } } services/core/java/com/android/server/backup/WearBackupInternal.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.backup; import android.app.backup.BackupRestoreEventLogger; import com.android.internal.annotations.Keep; /** A local service internal for Wear OS handle backup/restore */ @Keep public interface WearBackupInternal { /** Gets the backup payload */ byte[] getBackupPayload(BackupRestoreEventLogger logger); /** Applies the restored payload */ void applyRestoredPayload(byte[] payload); } Loading
services/core/java/com/android/server/backup/SystemBackupAgent.java +7 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,7 @@ public class SystemBackupAgent extends BackupAgentHelper { private static final String SYSTEM_GENDER_HELPER = "system_gender"; private static final String DISPLAY_HELPER = "display"; private static final String INPUT_HELPER = "input"; private static final String WEAR_BACKUP_HELPER = "wear"; // These paths must match what the WallpaperManagerService uses. The leaf *_FILENAME // are also used in the full-backup file format, so must not change unless steps are Loading Loading @@ -113,7 +114,7 @@ public class SystemBackupAgent extends BackupAgentHelper { private static final Set<String> sEligibleHelpersForNonSystemUser = SetUtils.union(sEligibleHelpersForProfileUser, Sets.newArraySet(ACCOUNT_MANAGER_HELPER, USAGE_STATS_HELPER, PREFERRED_HELPER, SHORTCUT_MANAGER_HELPER, INPUT_HELPER)); SHORTCUT_MANAGER_HELPER, INPUT_HELPER, WEAR_BACKUP_HELPER)); private int mUserId = UserHandle.USER_SYSTEM; private boolean mIsProfileUser = false; Loading Loading @@ -153,6 +154,11 @@ public class SystemBackupAgent extends BackupAgentHelper { if (com.android.hardware.input.Flags.enableBackupAndRestoreForInputGestures()) { addHelperIfEligibleForUser(INPUT_HELPER, new InputBackupHelper(mUserId)); } // Add Wear helper only if the device is a watch if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) { addHelperIfEligibleForUser(WEAR_BACKUP_HELPER, new WearBackupHelper()); } } @Override Loading
services/core/java/com/android/server/backup/WearBackupHelper.java 0 → 100644 +49 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.backup; import android.annotation.Nullable; import android.app.backup.BlobBackupHelper; import com.android.server.LocalServices; /** A {@link android.app.backup.BlobBackupHelper} for Wear */ public class WearBackupHelper extends BlobBackupHelper { private static final int BLOB_VERSION = 1; private static final String KEY_WEAR_BACKUP = "wear"; @Nullable private final WearBackupInternal mWearBackupInternal; public WearBackupHelper() { super(BLOB_VERSION, KEY_WEAR_BACKUP); mWearBackupInternal = LocalServices.getService(WearBackupInternal.class); } @Override protected byte[] getBackupPayload(String key) { return KEY_WEAR_BACKUP.equals(key) && mWearBackupInternal != null ? mWearBackupInternal.getBackupPayload(getLogger()) : null; } @Override protected void applyRestoredPayload(String key, byte[] payload) { if (KEY_WEAR_BACKUP.equals(key) && mWearBackupInternal != null) { mWearBackupInternal.applyRestoredPayload(payload); } } }
services/core/java/com/android/server/backup/WearBackupInternal.java 0 → 100644 +32 −0 Original line number Diff line number Diff line /* * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.backup; import android.app.backup.BackupRestoreEventLogger; import com.android.internal.annotations.Keep; /** A local service internal for Wear OS handle backup/restore */ @Keep public interface WearBackupInternal { /** Gets the backup payload */ byte[] getBackupPayload(BackupRestoreEventLogger logger); /** Applies the restored payload */ void applyRestoredPayload(byte[] payload); }