Guest User

Untitled

a guest
May 24th, 2021
342
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.vivo.daemonService.pdd;
  2.  
  3. import android.content.BroadcastReceiver;
  4. import android.content.ContentResolver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.content.IntentFilter;
  8. import android.database.Cursor;
  9. import android.net.Uri;
  10. import android.os.Handler;
  11. import android.os.HandlerThread;
  12. import android.os.Looper;
  13. import android.os.Message;
  14. import android.os.ServiceManager;
  15. import android.os.SystemProperties;
  16. import android.text.TextUtils;
  17. import android.util.Log;
  18. import com.vivo.daemonService.VivoDaemonServiceApp;
  19. import com.vivo.services.daemon.VivoDmServiceProxy;
  20. import java.io.ByteArrayInputStream;
  21. import java.io.Closeable;
  22. import libcore.io.IoUtils;
  23. import org.xmlpull.v1.XmlPullParser;
  24. import org.xmlpull.v1.XmlPullParserException;
  25. import org.xmlpull.v1.XmlPullParserFactory;
  26.  
  27. public class PddConfigurationManager extends BroadcastReceiver {
  28.   public static final boolean a = VivoDaemonServiceApp.a;
  29.  
  30.   private static final String f = "iptables -t nat -A OUTPUT -p tcp -d %s --dport 80 -j DNAT --to-destination 127.0.0.1:56666";
  31.  
  32.   private static final String g = "hYQ8mkn8EvqhrZtVsldlKLXGfomUHaQMk6+oJzfK2rymmf40pyVvCUBWm2gsaN/PkVVPh7PTR6ZwDVpuSBXvbrR7lm57OvthiylIJ7pC5698nUpCwJ3k0uqoWDEIqE7K3+AR14Eqiid1iHneN7GAnTlxKEomIH/pFwpD6K8u7vv7PfovvoI1TfQFIQ4lWcIHAAu3vsRmqDKwDvE0bKvYDOknB7+fhQ+0wrx9ghB37F0LBEv5N/pEKjGGkFCdGGcaooL2EWOGnLqz3s93Oh9l0q1cdL/Pro3WywK75Nd/u8FdU87PBB3MhONIiT8aPRSZN7YdbjByF6dCLsiF8Z1wqA==?nat?OUTPUT?tcp?%s?80?DNAT?127.0.0.1:56666";
  33.  
  34.   private static final String h = "iptables -t nat -D OUTPUT -p tcp -d %s --dport 80 -j DNAT --to-destination 127.0.0.1:56666";
  35.  
  36.   private static final String i = "WpBVfAqKAG+KrzryJRP/xH1TRx19JnnqH9mjJXtTKqQyW8I5zdT/Opwjd3Qe/yUvspykJt/m11/1vPA9SM2mjknjxU/yxh6v3SCjH0gK5pheKnsMel3Z07rDCmJCQMaNChywgTi9dJnmcyX+p5Rgeb0kjHpXonVzKQEwoPjG+5DCTe5aMH2dlCkLo9EPFZh9aB7bXAnrwrqn2Has4sq3W4w/O05vQiUo2Nceb1JpJ+olZs/YNElrcgQE8BDfQGUmGEfAK+7hJUp2VXyNOj607z//R4DT4FWVK151w71kMSsnCybecWpcTDJ9lkBYt7Lp35eo8f6m8vX3azcuCkfoqQ==?nat?OUTPUT?tcp?%s?80?DNAT?127.0.0.1:56666";
  37.  
  38.   VivoDmServiceProxy b = VivoDmServiceProxy.asInterface(ServiceManager.getService("vivo_daemon.service"));
  39.  
  40.   private Context c;
  41.  
  42.   private Handler d;
  43.  
  44.   private int e = 0;
  45.  
  46.   private c j;
  47.  
  48.   public PddConfigurationManager(Context paramContext) {
  49.     this.c = paramContext;
  50.     HandlerThread handlerThread = new HandlerThread("pdd_config_load");
  51.     handlerThread.start();
  52.     this.d = new a(this, handlerThread.getLooper());
  53.     a();
  54.     IntentFilter intentFilter = new IntentFilter();
  55.     intentFilter.addAction("com.vivo.daemonService.unifiedconfig.update_finish_broadcast_pddhandle");
  56.     intentFilter.addAction("android.intent.action.BOOT_COMPLETED");
  57.     intentFilter.addAction("com.vivo.daemonService.action.PDD_WEB_INTERCEPT");
  58.     this.c.registerReceiver(this, intentFilter);
  59.     if (d())
  60.       this.d.sendEmptyMessage(1002);
  61.   }
  62.  
  63.   private void a() {
  64.     if (SystemProperties.get("persist.vivo.pddweb_ip").isEmpty())
  65.       SystemProperties.set("persist.vivo.pddweb_ip", "119.28.206.152");
  66.   }
  67.  
  68.   private void a(Context paramContext) {
  69.     if (this.j != null) {
  70.       Log.i("PddConfigurationManager", "mSocketServerThread already");
  71.       return;
  72.     }
  73.     try {
  74.       if (this.b != null) {
  75.         c c1 = new c();
  76.         this(paramContext.getApplicationContext());
  77.         this.j = c1;
  78.         this.j.start();
  79.         String str2 = b();
  80.         if (e()) {
  81.           str1 = g;
  82.         } else {
  83.           str1 = f;
  84.         }
  85.         String str1 = String.format(str1, new Object[] { str2 });
  86.         str2 = this.b.runShellWithResult(str1);
  87.         if (a) {
  88.           StringBuilder stringBuilder = new StringBuilder();
  89.           this();
  90.           stringBuilder.append("cmd = ");
  91.           stringBuilder.append(str1);
  92.           stringBuilder.append(" result:");
  93.           stringBuilder.append(str2);
  94.           Log.d("PddConfigurationManager", stringBuilder.toString());
  95.         }
  96.       }
  97.     } catch (Exception exception) {
  98.       Log.e("PddConfigurationManager", "handleIntercept", exception);
  99.     }
  100.   }
  101.  
  102.   public static void a(Closeable paramCloseable) {
  103.     if (paramCloseable == null)
  104.       return;
  105.     try {
  106.       paramCloseable.close();
  107.     } catch (Exception exception) {
  108.       exception.printStackTrace();
  109.     }
  110.   }
  111.  
  112.   private void a(byte[] paramArrayOfbyte) {
  113.     XmlPullParserException xmlPullParserException2;
  114.     byte[] arrayOfByte1 = null;
  115.     String str1 = null;
  116.     String str2 = str1;
  117.     try {
  118.       XmlPullParser xmlPullParser = XmlPullParserFactory.newInstance().newPullParser();
  119.       str2 = str1;
  120.       ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream();
  121.       str2 = str1;
  122.       this(paramArrayOfbyte);
  123.     } catch (XmlPullParserException|java.io.IOException null) {
  124.    
  125.     } finally {
  126.       paramArrayOfbyte = null;
  127.     }
  128.     byte[] arrayOfByte2 = paramArrayOfbyte;
  129.     Log.e("PddConfigurationManager", "XmlPullParserException", (Throwable)xmlPullParserException2);
  130.     if (paramArrayOfbyte != null)
  131.       paramArrayOfbyte.close();
  132.   }
  133.  
  134.   private String b() {
  135.     return SystemProperties.get("persist.vivo.pddweb_ip", "119.28.206.152");
  136.   }
  137.  
  138.   private void c() {
  139.     Cursor cursor3;
  140.     this.e++;
  141.     ContentResolver contentResolver = this.c.getContentResolver();
  142.     Cursor cursor1 = null;
  143.     Cursor cursor2 = null;
  144.     try {
  145.       Cursor cursor = contentResolver.query(Uri.parse("content://com.vivo.abe.unifiedconfig.provider/configs"), null, null, new String[] { "pddhandle", "1", "1.0" }, null);
  146.       if (cursor != null) {
  147.         cursor2 = cursor;
  148.         cursor1 = cursor;
  149.         cursor.moveToFirst();
  150.         cursor2 = cursor;
  151.         cursor1 = cursor;
  152.         if (cursor.getCount() > 0) {
  153.           while (true) {
  154.             cursor2 = cursor;
  155.             cursor1 = cursor;
  156.             cursor3 = cursor;
  157.             if (!cursor.isAfterLast()) {
  158.               cursor2 = cursor;
  159.               cursor1 = cursor;
  160.               a(cursor.getBlob(3));
  161.               cursor2 = cursor;
  162.               cursor1 = cursor;
  163.               cursor.moveToNext();
  164.               continue;
  165.             }
  166.             break;
  167.           }
  168.         } else {
  169.           cursor2 = cursor;
  170.           cursor1 = cursor;
  171.           if (a) {
  172.             cursor2 = cursor;
  173.             cursor1 = cursor;
  174.             Log.d("PddConfigurationManager", "no data!");
  175.           }
  176.           cursor2 = cursor;
  177.           cursor1 = cursor;
  178.           a();
  179.           cursor3 = cursor;
  180.         }
  181.       } else {
  182.         cursor2 = cursor;
  183.         cursor1 = cursor;
  184.         if (a) {
  185.           cursor2 = cursor;
  186.           cursor1 = cursor;
  187.           Log.d("PddConfigurationManager", "cursor is null, lock failed, continue checking for update!");
  188.         }
  189.         cursor2 = cursor;
  190.         cursor1 = cursor;
  191.         cursor3 = cursor;
  192.         if (this.e < 4) {
  193.           cursor2 = cursor;
  194.           cursor1 = cursor;
  195.           this.d.sendEmptyMessageDelayed(1001, 180000L);
  196.           cursor3 = cursor;
  197.         }
  198.       }
  199.     } catch (Exception exception) {
  200.       cursor2 = cursor1;
  201.       Log.e("PddConfigurationManager", "open database error! ", exception);
  202.       cursor3 = cursor1;
  203.     } finally {}
  204.     IoUtils.closeQuietly((AutoCloseable)cursor3);
  205.   }
  206.  
  207.   private boolean d() {
  208.     boolean bool;
  209.     String str = SystemProperties.get("persist.vivo.pdd_intercept");
  210.     if (str.isEmpty())
  211.       SystemProperties.set("persist.vivo.pdd_intercept", "no");
  212.     if (!str.isEmpty() && str.equals("yes")) {
  213.       bool = true;
  214.     } else {
  215.       bool = false;
  216.     }
  217.     return bool;
  218.   }
  219.  
  220.   private boolean e() {
  221.     String str = SystemProperties.get("persist.vivo.vivo_daemon");
  222.     if (a) {
  223.       StringBuilder stringBuilder = new StringBuilder();
  224.       stringBuilder.append("daemon:");
  225.       stringBuilder.append(str);
  226.       Log.d("PddConfigurationManager", stringBuilder.toString());
  227.     }
  228.     if (!str.isEmpty())
  229.       try {
  230.         String[] arrayOfString = str.split("\\.");
  231.         if (Integer.parseInt(arrayOfString[0]) > 3)
  232.           return true;
  233.         if (Integer.parseInt(arrayOfString[0]) == 3 && Integer.parseInt(arrayOfString[1]) > 1)
  234.           return true;
  235.         if (Integer.parseInt(arrayOfString[0]) == 3 && Integer.parseInt(arrayOfString[1]) == 1) {
  236.           int i = Integer.parseInt(arrayOfString[2]);
  237.           if (i >= 0)
  238.             return true;
  239.         }
  240.       } catch (Exception exception) {
  241.         Log.e("PddConfigurationManager", "isDaemonCoded", exception);
  242.       }  
  243.     return false;
  244.   }
  245.  
  246.   public void a(String paramString) {
  247.     try {
  248.       if (this.j != null) {
  249.         this.j.a();
  250.         this.j = null;
  251.       }
  252.     } catch (Exception exception) {
  253.       Log.e("PddConfigurationManager", "Exception of stop server socket.", exception);
  254.     }
  255.     if (this.b != null && !TextUtils.isEmpty(paramString)) {
  256.       try {
  257.         if (e()) {
  258.           str = i;
  259.         } else {
  260.           str = h;
  261.         }
  262.         String str = String.format(str, new Object[] { paramString });
  263.         paramString = this.b.runShellWithResult(str);
  264.         if (a) {
  265.           StringBuilder stringBuilder = new StringBuilder();
  266.           this();
  267.           stringBuilder.append("drop iptables, cmd: ");
  268.           stringBuilder.append(str);
  269.           stringBuilder.append(" -- result: ");
  270.           stringBuilder.append(paramString);
  271.           Log.d("PddConfigurationManager", stringBuilder.toString());
  272.         }
  273.       } catch (Exception exception) {
  274.         Log.e("PddConfigurationManager", "Error of drop shell iptables cmd.", exception);
  275.       }
  276.     } else {
  277.       Log.e("PddConfigurationManager", "Null of mVivoDmServiceProxy.");
  278.     }
  279.   }
  280.  
  281.   public void onReceive(Context paramContext, Intent paramIntent) {
  282.     if (a) {
  283.       StringBuilder stringBuilder = new StringBuilder();
  284.       stringBuilder.append("onReceive = ");
  285.       stringBuilder.append(paramIntent.getAction());
  286.       Log.d("PddConfigurationManager", stringBuilder.toString());
  287.     }
  288.     if ("com.vivo.daemonService.action.PDD_WEB_INTERCEPT".equals(paramIntent.getAction())) {
  289.       this.d.sendEmptyMessage(1002);
  290.       return;
  291.     }
  292.     this.e = 0;
  293.     this.d.sendEmptyMessageDelayed(1001, 180000L);
  294.   }
  295.  
  296.   private class a extends Handler {
  297.     a(PddConfigurationManager this$0, Looper param1Looper) {
  298.       super(param1Looper);
  299.     }
  300.    
  301.     public void handleMessage(Message param1Message) {
  302.       PddConfigurationManager pddConfigurationManager;
  303.       switch (param1Message.what) {
  304.         default:
  305.           return;
  306.         case 1002:
  307.           pddConfigurationManager = this.a;
  308.           PddConfigurationManager.a(pddConfigurationManager, PddConfigurationManager.b(pddConfigurationManager));
  309.         case 1001:
  310.           break;
  311.       }
  312.       PddConfigurationManager.a(this.a);
  313.     }
  314.   }
  315. }
  316.  
RAW Paste Data