Skip to content

Commit be3267a

Browse files
krutonAndroid (Google) Code Review
authored andcommitted
Merge "Add a native library to test APKs" into jb-mr1-dev
2 parents 785aaa2 + e64e097 commit be3267a

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

core/tests/coretests/apks/FrameworkCoreTests_apk.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ LOCAL_DEX_PREOPT := false
77
# Make sure every package name gets the FrameworkCoreTests_ prefix.
88
LOCAL_PACKAGE_NAME := FrameworkCoreTests_$(LOCAL_PACKAGE_NAME)
99

10+
# Every package should have a native library
11+
LOCAL_JNI_SHARED_LIBRARIES := libframeworks_coretests_jni
12+
1013
FrameworkCoreTests_all_apks += $(LOCAL_PACKAGE_NAME)
1114

1215
include $(BUILD_PACKAGE)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (C) 2012 The Android Open Source Project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
LOCAL_PATH := $(call my-dir)
16+
17+
include $(CLEAR_VARS)
18+
19+
LOCAL_SRC_FILES := \
20+
com_android_frameworks_coretests_JNITest.cpp
21+
22+
LOCAL_SHARED_LIBRARIES := \
23+
libnativehelper
24+
25+
LOCAL_MODULE := libframeworks_coretests_jni
26+
LOCAL_MODULE_TAGS := optional
27+
28+
include $(BUILD_SHARED_LIBRARY)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright (C) 2012 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+
#include "nativehelper/JNIHelp.h"
18+
19+
namespace android {
20+
21+
static jint checkFunction(JNIEnv*, jclass) {
22+
return 1;
23+
}
24+
25+
static JNINativeMethod sMethods[] = {
26+
/* name, signature, funcPtr */
27+
{ "checkFunction", "()I", (void*) checkFunction },
28+
};
29+
30+
int register_com_android_framework_coretests_JNITests(JNIEnv* env) {
31+
return jniRegisterNativeMethods(env, "com/android/framework/coretests/JNITests", sMethods,
32+
NELEM(sMethods));
33+
}
34+
35+
}
36+
37+
/*
38+
* JNI Initialization
39+
*/
40+
jint JNI_OnLoad(JavaVM *jvm, void *reserved) {
41+
JNIEnv *e;
42+
int status;
43+
44+
// Check JNI version
45+
if (jvm->GetEnv((void **) &e, JNI_VERSION_1_6)) {
46+
return JNI_ERR;
47+
}
48+
49+
if ((status = android::register_com_android_framework_coretests_JNITests(e)) < 0) {
50+
return JNI_ERR;
51+
}
52+
53+
return JNI_VERSION_1_6;
54+
}

0 commit comments

Comments
 (0)