diff options
author | Alex Klyubin <klyubin@google.com> | 2016-12-21 11:19:52 -0800 |
---|---|---|
committer | Alex Klyubin <klyubin@google.com> | 2016-12-21 13:56:28 -0800 |
commit | abdc2b47b3b6736e202663dee93f37e53f4e3ebf (patch) | |
tree | 38aebbc08d7c69086a599c0a7069aab8b5f7ac86 /media/jni/android_mtp_MtpServer.cpp | |
parent | 26e50963641189733f32362b8db39a3a6f1e19fd (diff) |
Make users of MtpServer fill in DeviceInfo field values
This is part of weaning apps off accessing system identifiers via
system properties API. Apps should use android.os.Build API instead.
Bug: 33700679
Test: Enable MTP mode then check that mtp-detect output same as before this commit
Change-Id: I4e6696cdee18b9c3e987c432c095911e85a997db
Diffstat (limited to 'media/jni/android_mtp_MtpServer.cpp')
-rw-r--r-- | media/jni/android_mtp_MtpServer.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/media/jni/android_mtp_MtpServer.cpp b/media/jni/android_mtp_MtpServer.cpp index afd3082ec51b..c325f4ef078b 100644 --- a/media/jni/android_mtp_MtpServer.cpp +++ b/media/jni/android_mtp_MtpServer.cpp @@ -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}, |