360手机助手 v3.3.0版本的 MD5 值为:127c345ad16bbebee6e347381328afd0

以下内容为反编译后的 CaptureActivity.java 源代码,内容仅作参考


package com.qihoo.appstore.zxing;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.AnimationDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.qihoo.appstore.AppStoreApplication;
import com.qihoo.appstore.activities.AppInfoActivity;
import com.qihoo.appstore.activities.MainActivity;
import com.qihoo.appstore.activities.PopluarizeActivity;
import com.qihoo.appstore.resource.app.App;
import com.qihoo.appstore.utils.bk;
import com.qihoo.appstore.utils.de;
import com.qihoo.freewifi.push.R;
import com.qihoo.speedometer.Config;
import com.qihoo360.mobilesafe.util.aj;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONObject;

public final class CaptureActivity extends Activity implements SurfaceHolder.Callback {
    private static final Pattern s = Pattern.compile("mid=([A-Za-z0-9]+)&type=([0-9]+)(&ver=([0-9]+))*(&pcver=([0-9]+))*", 42);

    public LinearLayout f4078a;

    public LinearLayout f4079b;
    private com.qihoo.appstore.zxing.a.f c;
    private p d;
    private boolean e;
    private Collection f;
    private String g;
    private a h;
    private TextView i;
    private ImageView j;
    private AnimationDrawable o;
    private ViewfinderView q;
    private View r;
    private String t;
    private final int k = -1;
    private final int l = 0;
    private final int m = 1;
    private final int n = 2;
    private final Handler p = new b(this);
    private final String u = "DYGAME:";

    private void a(Bitmap bitmap, com.google.a.m mVar) {
        com.google.a.o[] b2 = mVar.b();
        if (b2 == null || b2.length <= 0) {
            return;
        }
        Canvas canvas = new Canvas(bitmap);
        Paint paint = new Paint();
        paint.setColor(getResources().getColor(R.color.result_image_border));
        paint.setStrokeWidth(3.0f);
        paint.setStyle(Paint.Style.STROKE);
        canvas.drawRect(new Rect(2, 2, bitmap.getWidth() - 2, bitmap.getHeight() - 2), paint);
        paint.setColor(getResources().getColor(R.color.result_points));
        if (b2.length == 2) {
            paint.setStrokeWidth(4.0f);
            a(canvas, paint, b2[0], b2[1]);
            return;
        }
        if (b2.length == 4 && (mVar.c() == com.google.a.a.UPC_A || mVar.c() == com.google.a.a.EAN_13)) {
            a(canvas, paint, b2[0], b2[1]);
            a(canvas, paint, b2[2], b2[3]);
            return;
        }
        paint.setStrokeWidth(10.0f);
        for (com.google.a.o oVar : b2) {
            canvas.drawPoint(oVar.a(), oVar.b(), paint);
        }
    }

    private static void a(Canvas canvas, Paint paint, com.google.a.o oVar, com.google.a.o oVar2) {
        canvas.drawLine(oVar.a(), oVar.b(), oVar2.a(), oVar2.b(), paint);
    }

    private void a(SurfaceHolder surfaceHolder) {
        if (surfaceHolder == null) {
            throw new IllegalStateException("No SurfaceHolder provided");
        }
        if (this.c.a()) {
            bk.d("CaptureActivity", "initCamera() while already open -- late SurfaceView callback?");
            return;
        }
        try {
            this.c.a(surfaceHolder);
            if (this.d == null) {
                this.d = new p(this, this.f, this.g, this.c);
            }
        } catch (IOException e) {
            bk.d("CaptureActivity", "IOException", e);
            e();
        } catch (RuntimeException e2) {
            bk.c("CaptureActivity", "Unexpected error initializing camera", e2);
            e();
        }
    }

    private void a(com.google.a.m mVar, com.qihoo.appstore.zxing.c.b bVar, Bitmap bitmap) {
        String str;
        int i;
        this.t = bVar.b().toString().trim();
        bk.c("CaptureActivity", "handleDecodeInternally.mBarcodeContent = " + this.t);
        if (c(this.t)) {
            return;
        }
        Matcher matcher = s.matcher(this.t);
        if (matcher.find()) {
            str = matcher.group(1);
            try {
                if (matcher.group(6) != null) {
                    Integer.parseInt(matcher.group(6));
                }
            } catch (Exception e) {
            }
            if (com.qihoo360.mobilesafe.a.a.f5313a) {
                bk.b("CaptureActivity", "cid:" + str);
            }
            if (matcher.group(4) != null) {
                try {
                    i = Integer.parseInt(matcher.group(4));
                } catch (Exception e2) {
                    i = 0;
                }
            } else {
                i = 0;
            }
        } else {
            str = null;
            i = 0;
        }
        try {
            if (de.a(i, getPackageManager().getPackageInfo(getPackageName(), 0).versionCode)) {
                new AlertDialog.Builder(this).setTitle(R.string.version_too_low_for_scan_title).setMessage(R.string.version_too_low_for_scan_content).setPositiveButton(R.string.scan_update_dialog, new i(this)).create().show();
                return;
            }
        } catch (Exception e3) {
        }
        if (str != null) {
            if (!com.qihoo.express.mini.c.i.b()) {
                a(false);
                return;
            }
            a(true);
            startActivity(new Intent(this, (Class<?>) MainActivity.class).setAction("ACTION_PC_LINK_FOR_QR").setData(Uri.parse(this.t)));
            this.p.sendEmptyMessageDelayed(2, 500L);
            return;
        }
        if (d(this.t)) {
            finish();
            return;
        }
        if (com.qihoo360.mobilesafe.a.a.f5313a && this.t.startsWith("dltest")) {
            new AlertDialog.Builder(this).setTitle(R.string.scan_result).setMessage(getString(R.string.found_apk_url) + this.t + getString(R.string.if_down)).setPositiveButton(R.string.download_scan_result, new k(this)).setNegativeButton(R.string.dialog_cancel, new j(this)).create().show();
            return;
        }
        if (this.t.startsWith("http://") || this.t.startsWith("https://")) {
            if (this.t.toLowerCase().endsWith(".apk")) {
                new AlertDialog.Builder(this).setTitle(R.string.scan_result).setMessage(getString(R.string.found_apk_url) + this.t + getString(R.string.if_down)).setPositiveButton(R.string.download_scan_result, new m(this)).setNegativeButton(R.string.dialog_cancel, new l(this)).create().show();
                return;
            }
            if (!aj.k(this.t) || !this.t.contains("360appstore=1")) {
                new AlertDialog.Builder(this).setTitle(R.string.scan_result).setMessage(getString(R.string.found_url) + this.t + "," + getString(R.string.is_open_url)).setPositiveButton(R.string.dialog_ok, new o(this)).setNegativeButton(R.string.dialog_cancel, new n(this)).create().show();
                return;
            }
            Intent intent = new Intent(this, (Class<?>) PopluarizeActivity.class);
            intent.putExtra("detail_url", this.t);
            MainActivity.e().b(intent);
            finish();
            return;
        }
        if (this.t.startsWith("qvod:")) {
            new AlertDialog.Builder(this).setTitle(R.string.scan_result).setMessage(getString(R.string.found_qvod_url) + this.t + getString(R.string.if_open_2_watch_video)).setPositiveButton(getString(R.string.yes), new d(this)).setNegativeButton(R.string.dialog_cancel, new c(this)).create().show();
            return;
        }
        if (this.t.startsWith("market:")) {
            try {
                String queryParameter = Uri.parse(this.t).getQueryParameter("id");
                if (TextUtils.isEmpty(queryParameter)) {
                    String queryParameter2 = Uri.parse(this.t).getQueryParameter("q");
                    if (queryParameter2.startsWith("pname:")) {
                        try {
                            queryParameter = queryParameter2.split(":")[1];
                        } catch (Exception e4) {
                        }
                    }
                }
                if (!TextUtils.isEmpty(queryParameter)) {
                    Intent intent2 = new Intent(this, (Class<?>) AppInfoActivity.class);
                    Bundle bundle = new Bundle();
                    bundle.putString("search_content", queryParameter);
                    bundle.putInt("Index", 7);
                    App app = new App();
                    app.m(queryParameter);
                    bundle.putParcelable("com.qihoo.appstore.App", app);
                    intent2.putExtras(bundle);
                    MainActivity.e().b(intent2);
                    finish();
                    return;
                }
            } catch (Exception e5) {
            }
        }
        new AlertDialog.Builder(this).setTitle(R.string.scan_result).setMessage(getString(R.string.found_such_content) + this.t).setPositiveButton(R.string.cancle, new g(this)).setNegativeButton(R.string.copy, new f(this)).create().show();
    }

    private void a(String str) {
        b("SM");
        Intent intent = new Intent(this, (Class<?>) MainActivity.class);
        intent.putExtra("scanResult", str);
        intent.setAction("com.qihoo.appstore.startShareNearby");
        startActivity(intent);
        finish();
    }

    private void a(boolean z) {
        if (z) {
            this.r.setVisibility(8);
            this.q.a(true);
        } else {
            this.r.setVisibility(0);
            this.q.a(false);
        }
    }

    private void b(String str) {
        com.qihoo.appstore.r.a.a(str, 1);
    }

    private boolean c(String str) {
        try {
            if (str.startsWith("http://mapp.360.cn/e?info=") || str.startsWith("http://mapp.360.cn/d?info=")) {
                str = Uri.parse(str).getQueryParameter("lllfx");
                if (!TextUtils.isEmpty(str)) {
                    str = URLDecoder.decode(str, "UTF-8");
                }
                if (com.qihoo360.mobilesafe.a.a.f5313a) {
                    bk.b("liruifeng", "scanResult = " + str);
                }
            }
            JSONObject jSONObject = new JSONObject(str);
            boolean z = jSONObject.has("rs") && (jSONObject.has("ps") && (jSONObject.has("sd") && jSONObject.has("ip")));
            if (!z) {
                return z;
            }
            a(str);
            return z;
        } catch (Exception e) {
            return false;
        }
    }

    private boolean d(String str) {
        try {
            str = URLDecoder.decode(str, "UTF-8");
        } catch (Exception e) {
        }
        if (str.startsWith("DYGAME:")) {
            Intent intent = new Intent();
            intent.setClassName(MainActivity.e(), "com.dygame.Stage.Root");
            Bundle bundle = new Bundle();
            bundle.putString("QR_CODE", str);
            intent.putExtras(bundle);
            com.qihoo.appstore.plugin.b.h.a(MainActivity.e(), "com.dygame.mobile2lib", intent, R.string.load_dygame);
            return true;
        }
        if (!str.contains("DYGAME:")) {
            return false;
        }
        Intent intent2 = new Intent();
        intent2.setClassName(MainActivity.e(), "com.dygame.Stage.Root");
        String substring = str.substring(str.indexOf("DYGAME:"));
        Bundle bundle2 = new Bundle();
        bundle2.putString("QR_CODE", substring);
        intent2.putExtras(bundle2);
        com.qihoo.appstore.plugin.b.h.a(MainActivity.e(), "com.dygame.mobile2lib", intent2, R.string.load_dygame);
        return true;
    }

    private void e() {
        this.p.sendEmptyMessageDelayed(-1, 1800L);
    }

    public Handler a() {
        return this.d;
    }

    public void a(long j) {
        if (this.d != null) {
            this.d.sendEmptyMessageDelayed(R.id.restart_preview, j);
        }
    }

    public void a(com.google.a.m mVar, Bitmap bitmap) {
        com.qihoo.appstore.zxing.c.b a2 = com.qihoo.appstore.zxing.c.d.a(this, mVar);
        this.h.b();
        if (bitmap != null) {
            a(bitmap, mVar);
        }
        a(mVar, a2, bitmap);
    }

    public com.qihoo.appstore.zxing.a.f b() {
        return this.c;
    }

    public ViewfinderView c() {
        return this.q;
    }

    public void d() {
        this.q.a();
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (Build.VERSION.SDK_INT <= 7) {
            setRequestedOrientation(0);
        }
        getWindow().addFlags(128);
        setContentView(R.layout.capture);
        if (Build.VERSION.SDK_INT < 8) {
            findViewById(R.id.titleLayout).setBackgroundDrawable(null);
        }
        this.e = false;
        this.h = new a(this);
        PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        switch (i) {
            case 4:
                this.p.sendEmptyMessageDelayed(2, 500L);
                return true;
            case 24:
                this.c.a(true);
                return true;
            case 25:
                this.c.a(false);
                return true;
            case 27:
            case Config.DEFAULT_BATTERY_THRESH_PRECENT:
                return true;
            default:
                return super.onKeyDown(i, keyEvent);
        }
    }

    @Override
    protected void onPause() {
        try {
            if (this.d != null) {
                this.d.a();
                this.d = null;
            }
            this.c.b();
            if (!this.e) {
                ((SurfaceView) findViewById(R.id.preview_view)).getHolder().removeCallback(this);
            }
            this.q.c();
        } catch (Throwable th) {
        }
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
        this.i = (TextView) findViewById(R.id.tvPrompt);
        this.j = (ImageView) findViewById(R.id.ivCamera);
        this.f4078a = (LinearLayout) findViewById(R.id.openCameraLayout);
        this.f4079b = (LinearLayout) findViewById(R.id.error_reason_layout);
        this.q = (ViewfinderView) findViewById(R.id.viewfinder_view);
        this.c = new com.qihoo.appstore.zxing.a.f(AppStoreApplication.d());
        this.r = findViewById(R.id.textview_no_network);
        this.q.setCameraManager(this.c);
        this.p.sendEmptyMessage(0);
        d();
        ((Button) findViewById(R.id.left_btn)).setOnClickListener(new h(this));
        this.d = null;
        SurfaceHolder holder = ((SurfaceView) findViewById(R.id.preview_view)).getHolder();
        if (this.e) {
            a(holder);
        } else {
            holder.addCallback(this);
            holder.setType(3);
        }
        this.q.b();
        this.h.a();
        this.f = null;
        this.g = null;
        Intent intent = new Intent();
        intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
        this.f = r.a(intent);
        this.p.sendEmptyMessageDelayed(1, 800L);
    }

    @Override
    public void onWindowFocusChanged(boolean z) {
        super.onWindowFocusChanged(z);
        if (z) {
            a(500L);
        }
    }

    @Override
    public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i2, int i3) {
    }

    @Override
    public void surfaceCreated(SurfaceHolder surfaceHolder) {
        if (surfaceHolder == null) {
            bk.e("CaptureActivity", "*** WARNING *** surfaceCreated() gave us a null surface!");
        }
        if (this.e) {
            return;
        }
        this.e = true;
        a(surfaceHolder);
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
        this.e = false;
    }
}