Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a8eac54 authored by Alex Klyubin's avatar Alex Klyubin Committed by Android (Google) Code Review
Browse files

Merge "resolve merge conflicts of b53d9841 to master"

parents 3070dbfa f271c6d2
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -32,10 +32,23 @@ public class MtpServer implements Runnable {
        System.loadLibrary("media_jni");
    }

    public MtpServer(MtpDatabase database, boolean usePtp, Runnable onTerminate) {
    public MtpServer(
            MtpDatabase database,
            boolean usePtp,
            Runnable onTerminate,
            String deviceInfoManufacturer,
            String deviceInfoModel,
            String deviceInfoDeviceVersion,
            String deviceInfoSerialNumber) {
        mDatabase = Preconditions.checkNotNull(database);
        mOnTerminate = Preconditions.checkNotNull(onTerminate);
        native_setup(database, usePtp);
        native_setup(
                database,
                usePtp,
                deviceInfoManufacturer,
                deviceInfoModel,
                deviceInfoDeviceVersion,
                deviceInfoSerialNumber);
        database.setServer(this);
    }

@@ -77,7 +90,13 @@ public class MtpServer implements Runnable {
    }

    public static native final void native_configure(boolean usePtp);
    private native final void native_setup(MtpDatabase database, boolean usePtp);
    private native final void native_setup(
            MtpDatabase database,
            boolean usePtp,
            String deviceInfoManufacturer,
            String deviceInfoModel,
            String deviceInfoDeviceVersion,
            String deviceInfoSerialNumber);
    private native final void native_run();
    private native final void native_cleanup();
    private native final void native_send_object_added(int handle);
+27 −3
Original line number Diff line number Diff line
@@ -61,10 +61,34 @@ static void android_mtp_configure(JNIEnv *, jobject, jboolean usePtp) {
}

static void
android_mtp_MtpServer_setup(JNIEnv *env, jobject thiz, jobject javaDatabase, jboolean usePtp)
android_mtp_MtpServer_setup(JNIEnv *env, jobject thiz, jobject javaDatabase, jboolean usePtp,
        jstring deviceInfoManufacturer,
        jstring deviceInfoModel,
        jstring deviceInfoDeviceVersion,
        jstring deviceInfoSerialNumber)
{
    const char *deviceInfoManufacturerStr = env->GetStringUTFChars(deviceInfoManufacturer, NULL);
    const char *deviceInfoModelStr = env->GetStringUTFChars(deviceInfoModel, NULL);
    const char *deviceInfoDeviceVersionStr = env->GetStringUTFChars(deviceInfoDeviceVersion, NULL);
    const char *deviceInfoSerialNumberStr = env->GetStringUTFChars(deviceInfoSerialNumber, NULL);
    MtpServer* server = new MtpServer(getMtpDatabase(env, javaDatabase),
            usePtp, AID_MEDIA_RW, 0664, 0775);
            usePtp, AID_MEDIA_RW, 0664, 0775,
            MtpString((deviceInfoManufacturerStr != NULL) ? deviceInfoManufacturerStr : ""),
            MtpString((deviceInfoModelStr != NULL) ? deviceInfoModelStr : ""),
            MtpString((deviceInfoDeviceVersionStr != NULL) ? deviceInfoDeviceVersionStr : ""),
            MtpString((deviceInfoSerialNumberStr != NULL) ? deviceInfoSerialNumberStr : ""));
    if (deviceInfoManufacturerStr != NULL) {
        env->ReleaseStringUTFChars(deviceInfoManufacturer, deviceInfoManufacturerStr);
    }
    if (deviceInfoModelStr != NULL) {
        env->ReleaseStringUTFChars(deviceInfoModel, deviceInfoModelStr);
    }
    if (deviceInfoDeviceVersionStr != NULL) {
        env->ReleaseStringUTFChars(deviceInfoDeviceVersion, deviceInfoDeviceVersionStr);
    }
    if (deviceInfoSerialNumberStr != NULL) {
        env->ReleaseStringUTFChars(deviceInfoSerialNumber, deviceInfoSerialNumberStr);
    }
    env->SetLongField(thiz, field_MtpServer_nativeContext, (jlong)server);
}

@@ -180,7 +204,7 @@ android_mtp_MtpServer_remove_storage(JNIEnv *env, jobject thiz, jint storageId)

static const JNINativeMethod gMethods[] = {
    {"native_configure",              "(Z)V",  (void *)android_mtp_configure},
    {"native_setup",                "(Landroid/mtp/MtpDatabase;Z)V",
    {"native_setup",                "(Landroid/mtp/MtpDatabase;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
                                            (void *)android_mtp_MtpServer_setup},
    {"native_run",                  "()V",  (void *)android_mtp_MtpServer_run},
    {"native_cleanup",              "()V",  (void *)android_mtp_MtpServer_cleanup},