summaryrefslogtreecommitdiff
path: root/core/java/android/content/ContentProviderNative.java
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-03-04 17:48:13 -0800
committerBrad Fitzpatrick <bradfitz@android.com>2010-03-05 12:08:39 -0800
commit1877d0158b529663b8315482e7346a7bcaa96166 (patch)
tree5194b59937b70c2f48366f27a4458d4043957d16 /core/java/android/content/ContentProviderNative.java
parentcd47f11dfad012be1b176ea06904a00da157ed7b (diff)
Add "call" method on ContentProvider.
This permits implementing interfaces which are faster than using remote Cursors. It then uses it for Settings & SettingProvider, which together account for ~50% of total ContentProvider event loop stalls across Froyo dogfooders. For fetching Settings this looks like it should reduce average Settings lookup from 10 ms to 0.4 ms on Sholes, once the SettingsProvider serves most gets from in-memory cache. Currently it brings the Sholes average down from 10ms to 2.5 ms while still using SQLite queries on each get.
Diffstat (limited to 'core/java/android/content/ContentProviderNative.java')
-rw-r--r--core/java/android/content/ContentProviderNative.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/core/java/android/content/ContentProviderNative.java b/core/java/android/content/ContentProviderNative.java
index bacb6849e11f..81b805564921 100644
--- a/core/java/android/content/ContentProviderNative.java
+++ b/core/java/android/content/ContentProviderNative.java
@@ -26,6 +26,7 @@ import android.database.IBulkCursor;
import android.database.IContentObserver;
import android.net.Uri;
import android.os.Binder;
+import android.os.Bundle;
import android.os.RemoteException;
import android.os.IBinder;
import android.os.Parcel;
@@ -222,6 +223,21 @@ abstract public class ContentProviderNative extends Binder implements IContentPr
}
return true;
}
+
+ case CALL_TRANSACTION:
+ {
+ data.enforceInterface(IContentProvider.descriptor);
+
+ String method = data.readString();
+ String stringArg = data.readString();
+ Bundle args = data.readBundle();
+
+ Bundle responseBundle = call(method, stringArg, args);
+
+ reply.writeNoException();
+ reply.writeBundle(responseBundle);
+ return true;
+ }
}
} catch (Exception e) {
DatabaseUtils.writeExceptionToParcel(reply, e);
@@ -485,6 +501,22 @@ final class ContentProviderProxy implements IContentProvider
return fd;
}
+ public Bundle call(String method, String request, Bundle args)
+ throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+
+ data.writeInterfaceToken(IContentProvider.descriptor);
+
+ data.writeString(method);
+ data.writeString(request);
+ data.writeBundle(args);
+
+ mRemote.transact(IContentProvider.CALL_TRANSACTION, data, reply, 0);
+
+ DatabaseUtils.readExceptionFromParcel(reply);
+ return reply.readBundle();
+ }
+
private IBinder mRemote;
}
-