Modern Apps git

← Modern-Apps.git

backup: add system BackupTransport with @SystemApi stubs

Commit
9def95b15563617e6f764206419466c6cdd61025
Author
Vayun Mathur <[email protected]>
When
2026-08-12 19:14 UTC (3 months ago)
Parents
9645cfe

Diff

backup/build.gradle.kts
diff --git a/backup/build.gradle.kts b/backup/build.gradle.ktsindex 5b39a220e4..38501d3e2c 100644--- a/backup/build.gradle.kts+++ b/backup/build.gradle.kts@@ -16,6 +16,10 @@ android { }  dependencies {+    // Compile-only stubs for the framework's @SystemApi app-data backup transport+    // classes (android.app.backup.BackupTransport + RestoreDescription/RestoreSet).+    // Provided by the framework at runtime on a system image; must NOT be packaged.+    compileOnly(project(":library:backup-stubs"))     // WebDAV/Nextcloud remote reaches the server over the platform HTTP stack.     implementation(project(":library:network"))     // Scheduled file/media backups.
backup/src/main/AndroidManifest.xml
diff --git a/backup/src/main/AndroidManifest.xml b/backup/src/main/AndroidManifest.xmlindex baf0cf9707..b191a55215 100644--- a/backup/src/main/AndroidManifest.xml+++ b/backup/src/main/AndroidManifest.xml@@ -1,5 +1,21 @@ <?xml version="1.0" encoding="utf-8"?>-<manifest xmlns:android="http://schemas.android.com/apk/res/android">+<manifest xmlns:android="http://schemas.android.com/apk/res/android"+    xmlns:tools="http://schemas.android.com/tools">++    <!-- Privileged: act as the system app-data backup transport. Granted only to a+         platform-signed priv-app whitelisted in privapp-permissions*.xml. -->+    <uses-permission android:name="android.permission.BACKUP" />+    <!-- Set ourselves as the active transport where permitted. -->+    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />+    <!-- Long-running scheduled file/media backups. -->+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />+    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />+    <!-- Reaching a WebDAV/Nextcloud remote. -->+    <uses-permission android:name="android.permission.INTERNET" />+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />+    <!-- Enumerate installed apps to present per-app backup toggles. -->+    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"+        tools:ignore="QueryAllPackagesPermission" />      <application         android:allowBackup="true"@@ -19,6 +35,19 @@                 <category android:name="android.intent.category.LAUNCHER" />             </intent-filter>         </activity>++        <!-- System app-data backup transport. The platform's BackupManagerService+             binds this via the TRANSPORT_HOST action once this app is a whitelisted+             priv-app holding BACKUP; access is gated by the system-only+             BIND_BACKUP_TRANSPORT permission. -->+        <service+            android:name=".transport.ConfigurableBackupTransportService"+            android:exported="true"+            android:permission="android.permission.BIND_BACKUP_TRANSPORT">+            <intent-filter>+                <action android:name="android.backup.TRANSPORT_HOST" />+            </intent-filter>+        </service>     </application>  </manifest>
backup/src/main/java/com/vayunmathur/backup/transport/ConfigurableBackupTransport.kt
diff --git a/backup/src/main/java/com/vayunmathur/backup/transport/ConfigurableBackupTransport.kt b/backup/src/main/java/com/vayunmathur/backup/transport/ConfigurableBackupTransport.ktnew file mode 100644index 0000000000..1740fc1aca--- /dev/null+++ b/backup/src/main/java/com/vayunmathur/backup/transport/ConfigurableBackupTransport.kt@@ -0,0 +1,333 @@+package com.vayunmathur.backup.transport++import android.app.backup.BackupDataInput+import android.app.backup.BackupDataOutput+import android.app.backup.BackupTransport+import android.app.backup.RestoreDescription+import android.app.backup.RestoreSet+import android.content.Context+import android.content.pm.PackageInfo+import android.os.Build+import android.os.ParcelFileDescriptor+import android.util.Base64+import com.vayunmathur.backup.backend.BackendFactory+import com.vayunmathur.backup.backend.BackupRepository+import com.vayunmathur.backup.crypto.Crypto+import com.vayunmathur.backup.crypto.KeyManager+import com.vayunmathur.backup.data.BackupConfig+import kotlinx.coroutines.flow.first+import kotlinx.coroutines.runBlocking+import java.io.File+import java.io.FileInputStream+import java.io.FileOutputStream+import java.io.InputStream+import java.io.OutputStream++/**+ * The system app-data backup transport: the framework's BackupManager streams each+ * app's key/value entities and full-data tar streams through here, and we encrypt them+ * with [Crypto] and store them via the active [BackupRepository] backend; restore+ * reverses it. Bound by the platform through [ConfigurableBackupTransportService].+ *+ * Live behavior requires a platform-signed priv-app install whitelisted for+ * android.permission.BACKUP; it cannot be exercised on a stock device. The framework+ * callbacks are synchronous on a binder thread, so suspend backend calls are bridged+ * with [runBlocking].+ *+ * Ported concept (Seedvault ConfigurableBackupTransport) — see backup/LICENSE-Seedvault.+ */+class ConfigurableBackupTransport(private val context: Context) : BackupTransport() {++    private val config = BackupConfig(context)+    private val keyManager = KeyManager(context)++    // --- Full-backup streaming state (spans performFullBackup → sendBackupData* → finishBackup) ---+    private var fullBackupPackage: String? = null+    private var fullBackupInput: InputStream? = null+    private var fullBackupTemp: File? = null+    private var fullBackupTempOut: OutputStream? = null++    // --- Restore state ---+    private var restorePackages: List<String> = emptyList()+    private var restoreIndex = 0+    private var currentRestorePackage: String? = null+    private var fullRestoreTemp: File? = null+    private var fullRestoreInput: InputStream? = null+    private var fullRestoreOutput: OutputStream? = null++    // --- Identity / configuration ---++    override fun name(): String = COMPONENT+    override fun transportDirName(): String = "com.vayunmathur.backup"+    override fun configurationIntent() = null+    override fun dataManagementIntent() = null+    override fun dataManagementIntentLabel(): CharSequence? = null++    override fun currentDestinationString(): String =+        repoOrNull()?.backend?.displayName ?: "Not configured"++    override fun getTransportFlags(): Int = 0+    override fun requestBackupTime(): Long = 0+    override fun requestFullBackupTime(): Long = 0+    override fun getBackupQuota(packageName: String, isFullBackup: Boolean): Long = Long.MAX_VALUE++    override fun initializeDevice(): Int = tryOp {+        val repo = repoOrNull() ?: return@tryOp TRANSPORT_NOT_INITIALIZED+        runBlocking {+            // Wipe any previous backup set so the device starts clean.+            for (pkg in repo.list(BackupRepository.KV_DIR)) repo.delete(BackupRepository.kvPackageDir(pkg))+            for (pkg in repo.list(BackupRepository.FULL_DIR)) repo.delete(BackupRepository.fullPath(pkg))+        }+        TRANSPORT_OK+    }++    // --- Key/value backup ---++    override fun performBackup(packageInfo: PackageInfo, inFd: ParcelFileDescriptor): Int =+        performBackup(packageInfo, inFd, 0)++    override fun performBackup(packageInfo: PackageInfo, inFd: ParcelFileDescriptor, flags: Int): Int = tryOp {+        val repo = repoOrNull() ?: return@tryOp TRANSPORT_NOT_INITIALIZED+        val pkg = packageInfo.packageName+        val reader = backupDataInput(inFd.fileDescriptor)+        runBlocking {+            while (reader.readNextHeader()) {+                val key = reader.key+                val keyId = encodeKey(key)+                val size = reader.dataSize+                if (size < 0) {+                    repo.delete(BackupRepository.kvPath(pkg, keyId))+                } else {+                    val data = ByteArray(size)+                    reader.readEntityData(data, 0, size)+                    repo.writeEncrypted(BackupRepository.kvPath(pkg, keyId), data)+                }+            }+        }+        TRANSPORT_OK+    }++    override fun clearBackupData(packageInfo: PackageInfo): Int = tryOp {+        val repo = repoOrNull() ?: return@tryOp TRANSPORT_NOT_INITIALIZED+        val pkg = packageInfo.packageName+        runBlocking {+            repo.delete(BackupRepository.kvPackageDir(pkg))+            repo.delete(BackupRepository.fullPath(pkg))+        }+        TRANSPORT_OK+    }++    override fun finishBackup(): Int = tryOp {+        val pkg = fullBackupPackage ?: return@tryOp TRANSPORT_OK // key/value: writes already flushed+        val temp = fullBackupTemp+        try {+            fullBackupTempOut?.flush()+            fullBackupTempOut?.close()+            fullBackupInput?.close()+            val repo = repoOrNull() ?: return@tryOp TRANSPORT_NOT_INITIALIZED+            if (temp != null && temp.exists()) {+                runBlocking {+                    FileInputStream(temp).use { repo.writeEncrypted(BackupRepository.fullPath(pkg), it) }+                }+            }+            TRANSPORT_OK+        } finally {+            temp?.delete()+            resetFullBackup()+        }+    }++    // --- Full-data backup ---++    override fun checkFullBackupSize(size: Long): Int = TRANSPORT_OK++    override fun performFullBackup(targetPackage: PackageInfo, socket: ParcelFileDescriptor): Int =+        performFullBackup(targetPackage, socket, 0)++    override fun performFullBackup(targetPackage: PackageInfo, socket: ParcelFileDescriptor, flags: Int): Int =+        tryOp {+            if (repoOrNull() == null) return@tryOp TRANSPORT_NOT_INITIALIZED+            resetFullBackup()+            val pkg = targetPackage.packageName+            val temp = File.createTempFile("full-backup", ".tmp", context.cacheDir)+            fullBackupPackage = pkg+            fullBackupInput = ParcelFileDescriptor.AutoCloseInputStream(socket)+            fullBackupTemp = temp+            fullBackupTempOut = FileOutputStream(temp)+            TRANSPORT_OK+        }++    override fun sendBackupData(numBytes: Int): Int = tryOp {+        val input = fullBackupInput ?: return@tryOp TRANSPORT_ERROR+        val out = fullBackupTempOut ?: return@tryOp TRANSPORT_ERROR+        val buffer = ByteArray(CHUNK)+        var remaining = numBytes+        while (remaining > 0) {+            val read = input.read(buffer, 0, minOf(buffer.size, remaining))+            if (read < 0) break+            out.write(buffer, 0, read)+            remaining -= read+        }+        TRANSPORT_OK+    }++    override fun cancelFullBackup() {+        fullBackupTemp?.delete()+        resetFullBackup()+    }++    // --- Restore-set discovery ---++    override fun getAvailableRestoreSets(): Array<RestoreSet> =+        arrayOf(RestoreSet(name(), Build.MODEL ?: "device", CURRENT_TOKEN))++    override fun getCurrentRestoreSet(): Long = CURRENT_TOKEN++    override fun startRestore(token: Long, packages: Array<PackageInfo>): Int = tryOp {+        if (repoOrNull() == null) return@tryOp TRANSPORT_NOT_INITIALIZED+        restorePackages = packages.map { it.packageName }+        restoreIndex = 0+        currentRestorePackage = null+        resetFullRestore()+        TRANSPORT_OK+    }++    override fun nextRestorePackage(): RestoreDescription {+        val repo = repoOrNull() ?: return RestoreDescription.NO_MORE_PACKAGES+        return runBlocking {+            while (restoreIndex < restorePackages.size) {+                val pkg = restorePackages[restoreIndex++]+                val hasKv = repo.list(BackupRepository.kvPackageDir(pkg)).isNotEmpty()+                if (hasKv) {+                    currentRestorePackage = pkg+                    return@runBlocking RestoreDescription(pkg, RestoreDescription.TYPE_KEY_VALUE)+                }+                if (repo.exists(BackupRepository.fullPath(pkg))) {+                    currentRestorePackage = pkg+                    resetFullRestore()+                    return@runBlocking RestoreDescription(pkg, RestoreDescription.TYPE_FULL_STREAM)+                }+            }+            currentRestorePackage = null+            RestoreDescription.NO_MORE_PACKAGES+        }+    }++    // --- Key/value restore ---++    override fun getRestoreData(outFd: ParcelFileDescriptor): Int = tryOp {+        val repo = repoOrNull() ?: return@tryOp TRANSPORT_NOT_INITIALIZED+        val pkg = currentRestorePackage ?: return@tryOp TRANSPORT_ERROR+        val writer = backupDataOutput(outFd.fileDescriptor)+        runBlocking {+            for (keyId in repo.list(BackupRepository.kvPackageDir(pkg))) {+                val data = repo.readEncrypted(BackupRepository.kvPath(pkg, keyId))+                writer.writeEntityHeader(decodeKey(keyId), data.size)+                writer.writeEntityData(data, data.size)+            }+        }+        TRANSPORT_OK+    }++    // --- Full-data restore ---++    override fun getNextFullRestoreDataChunk(socket: ParcelFileDescriptor): Int {+        return try {+            val pkg = currentRestorePackage ?: return NO_MORE_DATA+            if (fullRestoreInput == null) {+                val repo = repoOrNull() ?: return TRANSPORT_ERROR+                if (!runBlocking { repo.exists(BackupRepository.fullPath(pkg)) }) return NO_MORE_DATA+                val temp = File.createTempFile("full-restore", ".tmp", context.cacheDir)+                runBlocking {+                    FileOutputStream(temp).use { repo.readEncryptedTo(BackupRepository.fullPath(pkg), it) }+                }+                fullRestoreTemp = temp+                fullRestoreInput = FileInputStream(temp)+                fullRestoreOutput = ParcelFileDescriptor.AutoCloseOutputStream(socket)+            }+            val input = fullRestoreInput ?: return TRANSPORT_ERROR+            val out = fullRestoreOutput ?: return TRANSPORT_ERROR+            val buffer = ByteArray(CHUNK)+            val read = input.read(buffer)+            if (read < 0) {+                resetFullRestore()+                NO_MORE_DATA+            } else {+                out.write(buffer, 0, read)+                out.flush()+                read+            }+        } catch (_: Exception) {+            resetFullRestore()+            TRANSPORT_ERROR+        }+    }++    override fun abortFullRestore(): Int {+        resetFullRestore()+        return TRANSPORT_OK+    }++    override fun finishRestore() {+        resetFullRestore()+        currentRestorePackage = null+    }++    // --- Internals ---++    private fun repoOrNull(): BackupRepository? {+        return try {+            val settings = runBlocking { config.settings.first() }+            val backend = BackendFactory.create(context, settings) ?: return null+            if (!keyManager.hasMasterKey()) return null+            BackupRepository(backend, Crypto(keyManager.getMasterKey()))+        } catch (_: Exception) {+            null+        }+    }++    private inline fun tryOp(block: () -> Int): Int = try {+        block()+    } catch (_: Exception) {+        TRANSPORT_ERROR+    }++    private fun resetFullBackup() {+        fullBackupPackage = null+        fullBackupInput = null+        fullBackupTemp = null+        fullBackupTempOut = null+    }++    private fun resetFullRestore() {+        runCatching { fullRestoreInput?.close() }+        runCatching { fullRestoreOutput?.close() }+        fullRestoreTemp?.delete()+        fullRestoreInput = null+        fullRestoreOutput = null+        fullRestoreTemp = null+    }++    // The FileDescriptor constructors of BackupDataInput/Output are hidden from the+    // public SDK (only the read/write methods are public API), so build them reflectively.+    private fun backupDataInput(fd: java.io.FileDescriptor): BackupDataInput =+        BackupDataInput::class.java.getDeclaredConstructor(java.io.FileDescriptor::class.java)+            .apply { isAccessible = true }.newInstance(fd)++    private fun backupDataOutput(fd: java.io.FileDescriptor): BackupDataOutput =+        BackupDataOutput::class.java.getDeclaredConstructor(java.io.FileDescriptor::class.java)+            .apply { isAccessible = true }.newInstance(fd)++    private fun encodeKey(key: String): String =+        Base64.encodeToString(key.toByteArray(Charsets.UTF_8), Base64.URL_SAFE or Base64.NO_WRAP or Base64.NO_PADDING)++    private fun decodeKey(keyId: String): String =+        String(Base64.decode(keyId, Base64.URL_SAFE or Base64.NO_WRAP or Base64.NO_PADDING), Charsets.UTF_8)++    companion object {+        private const val COMPONENT = "com.vayunmathur.backup/.transport.ConfigurableBackupTransportService"+        private const val CHUNK = 32 * 1024+        // A single current backup set; token is stable so restore can find it.+        private const val CURRENT_TOKEN = 1L+    }+}
backup/src/main/java/com/vayunmathur/backup/transport/ConfigurableBackupTransportService.kt
diff --git a/backup/src/main/java/com/vayunmathur/backup/transport/ConfigurableBackupTransportService.kt b/backup/src/main/java/com/vayunmathur/backup/transport/ConfigurableBackupTransportService.ktnew file mode 100644index 0000000000..7f4c9f5eeb--- /dev/null+++ b/backup/src/main/java/com/vayunmathur/backup/transport/ConfigurableBackupTransportService.kt@@ -0,0 +1,20 @@+package com.vayunmathur.backup.transport++import android.app.Service+import android.content.Intent+import android.os.IBinder++/**+ * Framework-bound host for [ConfigurableBackupTransport]. The platform's+ * BackupManagerService binds this (via the `android.backup.TRANSPORT_HOST` action,+ * gated by the system-only BIND_BACKUP_TRANSPORT permission) and talks to the+ * transport through the binder returned here.+ *+ * Live behavior requires a platform-signed priv-app install whitelisted for+ * android.permission.BACKUP; it cannot be exercised on a stock device.+ */+class ConfigurableBackupTransportService : Service() {+    private val transport by lazy { ConfigurableBackupTransport(applicationContext) }++    override fun onBind(intent: Intent?): IBinder? = transport.binder+}
library/backup-stubs/build.gradle.kts
diff --git a/library/backup-stubs/build.gradle.kts b/library/backup-stubs/build.gradle.ktsnew file mode 100644index 0000000000..38878f0403--- /dev/null+++ b/library/backup-stubs/build.gradle.kts@@ -0,0 +1,13 @@+plugins {+    id("common-conventions-library")+}++// Compile-only stubs for the framework's @SystemApi app-data backup transport API+// (`android.app.backup.BackupTransport` + `RestoreDescription` / `RestoreSet`). These+// classes exist in the base framework at runtime on every device but are hidden from+// the public SDK, so this module is depended on with `compileOnly` and its classes+// must NOT be packaged into any APK.+//+// Signatures and constant values mirror AOSP so `ConfigurableBackupTransport`+// overrides the real methods exactly. Live behavior requires a platform-signed+// priv-app install whitelisted for android.permission.BACKUP.
library/backup-stubs/src/main/java/android/app/backup/BackupTransport.java
diff --git a/library/backup-stubs/src/main/java/android/app/backup/BackupTransport.java b/library/backup-stubs/src/main/java/android/app/backup/BackupTransport.javanew file mode 100644index 0000000000..c51b84c739--- /dev/null+++ b/library/backup-stubs/src/main/java/android/app/backup/BackupTransport.java@@ -0,0 +1,147 @@+package android.app.backup;++import android.content.Intent;+import android.content.pm.PackageInfo;+import android.os.IBinder;+import android.os.ParcelFileDescriptor;++/**+ * Compile-only stub of the framework's {@code @SystemApi}+ * {@code android.app.backup.BackupTransport}. Mirrors the AOSP surface (method+ * signatures and constant values) that a backup transport implements. Not packaged;+ * the real class is provided by the framework at runtime on a system image.+ */+public class BackupTransport {+    // Result codes — values must match AOSP because they are inlined into callers.+    public static final int TRANSPORT_OK = 0;+    public static final int TRANSPORT_ERROR = 1;+    public static final int TRANSPORT_NOT_INITIALIZED = 2;+    public static final int TRANSPORT_PACKAGE_REJECTED = 3;+    public static final int AGENT_ERROR = 4;+    public static final int AGENT_UNKNOWN = 5;+    public static final int TRANSPORT_QUOTA_EXCEEDED = 6;+    public static final int TRANSPORT_NON_INCREMENTAL_BACKUP_REQUIRED = 7;++    // Sentinel returned by getNextFullRestoreDataChunk when a stream is exhausted.+    public static final int NO_MORE_DATA = -1;++    // performBackup / performFullBackup flags.+    public static final int FLAG_USER_INITIATED = 1;+    public static final int FLAG_NON_INCREMENTAL = 1 << 1;+    public static final int FLAG_INCREMENTAL = 1 << 2;+    public static final int FLAG_DATA_NOT_CHANGED = 1 << 3;++    public IBinder getBinder() {+        return null;+    }++    public String name() {+        return null;+    }++    public Intent configurationIntent() {+        return null;+    }++    public String currentDestinationString() {+        return null;+    }++    public Intent dataManagementIntent() {+        return null;+    }++    public CharSequence dataManagementIntentLabel() {+        return null;+    }++    public String transportDirName() {+        return null;+    }++    public long requestBackupTime() {+        return 0;+    }++    public int initializeDevice() {+        return TRANSPORT_ERROR;+    }++    public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd) {+        return TRANSPORT_ERROR;+    }++    public int performBackup(PackageInfo packageInfo, ParcelFileDescriptor inFd, int flags) {+        return performBackup(packageInfo, inFd);+    }++    public int clearBackupData(PackageInfo packageInfo) {+        return TRANSPORT_ERROR;+    }++    public int finishBackup() {+        return TRANSPORT_ERROR;+    }++    public RestoreSet[] getAvailableRestoreSets() {+        return null;+    }++    public long getCurrentRestoreSet() {+        return 0;+    }++    public int startRestore(long token, PackageInfo[] packages) {+        return TRANSPORT_ERROR;+    }++    public RestoreDescription nextRestorePackage() {+        return null;+    }++    public int getRestoreData(ParcelFileDescriptor outFd) {+        return TRANSPORT_ERROR;+    }++    public void finishRestore() {+    }++    public long requestFullBackupTime() {+        return 0;+    }++    public int checkFullBackupSize(long size) {+        return TRANSPORT_OK;+    }++    public int performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket) {+        return TRANSPORT_ERROR;+    }++    public int performFullBackup(PackageInfo targetPackage, ParcelFileDescriptor socket, int flags) {+        return performFullBackup(targetPackage, socket);+    }++    public int sendBackupData(int numBytes) {+        return TRANSPORT_ERROR;+    }++    public void cancelFullBackup() {+    }++    public int getTransportFlags() {+        return 0;+    }++    public long getBackupQuota(String packageName, boolean isFullBackup) {+        return Long.MAX_VALUE;+    }++    public int getNextFullRestoreDataChunk(ParcelFileDescriptor socket) {+        return NO_MORE_DATA;+    }++    public int abortFullRestore() {+        return TRANSPORT_OK;+    }+}
library/backup-stubs/src/main/java/android/app/backup/RestoreDescription.java
diff --git a/library/backup-stubs/src/main/java/android/app/backup/RestoreDescription.java b/library/backup-stubs/src/main/java/android/app/backup/RestoreDescription.javanew file mode 100644index 0000000000..a31e606302--- /dev/null+++ b/library/backup-stubs/src/main/java/android/app/backup/RestoreDescription.java@@ -0,0 +1,32 @@+package android.app.backup;++/**+ * Compile-only stub of the framework's {@code @SystemApi}+ * {@code android.app.backup.RestoreDescription}. Describes the next package to+ * restore and whether its data is key/value or a full stream. Not packaged; the real+ * class is provided by the framework at runtime.+ */+public class RestoreDescription {+    public static final int TYPE_KEY_VALUE = 1;+    public static final int TYPE_FULL_STREAM = 2;++    /** Sentinel returned by {@code nextRestorePackage()} when the set is exhausted. */+    public static final RestoreDescription NO_MORE_PACKAGES =+            new RestoreDescription("NO_MORE_PACKAGES", 0);++    private final String mPackageName;+    private final int mDataType;++    public RestoreDescription(String packageName, int dataType) {+        mPackageName = packageName;+        mDataType = dataType;+    }++    public String getPackageName() {+        return mPackageName;+    }++    public int getDataType() {+        return mDataType;+    }+}
library/backup-stubs/src/main/java/android/app/backup/RestoreSet.java
diff --git a/library/backup-stubs/src/main/java/android/app/backup/RestoreSet.java b/library/backup-stubs/src/main/java/android/app/backup/RestoreSet.javanew file mode 100644index 0000000000..242e854c2f--- /dev/null+++ b/library/backup-stubs/src/main/java/android/app/backup/RestoreSet.java@@ -0,0 +1,21 @@+package android.app.backup;++/**+ * Compile-only stub of the framework's {@code @SystemApi}+ * {@code android.app.backup.RestoreSet}. Identifies an available backup set by its+ * token. Not packaged; the real class is provided by the framework at runtime.+ */+public class RestoreSet {+    public String name;+    public String device;+    public long token;++    public RestoreSet() {+    }++    public RestoreSet(String name, String device, long token) {+        this.name = name;+        this.device = device;+        this.token = token;+    }+}
settings.gradle.kts
diff --git a/settings.gradle.kts b/settings.gradle.ktsindex 7cf7a49c4f..0e2605ce69 100644--- a/settings.gradle.kts+++ b/settings.gradle.kts@@ -90,6 +90,7 @@ include(":web") include(":appstore") include(":library:locationprovider") include(":library:euicc-stubs")+include(":library:backup-stubs") include(":networklocation") include(":fooddelivery") include(":musicbrainz")