Guest User

Untitled

a guest
Dec 7th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.04 KB | None | 0 0
  1. package com.qihoo.util;
  2.  
  3. import android.app.Application;
  4. import android.content.Context;
  5. import android.os.Build;
  6. import android.util.Log;
  7. import java.io.BufferedInputStream;
  8. import java.io.File;
  9. import java.io.FileInputStream;
  10. import java.io.FileNotFoundException;
  11. import java.io.FileOutputStream;
  12. import java.io.IOException;
  13. import java.io.InputStream;
  14. import java.io.RandomAccessFile;
  15. import java.lang.reflect.Method;
  16.  
  17. public class StubApp1868252644 extends Application {
  18. private static Context context;
  19. public static Application newApp = null;
  20. public static Application runApp = null;
  21. private static String soName = "libjiagu";
  22. public static String strEntryApplication = "com.qihoo360.crypt.entryRunApplication";
  23.  
  24. public static native void interface5(Application application);
  25.  
  26. public static native String interface6(String str);
  27.  
  28. public static native boolean interface7(Application application, Context context);
  29.  
  30. public static native boolean interface8(Application application, Context context);
  31.  
  32. public static native void mark();
  33.  
  34. public static native int n0111();
  35.  
  36. public static native long n01112(boolean z);
  37.  
  38. public static native long n0112();
  39.  
  40. public static native void n01120(long j);
  41.  
  42. public static native long n01122(long j);
  43.  
  44. public static native void n011230(long j, Object obj);
  45.  
  46. public static native float n011231(long j, Object obj);
  47.  
  48. public static native void n0112310(long j, Object obj, float f);
  49.  
  50. public static native void n01123110(long j, Object obj, int i, boolean z);
  51.  
  52. public static native void n011231110(long j, Object obj, int i, int i2, int i3);
  53.  
  54. public static native long n0112312(long j, Object obj, int i);
  55.  
  56. public static native long n011232(long j, Object obj);
  57.  
  58. public static native void n0112322323230(long j, Object obj, long j2, long j3, Object obj2, long j4, Object obj3, long j5, Object obj4);
  59.  
  60. public static native void n01123230(long j, Object obj, long j2, Object obj2);
  61.  
  62. public static native boolean n01123231(long j, Object obj, long j2, Object obj2);
  63.  
  64. public static native void n011232310(long j, Object obj, long j2, Object obj2, int i);
  65.  
  66. public static native void n0112332310(long j, Object obj, Object obj2, long j2, Object obj3, boolean z);
  67.  
  68. public static native void n01123330(long j, Object obj, Object obj2, Object obj3);
  69.  
  70. public static native boolean n0112333111(long j, Object obj, Object obj2, Object obj3, int i, int i2);
  71.  
  72. public static native int n011311131(Object obj, int i, int i2, int i3, Object obj2);
  73.  
  74. public static native void n01131130(Object obj, int i, int i2, Object obj2);
  75.  
  76. public static native boolean n0113311(Object obj, Object obj2, int i);
  77.  
  78. public static native boolean n01133111(Object obj, Object obj2, int i, boolean z);
  79.  
  80. public static native boolean n01133331(Object obj, Object obj2, Object obj3, Object obj4);
  81.  
  82. public native Object n1113113(Object obj, int i, float f);
  83.  
  84. public native Object n111313(Object obj, int i);
  85.  
  86. public native Object n111313113(Object obj, int i, Object obj2, int i2, int i3);
  87.  
  88. public native Object n111323(Object obj, long j);
  89.  
  90. public native Object n11133(Object obj);
  91.  
  92. public native boolean n111331(Object obj, Object obj2);
  93.  
  94. public static Context getAppContext() {
  95. return context;
  96. }
  97.  
  98. public static Application getNewAppInstance(Context context) {
  99. try {
  100. if (newApp == null) {
  101. ClassLoader classLoader = context.getClassLoader();
  102. if (classLoader != null) {
  103. Class loadClass = classLoader.loadClass(strEntryApplication);
  104. if (loadClass != null) {
  105. newApp = (Application) loadClass.newInstance();
  106. }
  107. }
  108. }
  109. } catch (Exception e) {
  110. e.printStackTrace();
  111. }
  112. return newApp;
  113. }
  114.  
  115. public static void ChangeTopApplication() {
  116. try {
  117. interface7(newApp, runApp.getBaseContext());
  118. } catch (Exception e) {
  119. e.printStackTrace();
  120. }
  121. }
  122.  
  123. public void onCreate() {
  124. super.onCreate();
  125. if (Configuration.ENABLE_CRASH_REPORT) {
  126. prepareInitCrashReport();
  127. }
  128. ChangeTopApplication();
  129. if (newApp != null) {
  130. interface5(newApp);
  131. newApp.onCreate();
  132. }
  133. if (Configuration.ENABLE_CRASH_REPORT) {
  134. initCrashReport();
  135. }
  136. }
  137.  
  138. private void prepareInitCrashReport() {
  139. try {
  140. Class.forName("com.qihoo.bugreport.CrashReport").getDeclaredMethod("prepareInit", new Class[0]).invoke(null, new Object[0]);
  141. } catch (Throwable th) {
  142. Log.e("CRASH_REPORT", "Failed to reflect prepareInit method of Class CrashReport.");
  143. }
  144. }
  145.  
  146. private void initCrashReport() {
  147. try {
  148. Class.forName("com.qihoo.bugreport.CrashReport").getDeclaredMethod("init", new Class[]{Context.class}).invoke(null, new Object[]{getApplicationContext()});
  149. } catch (Throwable th) {
  150. Log.e("CRASH_REPORT", "Failed to reflect init method of Class CrashReport.");
  151. }
  152. }
  153.  
  154. public static Boolean isX86Arch() {
  155. try {
  156. for (String contains : Build.SUPPORTED_32_BIT_ABIS) {
  157. if (contains.contains("x86")) {
  158. return Boolean.valueOf(true);
  159. }
  160. }
  161. } catch (NoSuchFieldError e) {
  162. if (Build.CPU_ABI.contains("x86") || Build.CPU_ABI2.contains("x86")) {
  163. return Boolean.valueOf(true);
  164. }
  165. try {
  166. RandomAccessFile randomAccessFile = new RandomAccessFile("/system/build.prop", "r");
  167. String readLine = randomAccessFile.readLine();
  168. while (readLine != null) {
  169. if (readLine.contains("ro.product.cpu.abi") && readLine.contains("x86")) {
  170. return Boolean.valueOf(true);
  171. }
  172. readLine = randomAccessFile.readLine();
  173. }
  174. } catch (FileNotFoundException e2) {
  175. e2.printStackTrace();
  176. } catch (IOException e3) {
  177. e3.printStackTrace();
  178. }
  179. }
  180. return Boolean.valueOf(false);
  181. }
  182.  
  183. private void initAssetForNative() {
  184. try {
  185. Class.forName("com.qihoo.dexjiagu.TransitMgr").getMethod("initAssetForNative", new Class[]{Context.class}).invoke(null, new Object[]{this});
  186. } catch (Exception e) {
  187. }
  188. }
  189.  
  190. protected void attachBaseContext(Context context) {
  191. super.attachBaseContext(context);
  192. context = context;
  193. if (newApp == null) {
  194. String absolutePath = context.getFilesDir().getAbsolutePath();
  195. Boolean isX86Arch = isX86Arch();
  196. Boolean valueOf = Boolean.valueOf(false);
  197. if (Build.CPU_ABI.contains("64") || Build.CPU_ABI2.contains("64")) {
  198. valueOf = Boolean.valueOf(true);
  199. }
  200. if (isX86Arch.booleanValue()) {
  201. copy(context, soName + "_x86.so", absolutePath, soName + ".so");
  202. } else {
  203. copy(context, soName + ".so", absolutePath, soName + ".so");
  204. }
  205. if (valueOf.booleanValue()) {
  206. if (isX86Arch.booleanValue()) {
  207. copy(context, soName + "_x64.so", absolutePath, soName + "_64.so");
  208. } else {
  209. copy(context, soName + "_a64.so", absolutePath, soName + "_64.so");
  210. }
  211. System.load(absolutePath + "/" + soName + "_64.so");
  212. } else {
  213. System.load(absolutePath + "/" + soName + ".so");
  214. }
  215. }
  216. if (runApp == null) {
  217. runApp = this;
  218. }
  219. newApp = getNewAppInstance(context);
  220. if (newApp != null) {
  221. try {
  222. Method declaredMethod = Application.class.getDeclaredMethod("attach", new Class[]{Context.class});
  223. if (declaredMethod != null) {
  224. declaredMethod.setAccessible(true);
  225. declaredMethod.invoke(newApp, new Object[]{context});
  226. }
  227. } catch (Exception e) {
  228. e.printStackTrace();
  229. }
  230. }
  231. interface8(newApp, context);
  232. initAssetForNative();
  233. }
  234.  
  235. public static boolean copy(Context context, String str, String str2, String str3) {
  236. String str4 = str2 + "/" + str3;
  237. File file = new File(str2);
  238. if (!file.exists()) {
  239. file.mkdir();
  240. }
  241. try {
  242. file = new File(str4);
  243. if (file.exists()) {
  244. boolean z;
  245. InputStream open = context.getResources().getAssets().open(str);
  246. InputStream fileInputStream = new FileInputStream(file);
  247. BufferedInputStream bufferedInputStream = new BufferedInputStream(open);
  248. BufferedInputStream bufferedInputStream2 = new BufferedInputStream(fileInputStream);
  249. if (isSameFile(bufferedInputStream, bufferedInputStream2)) {
  250. z = true;
  251. } else {
  252. z = false;
  253. }
  254. open.close();
  255. fileInputStream.close();
  256. bufferedInputStream.close();
  257. bufferedInputStream2.close();
  258. if (z) {
  259. return z;
  260. }
  261. }
  262. InputStream open2 = context.getResources().getAssets().open(str);
  263. FileOutputStream fileOutputStream = new FileOutputStream(str4);
  264. byte[] bArr = new byte[7168];
  265. while (true) {
  266. int read = open2.read(bArr);
  267. if (read <= 0) {
  268. break;
  269. }
  270. fileOutputStream.write(bArr, 0, read);
  271. }
  272. fileOutputStream.close();
  273. open2.close();
  274. try {
  275. Runtime.getRuntime().exec("chmod 755 " + str4);
  276. } catch (Exception e) {
  277. }
  278. return true;
  279. } catch (Exception e2) {
  280. e2.printStackTrace();
  281. return false;
  282. }
  283. }
  284.  
  285. public static boolean isSameFile(BufferedInputStream bufferedInputStream, BufferedInputStream bufferedInputStream2) {
  286. try {
  287. int available = bufferedInputStream.available();
  288. int available2 = bufferedInputStream2.available();
  289. if (available != available2) {
  290. return false;
  291. }
  292. byte[] bArr = new byte[available];
  293. byte[] bArr2 = new byte[available2];
  294. bufferedInputStream.read(bArr);
  295. bufferedInputStream2.read(bArr2);
  296. for (available2 = 0; available2 < available; available2++) {
  297. if (bArr[available2] != bArr2[available2]) {
  298. return false;
  299. }
  300. }
  301. return true;
  302. } catch (FileNotFoundException e) {
  303. e.printStackTrace();
  304. return false;
  305. } catch (IOException e2) {
  306. e2.printStackTrace();
  307. return false;
  308. }
  309. }
  310. }
Add Comment
Please, Sign In to add comment