MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / AiClient

Class AiClient

monkey/src/main/java/com/bytedance/fastbot/AiClient.java:22–167  ·  view source on GitHub ↗

@author Jianqiang Guo, Zhao Zhang

Source from the content-addressed store, hash-verified

20 */
21
22public class AiClient {
23
24 private static final AiClient singleton;
25
26 static {
27 boolean success;
28 long begin = SystemClock.elapsedRealtimeNanos();
29 success = tryToLoadNativeLib(false);
30 if (!success){
31 success = tryToLoadNativeLib(true);
32 }
33 long end = SystemClock.elapsedRealtimeNanos();
34 Logger.infoFormat("load fastbot_native takes %d ms.", TimeUnit.NANOSECONDS.toMillis(end - begin));
35 singleton = new AiClient(success);
36 }
37
38 public enum AlgorithmType {
39 Random(0),
40 SataRL(1),
41 SataNStep(2),
42 NStepQ(3),
43 Reuse(4);
44
45 private final int _value;
46
47 AlgorithmType(int value) {
48 this._value = value;
49 }
50
51 public int value() {
52 return this._value;
53 }
54 }
55
56 public static void InitAgent(AlgorithmType agentType, String packagename) {
57 singleton.fgdsaf5d(agentType.value(), packagename, 0);
58 }
59
60 private boolean loaded = false;
61
62 protected AiClient(boolean success) {
63 loaded = success;
64 }
65
66 private static boolean tryToLoadNativeLib(boolean fromAPK){
67 String path = "";
68 try {
69 path = getAiPath(fromAPK);
70 System.load(path);
71 Logger.println("fastbot native : library load!");
72 Logger.println("fastbot native path is : "+path);
73 } catch (UnsatisfiedLinkError e) {
74 Logger.errorPrintln("Error: Could not load library!");
75 Logger.errorPrintln(path);
76 e.printStackTrace();
77 return false;
78 }
79 return true;

Callers

nothing calls this directly

Calls 2

tryToLoadNativeLibMethod · 0.95
infoFormatMethod · 0.95

Tested by

no test coverage detected