Instead of a raw AIDL interface, give DropBox a Java
interface (android.os.DropBox); move the Binder interface
behind the scenes. Make DropBoxEntry into DropBox.Entry.
Make it possible to get a dropbox from an (Application)Context
with the usual getSystemService(DROPBOX_SERVICE) type thing.
Update the tests accordingly.
diff --git a/core/java/android/app/ApplicationContext.java b/core/java/android/app/ApplicationContext.java
index f48f150..305ee6a 100644
--- a/core/java/android/app/ApplicationContext.java
+++ b/core/java/android/app/ApplicationContext.java
@@ -70,6 +70,7 @@
import android.net.wifi.WifiManager;
import android.os.Binder;
import android.os.Bundle;
+import android.os.DropBox;
import android.os.FileUtils;
import android.os.Handler;
import android.os.IBinder;
@@ -93,6 +94,8 @@
import android.accounts.AccountManager;
import android.accounts.IAccountManager;
+import com.android.internal.os.IDropBoxService;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -182,6 +185,7 @@
private ClipboardManager mClipboardManager = null;
private boolean mRestricted;
private AccountManager mAccountManager; // protected by mSync
+ private DropBox mDropBox = null;
private final Object mSync = new Object();
@@ -896,6 +900,8 @@
return getClipboardManager();
} else if (WALLPAPER_SERVICE.equals(name)) {
return getWallpaperManager();
+ } else if (DROPBOX_SERVICE.equals(name)) {
+ return getDropBox();
}
return null;
@@ -1045,7 +1051,7 @@
}
return mVibrator;
}
-
+
private AudioManager getAudioManager()
{
if (mAudioManager == null) {
@@ -1054,6 +1060,17 @@
return mAudioManager;
}
+ private DropBox getDropBox() {
+ synchronized (mSync) {
+ if (mDropBox == null) {
+ IBinder b = ServiceManager.getService(DROPBOX_SERVICE);
+ IDropBoxService service = IDropBoxService.Stub.asInterface(b);
+ mDropBox = new DropBox(service);
+ }
+ }
+ return mDropBox;
+ }
+
@Override
public int checkPermission(String permission, int pid, int uid) {
if (permission == null) {