Esempio n. 1
0
    @Override
    public void uncaughtException(final Thread thread, final Throwable ex) {
      File file = getAppPath(EXCEPTION_PATH);
      try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(out);
        ex.printStackTrace(printStream);
        StringBuilder msg = new StringBuilder();
        msg.append("Version  " + Version.getFullVersion(OsmandApplication.this) + "\n")
            . //$NON-NLS-1$
            append(DateFormat.format("dd.MM.yyyy h:mm:ss", System.currentTimeMillis()));
        try {
          PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0);
          if (info != null) {
            msg.append("\nApk Version : ")
                .append(info.versionName)
                .append(" ")
                .append(info.versionCode); // $NON-NLS-1$ //$NON-NLS-2$
          }
        } catch (Throwable e) {
        }
        msg.append("\n")
            . //$NON-NLS-1$//$NON-NLS-2$
            append("Exception occured in thread " + thread.toString() + " : \n")
            . //$NON-NLS-1$ //$NON-NLS-2$
            append(new String(out.toByteArray()));

        if (file.getParentFile().canWrite()) {
          BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
          writer.write(msg.toString());
          writer.close();
        }
        if (routingHelper.isFollowingMode()) {
          AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
          mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 2000, intent);
          System.exit(2);
        }
        defaultHandler.uncaughtException(thread, ex);
      } catch (Exception e) {
        // swallow all exceptions
        android.util.Log.e(
            PlatformUtil.TAG, "Exception while handle other exception", e); // $NON-NLS-1$
      }
    }
  private SageAlertViewport() {

    westPanel = new ContentPanel();
    westPanel.setScrollMode(Scroll.AUTOY);
    BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 280);
    westPanel.add(new MenuTreePanel(new MenuDataStore()));
    westPanel.setHeaderVisible(false);
    westPanel.setBottomComponent(new SageAlertToolBar());

    centerPanel = new ContentPanel();
    centerPanel.setLayout(new FitLayout());
    BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
    centerPanel.setHeaderVisible(false);

    mainWindow = new Window();
    mainWindow.setDraggable(false);
    mainWindow.setHeading("SageAlert v" + Version.getFullVersion());
    mainWindow.setClosable(false);
    mainWindow.setResizable(false);
    mainWindow.setSize(600, 450);
    mainWindow.setLayout(new BorderLayout());
    mainWindow.add(westPanel, westData);
    mainWindow.add(centerPanel, centerData);
    add(mainWindow);
    SettingsServiceAsync rpc = GWT.create(SettingsService.class);
    rpc.isLicensed(
        new AsyncCallback<Boolean>() {

          public void onFailure(Throwable caught) {
            GWT.log("ERROR", caught);
          }

          public void onSuccess(Boolean result) {
            String newHeading = mainWindow.getHeading();
            if (!result) newHeading = newHeading.concat(" (Unlicensed)");
            else newHeading = newHeading.concat(" (Licensed)");
            mainWindow.setHeading(newHeading);
          }
        });
  }