summaryrefslogtreecommitdiffstats
path: root/core/java/android/backup/BackupDataOutput.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/backup/BackupDataOutput.java')
-rw-r--r--core/java/android/backup/BackupDataOutput.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/core/java/android/backup/BackupDataOutput.java b/core/java/android/backup/BackupDataOutput.java
index 555494e..25ae15b 100644
--- a/core/java/android/backup/BackupDataOutput.java
+++ b/core/java/android/backup/BackupDataOutput.java
@@ -22,24 +22,30 @@ import java.io.FileDescriptor;
/** @hide */
public class BackupDataOutput {
- /* package */ FileDescriptor fd;
+ int mBackupWriter;
+ private Context mContext;
public static final int OP_UPDATE = 1;
public static final int OP_DELETE = 2;
public BackupDataOutput(Context context, FileDescriptor fd) {
- this.fd = fd;
+ mContext = context;
+ if (fd == null) throw new NullPointerException();
+ mBackupWriter = ctor(fd);
+ if (mBackupWriter == 0) {
+ throw new RuntimeException("Native initialization failed with fd=" + fd);
+ }
}
- public void close() {
- // do we close the fd?
+ protected void finalize() throws Throwable {
+ try {
+ dtor(mBackupWriter);
+ } finally {
+ super.finalize();
+ }
}
- public native void flush();
- public native void write(byte[] buffer);
- public native void write(int oneByte);
- public native void write(byte[] buffer, int offset, int count);
-
- public native void writeOperation(int op);
- public native void writeKey(String key);
+
+ private native static int ctor(FileDescriptor fd);
+ private native static void dtor(int mBackupWriter);
}