Skip to content

Commit

Permalink
Merge pull request #107 from google/priv-libs-flagger
Browse files Browse the repository at this point in the history
native libs looking inspector
  • Loading branch information
borisf committed Jun 3, 2016
2 parents 1f5f41d + 834af1d commit 93ca26a
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,33 @@ public void apply() {

List<String> sortedNativeDependencies = new LinkedList<>(apkAnalysis.nativeDependencies);
Collections.sort(sortedNativeDependencies);
List<String> nativeLibNames = extractLibNames(apkAnalysis.nativeLibs);
for (String nativeLib : sortedNativeDependencies) {
element = new ELEMENT(nativeLib + "\n", TAG.DOCUMENT);
element = new ELEMENT(nativeLib + " " +
PrivateNativeLibsInspector.check(nativeLib, nativeLibNames) + "\n", TAG.DOCUMENT);
elements.add(element);
}
}


private static List<String> extractLibNames(List<String> nativeLibs) {
// libs/x86/lib.so\n ==> libs.so
LinkedList<String> result = new LinkedList<>();

for (String nativeLib : nativeLibs) {
String simpleNativeLibName = nativeLib;

if (nativeLib.contains("/")) {
simpleNativeLibName = simpleNativeLibName.substring(simpleNativeLibName.lastIndexOf("/") + 1,
simpleNativeLibName.length() - 1);
}

result.add(simpleNativeLibName);
}

return result;
}

@Override
public List<ELEMENT> getElementsList() {
return elements;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2016 Google, Inc.
*
* 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 com.google.classyshark.silverghost.translator.apk;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class PrivateNativeLibsInspector {

private static final String[] apiLibs = {
"libz.so",
"libz.a",
"libvulkan.so",
"libstdc++.so",
"libstdc++.a",
"libmediandk.so",
"libm.so",
"libm.a",
"liblog.so",
"libjnigraphics.so",
"libdl.so",
"libc.so",
"libc.a",
"libandroid.so",
"libOpenSLES.so",
"libOpenMAXAL.so",
"libGLESv3.so",
"libGLESv2.so",
"libGLESv1_CM.so",
"libEGL.so",
"crtend_so.o",
"crtend_android.o",
"crtbegin_static.o",
"crtbegin_so.o",
"crtbegin_dynamic.o",
"lsOutput.log"
};

private static List<String> APIS_LIB_LIST = new LinkedList<>(Arrays.asList(apiLibs));

public static String check(String nativeLib, List<String> nativeLibNames) {

if (!APIS_LIB_LIST.contains(nativeLib) && !nativeLibNames.contains(nativeLib)) {
return " -- private api!";
}

return "";
}
}

0 comments on commit 93ca26a

Please sign in to comment.