upload android base code part4
This commit is contained in:
parent
b9e30e05b1
commit
78ea2404cd
23455 changed files with 5250148 additions and 0 deletions
|
@ -0,0 +1,64 @@
|
|||
#
|
||||
# Copyright (C) 2017 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_STATIC_JAVA_LIBRARIES := \
|
||||
android-support-test
|
||||
|
||||
LOCAL_JNI_SHARED_LIBRARIES := libstaticsharednativelibconsumerjni
|
||||
|
||||
LOCAL_PACKAGE_NAME := CtsStaticSharedNativeLibConsumer
|
||||
|
||||
LOCAL_MULTILIB := both
|
||||
|
||||
LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
|
||||
|
||||
include $(BUILD_CTS_SUPPORT_PACKAGE)
|
||||
|
||||
#########################################################################
|
||||
# Build JNI Shared Library
|
||||
#########################################################################
|
||||
|
||||
LOCAL_PATH:= $(LOCAL_PATH)/jni
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
LOCAL_CFLAGS := -Wall -Wextra -Werror
|
||||
|
||||
LOCAL_SRC_FILES := $(call all-cpp-files-under)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := liblog \
|
||||
libstaticsharednativelibprovider
|
||||
|
||||
LOCAL_CXX_STL := none
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(JNI_H_INCLUDE) \
|
||||
$(LOCAL_PATH)/../CtsStaticSharedNativeLibProvider/native/version.h
|
||||
|
||||
LOCAL_MODULE := libstaticsharednativelibconsumerjni
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="android.os.lib.consumer"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
|
||||
|
||||
<application>
|
||||
<uses-static-library
|
||||
android:name="foo.bar.lib"
|
||||
android:version="1"
|
||||
android:certDigest="E4:95:82:FF:3A:0A:A4:C5:58:9F:C5:FE:AA:C6:B7:D6:E7:57:19:9D:D0:C6:74:2D:F7:BF:37:C2:FF:EF:95:F5">
|
||||
</uses-static-library>
|
||||
</application>
|
||||
|
||||
<instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
|
||||
android:targetPackage="android.os.lib.consumer"/>
|
||||
|
||||
</manifest>
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2017, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "../../StaticSharedNativeLibProvider/native/version.h"
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
static jint android_os_lib_consumer_UseSharedLibraryTest_getVersion(JNIEnv*, jclass) {
|
||||
return StaticSharedLib::android_os_lib_provider_getVersion();
|
||||
}
|
||||
|
||||
static int registerNativeMethods(JNIEnv* env, const char* className,
|
||||
JNINativeMethod* gMethods, int numMethods) {
|
||||
jclass clazz;
|
||||
clazz = env->FindClass(className);
|
||||
if (clazz == NULL) {
|
||||
ALOGE("Native registration unable to find class '%s'", className);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
|
||||
ALOGE("RegisterNatives failed for '%s'", className);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
extern "C" jint JNI_OnLoad(JavaVM* vm, void*) {
|
||||
JNIEnv *env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static JNINativeMethod gMethods[] = {
|
||||
{ "getVersion", "()I", (void*) android_os_lib_consumer_UseSharedLibraryTest_getVersion }
|
||||
};
|
||||
|
||||
registerNativeMethods(env, "android/os/lib/consumer/UseSharedLibraryTest",
|
||||
gMethods, ARRAY_SIZE(gMethods));
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.os.lib.consumer;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class UseSharedLibraryTest {
|
||||
static {
|
||||
System.loadLibrary("staticsharednativelibconsumerjni");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadNativeCode() throws Exception {
|
||||
assertSame(1, getVersion());
|
||||
}
|
||||
|
||||
private static native int getVersion();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue