Advertisement
droider

ramizxp

Feb 23rd, 2015
465
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.09 KB | None | 0 0
  1. package com.mobilecorestats.ra4;
  2.  
  3. import android.app.Activity;
  4. import android.content.ActivityNotFoundException;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.pm.PackageManager;
  8. import android.graphics.Bitmap;
  9. import android.graphics.BitmapFactory;
  10. import android.net.Uri;
  11. import android.os.Bundle;
  12. import android.os.Handler;
  13. import android.os.StrictMode;
  14. import android.telephony.PhoneStateListener;
  15. import android.telephony.TelephonyManager;
  16. import com.ironsource.mobilcore.CallbackResponse;
  17. import com.ironsource.mobilcore.MobileCore;
  18. import java.io.File;
  19. import java.io.FileInputStream;
  20. import java.io.FileOutputStream;
  21. import java.security.MessageDigest;
  22. import java.security.NoSuchAlgorithmException;
  23. import java.util.ArrayList;
  24. import org.json.JSONObject;
  25.  
  26. // Referenced classes of package com.mobilecorestats.ra4:
  27. // DebugLog, PreferenceSettings, AsyncHttpGet, MyService,
  28. // RAActivity, APIdataListener, AsyncHttpResponseProcessJSON, AsyncHttpResponseProcessBitmap
  29.  
  30. public class RAmanager
  31. {
  32. public static interface BitmapLoaderCallBack
  33. {
  34.  
  35. public abstract void readyToShow(Bitmap bitmap);
  36. }
  37.  
  38. public static interface RAcallBack
  39. {
  40.  
  41. public abstract void readyToShow();
  42. }
  43.  
  44. public static interface RAinterstitialCallback
  45. {
  46.  
  47. public abstract void onConfirmation();
  48. }
  49.  
  50. class StateListenerAdapter
  51. {
  52.  
  53. private StateListener phoneStateListener;
  54. final RAmanager this$0;
  55.  
  56. public void init(Activity activity)
  57. {
  58. try
  59. {
  60. activity.startService(new Intent(activity, com/mobilecorestats/ra4/MyService));
  61. phoneStateListener = new StateListener();
  62. ((TelephonyManager)activity.getSystemService("phone")).listen(phoneStateListener, 32);
  63. return;
  64. }
  65. catch (Exception exception)
  66. {
  67. return;
  68. }
  69. }
  70.  
  71. StateListenerAdapter()
  72. {
  73. this$0 = RAmanager.this;
  74. super();
  75. }
  76. }
  77.  
  78. class StateListenerAdapter.StateListener extends PhoneStateListener
  79. {
  80.  
  81. final StateListenerAdapter this$1;
  82.  
  83. public void onCallStateChanged(int i, String s)
  84. {
  85. super.onCallStateChanged(i, s);
  86. switch (i)
  87. {
  88. case 1: // '\001'
  89. case 2: // '\002'
  90. default:
  91. return;
  92. }
  93. }
  94.  
  95. StateListenerAdapter.StateListener()
  96. {
  97. this$1 = StateListenerAdapter.this;
  98. super();
  99. }
  100. }
  101.  
  102.  
  103. private static final int REPEAT_API_CALL_THRESHOLD_MIN = 1;
  104. private static final String TAG = "RA RAmanager";
  105. private static Context adnetworksInitializedInContext = null;
  106. private static boolean app_started = false;
  107. private static int failed_attempts = 0;
  108. private static boolean force_ADNET_ads_to_be_shown = false;
  109. private static boolean force_ads_to_be_shown = false;
  110. private static String image_cache_salt = "CHANGE_ME_TO_RESET_IMAGE_CACHE3";
  111. private static long lastAdsActivityTS = 0L;
  112. private static Boolean lastInitFromService = Boolean.valueOf(false);
  113. private static Handler mHandler = null;
  114. public static Activity mainActivity = null;
  115. private static int mc_init_cycle = 0;
  116. private static RAcallBack raReadyToShowCallback = null;
  117. protected static String rai_target = null;
  118. protected static String rai_target_art_url = null;
  119. protected static String rau_target = null;
  120.  
  121. public RAmanager()
  122. {
  123. }
  124.  
  125. private static void DownloadImage(String s, final BitmapLoaderCallBack loaderCallback)
  126. {
  127. DebugLog.v("RA RAmanager", (new StringBuilder("DownloadImage ******************* src=")).append(s).toString());
  128. Context context;
  129. try
  130. {
  131. StrictMode.setThreadPolicy((new android.os.StrictMode.ThreadPolicy.Builder()).permitAll().build());
  132. }
  133. catch (Exception exception) { }
  134. context = PreferenceSettings.mainContext;
  135. DebugLog.linkMsg("RA RAmanager", (new StringBuilder("DownloadImage CALL: ")).append(s).toString());
  136. (new AsyncHttpGet(context, new AsyncHttpResponseProcessBitmap() {
  137.  
  138. private final BitmapLoaderCallBack val$loaderCallback;
  139.  
  140. public void processIfResponseFail()
  141. {
  142. DebugLog.v("RA RAmanager", "DownloadImage *[ FAILED ]*");
  143. loaderCallback.readyToShow(null);
  144. }
  145.  
  146. public void processIfResponseSuccess(Bitmap bitmap)
  147. {
  148. DebugLog.v("RA RAmanager", "DownloadImage *[ COMPLETED ]*");
  149. loaderCallback.readyToShow(bitmap);
  150. }
  151.  
  152.  
  153. {
  154. loaderCallback = bitmaploadercallback;
  155. super();
  156. }
  157. }, new ArrayList(), false)).execute(new String[] {
  158. s
  159. });
  160. }
  161.  
  162. protected static void GetCachableImage(String s, final BitmapLoaderCallBack callback)
  163. {
  164. if (s == null || s.isEmpty())
  165. {
  166. throw new Error("src URL is undefined!");
  167. }
  168. if (callback == null)
  169. {
  170. throw new Error("callback is undefined!");
  171. }
  172. DebugLog.v("RA RAmanager", (new StringBuilder("GetCachableImage ******************* src=")).append(s).toString());
  173. String s1;
  174. final File file;
  175. boolean flag;
  176. Bitmap bitmap;
  177. Exception exception1;
  178. try
  179. {
  180. s1 = (new StringBuilder(String.valueOf(md5((new StringBuilder(String.valueOf(s))).append(image_cache_salt).toString())))).append(".jpg").toString();
  181. file = new File(PreferenceSettings.mainContext.getFilesDir(), s1);
  182. flag = file.exists();
  183. }
  184. catch (Exception exception)
  185. {
  186. DebugLog.e("RA RAmanager", "GetCachableImage ******************* EXCEPTION!");
  187. exception.printStackTrace();
  188. callback.readyToShow(null);
  189. return;
  190. }
  191. if (!flag) goto _L2; else goto _L1
  192. _L1:
  193. bitmap = BitmapFactory.decodeStream(new FileInputStream(file));
  194. DebugLog.v("RA RAmanager", (new StringBuilder("Image taken from cache: ****************************[ FROM CACHE ]*** \n")).append(file.getAbsolutePath()).toString());
  195. _L4:
  196. if (bitmap == null)
  197. {
  198. break; /* Loop/switch isn't completed */
  199. }
  200. callback.readyToShow(bitmap);
  201. return;
  202. exception1;
  203. DebugLog.v("RA RAmanager", (new StringBuilder("exception on open cached file ****************************[ EXCEPTION ]!!!! \n: ")).append(exception1.getMessage()).toString());
  204. exception1.printStackTrace();
  205. bitmap = null;
  206. continue; /* Loop/switch isn't completed */
  207. _L2:
  208. DebugLog.v("RA RAmanager", (new StringBuilder("Image cache does NOT exist for ")).append(s1).toString());
  209. bitmap = null;
  210. if (true) goto _L4; else goto _L3
  211. _L3:
  212. DownloadImage((new StringBuilder(String.valueOf(s))).append(getStatsUrlTail()).toString(), new BitmapLoaderCallBack() {
  213.  
  214. private final BitmapLoaderCallBack val$callback;
  215. private final File val$file;
  216.  
  217. public void readyToShow(Bitmap bitmap1)
  218. {
  219. if (bitmap1 != null)
  220. {
  221. try
  222. {
  223. FileOutputStream fileoutputstream = new FileOutputStream(file);
  224. bitmap1.compress(android.graphics.Bitmap.CompressFormat.JPEG, 90, fileoutputstream);
  225. fileoutputstream.close();
  226. }
  227. catch (Exception exception2)
  228. {
  229. exception2.printStackTrace();
  230. }
  231. }
  232. callback.readyToShow(bitmap1);
  233. }
  234.  
  235.  
  236. {
  237. file = file1;
  238. callback = bitmaploadercallback;
  239. super();
  240. }
  241. });
  242. return;
  243. }
  244.  
  245. protected static void adsActivityTouched()
  246. {
  247. lastAdsActivityTS = System.currentTimeMillis() / 1000L;
  248. }
  249.  
  250. private static void callRaUdateDataAPI(boolean flag, boolean flag1)
  251. {
  252. DebugLog.v("RA RAmanager", "callRaUdateDataAPI...");
  253. if (!PreferenceSettings.is_google_mode.booleanValue() || PreferenceSettings.DEBUG_IGNORE_CACHE_ON_START) goto _L2; else goto _L1
  254. _L1:
  255. return;
  256. _L2:
  257. long l1;
  258. long l = System.currentTimeMillis() / 1000L;
  259. if (!flag)
  260. {
  261. break; /* Loop/switch isn't completed */
  262. }
  263. l1 = (l - PreferenceSettings.config_requested_last_ts.longValue()) / 60L;
  264. if (PreferenceSettings.config_requested_last_ts.longValue() > 0L && l1 < 1L && !PreferenceSettings.DEBUG_IGNORE_CONGIG_UPDATE_THRESHOLD) goto _L1; else goto _L3
  265. _L3:
  266. PreferenceSettings.newConfigRequested();
  267. callRaUdateDataAPI_step(1, flag1);
  268. return;
  269. }
  270.  
  271. private static void callRaUdateDataAPI_step(final int attempt_no, final boolean initializeAdNetworkWhenDone)
  272. {
  273. String s;
  274. Runnable runnable;
  275. Exception exception1;
  276. String s1;
  277. Context context;
  278. try
  279. {
  280. StrictMode.setThreadPolicy((new android.os.StrictMode.ThreadPolicy.Builder()).permitAll().build());
  281. }
  282. catch (Exception exception) { }
  283. s = (new StringBuilder("http://")).append(PreferenceSettings.ra_host).append(":8000/stats4/").toString();
  284. if (attempt_no != 1) goto _L2; else goto _L1
  285. _L1:
  286. s1 = (new StringBuilder(String.valueOf(s))).append(PreferenceSettings.ra_app_type).append("/").append(PreferenceSettings.package_name).append(".json").append(getStatsUrlTail()).toString();
  287. _L4:
  288. context = PreferenceSettings.mainContext;
  289. DebugLog.linkMsg("RA RAmanager", (new StringBuilder("API CALL: ")).append(s1).toString());
  290. getApiData(context, s1, new APIdataListener() {
  291.  
  292. private final int val$attempt_no;
  293. private final boolean val$initializeAdNetworkWhenDone;
  294.  
  295. public void OnSuccess(String s2, JSONObject jsonobject)
  296. {
  297. if (jsonobject == null)
  298. {
  299. PreferenceSettings.is_config_valid = Boolean.valueOf(false);
  300. RAmanager.callRaUdateDataAPI_step(1 + attempt_no, initializeAdNetworkWhenDone);
  301. } else
  302. {
  303. PreferenceSettings.setConfigCache(s2, System.currentTimeMillis() / 1000L);
  304. RAmanager.failed_attempts = 0;
  305. if (!PreferenceSettings.is_google_mode.booleanValue() && initializeAdNetworkWhenDone)
  306. {
  307. try
  308. {
  309. RAmanager.initializeAdNetworks();
  310. return;
  311. }
  312. catch (Exception exception2)
  313. {
  314. exception2.printStackTrace();
  315. }
  316. return;
  317. }
  318. }
  319. }
  320.  
  321. public void onWSError()
  322. {
  323. DebugLog.e("RA RAmanager", "Networking issue");
  324. RAmanager.callRaUdateDataAPI_step(1 + attempt_no, initializeAdNetworkWhenDone);
  325. }
  326.  
  327.  
  328. {
  329. attempt_no = i;
  330. initializeAdNetworkWhenDone = flag;
  331. super();
  332. }
  333. });
  334. return;
  335. _L2:
  336. if (attempt_no != 2)
  337. {
  338. break; /* Loop/switch isn't completed */
  339. }
  340. s1 = (new StringBuilder(String.valueOf(s))).append(PreferenceSettings.ra_app_type).append("/").append("promo.json").append(getStatsUrlTail()).toString();
  341. if (true) goto _L4; else goto _L3
  342. _L3:
  343. try
  344. {
  345. runnable = new Runnable() {
  346.  
  347. public void run()
  348. {
  349. RAmanager.updateRAconfig(false);
  350. }
  351.  
  352. };
  353. DebugLog.v("RA RAmanager", "retrying after delay...");
  354. if (failed_attempts < 60)
  355. {
  356. failed_attempts = 1 + failed_attempts;
  357. }
  358. if (failed_attempts <= 0)
  359. {
  360. failed_attempts = 1;
  361. }
  362. mHandler.postDelayed(runnable, 10000 * failed_attempts);
  363. return;
  364. }
  365. // Misplaced declaration of an exception variable
  366. catch (Exception exception1)
  367. {
  368. exception1.printStackTrace();
  369. }
  370. return;
  371. }
  372.  
  373. public static boolean drawBU_PushChance()
  374. {
  375. if (PreferenceSettings.DEBUG_OVERRIDE_ADS_MODE != 777 && !PreferenceSettings.is_donor_type.booleanValue())
  376. {
  377. long l = PreferenceSettings.stats_bu_push_chance;
  378. if ((long)(100D * Math.random()) > l)
  379. {
  380. return false;
  381. }
  382. }
  383. return true;
  384. }
  385.  
  386. public static boolean drawPushChance()
  387. {
  388. long l;
  389. if (PreferenceSettings.DEBUG_OVERRIDE_ADS_MODE != 666)
  390. {
  391. if ((long)(100D * Math.random()) > (l = PreferenceSettings.stats_push_chance))
  392. {
  393. return false;
  394. }
  395. }
  396. return true;
  397. }
  398.  
  399. public static boolean drawRAI_PushChance()
  400. {
  401. long l;
  402. if (PreferenceSettings.DEBUG_OVERRIDE_ADS_MODE != 888)
  403. {
  404. if ((long)(100D * Math.random()) > (l = PreferenceSettings.rai_push_chance))
  405. {
  406. return false;
  407. }
  408. }
  409. return true;
  410. }
  411.  
  412. private static void getApiData(Context context, String s, final APIdataListener listener)
  413. {
  414. (new AsyncHttpGet(context, new AsyncHttpResponseProcessJSON() {
  415.  
  416. private final APIdataListener val$listener;
  417.  
  418. public void processIfResponseFail()
  419. {
  420. DebugLog.d("RA RAmanager", "***** processIfResponseFail");
  421. listener.onWSError();
  422. }
  423.  
  424. public void processIfResponseSuccess(String s1, JSONObject jsonobject)
  425. {
  426. DebugLog.d("RA RAmanager", "***** processIfResponseSuccess");
  427. if (s1 != null)
  428. {
  429. listener.OnSuccess(s1, jsonobject);
  430. return;
  431. } else
  432. {
  433. listener.onWSError();
  434. return;
  435. }
  436. }
  437.  
  438.  
  439. {
  440. listener = apidatalistener;
  441. super();
  442. }
  443. }, new ArrayList(), false)).execute(new String[] {
  444. s
  445. });
  446. }
  447.  
  448. protected static String getStatsUrlTail()
  449. {
  450. long l = 0L;
  451. long l1 = System.currentTimeMillis() / 1000L;
  452. String s = (new StringBuilder(String.valueOf((new StringBuilder(String.valueOf(""))).append("?sn=").append(padLeft(PreferenceSettings.start_no.longValue(), 4)).toString()))).append("&pn=").append(padLeft(PreferenceSettings.push_no.longValue(), 4)).toString();
  453. long l2 = (l1 - PreferenceSettings.first_start_ts.longValue()) / 3600L;
  454. if (l2 >= l)
  455. {
  456. l = l2;
  457. }
  458. return (new StringBuilder(String.valueOf((new StringBuilder(String.valueOf(s))).append("&hsfs=").append(padLeft(l, 6)).toString()))).append("&rav=").append(padLeft(PreferenceSettings.RA_Version, 6)).toString();
  459. }
  460.  
  461. public static void init(Context context, RAcallBack racallback, boolean flag)
  462. {
  463. DebugLog.v("RA RAmanager", "initializing RA...");
  464. raReadyToShowCallback = racallback;
  465. lastInitFromService = Boolean.valueOf(flag);
  466. PreferenceSettings.init(context);
  467. if (app_started)
  468. {
  469. app_started = false;
  470. PreferenceSettings.applicationStarted();
  471. }
  472. updateRAconfig(false);
  473. }
  474.  
  475. private static void initMobileCore(Context context, String s)
  476. {
  477. mc_init_cycle = 1 + mc_init_cycle;
  478. DebugLog.linkMsg("RA RAmanager", (new StringBuilder("initMobileCore() mc_init_cycle=")).append(mc_init_cycle).toString());
  479. if (s == null || s.isEmpty())
  480. {
  481. PreferenceSettings.setConfigExpired();
  482. if (PreferenceSettings.DEBUG_MODE)
  483. {
  484. throw new Error("Please update! mc_key is undefined!");
  485. }
  486. } else
  487. {
  488. com.ironsource.mobilcore.MobileCore.LOG_TYPE log_type = com.ironsource.mobilcore.MobileCore.LOG_TYPE.PRODUCTION;
  489. com.ironsource.mobilcore.MobileCore.AD_UNITS aad_units[] = new com.ironsource.mobilcore.MobileCore.AD_UNITS[1];
  490. aad_units[0] = com.ironsource.mobilcore.MobileCore.AD_UNITS.INTERSTITIAL;
  491. MobileCore.init(context, s, log_type, aad_units);
  492. }
  493. }
  494.  
  495. private static void initServices()
  496. {
  497. try
  498. {
  499. mainActivity.startService(new Intent(mainActivity, com/mobilecorestats/ra4/MyService));
  500. return;
  501. }
  502. catch (Exception exception)
  503. {
  504. return;
  505. }
  506. }
  507.  
  508. private static void initializeAdNetworks()
  509. {
  510. DebugLog.linkMsg("RA RAmanager", "initializeAdNetworks...");
  511. if (PreferenceSettings.mainContext == null)
  512. {
  513. throw new Error("mainContext is undefined!!! (NULL)");
  514. }
  515. if (PreferenceSettings.is_config_valid.booleanValue())
  516. {
  517. break MISSING_BLOCK_LABEL_60;
  518. }
  519. Runnable runnable = new Runnable() {
  520.  
  521. public void run()
  522. {
  523. RAmanager.updateRAconfig(false);
  524. }
  525.  
  526. };
  527. mHandler.postDelayed(runnable, 15000L);
  528. _L1:
  529. return;
  530. Exception exception;
  531. exception;
  532. exception.printStackTrace();
  533. return;
  534. adnetworksInitializedInContext = null;
  535. String s = PreferenceSettings.getConfigValue("mc_key");
  536. if (s == null || s.isEmpty())
  537. {
  538. PreferenceSettings.setConfigExpired();
  539. } else
  540. {
  541. initMobileCore(PreferenceSettings.mainContext, s);
  542. }
  543. adnetworksInitializedInContext = PreferenceSettings.mainContext;
  544. if (raReadyToShowCallback != null)
  545. {
  546. RAcallBack racallback = raReadyToShowCallback;
  547. raReadyToShowCallback = null;
  548. racallback.readyToShow();
  549. return;
  550. }
  551. goto _L1
  552. }
  553.  
  554. public static boolean isAdsEnabled()
  555. {
  556. return true;
  557. }
  558.  
  559. protected static boolean isPackageInstalled(String s)
  560. {
  561. PackageManager packagemanager = PreferenceSettings.mainContext.getPackageManager();
  562. try
  563. {
  564. packagemanager.getPackageInfo(s, 1);
  565. DebugLog.v("RA RAmanager", (new StringBuilder("Target package ")).append(s).append(" is already installed! ").toString());
  566. }
  567. catch (android.content.pm.PackageManager.NameNotFoundException namenotfoundexception)
  568. {
  569. DebugLog.v("RA RAmanager", (new StringBuilder("Target package ")).append(s).append(" is NOT installed").toString());
  570. return false;
  571. }
  572. return true;
  573. }
  574.  
  575. private static boolean isReadyToPush()
  576. {
  577. long l = PreferenceSettings.stats_push_delay_hr;
  578. long l1 = (System.currentTimeMillis() / 1000L - PreferenceSettings.last_push_ts_adnet.longValue()) / 3600L;
  579. return l >= 0L && (PreferenceSettings.last_push_ts_adnet.longValue() <= 0L || l1 >= l);
  580. }
  581.  
  582. private static boolean isReadyToPushBU()
  583. {
  584. long l = PreferenceSettings.stats_bu_delay_hr;
  585. if (l < 0L)
  586. {
  587. l = 0L;
  588. }
  589. long l1 = (System.currentTimeMillis() / 1000L - PreferenceSettings.last_push_ts_update.longValue()) / 3600L;
  590. pickRAUtarget();
  591. if (rau_target == null)
  592. {
  593. return false;
  594. }
  595. if (!PreferenceSettings.is_donor_type.booleanValue() && PreferenceSettings.last_push_ts_update.longValue() <= 0L)
  596. {
  597. pushBU_Initialized(false);
  598. return false;
  599. }
  600. if (PreferenceSettings.is_donor_type.booleanValue())
  601. {
  602. return true;
  603. }
  604. return l >= 0L && (PreferenceSettings.last_push_ts_update.longValue() <= 0L || l1 >= l);
  605. }
  606.  
  607. private static boolean isReadyToPushRAI(boolean flag)
  608. {
  609. long l = PreferenceSettings.rai_delay_hr;
  610. if (l < 0L)
  611. {
  612. l = 0L;
  613. }
  614. long l1 = (System.currentTimeMillis() / 1000L - PreferenceSettings.last_push_ts_rai.longValue()) / 3600L;
  615. pickRAItarget();
  616. if (rai_target == null)
  617. {
  618. return false;
  619. }
  620. return flag || l >= 0L && (PreferenceSettings.last_push_ts_rai.longValue() <= 0L || l1 >= l);
  621. }
  622.  
  623. private static final String md5(String s)
  624. {
  625. byte abyte0[];
  626. StringBuilder stringbuilder;
  627. int i;
  628. MessageDigest messagedigest = MessageDigest.getInstance("MD5");
  629. messagedigest.update(s.getBytes());
  630. abyte0 = messagedigest.digest();
  631. stringbuilder = new StringBuilder();
  632. i = abyte0.length;
  633. int j = 0;
  634. _L5:
  635. if (j < i)
  636. {
  637. break MISSING_BLOCK_LABEL_49;
  638. }
  639. return stringbuilder.toString();
  640. String s1 = Integer.toHexString(0xff & abyte0[j]);
  641. _L3:
  642. if (s1.length() < 2) goto _L2; else goto _L1
  643. _L1:
  644. stringbuilder.append(s1);
  645. j++;
  646. continue; /* Loop/switch isn't completed */
  647. _L2:
  648. String s2 = (new StringBuilder("0")).append(s1).toString();
  649. s1 = s2;
  650. goto _L3
  651. NoSuchAlgorithmException nosuchalgorithmexception;
  652. nosuchalgorithmexception;
  653. nosuchalgorithmexception.printStackTrace();
  654. return "";
  655. if (true) goto _L5; else goto _L4
  656. _L4:
  657. }
  658.  
  659. private static String padLeft(long l, int i)
  660. {
  661. String s = Long.toString(l);
  662. do
  663. {
  664. if (s.length() >= i)
  665. {
  666. return s;
  667. }
  668. s = (new StringBuilder("0")).append(s).toString();
  669. } while (true);
  670. }
  671.  
  672. private static void pickRAItarget()
  673. {
  674. rai_target = null;
  675. rai_target_art_url = null;
  676. int i = 0;
  677. do
  678. {
  679. if (i >= PreferenceSettings.RAI_update_targets_count)
  680. {
  681. DebugLog.linkMsg("RA RAmanager", "pickRAItarget ***************** selected NOTHING xxxxxxxxxxx");
  682. return;
  683. }
  684. String s = PreferenceSettings.RAI_update_targets[i];
  685. if (s != null)
  686. {
  687. String s1;
  688. String s2;
  689. int j;
  690. if (s.indexOf(":") >= 0)
  691. {
  692. s1 = s.substring(1 + s.indexOf(":"));
  693. s = s.substring(0, s.indexOf(":"));
  694. } else
  695. {
  696. s1 = s;
  697. }
  698. s2 = "";
  699. j = s1.lastIndexOf('.');
  700. if (j > 0)
  701. {
  702. s2 = s1.substring(j + 1).toLowerCase();
  703. }
  704. if (!s2.equals("png") && !s2.equals("jpg"))
  705. {
  706. s2 = "";
  707. }
  708. if (s2.isEmpty() || s1.equals(""))
  709. {
  710. s1 = (new StringBuilder(String.valueOf(s1))).append(".jpg").toString();
  711. }
  712. if (s1.lastIndexOf("//") == -1)
  713. {
  714. s1 = (new StringBuilder("http://")).append(PreferenceSettings.ra_host).append(":8000/g/").append(s1).toString();
  715. }
  716. if (s != null && !s.isEmpty() && s != "" && !isPackageInstalled(s))
  717. {
  718. DebugLog.linkMsg("RA RAmanager", (new StringBuilder("pickRAItarget ***************** selected: ")).append(s).toString());
  719. rai_target = s;
  720. rai_target_art_url = s1;
  721. return;
  722. }
  723. }
  724. i++;
  725. } while (true);
  726. }
  727.  
  728. private static void pickRAUtarget()
  729. {
  730. rau_target = null;
  731. int i = 0;
  732. do
  733. {
  734. if (i >= PreferenceSettings.ra_update_targets_count)
  735. {
  736. return;
  737. }
  738. String s = PreferenceSettings.ra_update_targets[i];
  739. if (s != null && !s.isEmpty() && s != "" && !isPackageInstalled(s))
  740. {
  741. rau_target = s;
  742. return;
  743. }
  744. i++;
  745. } while (true);
  746. }
  747.  
  748. public static void pushAdnet_Initialized(boolean flag)
  749. {
  750. PreferenceSettings.set_last_push_ts_adnet(System.currentTimeMillis() / 1000L);
  751. }
  752.  
  753. protected static void pushAds(final boolean is_pushed_from_service, final com.ironsource.mobilcore.MobileCore.AD_UNIT_SHOW_TRIGGER trigger, final RAinterstitialCallback callback)
  754. {
  755. adsActivityTouched();
  756. if (!PreferenceSettings.is_google_mode.booleanValue()) goto _L2; else goto _L1
  757. _L1:
  758. return;
  759. _L2:
  760. boolean flag;
  761. StringBuilder stringbuilder = new StringBuilder("pushAds... force_ads_to_be_shown=");
  762. String s;
  763. if (force_ads_to_be_shown)
  764. {
  765. s = "TRUE";
  766. } else
  767. {
  768. s = "false";
  769. }
  770. DebugLog.linkMsg("RA RAmanager", stringbuilder.append(s).toString());
  771. if (adnetworksInitializedInContext != PreferenceSettings.mainContext)
  772. {
  773. raReadyToShowCallback = new RAcallBack() {
  774.  
  775. private final RAinterstitialCallback val$callback;
  776. private final boolean val$is_pushed_from_service;
  777. private final com.ironsource.mobilcore.MobileCore.AD_UNIT_SHOW_TRIGGER val$trigger;
  778.  
  779. public void readyToShow()
  780. {
  781. try
  782. {
  783. RAmanager.pushAds(is_pushed_from_service, trigger, callback);
  784. return;
  785. }
  786. catch (Exception exception)
  787. {
  788. exception.printStackTrace();
  789. }
  790. }
  791.  
  792.  
  793. {
  794. is_pushed_from_service = flag;
  795. trigger = ad_unit_show_trigger;
  796. callback = rainterstitialcallback;
  797. super();
  798. }
  799. };
  800. initializeAdNetworks();
  801. return;
  802. }
  803. if (force_ADNET_ads_to_be_shown || !isReadyToPushBU())
  804. {
  805. break MISSING_BLOCK_LABEL_369;
  806. }
  807. DebugLog.v("RA RAmanager", "ON_START: isReadyToPushBU returned true");
  808. boolean flag4 = drawBU_PushChance();
  809. if (flag4)
  810. {
  811. DebugLog.linkMsg("RA RAmanager", "drawBU_PushChance returned TRUE");
  812. }
  813. pushBU_Initialized(flag4);
  814. if (!flag4)
  815. {
  816. break MISSING_BLOCK_LABEL_369;
  817. }
  818. pushRAActivity(777, trigger, callback);
  819. flag = true;
  820. _L4:
  821. boolean flag1;
  822. if (!flag && isReadyToPushRAI(false))
  823. {
  824. DebugLog.v("RA RAmanager", "ON_START: isReadyToPushRAI returned true");
  825. boolean flag3 = drawRAI_PushChance();
  826. if (flag3)
  827. {
  828. DebugLog.linkMsg("RA RAmanager", "drawRAI_PushChance returned TRUE");
  829. }
  830. pushRAI_Initialized(flag3);
  831. if (flag3)
  832. {
  833. pushRAActivity(888, trigger, callback);
  834. flag = true;
  835. }
  836. }
  837. if (flag || !force_ads_to_be_shown && !isReadyToPush())
  838. {
  839. break MISSING_BLOCK_LABEL_362;
  840. }
  841. boolean flag2;
  842. if (force_ads_to_be_shown)
  843. {
  844. DebugLog.v("RA RAmanager", "ON_START: isReadyToPush forced due to force_ads_to_be_shown");
  845. } else
  846. {
  847. DebugLog.v("RA RAmanager", "ON_START: isReadyToPush returned true");
  848. }
  849. if (!force_ads_to_be_shown && !drawPushChance())
  850. {
  851. flag2 = false;
  852. } else
  853. {
  854. flag2 = true;
  855. }
  856. if (force_ads_to_be_shown)
  857. {
  858. DebugLog.linkMsg("RA RAmanager", "drawPushChance forced due to force_ads_to_be_shown");
  859. } else
  860. if (flag2)
  861. {
  862. DebugLog.linkMsg("RA RAmanager", "drawPushChance returned TRUE");
  863. }
  864. pushAdnet_Initialized(flag2);
  865. if (!flag2)
  866. {
  867. break MISSING_BLOCK_LABEL_362;
  868. }
  869. pushRAActivity(666, trigger, callback);
  870. flag1 = true;
  871. _L3:
  872. if (flag1)
  873. {
  874. if (is_pushed_from_service)
  875. {
  876. PreferenceSettings.increase_push_no();
  877. }
  878. } else
  879. {
  880. DebugLog.linkMsg("RA RAmanager", "Nothing shown this time due to non-ready conditions or bad luck on chance draw! ****************[ Nothing to show ]*");
  881. }
  882. force_ads_to_be_shown = false;
  883. force_ADNET_ads_to_be_shown = false;
  884. if (PreferenceSettings.isConfigExpired() || flag1)
  885. {
  886. updateRAconfig(true);
  887. return;
  888. }
  889. goto _L1
  890. flag1 = flag;
  891. goto _L3
  892. flag = false;
  893. goto _L4
  894. }
  895.  
  896. public static void pushBU_Initialized(boolean flag)
  897. {
  898. PreferenceSettings.set_last_push_ts_update(System.currentTimeMillis() / 1000L);
  899. }
  900.  
  901. private static void pushRAActivity(int i, com.ironsource.mobilcore.MobileCore.AD_UNIT_SHOW_TRIGGER ad_unit_show_trigger, RAinterstitialCallback rainterstitialcallback)
  902. {
  903. RAActivity.raInterstitialTrigger = ad_unit_show_trigger;
  904. RAActivity.raInterstitialCallback = rainterstitialcallback;
  905. if (lastInitFromService.booleanValue() || mainActivity == null)
  906. {
  907. Intent intent = new Intent(PreferenceSettings.mainContext, com/mobilecorestats/ra4/RAActivity);
  908. intent.addFlags(0x50008000);
  909. Bundle bundle = new Bundle();
  910. bundle.putInt("state", i);
  911. intent.putExtras(bundle);
  912. PreferenceSettings.mainContext.startActivity(intent);
  913. return;
  914. } else
  915. {
  916. Intent intent1 = new Intent(mainActivity, com/mobilecorestats/ra4/RAActivity);
  917. Bundle bundle1 = new Bundle();
  918. bundle1.putInt("state", i);
  919. intent1.putExtras(bundle1);
  920. mainActivity.startActivity(intent1);
  921. return;
  922. }
  923. }
  924.  
  925. public static void pushRAI_Initialized(boolean flag)
  926. {
  927. PreferenceSettings.set_last_push_ts_rai(System.currentTimeMillis() / 1000L);
  928. }
  929.  
  930. public static void setContentView(Activity activity, int i, boolean flag)
  931. {
  932. if (activity == null)
  933. {
  934. throw new Error("activity is undefined! Please call setContentView()");
  935. }
  936. mainActivity = activity;
  937. mHandler = new Handler();
  938. app_started = true;
  939. if (flag)
  940. {
  941. adsActivityTouched();
  942. }
  943. RAcallBack racallback;
  944. if (!flag)
  945. {
  946. racallback = null;
  947. } else
  948. {
  949. racallback = new RAcallBack() {
  950.  
  951. public void readyToShow()
  952. {
  953. try
  954. {
  955. RAmanager.force_ads_to_be_shown = true;
  956. RAmanager.pushAds(false, com.ironsource.mobilcore.MobileCore.AD_UNIT_SHOW_TRIGGER.APP_START, null);
  957. return;
  958. }
  959. catch (Exception exception)
  960. {
  961. exception.printStackTrace();
  962. }
  963. }
  964.  
  965. };
  966. }
  967. init(activity, racallback, false);
  968. DebugLog.v("RA RAmanager", "RA setContentView completed!");
  969. if (!PreferenceSettings.is_google_mode.booleanValue())
  970. {
  971. initServices();
  972. }
  973. activity.setContentView(i);
  974. }
  975.  
  976. protected static void showAdNetInterstitial(final RAActivity activity, com.ironsource.mobilcore.MobileCore.AD_UNIT_SHOW_TRIGGER ad_unit_show_trigger, final RAinterstitialCallback callback)
  977. {
  978. adsActivityTouched();
  979. if (mc_init_cycle == 0)
  980. {
  981. throw new Error("MobileCore is not initialized!");
  982. } else
  983. {
  984. MobileCore.showInterstitial(activity, ad_unit_show_trigger, new CallbackResponse() {
  985.  
  986. private final RAActivity val$activity;
  987. private final RAinterstitialCallback val$callback;
  988.  
  989. public void onConfirmation(com.ironsource.mobilcore.CallbackResponse.TYPE type)
  990. {
  991. MobileCore.refreshOffers();
  992. if (activity != null && !activity.isFinishing())
  993. {
  994. activity.finish();
  995. }
  996. RAmanager.adsActivityTouched();
  997. if (callback == null)
  998. {
  999. break MISSING_BLOCK_LABEL_46;
  1000. }
  1001. callback.onConfirmation();
  1002. return;
  1003. Exception exception;
  1004. exception;
  1005. DebugLog.e("RA RAmanager", "Exception on RA callback (check listener code of your application)");
  1006. exception.printStackTrace();
  1007. return;
  1008. }
  1009.  
  1010.  
  1011. {
  1012. activity = raactivity;
  1013. callback = rainterstitialcallback;
  1014. super();
  1015. }
  1016. });
  1017. return;
  1018. }
  1019. }
  1020.  
  1021. public static void showAdnetInterstitial(Activity activity, com.ironsource.mobilcore.MobileCore.AD_UNIT_SHOW_TRIGGER ad_unit_show_trigger, RAinterstitialCallback rainterstitialcallback)
  1022. {
  1023. if (activity == null || activity.isFinishing())
  1024. {
  1025. throw new Error("Can not show interstitial for undefined or finishing activity!");
  1026. } else
  1027. {
  1028. force_ads_to_be_shown = true;
  1029. force_ADNET_ads_to_be_shown = true;
  1030. mainActivity = activity;
  1031. pushAds(false, ad_unit_show_trigger, rainterstitialcallback);
  1032. return;
  1033. }
  1034. }
  1035.  
  1036. public static void showInterstitial(Activity activity, com.ironsource.mobilcore.MobileCore.AD_UNIT_SHOW_TRIGGER ad_unit_show_trigger, RAinterstitialCallback rainterstitialcallback)
  1037. {
  1038. if (!PreferenceSettings.is_donor_type.booleanValue() && System.currentTimeMillis() / 1000L < 5L + lastAdsActivityTS)
  1039. {
  1040. DebugLog.i("RA RAmanager", "showInterstitial skipped due to 5 seconds rpeat delay rule.");
  1041. return;
  1042. }
  1043. if (activity == null || activity.isFinishing())
  1044. {
  1045. throw new Error("Can not show interstitial for undefined or finishing activity!");
  1046. } else
  1047. {
  1048. force_ads_to_be_shown = true;
  1049. force_ADNET_ads_to_be_shown = false;
  1050. mainActivity = activity;
  1051. pushAds(false, ad_unit_show_trigger, rainterstitialcallback);
  1052. return;
  1053. }
  1054. }
  1055.  
  1056. public static void showRateUsPage()
  1057. {
  1058. Object obj = mainActivity;
  1059. if (obj == null)
  1060. {
  1061. obj = PreferenceSettings.mainContext;
  1062. }
  1063. if (obj == null)
  1064. {
  1065. return;
  1066. }
  1067. try
  1068. {
  1069. ((Context) (obj)).startActivity(new Intent("android.intent.action.VIEW", Uri.parse((new StringBuilder("market://details?id=")).append(PreferenceSettings.package_name).toString())));
  1070. return;
  1071. }
  1072. catch (ActivityNotFoundException activitynotfoundexception)
  1073. {
  1074. ((Context) (obj)).startActivity(new Intent("android.intent.action.VIEW", Uri.parse((new StringBuilder("http://play.google.com/store/apps/details?id=")).append(PreferenceSettings.package_name).toString())));
  1075. }
  1076. }
  1077.  
  1078. private static void updateRAconfig(boolean flag)
  1079. {
  1080. if (PreferenceSettings.is_google_mode.booleanValue() && !PreferenceSettings.DEBUG_IGNORE_CACHE_ON_START)
  1081. {
  1082. return;
  1083. }
  1084. DebugLog.linkMsg("RA RAmanager", "updateRAconfig...");
  1085. if (!PreferenceSettings.is_config_valid.booleanValue() || flag)
  1086. {
  1087. callRaUdateDataAPI(false, true);
  1088. return;
  1089. } else
  1090. {
  1091. DebugLog.linkMsg("RA RAmanager", "RAconfig is VALID (already)");
  1092. initializeAdNetworks();
  1093. return;
  1094. }
  1095. }
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement