/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  javax.microedition.lcdui.Display
 *  javax.microedition.lcdui.Displayable
 *  javax.microedition.midlet.MIDlet
 */
package com.google.googlenav;

import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;

public class GoogleNav
extends MIDlet
implements Runnable,
ey {
    private static volatile long i;
    private final Object h = new Object();
    private final Object l = new Object();
    private kh a;
    private gd b;
    private hj c;
    private lh d;
    private boolean e = false;
    private boolean f = false;
    private int g = 0;
    private oo k;
    private String m;
    private String n;

    public void destroyApp(boolean bl2) {
        this.a(true);
    }

    public final void a(String string) {
        this.e(string);
    }

    public final void d() {
        this.f = true;
        this.b(true);
    }

    public final void a() {
        this.b(true);
    }

    public final void c() {
        this.a.a();
    }

    public void pauseApp() {
        if (this.b != null) {
            this.b.t();
        }
    }

    private void b(boolean bl2) {
        this.a(bl2);
        if (bl2) {
            this.notifyDestroyed();
        }
    }

    public final synchronized String b() {
        if (this.n == null) {
            this.n = lh.k().a("PlatformID");
            if (ed.b(this.n)) {
                this.n = System.getProperty("microedition.platform");
            }
            if (ed.b(this.n)) {
                this.n = "Generic-Advanced MIDP2";
            }
            if (this.n.equals("Sony_Ericsson-photomap")) {
                String string = this.n = System.getProperty("microedition.profile");
                int n = string.indexOf("SonyEricsson");
                int n2 = string.indexOf("/");
                if (n > -1 && n2 > -1) {
                    string = "Sony_Ericsson-" + string.substring(n + 12, n2);
                }
                this.n = string;
            }
        }
        return this.n;
    }

    private void e(String string) {
        try {
            if (string.startsWith("tel:")) {
                string.substring("tel:".length());
            }
            if (this.platformRequest(string)) {
                if (this.k == null) {
                    this.b(true);
                    return;
                }
                this.g = 2;
                new Thread(this).start();
                this.b(false);
                return;
            }
            this.k = null;
            return;
        }
        catch (Exception exception) {
            me.a("Platform Request", exception);
            return;
        }
    }

    public final void c(String string) {
        boolean bl2 = false;
        if (!string.startsWith("tel:")) {
            if (string.startsWith("http")) {
                bl2 = this.b.a((short)32);
            }
        } else {
            bl2 = this.b.a((short)30);
        }
        if (bl2) {
            this.k = me.a(true, this.l);
            this.g = 1;
            this.m = string;
            new Thread(this).start();
            return;
        }
        this.e(string);
    }

    public void startApp() {
        if (!this.e) {
            this.e = true;
            i = System.currentTimeMillis();
            lh.a(this);
            lh.k().d();
            gu.c(new gu(false, false, false, false));
            this.a = new kh();
            Display.getDisplay((MIDlet)this).setCurrent((Displayable)this.a);
            Thread thread = new Thread(this);
            thread.setPriority(Math.min(2, 5));
            thread.start();
            return;
        }
        if (this.b != null) {
            this.b.u();
        }
    }

    /*
     * Unable to fully structure code
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    private void a(boolean var1_1) {
        var3_2 = this.h;
        synchronized (var3_2) {
            if (this.b == null) lbl-1000:
            // 2 sources

            {
                while (true) {
                    if (ck.e() == null) return;
                    if (var1_1 == false) return;
                    ck.e().s();
                    ck.ad();
                    return;
                }
            }
            try {
                var7_5 = this.b;
                var6_6 = this.f == false;
            }
            catch (Throwable var4_3) {}
            this.d = null;
            this.b = null;
            throw var4_3;
            var7_5.b(var6_6);
            if (this.d != null) {
                this.d.g();
            }
            if ((var5_7 = ck.e()) != null) {
                v0 = gu.c();
                v0.f(var5_7.s);
                v0.b(var5_7.i);
            }
            var2_8 = lh.k().f();
            if (this.f) {
                var2_8.c("");
                var2_8.a();
                var2_8.h();
            } else {
                gu.ad();
                var2_8.h();
            }
            this.d = null;
            this.b = null;
            ** continue;
        }
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     * Converted monitor instructions to comments
     * Lifted jumps to return sites
     */
    public void run() {
        int n;
        block39: {
            block38: {
                block33: {
                    block34: {
                        block32: {
                            if (this.g == 0) break block32;
                            n = this.g;
                            Object object = this.l;
                            // MONITORENTER : object
                            if (n != 1) break block33;
                            break block34;
                        }
                        try {
                            gu gu2;
                            jf jf2;
                            ck ck2;
                            int n2;
                            String string;
                            block35: {
                                block36: {
                                    block37: {
                                        this.c();
                                        lh lh2 = lh.k();
                                        string = lh2.a("HelpTags");
                                        if (string == null) {
                                            string = "";
                                        }
                                        if (!gu.w()) {
                                            string = string + ",NO_DRIVING_DIRECTIONS";
                                        }
                                        if (!gu.o()) {
                                            string = string + ",NO_SATELLITE";
                                        }
                                        if (lh.t()) {
                                            string = string + ",TOUCHSCREEN";
                                        }
                                        if (!gu.r()) {
                                            if (!string.startsWith("TRAFFIC")) {
                                                n2 = string.indexOf(",TRAFFIC");
                                                if (n2 >= 0) {
                                                    string = string.substring(0, n2) + string.substring(n2 + 8);
                                                }
                                            } else {
                                                string = string.substring(7);
                                            }
                                        }
                                        string = string + ",FRIENDS";
                                        this.c();
                                        ck2 = ck.a(gu.g().x(), this.b(), lh2.a(), lh.p());
                                        ck2.u();
                                        if (lh.r()) {
                                            ck2.a("cn", "true");
                                        }
                                        ck2.a("gzip", "true");
                                        if (lh.t()) {
                                            ck2.a("touchscreen", "true");
                                        }
                                        ck2.p();
                                        jf2 = null;
                                        me.a(false, null);
                                        me.a((short)11);
                                        gu2 = gu.g();
                                        if (!je.p()) break block35;
                                        if (this.b().startsWith("Sony_Ericsson")) break block36;
                                        if (this.b().startsWith("Motorola")) break block37;
                                        if (!this.b().startsWith("Samsung")) {
                                            if (this.b().startsWith("LG")) {
                                                jf2 = new px(false, false);
                                            }
                                            break block35;
                                        } else {
                                            jf2 = new iu();
                                        }
                                        break block35;
                                    }
                                    jf2 = new bq(false, false);
                                    break block35;
                                }
                                jf2 = new gu(false, false, false, false, false, false, false, false, false, false, false, false);
                            }
                            ej.a(jf2);
                            this.d = new lh(je.p(), gu2.i());
                            this.d.f();
                            cw.a(this.d);
                            ck2 = new ck(-1, -1, 0x400000, gu.b(), gu.d(), 400);
                            this.c();
                            this.c = new hj(this);
                            ap ap2 = new ap(this.c.getHeight());
                            lh.k().d = new mg(ap2);
                            if (gu2.h()) {
                                gu2.s();
                            }
                            n2 = gd.l() + 1;
                            ps.a(new ps(0, 0, n2));
                            this.c();
                            ap2.a = ps.a().k;
                            this.b = new gd(this, ck2, this.d, this.c, string, new lh(), new jt(false, false, false));
                            this.c.a(this.b);
                            this.b.f();
                            this.c();
                            ck2.a(this.b);
                            a.c(-1, -4860423);
                            this.b.x();
                            this.a = null;
                            Display.getDisplay((MIDlet)this).setCurrent((Displayable)this.c);
                            gu2 = new gu(this.b);
                            while (this.b != null && !this.b.h()) {
                                try {
                                    Thread.sleep(200);
                                }
                                catch (InterruptedException interruptedException) {}
                            }
                            if (this.b == null) return;
                            if (!gu2.b) {
                                this.b.g();
                            }
                            gu.c(gu2.d);
                            me.a((short)22, "guis", "" + (System.currentTimeMillis() - i));
                            gu.g().t();
                            return;
                        }
                        catch (RuntimeException runtimeException) {
                            this.a.a(runtimeException);
                            me.a("GNav", runtimeException);
                            aa aa2 = lh.k().f();
                            if (aa2 == null) return;
                            aa2.c("");
                            return;
                        }
                    }
                    if (!this.k.a) break block38;
                }
                if (n != 2 || this.k.b) break block39;
            }
            try {
                this.l.wait(3500);
            }
            catch (InterruptedException interruptedException) {}
        }
        // MONITOREXIT : object
        if (n != 1) {
            this.b(true);
            return;
        }
        try {
            Thread.sleep(1000);
        }
        catch (InterruptedException interruptedException) {}
        this.e(this.m);
        this.m = null;
    }
}

