• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 #define LOG_NDEBUG 0
17 
18 #define LOG_TAG "AutoLockJNI"
19 #include <utils/Log.h>
20 #include "com_android_cts_verifier_camera_analyzer_AutoLockTest.h"
21 
22 #include <vector>
23 #include <string>
24 #include <string.h>
25 
26 #include "testingimage.h"
27 #include "autolocktest.h"
28 #include "vec2.h"
29 #include "android/bitmap.h"
30 
Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_createAutoLockTest(JNIEnv * env,jobject thiz)31 jlong Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_createAutoLockTest(
32         JNIEnv*      env,
33         jobject      thiz) {
34 
35     AutoLockTest* testHandler = new AutoLockTest();
36     long handlerAddress = (long)testHandler;
37     return handlerAddress;
38 }
39 
Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_createAutoLockClass(JNIEnv * env,jobject thiz,jlong inputImageAddress,jlong inputHandlerAddress,jlong checkercenterAddress,jlong checkerradiusAddress)40 void Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_createAutoLockClass(
41         JNIEnv*      env,
42         jobject      thiz,
43         jlong        inputImageAddress,
44         jlong        inputHandlerAddress,
45         jlong        checkercenterAddress,
46         jlong        checkerradiusAddress) {
47 
48     ALOGV("JNI createAutoLockClass starts!");
49     long imageAddress = (long)inputImageAddress;
50     long handlerAddress = (long)inputHandlerAddress;
51 
52     TestingImage *image = (TestingImage*) imageAddress;
53     AutoLockTest *testHandler = (AutoLockTest*) handlerAddress;
54 
55     std::vector<std::vector< Vec2f > >* checkerCenter =
56             (std::vector<std::vector< Vec2f > >*) (long) checkercenterAddress;
57     std::vector<std::vector< float > >* checkerRadius =
58             (std::vector<std::vector< float > >*) (long) checkerradiusAddress;
59     ALOGV("Classes recovered");
60 
61     // Uses only the gray patches on the color checker for comparison.
62     testHandler->addDataToList(image->getColorChecker(3, 4, 0, 6,
63                                                       checkerCenter,
64                                                       checkerRadius));
65 
66     delete image;
67 }
68 
Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_processAutoLockTest(JNIEnv * env,jobject thiz,jlong inputHandlerAddress,jbooleanArray tempArray)69 void Java_com_android_cts_verifier_camera_analyzer_AutoLockTest_processAutoLockTest(
70         JNIEnv*          env,
71         jobject          thiz,
72         jlong            inputHandlerAddress,
73         jbooleanArray    tempArray) {
74 
75     ALOGV("Processing Auto Lock data!");
76 
77     long handlerAddress = (long) inputHandlerAddress;
78     AutoLockTest *testHandler = (AutoLockTest*) handlerAddress;
79 
80     testHandler->processData();
81 
82     // Converts the native boolean array into a java boolean array.
83     const std::vector<bool>* nativeComparisonResults =
84             testHandler->getComparisonResults();
85     jboolean comparisonResults[nativeComparisonResults->size()];
86 
87     for (int i = 0; i < nativeComparisonResults->size(); ++i) {
88         comparisonResults[i] = (jboolean) (*nativeComparisonResults)[i];
89     }
90 
91     env->SetBooleanArrayRegion(tempArray,
92                                0, nativeComparisonResults->size(),
93                                comparisonResults);
94     testHandler->clearData();
95 }
96