Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 93ca26a

Browse files
committed
Merge pull request #107 from google/priv-libs-flagger
native libs looking inspector
2 parents 1f5f41d + 834af1d commit 93ca26a

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

ClassySharkWS/src/com/google/classyshark/silverghost/translator/apk/ApkTranslator.java

+22-1
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,33 @@ public void apply() {
100100

101101
List<String> sortedNativeDependencies = new LinkedList<>(apkAnalysis.nativeDependencies);
102102
Collections.sort(sortedNativeDependencies);
103+
List<String> nativeLibNames = extractLibNames(apkAnalysis.nativeLibs);
103104
for (String nativeLib : sortedNativeDependencies) {
104-
element = new ELEMENT(nativeLib + "\n", TAG.DOCUMENT);
105+
element = new ELEMENT(nativeLib + " " +
106+
PrivateNativeLibsInspector.check(nativeLib, nativeLibNames) + "\n", TAG.DOCUMENT);
105107
elements.add(element);
106108
}
107109
}
108110

111+
112+
private static List<String> extractLibNames(List<String> nativeLibs) {
113+
// libs/x86/lib.so\n ==> libs.so
114+
LinkedList<String> result = new LinkedList<>();
115+
116+
for (String nativeLib : nativeLibs) {
117+
String simpleNativeLibName = nativeLib;
118+
119+
if (nativeLib.contains("/")) {
120+
simpleNativeLibName = simpleNativeLibName.substring(simpleNativeLibName.lastIndexOf("/") + 1,
121+
simpleNativeLibName.length() - 1);
122+
}
123+
124+
result.add(simpleNativeLibName);
125+
}
126+
127+
return result;
128+
}
129+
109130
@Override
110131
public List<ELEMENT> getElementsList() {
111132
return elements;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2016 Google, Inc.
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+
package com.google.classyshark.silverghost.translator.apk;
18+
19+
import java.util.Arrays;
20+
import java.util.LinkedList;
21+
import java.util.List;
22+
23+
public class PrivateNativeLibsInspector {
24+
25+
private static final String[] apiLibs = {
26+
"libz.so",
27+
"libz.a",
28+
"libvulkan.so",
29+
"libstdc++.so",
30+
"libstdc++.a",
31+
"libmediandk.so",
32+
"libm.so",
33+
"libm.a",
34+
"liblog.so",
35+
"libjnigraphics.so",
36+
"libdl.so",
37+
"libc.so",
38+
"libc.a",
39+
"libandroid.so",
40+
"libOpenSLES.so",
41+
"libOpenMAXAL.so",
42+
"libGLESv3.so",
43+
"libGLESv2.so",
44+
"libGLESv1_CM.so",
45+
"libEGL.so",
46+
"crtend_so.o",
47+
"crtend_android.o",
48+
"crtbegin_static.o",
49+
"crtbegin_so.o",
50+
"crtbegin_dynamic.o",
51+
"lsOutput.log"
52+
};
53+
54+
private static List<String> APIS_LIB_LIST = new LinkedList<>(Arrays.asList(apiLibs));
55+
56+
public static String check(String nativeLib, List<String> nativeLibNames) {
57+
58+
if (!APIS_LIB_LIST.contains(nativeLib) && !nativeLibNames.contains(nativeLib)) {
59+
return " -- private api!";
60+
}
61+
62+
return "";
63+
}
64+
}

0 commit comments

Comments
 (0)