Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.vivo.daemonService.pdd;
- import android.content.BroadcastReceiver;
- import android.content.ContentResolver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.database.Cursor;
- import android.net.Uri;
- import android.os.Handler;
- import android.os.HandlerThread;
- import android.os.Looper;
- import android.os.Message;
- import android.os.ServiceManager;
- import android.os.SystemProperties;
- import android.text.TextUtils;
- import android.util.Log;
- import com.vivo.daemonService.VivoDaemonServiceApp;
- import com.vivo.services.daemon.VivoDmServiceProxy;
- import java.io.ByteArrayInputStream;
- import java.io.Closeable;
- import libcore.io.IoUtils;
- import org.xmlpull.v1.XmlPullParser;
- import org.xmlpull.v1.XmlPullParserException;
- import org.xmlpull.v1.XmlPullParserFactory;
- public class PddConfigurationManager extends BroadcastReceiver {
- public static final boolean a = VivoDaemonServiceApp.a;
- 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";
- 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";
- 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";
- 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";
- VivoDmServiceProxy b = VivoDmServiceProxy.asInterface(ServiceManager.getService("vivo_daemon.service"));
- private Context c;
- private Handler d;
- private int e = 0;
- private c j;
- public PddConfigurationManager(Context paramContext) {
- this.c = paramContext;
- HandlerThread handlerThread = new HandlerThread("pdd_config_load");
- handlerThread.start();
- this.d = new a(this, handlerThread.getLooper());
- a();
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction("com.vivo.daemonService.unifiedconfig.update_finish_broadcast_pddhandle");
- intentFilter.addAction("android.intent.action.BOOT_COMPLETED");
- intentFilter.addAction("com.vivo.daemonService.action.PDD_WEB_INTERCEPT");
- this.c.registerReceiver(this, intentFilter);
- if (d())
- this.d.sendEmptyMessage(1002);
- }
- private void a() {
- if (SystemProperties.get("persist.vivo.pddweb_ip").isEmpty())
- SystemProperties.set("persist.vivo.pddweb_ip", "119.28.206.152");
- }
- private void a(Context paramContext) {
- if (this.j != null) {
- Log.i("PddConfigurationManager", "mSocketServerThread already");
- return;
- }
- try {
- if (this.b != null) {
- c c1 = new c();
- this(paramContext.getApplicationContext());
- this.j = c1;
- this.j.start();
- String str2 = b();
- if (e()) {
- str1 = g;
- } else {
- str1 = f;
- }
- String str1 = String.format(str1, new Object[] { str2 });
- str2 = this.b.runShellWithResult(str1);
- if (a) {
- StringBuilder stringBuilder = new StringBuilder();
- this();
- stringBuilder.append("cmd = ");
- stringBuilder.append(str1);
- stringBuilder.append(" result:");
- stringBuilder.append(str2);
- Log.d("PddConfigurationManager", stringBuilder.toString());
- }
- }
- } catch (Exception exception) {
- Log.e("PddConfigurationManager", "handleIntercept", exception);
- }
- }
- public static void a(Closeable paramCloseable) {
- if (paramCloseable == null)
- return;
- try {
- paramCloseable.close();
- } catch (Exception exception) {
- exception.printStackTrace();
- }
- }
- private void a(byte[] paramArrayOfbyte) {
- XmlPullParserException xmlPullParserException2;
- byte[] arrayOfByte1 = null;
- String str1 = null;
- String str2 = str1;
- try {
- XmlPullParser xmlPullParser = XmlPullParserFactory.newInstance().newPullParser();
- str2 = str1;
- ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream();
- str2 = str1;
- this(paramArrayOfbyte);
- } catch (XmlPullParserException|java.io.IOException null) {
- } finally {
- paramArrayOfbyte = null;
- }
- byte[] arrayOfByte2 = paramArrayOfbyte;
- Log.e("PddConfigurationManager", "XmlPullParserException", (Throwable)xmlPullParserException2);
- if (paramArrayOfbyte != null)
- paramArrayOfbyte.close();
- }
- private String b() {
- return SystemProperties.get("persist.vivo.pddweb_ip", "119.28.206.152");
- }
- private void c() {
- Cursor cursor3;
- this.e++;
- ContentResolver contentResolver = this.c.getContentResolver();
- Cursor cursor1 = null;
- Cursor cursor2 = null;
- try {
- Cursor cursor = contentResolver.query(Uri.parse("content://com.vivo.abe.unifiedconfig.provider/configs"), null, null, new String[] { "pddhandle", "1", "1.0" }, null);
- if (cursor != null) {
- cursor2 = cursor;
- cursor1 = cursor;
- cursor.moveToFirst();
- cursor2 = cursor;
- cursor1 = cursor;
- if (cursor.getCount() > 0) {
- while (true) {
- cursor2 = cursor;
- cursor1 = cursor;
- cursor3 = cursor;
- if (!cursor.isAfterLast()) {
- cursor2 = cursor;
- cursor1 = cursor;
- a(cursor.getBlob(3));
- cursor2 = cursor;
- cursor1 = cursor;
- cursor.moveToNext();
- continue;
- }
- break;
- }
- } else {
- cursor2 = cursor;
- cursor1 = cursor;
- if (a) {
- cursor2 = cursor;
- cursor1 = cursor;
- Log.d("PddConfigurationManager", "no data!");
- }
- cursor2 = cursor;
- cursor1 = cursor;
- a();
- cursor3 = cursor;
- }
- } else {
- cursor2 = cursor;
- cursor1 = cursor;
- if (a) {
- cursor2 = cursor;
- cursor1 = cursor;
- Log.d("PddConfigurationManager", "cursor is null, lock failed, continue checking for update!");
- }
- cursor2 = cursor;
- cursor1 = cursor;
- cursor3 = cursor;
- if (this.e < 4) {
- cursor2 = cursor;
- cursor1 = cursor;
- this.d.sendEmptyMessageDelayed(1001, 180000L);
- cursor3 = cursor;
- }
- }
- } catch (Exception exception) {
- cursor2 = cursor1;
- Log.e("PddConfigurationManager", "open database error! ", exception);
- cursor3 = cursor1;
- } finally {}
- IoUtils.closeQuietly((AutoCloseable)cursor3);
- }
- private boolean d() {
- boolean bool;
- String str = SystemProperties.get("persist.vivo.pdd_intercept");
- if (str.isEmpty())
- SystemProperties.set("persist.vivo.pdd_intercept", "no");
- if (!str.isEmpty() && str.equals("yes")) {
- bool = true;
- } else {
- bool = false;
- }
- return bool;
- }
- private boolean e() {
- String str = SystemProperties.get("persist.vivo.vivo_daemon");
- if (a) {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("daemon:");
- stringBuilder.append(str);
- Log.d("PddConfigurationManager", stringBuilder.toString());
- }
- if (!str.isEmpty())
- try {
- String[] arrayOfString = str.split("\\.");
- if (Integer.parseInt(arrayOfString[0]) > 3)
- return true;
- if (Integer.parseInt(arrayOfString[0]) == 3 && Integer.parseInt(arrayOfString[1]) > 1)
- return true;
- if (Integer.parseInt(arrayOfString[0]) == 3 && Integer.parseInt(arrayOfString[1]) == 1) {
- int i = Integer.parseInt(arrayOfString[2]);
- if (i >= 0)
- return true;
- }
- } catch (Exception exception) {
- Log.e("PddConfigurationManager", "isDaemonCoded", exception);
- }
- return false;
- }
- public void a(String paramString) {
- try {
- if (this.j != null) {
- this.j.a();
- this.j = null;
- }
- } catch (Exception exception) {
- Log.e("PddConfigurationManager", "Exception of stop server socket.", exception);
- }
- if (this.b != null && !TextUtils.isEmpty(paramString)) {
- try {
- if (e()) {
- str = i;
- } else {
- str = h;
- }
- String str = String.format(str, new Object[] { paramString });
- paramString = this.b.runShellWithResult(str);
- if (a) {
- StringBuilder stringBuilder = new StringBuilder();
- this();
- stringBuilder.append("drop iptables, cmd: ");
- stringBuilder.append(str);
- stringBuilder.append(" -- result: ");
- stringBuilder.append(paramString);
- Log.d("PddConfigurationManager", stringBuilder.toString());
- }
- } catch (Exception exception) {
- Log.e("PddConfigurationManager", "Error of drop shell iptables cmd.", exception);
- }
- } else {
- Log.e("PddConfigurationManager", "Null of mVivoDmServiceProxy.");
- }
- }
- public void onReceive(Context paramContext, Intent paramIntent) {
- if (a) {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("onReceive = ");
- stringBuilder.append(paramIntent.getAction());
- Log.d("PddConfigurationManager", stringBuilder.toString());
- }
- if ("com.vivo.daemonService.action.PDD_WEB_INTERCEPT".equals(paramIntent.getAction())) {
- this.d.sendEmptyMessage(1002);
- return;
- }
- this.e = 0;
- this.d.sendEmptyMessageDelayed(1001, 180000L);
- }
- private class a extends Handler {
- a(PddConfigurationManager this$0, Looper param1Looper) {
- super(param1Looper);
- }
- public void handleMessage(Message param1Message) {
- PddConfigurationManager pddConfigurationManager;
- switch (param1Message.what) {
- default:
- return;
- case 1002:
- pddConfigurationManager = this.a;
- PddConfigurationManager.a(pddConfigurationManager, PddConfigurationManager.b(pddConfigurationManager));
- case 1001:
- break;
- }
- PddConfigurationManager.a(this.a);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement