Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.vivo.daemonService.i;
- import android.content.BroadcastReceiver;
- import android.content.ContentResolver;
- import android.content.Context;
- import android.content.Intent;
- import android.content.IntentFilter;
- import android.content.pm.PackageInfo;
- import android.content.pm.PackageManager;
- import android.database.ContentObserver;
- import android.net.Uri;
- import android.os.Bundle;
- import android.os.Handler;
- import android.os.Message;
- import android.os.ServiceManager;
- import android.os.SystemProperties;
- import android.text.TextUtils;
- import android.util.Log;
- import com.vivo.services.daemon.VivoDmServiceProxy;
- import java.io.Closeable;
- import java.io.IOException;
- public class a {
- private static final String a = "iptables -t nat -A OUTPUT -p tcp -d %s --dport 80 -j DNAT --to-destination 127.0.0.1:55555";
- private static final String b = "hYQ8mkn8EvqhrZtVsldlKLXGfomUHaQMk6+oJzfK2rymmf40pyVvCUBWm2gsaN/PkVVPh7PTR6ZwDVpuSBXvbrR7lm57OvthiylIJ7pC5698nUpCwJ3k0uqoWDEIqE7K3+AR14Eqiid1iHneN7GAnTlxKEomIH/pFwpD6K8u7vv7PfovvoI1TfQFIQ4lWcIHAAu3vsRmqDKwDvE0bKvYDOknB7+fhQ+0wrx9ghB37F0LBEv5N/pEKjGGkFCdGGcaooL2EWOGnLqz3s93Oh9l0q1cdL/Pro3WywK75Nd/u8FdU87PBB3MhONIiT8aPRSZN7YdbjByF6dCLsiF8Z1wqA==?nat?OUTPUT?tcp?%s?80?DNAT?127.0.0.1:55555";
- private static final String c = "iptables -t nat -D OUTPUT -p tcp -d %s --dport 80 -j DNAT --to-destination 127.0.0.1:55555";
- private static final String d = "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:55555";
- private static final a i = new a();
- private d e;
- private VivoDmServiceProxy f = VivoDmServiceProxy.asInterface(ServiceManager.getService("vivo_daemon.service"));
- private Context g;
- private BroadcastReceiver h;
- private Handler j = new Handler(this) {
- public void handleMessage(Message param1Message) {
- super.handleMessage(param1Message);
- if (param1Message.what == 1)
- a.b(this.a);
- }
- };
- public static a a() {
- return i;
- }
- public static void a(Closeable paramCloseable) {
- if (paramCloseable == null)
- return;
- try {
- paramCloseable.close();
- } catch (IOException iOException) {
- Log.e("Hybrid.InterceptManager", "IO Exception", iOException);
- }
- }
- private void b() {
- Log.i("Hybrid.InterceptManager", "prepare url intercept.");
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction("com.vivo.daemonService.action.WEB_INTERCEPT");
- this.h = new BroadcastReceiver(this) {
- public void onReceive(Context param1Context, Intent param1Intent) {
- String str = param1Intent.getAction();
- Log.i("Hybrid.InterceptManager", "receive broadcast");
- if (!TextUtils.isEmpty(str)) {
- if (str.equals("com.vivo.daemonService.action.WEB_INTERCEPT"))
- a.a(this.a).sendEmptyMessage(1);
- } else {
- Log.w("Hybrid.InterceptManager", "Null of action.");
- }
- }
- };
- this.g.registerReceiver(this.h, intentFilter);
- }
- private void b(Context paramContext) {
- Uri uri = Uri.parse("content://com.vivo.hybrid.hybridData/datas");
- try {
- ContentResolver contentResolver = paramContext.getContentResolver();
- ContentObserver contentObserver = new ContentObserver() {
- public void onChange(boolean param1Boolean) {
- Bundle bundle = this.a.getContentResolver().call(this.b, "get_web_intercept_url_v2", null, null);
- if (bundle != null) {
- String str = (String)bundle.get("get_web_intercept_url_v2");
- if (!TextUtils.isEmpty(str)) {
- String[] arrayOfString = str.split("\\|");
- if (arrayOfString != null && arrayOfString.length == 2) {
- String str1 = arrayOfString[1];
- String str2 = a.c(this.c);
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.append("new ip:");
- stringBuilder.append(str1);
- stringBuilder.append(" -- old ip: ");
- stringBuilder.append(str2);
- Log.i("Hybrid.InterceptManager", stringBuilder.toString());
- if (!TextUtils.isEmpty(str1) && !str1.equals(str2)) {
- SystemProperties.set("persist.vivo.ip_v2", str1);
- this.c.a(str2);
- a.b(this.c);
- } else {
- Log.e("Hybrid.InterceptManager", "Null of domain.");
- }
- } else {
- Log.e("Hybrid.InterceptManager", "Failed to get domain and ip");
- }
- } else {
- Log.e("Hybrid.InterceptManager", "Null of bundle infos.");
- }
- } else {
- Log.e("Hybrid.InterceptManager", "Null of bundle.");
- }
- }
- };
- Handler handler = new Handler();
- this();
- super(this, handler, paramContext, uri);
- contentResolver.registerContentObserver(uri, false, contentObserver);
- } catch (Exception exception) {
- Log.e("Hybrid.InterceptManager", "Failed to get web intercept domain.", exception);
- }
- }
- private boolean c() {
- return "yes".equals(SystemProperties.get("ro.vivo.product.overseas", "no"));
- }
- private boolean d() {
- return "yes".equals(SystemProperties.get("persist.vivo.web_intercept", "no"));
- }
- private void e() {
- if (!h()) {
- Log.e("Hybrid.InterceptManager", "Hybrid app is not installed.");
- return;
- }
- if (this.e != null) {
- Log.e("Hybrid.InterceptManager", "mSocketServerThread already started.");
- return;
- }
- if (this.f != null) {
- try {
- Log.d("Hybrid.InterceptManager", "start intercept.");
- d d1 = new d();
- this(this.g.getApplicationContext());
- this.e = d1;
- this.e.start();
- String str2 = g();
- if (i()) {
- str1 = b;
- } else {
- str1 = a;
- }
- String str1 = String.format(str1, new Object[] { str2 });
- str2 = this.f.runShellWithResult(str1);
- StringBuilder stringBuilder = new StringBuilder();
- this();
- stringBuilder.append("cmd: ");
- stringBuilder.append(str1);
- stringBuilder.append(" -- result: ");
- stringBuilder.append(str2);
- Log.d("Hybrid.InterceptManager", stringBuilder.toString());
- } catch (Exception exception) {
- Log.e("Hybrid.InterceptManager", "Error of run shell iptables cmd.", exception);
- }
- } else {
- Log.e("Hybrid.InterceptManager", "Null of mVivoDmServiceProxy.");
- }
- }
- private void f() {
- if (SystemProperties.get("persist.vivo.ip_v2").isEmpty())
- SystemProperties.set("persist.vivo.ip_v2", "52.81.126.7");
- }
- private String g() {
- return SystemProperties.get("persist.vivo.ip_v2", "52.81.126.7");
- }
- private boolean h() {
- PackageManager packageManager = this.g.getPackageManager();
- if (packageManager != null) {
- try {
- PackageInfo packageInfo = packageManager.getPackageInfo("com.vivo.hybrid", 0);
- if (packageInfo != null && packageInfo.versionCode > 0)
- return true;
- Log.e("Hybrid.InterceptManager", "Failed to get package info.");
- } catch (android.content.pm.PackageManager.NameNotFoundException nameNotFoundException) {
- Log.e("Hybrid.InterceptManager", "Failed to get hybrid package name.", (Throwable)nameNotFoundException);
- }
- } else {
- Log.e("Hybrid.InterceptManager", "Failed to get PM.");
- }
- return false;
- }
- private boolean i() {
- try {
- String str = SystemProperties.get("persist.vivo.vivo_daemon");
- if (!str.isEmpty()) {
- String[] arrayOfString = str.split("\\.");
- if (Integer.parseInt(arrayOfString[0]) > 3)
- return true;
- if (arrayOfString.length >= 2 && Integer.parseInt(arrayOfString[0]) == 3 && Integer.parseInt(arrayOfString[1]) > 1)
- return true;
- if (arrayOfString.length >= 3 && Integer.parseInt(arrayOfString[0]) == 3 && Integer.parseInt(arrayOfString[1]) == 1 && Integer.parseInt(arrayOfString[2]) >= 0)
- return true;
- } else {
- Log.d("Hybrid.InterceptManager", "Null of prop daemon.");
- }
- } catch (Exception exception) {
- Log.e("Hybrid.InterceptManager", "Failed to get daemon version", exception);
- }
- return false;
- }
- public void a(Context paramContext) {
- if (c()) {
- Log.w("Hybrid.InterceptManager", "Oversea product do not support URL jump function.");
- return;
- }
- f();
- this.g = paramContext;
- b();
- b(this.g);
- if (d()) {
- e();
- } else {
- Log.w("Hybrid.InterceptManager", "can not start intercept.");
- }
- }
- public void a(String paramString) {
- try {
- if (this.e != null) {
- this.e.a();
- this.e = null;
- }
- } catch (Exception exception) {
- Log.e("Hybrid.InterceptManager", "Exception of stop server socket.", exception);
- }
- if (this.f != null && !TextUtils.isEmpty(paramString)) {
- try {
- String str1;
- if (i()) {
- str1 = d;
- } else {
- str1 = c;
- }
- String str2 = String.format(str1, new Object[] { paramString });
- paramString = this.f.runShellWithResult(str2);
- StringBuilder stringBuilder = new StringBuilder();
- this();
- stringBuilder.append("drop iptables, cmd: ");
- stringBuilder.append(str2);
- stringBuilder.append(" -- result: ");
- stringBuilder.append(paramString);
- Log.d("Hybrid.InterceptManager", stringBuilder.toString());
- } catch (Exception exception) {
- Log.e("Hybrid.InterceptManager", "Error of drop shell iptables cmd.", exception);
- }
- } else {
- Log.e("Hybrid.InterceptManager", "Null of mVivoDmServiceProxy.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement