1 /*
2  * Copyright (C) 2010 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 #define LOG_TAG "NObb"
18 
19 #include <android/obb.h>
20 
21 #include <androidfw/ObbFile.h>
22 #include <utils/Log.h>
23 
24 using namespace android;
25 
26 struct AObbInfo : public ObbFile {};
27 
AObbScanner_getObbInfo(const char * filename)28 AObbInfo* AObbScanner_getObbInfo(const char* filename) {
29     AObbInfo* obbFile = new AObbInfo();
30     if (obbFile == NULL || !obbFile->readFrom(filename)) {
31         delete obbFile;
32         return NULL;
33     }
34     obbFile->incStrong((void*)AObbScanner_getObbInfo);
35     return static_cast<AObbInfo*>(obbFile);
36 }
37 
AObbInfo_delete(AObbInfo * obbInfo)38 void AObbInfo_delete(AObbInfo* obbInfo) {
39     if (obbInfo != NULL) {
40         obbInfo->decStrong((void*)AObbScanner_getObbInfo);
41     }
42 }
43 
AObbInfo_getPackageName(AObbInfo * obbInfo)44 const char* AObbInfo_getPackageName(AObbInfo* obbInfo) {
45     return obbInfo->getPackageName();
46 }
47 
AObbInfo_getVersion(AObbInfo * obbInfo)48 int32_t AObbInfo_getVersion(AObbInfo* obbInfo) {
49     return obbInfo->getVersion();
50 }
51 
AObbInfo_getFlags(AObbInfo * obbInfo)52 int32_t AObbInfo_getFlags(AObbInfo* obbInfo) {
53     return obbInfo->getFlags();
54 }
55