Merge "MTP host: Use Java longs for storage and object IDs"
This commit is contained in:
committed by
Android (Google) Code Review
commit
5a08b50e80
@ -75,7 +75,7 @@ public final class Mtp
|
||||
return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID + "/storage");
|
||||
}
|
||||
|
||||
public static Uri getContentUri(int deviceID, int storageID) {
|
||||
public static Uri getContentUri(int deviceID, long storageID) {
|
||||
return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID + "/storage/" + storageID);
|
||||
}
|
||||
|
||||
@ -97,17 +97,17 @@ public final class Mtp
|
||||
*/
|
||||
public static final class Object implements BaseColumns {
|
||||
|
||||
public static Uri getContentUri(int deviceID, int objectID) {
|
||||
public static Uri getContentUri(int deviceID, long objectID) {
|
||||
return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID
|
||||
+ "/object/" + objectID);
|
||||
}
|
||||
|
||||
public static Uri getContentUriForObjectChildren(int deviceID, int objectID) {
|
||||
public static Uri getContentUriForObjectChildren(int deviceID, long objectID) {
|
||||
return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID
|
||||
+ "/object/" + objectID + "/child");
|
||||
}
|
||||
|
||||
public static Uri getContentUriForStorageChildren(int deviceID, int storageID) {
|
||||
public static Uri getContentUriForStorageChildren(int deviceID, long storageID) {
|
||||
return Uri.parse(CONTENT_AUTHORITY_DEVICE_SLASH + deviceID
|
||||
+ "/storage/" + storageID + "/child");
|
||||
}
|
||||
|
@ -57,20 +57,20 @@ public class MtpClient {
|
||||
native_stop();
|
||||
}
|
||||
|
||||
public boolean deleteObject(int deviceID, int objectID) {
|
||||
public boolean deleteObject(int deviceID, long objectID) {
|
||||
return native_delete_object(deviceID, objectID);
|
||||
}
|
||||
|
||||
public int getParent(int deviceID, int objectID) {
|
||||
public long getParent(int deviceID, long objectID) {
|
||||
return native_get_parent(deviceID, objectID);
|
||||
}
|
||||
|
||||
public int getStorageID(int deviceID, int objectID) {
|
||||
public long getStorageID(int deviceID, long objectID) {
|
||||
return native_get_storage_id(deviceID, objectID);
|
||||
}
|
||||
|
||||
// create a file descriptor for reading the contents of an object over MTP
|
||||
public ParcelFileDescriptor openFile(int deviceID, int objectID) {
|
||||
public ParcelFileDescriptor openFile(int deviceID, long objectID) {
|
||||
return native_open_file(deviceID, objectID);
|
||||
}
|
||||
|
||||
@ -101,8 +101,8 @@ public class MtpClient {
|
||||
private native final void native_finalize();
|
||||
private native boolean native_start();
|
||||
private native void native_stop();
|
||||
private native boolean native_delete_object(int deviceID, int objectID);
|
||||
private native int native_get_parent(int deviceID, int objectID);
|
||||
private native int native_get_storage_id(int deviceID, int objectID);
|
||||
private native ParcelFileDescriptor native_open_file(int deviceID, int objectID);
|
||||
private native boolean native_delete_object(int deviceID, long objectID);
|
||||
private native long native_get_parent(int deviceID, long objectID);
|
||||
private native long native_get_storage_id(int deviceID, long objectID);
|
||||
private native ParcelFileDescriptor native_open_file(int deviceID, long objectID);
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ public final class MtpCursor extends AbstractWindowedCursor {
|
||||
|
||||
private int mQueryType;
|
||||
private int mDeviceID;
|
||||
private int mStorageID;
|
||||
private int mQbjectID;
|
||||
private long mStorageID;
|
||||
private long mQbjectID;
|
||||
|
||||
/** The names of the columns in the projection */
|
||||
private String[] mColumns;
|
||||
@ -54,7 +54,7 @@ public final class MtpCursor extends AbstractWindowedCursor {
|
||||
|
||||
private final MtpClient mClient;
|
||||
|
||||
public MtpCursor(MtpClient client, int queryType, int deviceID, int storageID, int objectID,
|
||||
public MtpCursor(MtpClient client, int queryType, int deviceID, long storageID, long objectID,
|
||||
String[] projection) {
|
||||
|
||||
mClient = client;
|
||||
@ -220,7 +220,7 @@ public final class MtpCursor extends AbstractWindowedCursor {
|
||||
private int mNativeContext;
|
||||
|
||||
private native final void native_setup(MtpClient client, int queryType,
|
||||
int deviceID, int storageID, int objectID, int[] columns);
|
||||
int deviceID, long storageID, long objectID, int[] columns);
|
||||
private native final void native_finalize();
|
||||
private native void native_wait_for_event();
|
||||
private native int native_fill_window(CursorWindow window, int startPos);
|
||||
|
@ -161,7 +161,7 @@ android_media_MtpClient_stop(JNIEnv *env, jobject thiz)
|
||||
|
||||
static jboolean
|
||||
android_media_MtpClient_delete_object(JNIEnv *env, jobject thiz,
|
||||
jint device_id, jint object_id)
|
||||
jint device_id, jlong object_id)
|
||||
{
|
||||
#ifdef HAVE_ANDROID_OS
|
||||
MyClient *client = (MyClient *)env->GetIntField(thiz, field_context);
|
||||
@ -173,9 +173,9 @@ android_media_MtpClient_delete_object(JNIEnv *env, jobject thiz,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static jint
|
||||
static jlong
|
||||
android_media_MtpClient_get_parent(JNIEnv *env, jobject thiz,
|
||||
jint device_id, jint object_id)
|
||||
jint device_id, jlong object_id)
|
||||
{
|
||||
#ifdef HAVE_ANDROID_OS
|
||||
MyClient *client = (MyClient *)env->GetIntField(thiz, field_context);
|
||||
@ -187,9 +187,9 @@ android_media_MtpClient_get_parent(JNIEnv *env, jobject thiz,
|
||||
return -1;
|
||||
}
|
||||
|
||||
static jint
|
||||
static jlong
|
||||
android_media_MtpClient_get_storage_id(JNIEnv *env, jobject thiz,
|
||||
jint device_id, jint object_id)
|
||||
jint device_id, jlong object_id)
|
||||
{
|
||||
#ifdef HAVE_ANDROID_OS
|
||||
MyClient *client = (MyClient *)env->GetIntField(thiz, field_context);
|
||||
@ -203,7 +203,7 @@ android_media_MtpClient_get_storage_id(JNIEnv *env, jobject thiz,
|
||||
|
||||
static jobject
|
||||
android_media_MtpClient_open_file(JNIEnv *env, jobject thiz,
|
||||
jint device_id, jint object_id)
|
||||
jint device_id, jlong object_id)
|
||||
{
|
||||
#ifdef HAVE_ANDROID_OS
|
||||
MyClient *client = (MyClient *)env->GetIntField(thiz, field_context);
|
||||
@ -240,10 +240,10 @@ static JNINativeMethod gMethods[] = {
|
||||
{"native_finalize", "()V", (void *)android_media_MtpClient_finalize},
|
||||
{"native_start", "()Z", (void *)android_media_MtpClient_start},
|
||||
{"native_stop", "()V", (void *)android_media_MtpClient_stop},
|
||||
{"native_delete_object", "(II)Z", (void *)android_media_MtpClient_delete_object},
|
||||
{"native_get_parent", "(II)I", (void *)android_media_MtpClient_get_parent},
|
||||
{"native_get_storage_id", "(II)I", (void *)android_media_MtpClient_get_storage_id},
|
||||
{"native_open_file", "(II)Landroid/os/ParcelFileDescriptor;",
|
||||
{"native_delete_object", "(IJ)Z", (void *)android_media_MtpClient_delete_object},
|
||||
{"native_get_parent", "(IJ)J", (void *)android_media_MtpClient_get_parent},
|
||||
{"native_get_storage_id", "(IJ)J", (void *)android_media_MtpClient_get_storage_id},
|
||||
{"native_open_file", "(IJ)Landroid/os/ParcelFileDescriptor;",
|
||||
(void *)android_media_MtpClient_open_file},
|
||||
};
|
||||
|
||||
|
@ -49,7 +49,7 @@ static bool ExceptionCheck(void* env)
|
||||
|
||||
static void
|
||||
android_media_MtpCursor_setup(JNIEnv *env, jobject thiz, jobject javaClient,
|
||||
jint queryType, jint deviceID, jint storageID, jint objectID, jintArray javaColumns)
|
||||
jint queryType, jint deviceID, jlong storageID, jlong objectID, jintArray javaColumns)
|
||||
{
|
||||
#ifdef HAVE_ANDROID_OS
|
||||
LOGD("android_media_MtpCursor_setup queryType: %d deviceID: %d storageID: %d objectID: %d\n",
|
||||
@ -104,7 +104,7 @@ android_media_MtpCursor_fill_window(JNIEnv *env, jobject thiz, jobject javaWindo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static JNINativeMethod gMethods[] = {
|
||||
{"native_setup", "(Landroid/media/MtpClient;IIII[I)V",
|
||||
{"native_setup", "(Landroid/media/MtpClient;IIJJ[I)V",
|
||||
(void *)android_media_MtpCursor_setup},
|
||||
{"native_finalize", "()V", (void *)android_media_MtpCursor_finalize},
|
||||
{"native_fill_window", "(Landroid/database/CursorWindow;I)I",
|
||||
|
@ -1,6 +1,8 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-subdir-java-files)
|
||||
|
||||
LOCAL_PACKAGE_NAME := CameraBrowser
|
||||
|
@ -44,8 +44,8 @@ public class ObjectBrowser extends ListActivity {
|
||||
private Cursor mCursor;
|
||||
private ObjectCursorAdapter mAdapter;
|
||||
private int mDeviceID;
|
||||
private int mStorageID;
|
||||
private int mObjectID;
|
||||
private long mStorageID;
|
||||
private long mObjectID;
|
||||
|
||||
private static final String[] OBJECT_COLUMNS =
|
||||
new String[] { Mtp.Object._ID, Mtp.Object.NAME, Mtp.Object.FORMAT, Mtp.Object.THUMB };
|
||||
@ -65,8 +65,8 @@ public class ObjectBrowser extends ListActivity {
|
||||
super.onResume();
|
||||
|
||||
mDeviceID = getIntent().getIntExtra("device", 0);
|
||||
mStorageID = getIntent().getIntExtra("storage", 0);
|
||||
mObjectID = getIntent().getIntExtra("object", 0);
|
||||
mStorageID = getIntent().getLongExtra("storage", 0);
|
||||
mObjectID = getIntent().getLongExtra("object", 0);
|
||||
if (mDeviceID != 0 && mStorageID != 0) {
|
||||
Cursor c;
|
||||
Uri uri;
|
||||
@ -88,7 +88,7 @@ public class ObjectBrowser extends ListActivity {
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
int rowID = (int)mAdapter.getItemId(position);
|
||||
long rowID = mAdapter.getItemId(position);
|
||||
Cursor c = getContentResolver().query(
|
||||
Mtp.Object.getContentUri(mDeviceID, rowID),
|
||||
OBJECT_COLUMNS, null, null, null);
|
||||
@ -111,7 +111,7 @@ public class ObjectBrowser extends ListActivity {
|
||||
Intent intent = new Intent(this, ObjectViewer.class);
|
||||
intent.putExtra("device", mDeviceID);
|
||||
intent.putExtra("storage", mStorageID);
|
||||
intent.putExtra("object",rowID);
|
||||
intent.putExtra("object", rowID);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +51,8 @@ public class ObjectViewer extends Activity {
|
||||
private static final String TAG = "ObjectViewer";
|
||||
|
||||
private int mDeviceID;
|
||||
private int mStorageID;
|
||||
private int mObjectID;
|
||||
private long mStorageID;
|
||||
private long mObjectID;
|
||||
|
||||
private static final String[] OBJECT_COLUMNS =
|
||||
new String[] { Mtp.Object._ID,
|
||||
@ -84,8 +84,8 @@ public class ObjectViewer extends Activity {
|
||||
super.onResume();
|
||||
|
||||
mDeviceID = getIntent().getIntExtra("device", 0);
|
||||
mStorageID = getIntent().getIntExtra("storage", 0);
|
||||
mObjectID = getIntent().getIntExtra("object", 0);
|
||||
mStorageID = getIntent().getLongExtra("storage", 0);
|
||||
mObjectID = getIntent().getLongExtra("object", 0);
|
||||
|
||||
if (mDeviceID != 0 && mObjectID != 0) {
|
||||
Cursor c = getContentResolver().query(
|
||||
|
@ -70,7 +70,7 @@ public class StorageBrowser extends ListActivity {
|
||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||
Intent intent = new Intent(this, ObjectBrowser.class);
|
||||
intent.putExtra("device", mDeviceID);
|
||||
intent.putExtra("storage", (int)mAdapter.getItemId(position));
|
||||
intent.putExtra("storage", mAdapter.getItemId(position));
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user