Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "MtpServerJNI" |
| 18 | #include "utils/Log.h" |
| 19 | |
| 20 | #include <stdio.h> |
| 21 | #include <assert.h> |
| 22 | #include <limits.h> |
| 23 | #include <unistd.h> |
| 24 | #include <fcntl.h> |
| 25 | #include <utils/threads.h> |
| 26 | |
| 27 | #include "jni.h" |
Steven Moreland | 2279b25 | 2017-07-19 09:50:45 -0700 | [diff] [blame] | 28 | #include <nativehelper/JNIHelp.h> |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 29 | #include "android_runtime/AndroidRuntime.h" |
Mike Lockwood | dad6927 | 2010-07-02 15:15:07 -0400 | [diff] [blame] | 30 | #include "private/android_filesystem_config.h" |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 31 | |
| 32 | #include "MtpServer.h" |
Mike Lockwood | 467ca0d | 2011-02-18 09:07:14 -0500 | [diff] [blame] | 33 | #include "MtpStorage.h" |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 34 | |
Mike Lockwood | 81ea83d | 2010-06-30 17:49:41 -0400 | [diff] [blame] | 35 | using namespace android; |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 36 | |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 37 | // MtpServer fields |
| 38 | static jfieldID field_MtpServer_nativeContext; |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 39 | |
| 40 | // MtpStorage fields |
| 41 | static jfieldID field_MtpStorage_storageId; |
| 42 | static jfieldID field_MtpStorage_path; |
| 43 | static jfieldID field_MtpStorage_description; |
Mike Lockwood | 5169054 | 2011-05-09 20:16:05 -0700 | [diff] [blame] | 44 | static jfieldID field_MtpStorage_removable; |
Mike Lockwood | 7a59dd2 | 2011-07-11 09:18:03 -0400 | [diff] [blame] | 45 | static jfieldID field_MtpStorage_maxFileSize; |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 46 | |
| 47 | static Mutex sMutex; |
| 48 | |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 49 | // ---------------------------------------------------------------------------- |
| 50 | |
Mike Lockwood | 0cd0136 | 2010-12-30 11:54:33 -0500 | [diff] [blame] | 51 | // in android_mtp_MtpDatabase.cpp |
Jerry Zhang | f9c5c25 | 2017-08-16 18:07:51 -0700 | [diff] [blame] | 52 | extern IMtpDatabase* getMtpDatabase(JNIEnv *env, jobject database); |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 53 | |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 54 | static inline MtpServer* getMtpServer(JNIEnv *env, jobject thiz) { |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 55 | return (MtpServer*)env->GetLongField(thiz, field_MtpServer_nativeContext); |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 56 | } |
| 57 | |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 58 | static void |
Jerry Zhang | 6d319b8 | 2017-12-06 16:03:57 -0800 | [diff] [blame] | 59 | android_mtp_MtpServer_setup(JNIEnv *env, jobject thiz, jobject javaDatabase, jobject jControlFd, |
| 60 | jboolean usePtp, jstring deviceInfoManufacturer, jstring deviceInfoModel, |
| 61 | jstring deviceInfoDeviceVersion, jstring deviceInfoSerialNumber) |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 62 | { |
Alex Klyubin | abdc2b4 | 2016-12-21 11:19:52 -0800 | [diff] [blame] | 63 | const char *deviceInfoManufacturerStr = env->GetStringUTFChars(deviceInfoManufacturer, NULL); |
| 64 | const char *deviceInfoModelStr = env->GetStringUTFChars(deviceInfoModel, NULL); |
| 65 | const char *deviceInfoDeviceVersionStr = env->GetStringUTFChars(deviceInfoDeviceVersion, NULL); |
| 66 | const char *deviceInfoSerialNumberStr = env->GetStringUTFChars(deviceInfoSerialNumber, NULL); |
Jerry Zhang | 6d319b8 | 2017-12-06 16:03:57 -0800 | [diff] [blame] | 67 | int controlFd = dup(jniGetFDFromFileDescriptor(env, jControlFd)); |
| 68 | MtpServer* server = new MtpServer(getMtpDatabase(env, javaDatabase), controlFd, |
Jerry Zhang | def7b193 | 2017-10-17 13:47:51 -0700 | [diff] [blame] | 69 | usePtp, |
Jerry Zhang | d9f3005 | 2018-03-27 15:29:09 -0700 | [diff] [blame] | 70 | (deviceInfoManufacturerStr != NULL) ? deviceInfoManufacturerStr : "", |
| 71 | (deviceInfoModelStr != NULL) ? deviceInfoModelStr : "", |
| 72 | (deviceInfoDeviceVersionStr != NULL) ? deviceInfoDeviceVersionStr : "", |
| 73 | (deviceInfoSerialNumberStr != NULL) ? deviceInfoSerialNumberStr : ""); |
Alex Klyubin | abdc2b4 | 2016-12-21 11:19:52 -0800 | [diff] [blame] | 74 | if (deviceInfoManufacturerStr != NULL) { |
| 75 | env->ReleaseStringUTFChars(deviceInfoManufacturer, deviceInfoManufacturerStr); |
| 76 | } |
| 77 | if (deviceInfoModelStr != NULL) { |
| 78 | env->ReleaseStringUTFChars(deviceInfoModel, deviceInfoModelStr); |
| 79 | } |
| 80 | if (deviceInfoDeviceVersionStr != NULL) { |
| 81 | env->ReleaseStringUTFChars(deviceInfoDeviceVersion, deviceInfoDeviceVersionStr); |
| 82 | } |
| 83 | if (deviceInfoSerialNumberStr != NULL) { |
| 84 | env->ReleaseStringUTFChars(deviceInfoSerialNumber, deviceInfoSerialNumberStr); |
| 85 | } |
Jerry Zhang | bb598ee | 2016-10-24 14:35:08 -0700 | [diff] [blame] | 86 | env->SetLongField(thiz, field_MtpServer_nativeContext, (jlong)server); |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | static void |
| 90 | android_mtp_MtpServer_run(JNIEnv *env, jobject thiz) |
| 91 | { |
| 92 | MtpServer* server = getMtpServer(env, thiz); |
| 93 | if (server) |
| 94 | server->run(); |
| 95 | else |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 96 | ALOGE("server is null in run"); |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | static void |
| 100 | android_mtp_MtpServer_cleanup(JNIEnv *env, jobject thiz) |
| 101 | { |
| 102 | Mutex::Autolock autoLock(sMutex); |
| 103 | |
| 104 | MtpServer* server = getMtpServer(env, thiz); |
| 105 | if (server) { |
| 106 | delete server; |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 107 | env->SetLongField(thiz, field_MtpServer_nativeContext, 0); |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 108 | } else { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 109 | ALOGE("server is null in cleanup"); |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 110 | } |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 111 | } |
| 112 | |
Mike Lockwood | be125a5 | 2010-07-12 18:54:16 -0400 | [diff] [blame] | 113 | static void |
Mike Lockwood | 0cd0136 | 2010-12-30 11:54:33 -0500 | [diff] [blame] | 114 | android_mtp_MtpServer_send_object_added(JNIEnv *env, jobject thiz, jint handle) |
Mike Lockwood | be125a5 | 2010-07-12 18:54:16 -0400 | [diff] [blame] | 115 | { |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 116 | Mutex::Autolock autoLock(sMutex); |
| 117 | |
| 118 | MtpServer* server = getMtpServer(env, thiz); |
| 119 | if (server) |
| 120 | server->sendObjectAdded(handle); |
| 121 | else |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 122 | ALOGE("server is null in send_object_added"); |
Mike Lockwood | be125a5 | 2010-07-12 18:54:16 -0400 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | static void |
Mike Lockwood | 0cd0136 | 2010-12-30 11:54:33 -0500 | [diff] [blame] | 126 | android_mtp_MtpServer_send_object_removed(JNIEnv *env, jobject thiz, jint handle) |
Mike Lockwood | be125a5 | 2010-07-12 18:54:16 -0400 | [diff] [blame] | 127 | { |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 128 | Mutex::Autolock autoLock(sMutex); |
| 129 | |
| 130 | MtpServer* server = getMtpServer(env, thiz); |
| 131 | if (server) |
| 132 | server->sendObjectRemoved(handle); |
| 133 | else |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 134 | ALOGE("server is null in send_object_removed"); |
Mike Lockwood | be125a5 | 2010-07-12 18:54:16 -0400 | [diff] [blame] | 135 | } |
| 136 | |
Mike Lockwood | eabe8bf | 2010-08-31 14:35:23 -0400 | [diff] [blame] | 137 | static void |
James | e4f680e | 2018-07-02 17:42:07 +0800 | [diff] [blame] | 138 | android_mtp_MtpServer_send_object_info_changed(JNIEnv *env, jobject thiz, jint handle) |
| 139 | { |
| 140 | Mutex::Autolock autoLock(sMutex); |
| 141 | |
| 142 | MtpServer* server = getMtpServer(env, thiz); |
| 143 | if (server) |
| 144 | server->sendObjectInfoChanged(handle); |
| 145 | else |
| 146 | ALOGE("server is null in send_object_info_changed"); |
| 147 | } |
| 148 | |
| 149 | static void |
Mike Lockwood | 56c8524 | 2014-03-07 13:29:08 -0800 | [diff] [blame] | 150 | android_mtp_MtpServer_send_device_property_changed(JNIEnv *env, jobject thiz, jint property) |
| 151 | { |
| 152 | Mutex::Autolock autoLock(sMutex); |
| 153 | |
| 154 | MtpServer* server = getMtpServer(env, thiz); |
| 155 | if (server) |
| 156 | server->sendDevicePropertyChanged(property); |
| 157 | else |
| 158 | ALOGE("server is null in send_object_removed"); |
| 159 | } |
| 160 | |
| 161 | static void |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 162 | android_mtp_MtpServer_add_storage(JNIEnv *env, jobject thiz, jobject jstorage) |
Mike Lockwood | 66e57f6 | 2011-02-18 13:24:01 -0500 | [diff] [blame] | 163 | { |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 164 | Mutex::Autolock autoLock(sMutex); |
| 165 | |
| 166 | MtpServer* server = getMtpServer(env, thiz); |
| 167 | if (server) { |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 168 | jint storageID = env->GetIntField(jstorage, field_MtpStorage_storageId); |
| 169 | jstring path = (jstring)env->GetObjectField(jstorage, field_MtpStorage_path); |
| 170 | jstring description = (jstring)env->GetObjectField(jstorage, field_MtpStorage_description); |
Mike Lockwood | 5169054 | 2011-05-09 20:16:05 -0700 | [diff] [blame] | 171 | jboolean removable = env->GetBooleanField(jstorage, field_MtpStorage_removable); |
Mike Lockwood | 7a59dd2 | 2011-07-11 09:18:03 -0400 | [diff] [blame] | 172 | jlong maxFileSize = env->GetLongField(jstorage, field_MtpStorage_maxFileSize); |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 173 | |
| 174 | const char *pathStr = env->GetStringUTFChars(path, NULL); |
James Dong | 3977472 | 2011-04-06 11:57:48 -0700 | [diff] [blame] | 175 | if (pathStr != NULL) { |
| 176 | const char *descriptionStr = env->GetStringUTFChars(description, NULL); |
| 177 | if (descriptionStr != NULL) { |
Mike Lockwood | 7a59dd2 | 2011-07-11 09:18:03 -0400 | [diff] [blame] | 178 | MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, |
Jerry Zhang | f9c5c25 | 2017-08-16 18:07:51 -0700 | [diff] [blame] | 179 | removable, maxFileSize); |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 180 | server->addStorage(storage); |
James Dong | 3977472 | 2011-04-06 11:57:48 -0700 | [diff] [blame] | 181 | env->ReleaseStringUTFChars(path, pathStr); |
| 182 | env->ReleaseStringUTFChars(description, descriptionStr); |
| 183 | } else { |
| 184 | env->ReleaseStringUTFChars(path, pathStr); |
| 185 | } |
| 186 | } |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 187 | } else { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 188 | ALOGE("server is null in add_storage"); |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 189 | } |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | static void |
| 193 | android_mtp_MtpServer_remove_storage(JNIEnv *env, jobject thiz, jint storageId) |
| 194 | { |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 195 | Mutex::Autolock autoLock(sMutex); |
| 196 | |
| 197 | MtpServer* server = getMtpServer(env, thiz); |
| 198 | if (server) { |
| 199 | MtpStorage* storage = server->getStorage(storageId); |
| 200 | if (storage) { |
| 201 | server->removeStorage(storage); |
| 202 | delete storage; |
| 203 | } |
| 204 | } else |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 205 | ALOGE("server is null in remove_storage"); |
Mike Lockwood | 66e57f6 | 2011-02-18 13:24:01 -0500 | [diff] [blame] | 206 | } |
| 207 | |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 208 | // ---------------------------------------------------------------------------- |
| 209 | |
Daniel Micay | 76f6a86 | 2015-09-19 17:31:01 -0400 | [diff] [blame] | 210 | static const JNINativeMethod gMethods[] = { |
Jerry Zhang | 6d319b8 | 2017-12-06 16:03:57 -0800 | [diff] [blame] | 211 | {"native_setup", "(Landroid/mtp/MtpDatabase;Ljava/io/FileDescriptor;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", |
Mike Lockwood | 0cd0136 | 2010-12-30 11:54:33 -0500 | [diff] [blame] | 212 | (void *)android_mtp_MtpServer_setup}, |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 213 | {"native_run", "()V", (void *)android_mtp_MtpServer_run}, |
| 214 | {"native_cleanup", "()V", (void *)android_mtp_MtpServer_cleanup}, |
Mike Lockwood | 0cd0136 | 2010-12-30 11:54:33 -0500 | [diff] [blame] | 215 | {"native_send_object_added", "(I)V", (void *)android_mtp_MtpServer_send_object_added}, |
| 216 | {"native_send_object_removed", "(I)V", (void *)android_mtp_MtpServer_send_object_removed}, |
James | e4f680e | 2018-07-02 17:42:07 +0800 | [diff] [blame] | 217 | {"native_send_object_info_changed", "(I)V", (void *)android_mtp_MtpServer_send_object_info_changed}, |
Mike Lockwood | 56c8524 | 2014-03-07 13:29:08 -0800 | [diff] [blame] | 218 | {"native_send_device_property_changed", "(I)V", |
| 219 | (void *)android_mtp_MtpServer_send_device_property_changed}, |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 220 | {"native_add_storage", "(Landroid/mtp/MtpStorage;)V", |
| 221 | (void *)android_mtp_MtpServer_add_storage}, |
| 222 | {"native_remove_storage", "(I)V", (void *)android_mtp_MtpServer_remove_storage}, |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 223 | }; |
| 224 | |
Mike Lockwood | 0cd0136 | 2010-12-30 11:54:33 -0500 | [diff] [blame] | 225 | int register_android_mtp_MtpServer(JNIEnv *env) |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 226 | { |
| 227 | jclass clazz; |
| 228 | |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 229 | clazz = env->FindClass("android/mtp/MtpStorage"); |
| 230 | if (clazz == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 231 | ALOGE("Can't find android/mtp/MtpStorage"); |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 232 | return -1; |
| 233 | } |
| 234 | field_MtpStorage_storageId = env->GetFieldID(clazz, "mStorageId", "I"); |
| 235 | if (field_MtpStorage_storageId == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 236 | ALOGE("Can't find MtpStorage.mStorageId"); |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 237 | return -1; |
| 238 | } |
| 239 | field_MtpStorage_path = env->GetFieldID(clazz, "mPath", "Ljava/lang/String;"); |
| 240 | if (field_MtpStorage_path == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 241 | ALOGE("Can't find MtpStorage.mPath"); |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 242 | return -1; |
| 243 | } |
| 244 | field_MtpStorage_description = env->GetFieldID(clazz, "mDescription", "Ljava/lang/String;"); |
| 245 | if (field_MtpStorage_description == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 246 | ALOGE("Can't find MtpStorage.mDescription"); |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 247 | return -1; |
| 248 | } |
Mike Lockwood | 5169054 | 2011-05-09 20:16:05 -0700 | [diff] [blame] | 249 | field_MtpStorage_removable = env->GetFieldID(clazz, "mRemovable", "Z"); |
| 250 | if (field_MtpStorage_removable == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 251 | ALOGE("Can't find MtpStorage.mRemovable"); |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 252 | return -1; |
| 253 | } |
Mike Lockwood | 7a59dd2 | 2011-07-11 09:18:03 -0400 | [diff] [blame] | 254 | field_MtpStorage_maxFileSize = env->GetFieldID(clazz, "mMaxFileSize", "J"); |
| 255 | if (field_MtpStorage_maxFileSize == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 256 | ALOGE("Can't find MtpStorage.mMaxFileSize"); |
Mike Lockwood | 7a59dd2 | 2011-07-11 09:18:03 -0400 | [diff] [blame] | 257 | return -1; |
| 258 | } |
Mike Lockwood | b239b683 | 2011-04-05 10:21:27 -0400 | [diff] [blame] | 259 | |
Mike Lockwood | 0cd0136 | 2010-12-30 11:54:33 -0500 | [diff] [blame] | 260 | clazz = env->FindClass("android/mtp/MtpServer"); |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 261 | if (clazz == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 262 | ALOGE("Can't find android/mtp/MtpServer"); |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 263 | return -1; |
| 264 | } |
Ashok Bhat | e2e5932 | 2013-12-17 19:04:19 +0000 | [diff] [blame] | 265 | field_MtpServer_nativeContext = env->GetFieldID(clazz, "mNativeContext", "J"); |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 266 | if (field_MtpServer_nativeContext == NULL) { |
Steve Block | 3762c31 | 2012-01-06 19:20:56 +0000 | [diff] [blame] | 267 | ALOGE("Can't find MtpServer.mNativeContext"); |
Mike Lockwood | dcc3194 | 2011-07-11 15:04:38 -0400 | [diff] [blame] | 268 | return -1; |
| 269 | } |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 270 | |
| 271 | return AndroidRuntime::registerNativeMethods(env, |
Mike Lockwood | 0cd0136 | 2010-12-30 11:54:33 -0500 | [diff] [blame] | 272 | "android/mtp/MtpServer", gMethods, NELEM(gMethods)); |
Mike Lockwood | 98ef64e | 2010-06-29 16:42:13 -0400 | [diff] [blame] | 273 | } |