DeskClock: Enable backup

* Set allowBackup to true.
* Properly support device-to-device migrations (D2D) in addition to
  normal backups by switching to dataExtractionRules.
* Include the files correctly using the device-encrypted domains,
  which is where they are stored now for access in Direct Boot.

Change-Id: I1321da4b2250d083c8785386af5ba096cd0e05eb
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7c127a0..047f1a6 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -39,9 +39,9 @@
 
     <application
         android:name=".DeskClockApplication"
-        android:allowBackup="false"
+        android:allowBackup="true"
         android:backupAgent="DeskClockBackupAgent"
-        android:fullBackupContent="@xml/backup_scheme"
+        android:dataExtractionRules="@xml/data_extraction_rules"
         android:fullBackupOnly="true"
         android:appCategory="productivity"
         android:icon="@mipmap/ic_launcher"
diff --git a/res/xml/backup_scheme.xml b/res/xml/backup_scheme.xml
deleted file mode 100644
index 3c34beb..0000000
--- a/res/xml/backup_scheme.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2015 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
-
-          http://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.
--->
-
-<full-backup-content>
-    <include domain="database" path="alarms.db" />
-    <include domain="sharedpref" path="com.android.deskclock_preferences.xml" />
-</full-backup-content>
diff --git a/res/xml/data_extraction_rules.xml b/res/xml/data_extraction_rules.xml
new file mode 100644
index 0000000..394f64f
--- /dev/null
+++ b/res/xml/data_extraction_rules.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  SPDX-FileCopyrightText: 2023 The Calyx Institute
+  SPDX-License-Identifier: Apache-2.0
+  -->
+<data-extraction-rules>
+    <cloud-backup>
+        <!-- use "device_" domains; these files are stored in device-encrypted storage (user_de) -->
+        <include domain="device_database" path="alarms.db" />
+        <include domain="device_sharedpref" path="com.android.deskclock_preferences.xml" />
+    </cloud-backup>
+    <device-transfer>
+        <!-- use "device_" domains; these files are stored in device-encrypted storage (user_de) -->
+        <include domain="device_database" path="alarms.db" />
+        <include domain="device_sharedpref" path="com.android.deskclock_preferences.xml" />
+    </device-transfer>
+</data-extraction-rules>