Commits

Stephen Smalley  committed cb60e35 Merge

Merge branch 'master' into seandroid

  • Participants
  • Parent commits 3affb35, 5cb0f21
  • Branches seandroid

Comments (0)

Files changed (9)

File core/jni/android_emoji_EmojiFactory.cpp

 
 #define LOG_TAG "EmojiFactory_jni"
 #include <utils/Log.h>
-#include <utils/String8.h>
-#include <utils/String16.h>
+#include <ScopedUtfChars.h>
 
 #include "EmojiFactory.h"
 #include <nativehelper/JNIHelp.h>
     return NULL;
   }
 
-  const jchar* jchars = env->GetStringChars(name, NULL);
-  jsize len = env->GetStringLength(name);
-  String8 str(String16(jchars, len));
+  ScopedUtfChars nameUtf(env, name);
 
-  EmojiFactory *factory = gCaller->TryCallGetImplementation(str.string());
+  EmojiFactory *factory = gCaller->TryCallGetImplementation(nameUtf.c_str());
   // EmojiFactory *factory = EmojiFactory::GetImplementation(str.string());
   if (NULL == factory) {
     return NULL;
   }
-  env->ReleaseStringChars(name, jchars);
 
   return create_java_EmojiFactory(env, factory, name);
 }
   if (NULL == factory) {
     return NULL;
   }
-  String16 name_16(String8(factory->Name()));
-  jstring jname = env->NewString(name_16.string(), name_16.size());
+
+  jstring jname = env->NewStringUTF(factory->Name());
   if (NULL == jname) {
     return NULL;
   }

File core/jni/android_media_ToneGenerator.cpp

     if (!lpToneGen->isInited()) {
         ALOGE("ToneGenerator init failed");
         jniThrowRuntimeException(env, "Init failed");
+        delete lpToneGen;
         return;
     }
 

File core/jni/android_util_StringBlock.cpp

 
     if (osb == NULL || osb->getError() != NO_ERROR) {
         jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+        delete osb;
         return 0;
     }
 

File media/java/android/media/MediaScanner.java

             mMimeType = mimeType;
             mFileType = 0;
             mFileSize = fileSize;
+            mIsDrm = false;
 
             if (!isDirectory) {
                 if (!noMedia && isNoMediaFile(path)) {
             mLastModified = lastModified;
             mWriter = null;
             mCompilation = 0;
-            mIsDrm = false;
             mWidth = 0;
             mHeight = 0;
 
             }
 
             if (mDrmManagerClient.canHandle(path, null)) {
+                mIsDrm = true;
                 String drmMimetype = mDrmManagerClient.getOriginalMimeType(path);
                 if (drmMimetype != null) {
                     mMimeType = drmMimetype;

File media/jni/audioeffect/android_media_AudioEffect.cpp

 {
     effect_descriptor_t desc;
     char str[EFFECT_STRING_LEN_MAX];
-    uint32_t numEffects;
+    uint32_t numEffects = 0;
     uint32_t i = 0;
     jstring jdescType;
     jstring jdescUuid;
     jstring jdescImplementor;
     jobject jdesc;
 
-    AudioEffect::queryNumberEffects(&numEffects);
+    if (AudioEffect::queryNumberEffects(&numEffects) != NO_ERROR) {
+        return NULL;
+    }
+
     jobjectArray ret = env->NewObjectArray(numEffects, fields.clazzDesc, NULL);
     if (ret == NULL) {
         return ret;

File media/mca/filterfw/jni/jni_gl_frame.cpp

   if (frame && bitmap) {
     uint8_t* pixels;
     const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&pixels));
-    if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
+    if (result == ANDROID_BITMAP_RESULT_SUCCESS) {
       const bool success = frame->WriteData(pixels, size);
       return ToJBool(success &&
-                     AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
+                     AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESULT_SUCCESS);
     }
   }
   return JNI_FALSE;
   if (frame && bitmap) {
     uint8_t* pixels;
     const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&pixels));
-    if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
+    if (result == ANDROID_BITMAP_RESULT_SUCCESS) {
       frame->CopyDataTo(pixels, frame->Size());
-      return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
+      return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESULT_SUCCESS);
     }
   }
   return JNI_FALSE;

File media/mca/filterfw/jni/jni_native_frame.cpp

 
     Pixel* src_ptr;
     const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&src_ptr));
-    if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
+    if (result == ANDROID_BITMAP_RESULT_SUCCESS) {
       // Create destination pointers
       uint8_t* dst_ptr = reinterpret_cast<uint8_t*>(frame->MutableData());
       const uint8_t* end_ptr = dst_ptr + frame->Size();
           ALOGE("Unsupported bytes-per-pixel %d in setBitmap!", bytes_per_sample);
           break;
       }
-      return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
+      return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESULT_SUCCESS);
     }
   }
   return JNI_FALSE;
   if (frame && bitmap) {
     Pixel* dst_ptr;
     const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&dst_ptr));
-    if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
+    if (result == ANDROID_BITMAP_RESULT_SUCCESS) {
       // Make sure frame size matches bitmap size
       if ((size / 4) != (frame->Size() / bytes_per_sample)) {
         ALOGE("Size mismatch in native getBitmap()!");
           ALOGE("Unsupported bytes-per-pixel %d in getBitmap!", bytes_per_sample);
           break;
       }
-      return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
+      return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESULT_SUCCESS);
     }
   }
   return JNI_FALSE;

File native/graphics/jni/bitmap.cpp

                 break;
         }
     }
-    return ANDROID_BITMAP_RESUT_SUCCESS;
+    return ANDROID_BITMAP_RESULT_SUCCESS;
 }
 
 int AndroidBitmap_lockPixels(JNIEnv* env, jobject jbitmap, void** addrPtr) {
     if (addrPtr) {
         *addrPtr = addr;
     }
-    return ANDROID_BITMAP_RESUT_SUCCESS;
+    return ANDROID_BITMAP_RESULT_SUCCESS;
 }
 
 int AndroidBitmap_unlockPixels(JNIEnv* env, jobject jbitmap) {
     bm->notifyPixelsChanged();
 
     bm->unlockPixels();
-    return ANDROID_BITMAP_RESUT_SUCCESS;
+    return ANDROID_BITMAP_RESULT_SUCCESS;
 }
 

File services/java/com/android/server/NsdService.java

                         break;
                     case NsdManager.NATIVE_DAEMON_EVENT:
                         NativeEvent event = (NativeEvent) msg.obj;
-                        handleNativeEvent(event.code, event.raw,
-                                NativeDaemonEvent.unescapeArgs(event.raw));
+                        if (!handleNativeEvent(event.code, event.raw,
+                                NativeDaemonEvent.unescapeArgs(event.raw))) {
+                            result = NOT_HANDLED;
+                        }
                         break;
                     default:
                         result = NOT_HANDLED;
                 }
                 return result;
             }
+
+            private boolean handleNativeEvent(int code, String raw, String[] cooked) {
+                boolean handled = true;
+                NsdServiceInfo servInfo;
+                int id = Integer.parseInt(cooked[1]);
+                ClientInfo clientInfo = mIdToClientInfoMap.get(id);
+                if (clientInfo == null) {
+                    Slog.e(TAG, "Unique id with no client mapping: " + id);
+                    handled = false;
+                    return handled;
+                }
+
+                /* This goes in response as msg.arg2 */
+                int clientId = -1;
+                int keyId = clientInfo.mClientIds.indexOfValue(id);
+                if (keyId != -1) {
+                    clientId = clientInfo.mClientIds.keyAt(keyId);
+                }
+                switch (code) {
+                    case NativeResponseCode.SERVICE_FOUND:
+                        /* NNN uniqueId serviceName regType domain */
+                        if (DBG) Slog.d(TAG, "SERVICE_FOUND Raw: " + raw);
+                        servInfo = new NsdServiceInfo(cooked[2], cooked[3], null);
+                        clientInfo.mChannel.sendMessage(NsdManager.SERVICE_FOUND, 0,
+                                clientId, servInfo);
+                        break;
+                    case NativeResponseCode.SERVICE_LOST:
+                        /* NNN uniqueId serviceName regType domain */
+                        if (DBG) Slog.d(TAG, "SERVICE_LOST Raw: " + raw);
+                        servInfo = new NsdServiceInfo(cooked[2], cooked[3], null);
+                        clientInfo.mChannel.sendMessage(NsdManager.SERVICE_LOST, 0,
+                                clientId, servInfo);
+                        break;
+                    case NativeResponseCode.SERVICE_DISCOVERY_FAILED:
+                        /* NNN uniqueId errorCode */
+                        if (DBG) Slog.d(TAG, "SERVICE_DISC_FAILED Raw: " + raw);
+                        clientInfo.mChannel.sendMessage(NsdManager.DISCOVER_SERVICES_FAILED,
+                                NsdManager.FAILURE_INTERNAL_ERROR, clientId);
+                        break;
+                    case NativeResponseCode.SERVICE_REGISTERED:
+                        /* NNN regId serviceName regType */
+                        if (DBG) Slog.d(TAG, "SERVICE_REGISTERED Raw: " + raw);
+                        servInfo = new NsdServiceInfo(cooked[2], null, null);
+                        clientInfo.mChannel.sendMessage(NsdManager.REGISTER_SERVICE_SUCCEEDED,
+                                id, clientId, servInfo);
+                        break;
+                    case NativeResponseCode.SERVICE_REGISTRATION_FAILED:
+                        /* NNN regId errorCode */
+                        if (DBG) Slog.d(TAG, "SERVICE_REGISTER_FAILED Raw: " + raw);
+                        clientInfo.mChannel.sendMessage(NsdManager.REGISTER_SERVICE_FAILED,
+                               NsdManager.FAILURE_INTERNAL_ERROR, clientId);
+                        break;
+                    case NativeResponseCode.SERVICE_UPDATED:
+                        /* NNN regId */
+                        break;
+                    case NativeResponseCode.SERVICE_UPDATE_FAILED:
+                        /* NNN regId errorCode */
+                        break;
+                    case NativeResponseCode.SERVICE_RESOLVED:
+                        /* NNN resolveId fullName hostName port txtlen txtdata */
+                        if (DBG) Slog.d(TAG, "SERVICE_RESOLVED Raw: " + raw);
+                        int index = cooked[2].indexOf(".");
+                        if (index == -1) {
+                            Slog.e(TAG, "Invalid service found " + raw);
+                            break;
+                        }
+                        String name = cooked[2].substring(0, index);
+                        String rest = cooked[2].substring(index);
+                        String type = rest.replace(".local.", "");
+
+                        clientInfo.mResolvedService.setServiceName(name);
+                        clientInfo.mResolvedService.setServiceType(type);
+                        clientInfo.mResolvedService.setPort(Integer.parseInt(cooked[4]));
+
+                        stopResolveService(id);
+                        if (!getAddrInfo(id, cooked[3])) {
+                            clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
+                                    NsdManager.FAILURE_INTERNAL_ERROR, clientId);
+                            removeRequestMap(clientId, id, clientInfo);
+                            clientInfo.mResolvedService = null;
+                        }
+                        break;
+                    case NativeResponseCode.SERVICE_RESOLUTION_FAILED:
+                        /* NNN resolveId errorCode */
+                        if (DBG) Slog.d(TAG, "SERVICE_RESOLVE_FAILED Raw: " + raw);
+                        stopResolveService(id);
+                        removeRequestMap(clientId, id, clientInfo);
+                        clientInfo.mResolvedService = null;
+                        clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
+                                NsdManager.FAILURE_INTERNAL_ERROR, clientId);
+                        break;
+                    case NativeResponseCode.SERVICE_GET_ADDR_FAILED:
+                        /* NNN resolveId errorCode */
+                        stopGetAddrInfo(id);
+                        removeRequestMap(clientId, id, clientInfo);
+                        clientInfo.mResolvedService = null;
+                        if (DBG) Slog.d(TAG, "SERVICE_RESOLVE_FAILED Raw: " + raw);
+                        clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
+                                NsdManager.FAILURE_INTERNAL_ERROR, clientId);
+                        break;
+                    case NativeResponseCode.SERVICE_GET_ADDR_SUCCESS:
+                        /* NNN resolveId hostname ttl addr */
+                        if (DBG) Slog.d(TAG, "SERVICE_GET_ADDR_SUCCESS Raw: " + raw);
+                        try {
+                            clientInfo.mResolvedService.setHost(InetAddress.getByName(cooked[4]));
+                            clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_SUCCEEDED,
+                                   0, clientId, clientInfo.mResolvedService);
+                        } catch (java.net.UnknownHostException e) {
+                            clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
+                                    NsdManager.FAILURE_INTERNAL_ERROR, clientId);
+                        }
+                        stopGetAddrInfo(id);
+                        removeRequestMap(clientId, id, clientInfo);
+                        clientInfo.mResolvedService = null;
+                        break;
+                    default:
+                        handled = false;
+                        break;
+                }
+                return handled;
+            }
        }
     }
 
     }
 
     private class NativeEvent {
-        int code;
-        String raw;
+        final int code;
+        final String raw;
 
         NativeEvent(int code, String raw) {
             this.code = code;
         }
     }
 
-    private void handleNativeEvent(int code, String raw, String[] cooked) {
-        NsdServiceInfo servInfo;
-        int id = Integer.parseInt(cooked[1]);
-        ClientInfo clientInfo = mIdToClientInfoMap.get(id);
-        if (clientInfo == null) {
-            Slog.e(TAG, "Unique id with no client mapping: " + id);
-            return;
-        }
-
-        /* This goes in response as msg.arg2 */
-        int clientId = -1;
-        int keyId = clientInfo.mClientIds.indexOfValue(id);
-        if (keyId != -1) {
-            clientId = clientInfo.mClientIds.keyAt(keyId);
-        }
-        switch (code) {
-            case NativeResponseCode.SERVICE_FOUND:
-                /* NNN uniqueId serviceName regType domain */
-                if (DBG) Slog.d(TAG, "SERVICE_FOUND Raw: " + raw);
-                servInfo = new NsdServiceInfo(cooked[2], cooked[3], null);
-                clientInfo.mChannel.sendMessage(NsdManager.SERVICE_FOUND, 0,
-                        clientId, servInfo);
-                break;
-            case NativeResponseCode.SERVICE_LOST:
-                /* NNN uniqueId serviceName regType domain */
-                if (DBG) Slog.d(TAG, "SERVICE_LOST Raw: " + raw);
-                servInfo = new NsdServiceInfo(cooked[2], cooked[3], null);
-                clientInfo.mChannel.sendMessage(NsdManager.SERVICE_LOST, 0,
-                        clientId, servInfo);
-                break;
-            case NativeResponseCode.SERVICE_DISCOVERY_FAILED:
-                /* NNN uniqueId errorCode */
-                if (DBG) Slog.d(TAG, "SERVICE_DISC_FAILED Raw: " + raw);
-                clientInfo.mChannel.sendMessage(NsdManager.DISCOVER_SERVICES_FAILED,
-                        NsdManager.FAILURE_INTERNAL_ERROR, clientId);
-                break;
-            case NativeResponseCode.SERVICE_REGISTERED:
-                /* NNN regId serviceName regType */
-                if (DBG) Slog.d(TAG, "SERVICE_REGISTERED Raw: " + raw);
-                servInfo = new NsdServiceInfo(cooked[2], null, null);
-                clientInfo.mChannel.sendMessage(NsdManager.REGISTER_SERVICE_SUCCEEDED,
-                        id, clientId, servInfo);
-                break;
-            case NativeResponseCode.SERVICE_REGISTRATION_FAILED:
-                /* NNN regId errorCode */
-                if (DBG) Slog.d(TAG, "SERVICE_REGISTER_FAILED Raw: " + raw);
-                clientInfo.mChannel.sendMessage(NsdManager.REGISTER_SERVICE_FAILED,
-                        NsdManager.FAILURE_INTERNAL_ERROR, clientId);
-                break;
-            case NativeResponseCode.SERVICE_UPDATED:
-                /* NNN regId */
-                break;
-            case NativeResponseCode.SERVICE_UPDATE_FAILED:
-                /* NNN regId errorCode */
-                break;
-            case NativeResponseCode.SERVICE_RESOLVED:
-                /* NNN resolveId fullName hostName port txtlen txtdata */
-                if (DBG) Slog.d(TAG, "SERVICE_RESOLVED Raw: " + raw);
-                int index = cooked[2].indexOf(".");
-                if (index == -1) {
-                    Slog.e(TAG, "Invalid service found " + raw);
-                    break;
-                }
-                String name = cooked[2].substring(0, index);
-                String rest = cooked[2].substring(index);
-                String type = rest.replace(".local.", "");
-
-                clientInfo.mResolvedService.setServiceName(name);
-                clientInfo.mResolvedService.setServiceType(type);
-                clientInfo.mResolvedService.setPort(Integer.parseInt(cooked[4]));
-
-                stopResolveService(id);
-                if (!getAddrInfo(id, cooked[3])) {
-                    clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
-                            NsdManager.FAILURE_INTERNAL_ERROR, clientId);
-                    mIdToClientInfoMap.remove(id);
-                    clientInfo.mResolvedService = null;
-                }
-                break;
-            case NativeResponseCode.SERVICE_RESOLUTION_FAILED:
-                /* NNN resolveId errorCode */
-                if (DBG) Slog.d(TAG, "SERVICE_RESOLVE_FAILED Raw: " + raw);
-                stopResolveService(id);
-                mIdToClientInfoMap.remove(id);
-                clientInfo.mResolvedService = null;
-                clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
-                        NsdManager.FAILURE_INTERNAL_ERROR, clientId);
-                break;
-            case NativeResponseCode.SERVICE_GET_ADDR_FAILED:
-                /* NNN resolveId errorCode */
-                stopGetAddrInfo(id);
-                mIdToClientInfoMap.remove(id);
-                clientInfo.mResolvedService = null;
-                if (DBG) Slog.d(TAG, "SERVICE_RESOLVE_FAILED Raw: " + raw);
-                clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
-                        NsdManager.FAILURE_INTERNAL_ERROR, clientId);
-                break;
-            case NativeResponseCode.SERVICE_GET_ADDR_SUCCESS:
-                /* NNN resolveId hostname ttl addr */
-                if (DBG) Slog.d(TAG, "SERVICE_GET_ADDR_SUCCESS Raw: " + raw);
-                try {
-                    clientInfo.mResolvedService.setHost(InetAddress.getByName(cooked[4]));
-                    clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_SUCCEEDED,
-                            0, clientId, clientInfo.mResolvedService);
-                } catch (java.net.UnknownHostException e) {
-                    clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
-                            NsdManager.FAILURE_INTERNAL_ERROR, clientId);
-                }
-                stopGetAddrInfo(id);
-                mIdToClientInfoMap.remove(id);
-                clientInfo.mResolvedService = null;
-                break;
-            default:
-                break;
-        }
-    }
-
     private boolean startMDnsDaemon() {
         if (DBG) Slog.d(TAG, "startMDnsDaemon");
         try {
     private class ClientInfo {
 
         private static final int MAX_LIMIT = 10;
-        private AsyncChannel mChannel;
-        private Messenger mMessenger;
+        private final AsyncChannel mChannel;
+        private final Messenger mMessenger;
         /* Remembers a resolved service until getaddrinfo completes */
         private NsdServiceInfo mResolvedService;