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

Commit 6ba776ad authored by Christopher Tate's avatar Christopher Tate Committed by Android Git Automerger
Browse files

am 078ccbdb: am 2c40582a: Merge "Add native C APIs for working with the Asset...

am 078ccbdb: am 2c40582a: Merge "Add native C APIs for working with the Asset Manager" into gingerbread

Merge commit '078ccbdb'

* commit '078ccbdb':
  Add native C APIs for working with the Asset Manager
parents 085d0f55 078ccbdb
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Bundle;
@@ -52,7 +53,8 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,
    private boolean mDestroyed;
    
    private native int loadNativeCode(String path, MessageQueue queue,
            String internalDataPath, String externalDataPath, int sdkVersion);
            String internalDataPath, String externalDataPath, int sdkVersion,
            AssetManager assetMgr);
    private native void unloadNativeCode(int handle);
    
    private native void onStartNative(int handle);
@@ -138,7 +140,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,
        mNativeHandle = loadNativeCode(path, Looper.myQueue(),
                 getFilesDir().toString(),
                 Environment.getExternalStorageAppFilesDirectory(ai.packageName).toString(),
                 Build.VERSION.SDK_INT);
                 Build.VERSION.SDK_INT, getAssets());
        
        if (mNativeHandle == 0) {
            throw new IllegalArgumentException("Unable to load native library: " + path);
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ public final class AssetManager {
    
    // For communication with native code.
    private int mObject;
    private int mNObject;  // used by the NDK

    private StringBlock mStringBlocks[] = null;
    
+8 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_app_NativeActivity.h>
#include <android_runtime/android_util_AssetManager.h>
#include <surfaceflinger/Surface.h>
#include <ui/egl/android_natives.h>
#include <ui/InputTransport.h>
@@ -451,7 +452,8 @@ static bool mainWorkCallback(int fd, int events, void* data) {

static jint
loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQueue,
        jstring internalDataDir, jstring externalDataDir, int sdkVersion)
        jstring internalDataDir, jstring externalDataDir, int sdkVersion,
        jobject jAssetMgr)
{
    LOG_TRACE("loadNativeCode_native");

@@ -515,6 +517,8 @@ loadNativeCode_native(JNIEnv* env, jobject clazz, jstring path, jobject messageQ

        code->sdkVersion = sdkVersion;
        
        code->assetManager = assetManagerForJavaObject(env, jAssetMgr);

        code->createActivityFunc(code, NULL, 0);
    }
    
@@ -770,7 +774,7 @@ dispatchKeyEvent_native(JNIEnv* env, jobject clazz, jint handle, jobject eventOb
}

static const JNINativeMethod g_methods[] = {
    { "loadNativeCode", "(Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;I)I",
    { "loadNativeCode", "(Ljava/lang/String;Landroid/os/MessageQueue;Ljava/lang/String;Ljava/lang/String;I;Landroid/content/res/AssetManager)I",
            (void*)loadNativeCode_native },
    { "unloadNativeCode", "(I)V", (void*)unloadNativeCode_native },
    { "onStartNative", "(I)V", (void*)onStart_native },
+19 −1
Original line number Diff line number Diff line
@@ -29,6 +29,24 @@
#include <utils/ZipFileRO.h>
#include <utils/threads.h>

/*
 * Native-app access is via the opaque typedef struct AAssetManager in the C namespace.
 */
#ifdef __cplusplus
extern "C" {
#endif

struct AAssetManager { };

#ifdef __cplusplus
};
#endif


/*
 * Now the proper C++ android-namespace definitions
 */

namespace android {

class Asset;        // fwd decl for things that include Asset.h first
@@ -48,7 +66,7 @@ struct ResTable_config;
 * The asset hierarchy may be examined like a filesystem, using
 * AssetDir objects to peruse a single directory.
 */
class AssetManager {
class AssetManager : public AAssetManager {
public:
    typedef enum CacheMode {
        CACHE_UNKNOWN = 0,
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ include $(CLEAR_VARS)
# our source files
#
LOCAL_SRC_FILES:= \
    asset_manager.cpp \
    input.cpp \
    looper.cpp \
    native_activity.cpp \
Loading