/** 初始化 */
 public void init(Context context) {
   this.context = context;
   // 获取系统默认的UncaughtException处理器
   mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
   // 设置该CrashHandler为程序的默认处理器
   Thread.setDefaultUncaughtExceptionHandler(this);
 }
  protected void initializeExceptionHandler() {
    Thread.setDefaultUncaughtExceptionHandler(
        new Thread.UncaughtExceptionHandler() {
          @Override
          public void uncaughtException(final Thread thread, final Throwable throwable) {
            Log.e(RapidFtrApplication.APP_IDENTIFIER, throwable.getMessage(), throwable);

            new Thread(
                    new Runnable() {
                      @Override
                      public void run() {
                        Looper.prepare();
                        Toast.makeText(
                                getContext(),
                                getContext().getString(R.string.internal_error),
                                Toast.LENGTH_LONG)
                            .show();
                        Looper.loop();
                      }
                    })
                .start();

            try {
              Thread.sleep(4000);
            } catch (InterruptedException e) {
            }

            Process.killProcess(Process.myPid());
            System.exit(10);
          }
        });
  }
 /**
  * 異常處理初始化
  *
  * @param context
  */
 public void init(Context context) {
   this.mContext = context;
   // 獲取系統默認的UncaughtException處理器
   defalutHandler = Thread.getDefaultUncaughtExceptionHandler();
   // 設置該CrashHandler為程序的默認處理器
   Thread.setDefaultUncaughtExceptionHandler(this);
 }
 /** This process finds all of the processes, puts them into a list, and adds them to the gui */
 @Override
 public void getInformation() {
   Thread.setDefaultUncaughtExceptionHandler(
       new Thread.UncaughtExceptionHandler() {
         public void uncaughtException(Thread t, Throwable e) {
           if (e instanceof NullPointerException) {
             e.printStackTrace();
           }
         }
       });
   File procDir = new File("/proc");
   processes = new ArrayList<ProcessData>();
   for (File f : procDir.listFiles()) {
     if (f.isDirectory()) {
       Pattern pidPattern = Pattern.compile("/proc/[0-9].*");
       Matcher pidMatcher = pidPattern.matcher(f.getAbsolutePath());
       if (pidMatcher.find()) {
         processes.add(getProcessData(f));
       }
     }
   }
   for (ProcessData proc : processes) {
     if (proc.getProcessState() == null) {
       System.out.println("Null process: " + proc.getName());
       System.out.println("Null Process: " + proc.getPid());
     }
     gui.addRowToProcList(proc.toStringCollection());
   }
 }
  /**
   * Creates a new proxy server.
   *
   * @param port The port the server should run on.
   * @param responseFilters The {@link Map} of request domains to match with associated {@link
   *     HttpFilter}s for filtering responses to those requests.
   * @param chainProxyManager The proxy to send requests to if chaining proxies. Typically <code>
   *     null</code>.
   * @param ksm The key manager if running the proxy over SSL.
   * @param requestFilter Optional filter for modifying incoming requests. Often <code>null</code>.
   * @param clientChannelFactory The factory for creating outgoing channels to external sites.
   * @param timer The global timer for timing out idle connections.
   * @param serverChannelFactory The factory for creating listening channels for incoming
   *     connections.
   */
  public DefaultHttpProxyServer(
      final int port,
      final HttpResponseFilters responseFilters,
      final ChainProxyManager chainProxyManager,
      final KeyStoreManager ksm,
      final HttpRequestFilter requestFilter,
      final ClientSocketChannelFactory clientChannelFactory,
      final Timer timer,
      final ServerSocketChannelFactory serverChannelFactory,
      final ProxyCacheManager cacheManager) {
    this.port = port;
    this.responseFilters = responseFilters;
    this.ksm = ksm;
    this.requestFilter = requestFilter;
    this.chainProxyManager = chainProxyManager;
    this.clientChannelFactory = clientChannelFactory;
    this.timer = timer;
    this.serverChannelFactory = serverChannelFactory;
    if (cacheManager == null) {
      this.cacheManager = ProxyUtils.loadCacheManager();
    } else {
      this.cacheManager = cacheManager;
    }
    Thread.setDefaultUncaughtExceptionHandler(
        new UncaughtExceptionHandler() {
          public void uncaughtException(final Thread t, final Throwable e) {
            log.error("Uncaught throwable", e);
          }
        });

    // Use our thread names so users know there are LittleProxy threads.
    ThreadRenamingRunnable.setThreadNameDeterminer(ThreadNameDeterminer.CURRENT);
    this.serverBootstrap = new ServerBootstrap(serverChannelFactory);
  }
Beispiel #6
0
  @Override
  public void start(Stage primaryStage) {
    this.primaryStage = primaryStage;
    ApplicationContextHolder.getContext();
    startLogAppender();
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionLogger());
    primaryStage.setScene(initScene());
    primaryStage
        .getIcons()
        .addAll(ApplicationContextHolder.getContext().getBeansOfType(Image.class).values());
    primaryStage.setTitle(ApplicationContextHolder.getContext().getBean(Pdfsam.class).name());
    primaryStage.setOnCloseRequest(e -> Platform.exit());
    initWindowsStatusController(primaryStage);
    initOverwriteDialogController(primaryStage);
    initActiveModule();
    primaryStage.show();

    requestCheckForUpdateIfNecessary();
    requestLatestNewsPanelDisplay();
    eventStudio().addAnnotatedListeners(this);
    closeSplash();
    STOPWATCH.stop();
    LOG.info(
        DefaultI18nContext.getInstance()
            .i18n(
                "Started in {0}",
                DurationFormatUtils.formatDurationWords(STOPWATCH.getTime(), true, true)));
  }
 /**
  * Diese Methode erstellt eine Verbindung zum Datenverteiler anhand der Standard-Parameter her.
  *
  * @param application Applikation, die eine Verbindung zum Datenverteiler benötigt.
  * @param applicationTypePid Pid des Applikationstyps. Der Datenverteiler erzeugt für die
  *     Appliaktion ein Objekt dieses Typs. Der Applikationstyp sollte "typ.applikation" sein oder
  *     davon abgeleitet sein.
  * @param args Aufrufargumente der Applikation
  */
 public static void run(
     StandardApplication application, String applicationTypePid, String[] args) {
   createApplicationLabel(args);
   final ArgumentList argumentList = new ArgumentList(args);
   initializeDebug(application, argumentList);
   Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
   try {
     // ArgumentListe wird in ClientDavParameters konvertiert
     final ClientDavParameters parameters = new ClientDavParameters(argumentList);
     parameters.setApplicationTypePid(applicationTypePid);
     parameters.setApplicationName(_applicationName);
     // zuerst darf die Applikation die ArgumentListe durcharbeiten
     application.parseArguments(argumentList);
     argumentList.ensureAllArgumentsUsed();
     final ClientDavInterface connection = new ClientDavConnection(parameters);
     // Fertigmeldung für Start/Stop wird eplizit selbst übernommen
     establishConnection(connection);
     _applicationLabel.append(
         connection.getLocalConfigurationAuthority().getPid()); // ApplikationsKennung
     MessageSender.getInstance().init(connection, _applicationName, _applicationLabel.toString());
     application.initialize(connection);
     // Fertigmeldung wird gesendet
     connection.sendApplicationReadyMessage();
   } catch (Exception ex) {
     _debug.error("Fehler", ex);
     System.exit(1);
   }
 }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Thread.setDefaultUncaughtExceptionHandler(
        new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this));

    final Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
      final Bundle data = intent.getBundleExtra(SearchManager.APP_DATA);
      if (data != null) {
        final NetworkLibrary library = NetworkLibrary.Instance();
        final NetworkTree.Key key =
            (NetworkTree.Key) data.getSerializable(NetworkLibraryActivity.TREE_KEY_KEY);
        final NetworkTree tree = library.getTreeByKey(key);
        if (tree instanceof SearchCatalogTree) {
          final SearchCatalogTree searchTree = (SearchCatalogTree) tree;
          final String pattern = intent.getStringExtra(SearchManager.QUERY);
          final MimeType mime = searchTree.getMimeType();
          if (MimeType.APP_ATOM_XML.weakEquals(mime)) {
            searchTree.startItemsLoader(new QuietNetworkContext(), pattern);
          } else if (MimeType.TEXT_HTML.weakEquals(mime)) {
            Util.openInBrowser(this, searchTree.getUrl(pattern));
          }
        }
      }
    }
    finish();
  }
  @Override
  public void onCreate() {
    super.onCreate();

    Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));

    // save instance of application
    myInstance = this;

    if (BuildConfig.DEBUG) Log.d(LOGCAT, "Application created");

    // create application folder
    Core core = new Core(getApplicationContext());
    core.getExternalStorageDirectoryApplication();

    // set default text size.
    setTextSize(new TextView(getApplicationContext()).getTextSize());
    // preference
    if (appPreferences == null) {
      appPreferences = PreferenceManager.getDefaultSharedPreferences(this);
      RobotoView.setUserFont(
          Integer.parseInt(
              appPreferences.getString(
                  getString(PreferenceConstants.PREF_APPLICATION_FONT), "-1")));
      RobotoView.setUserFontSize(
          getApplicationContext(),
          appPreferences.getString(
              getString(PreferenceConstants.PREF_APPLICATION_FONT_SIZE), "default"));
    }

    // Initialize font icons.
    FontIconTypefaceHolder.init(getAssets(), "fonts/mmex.ttf");
  }
 public void Init(Context context) {
   Log.d(LOG, "init");
   PreviousHandler = Thread.getDefaultUncaughtExceptionHandler();
   Thread.setDefaultUncaughtExceptionHandler(this);
   RecoltInformations(context);
   CurContext = context;
 }
  private void setup() throws IOException, TTransportException {
    int listenPort = DatabaseDescriptor.getThriftPort();

    Thread.setDefaultUncaughtExceptionHandler(
        new Thread.UncaughtExceptionHandler() {
          public void uncaughtException(Thread t, Throwable e) {
            logger.error("Fatal exception in thread " + t, e);
          }
        });

    CassandraServer peerStorageServer = new CassandraServer();
    peerStorageServer.start();
    Cassandra.Processor processor = new Cassandra.Processor(peerStorageServer);

    // Transport
    TServerSocket tServerSocket =
        new TServerSocket(new InetSocketAddress(FBUtilities.getHostName(), listenPort));

    // Protocol factory
    TProtocolFactory tProtocolFactory = new TBinaryProtocol.Factory();

    // ThreadPool Server
    TThreadPoolServer.Options options = new TThreadPoolServer.Options();
    options.minWorkerThreads = 64;
    serverEngine =
        new TThreadPoolServer(
            new TProcessorFactory(processor),
            tServerSocket,
            new TTransportFactory(),
            new TTransportFactory(),
            tProtocolFactory,
            tProtocolFactory,
            options);
  }
 public static void regist() {
   UncaughtExceptionHandler cur_handler = Thread.getDefaultUncaughtExceptionHandler();
   if (cur_handler instanceof ExceptionHandler) return;
   orig_handler = cur_handler;
   Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());
   log.d("setDefaultUncaughtExceptionHandler");
 }
Beispiel #13
0
  @Override
  public void onCreate() {
    super.onCreate();

    // 参考http://sixwolf.net/blog/2016/04/11/Android去除烦人的闪退弹窗/
    Thread.setDefaultUncaughtExceptionHandler(new MyUnCaughtExceptionHandler());
  }
Beispiel #14
0
 /**
  * 初始化,注册Context对象, 获取系统默认的UncaughtException处理器, 设置该CrashHandler为程序的默认处理器
  *
  * @param ctx
  */
 public void init(Context ctx) {
   mContext = ctx;
   mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
   Thread.setDefaultUncaughtExceptionHandler(this);
   SharedPreferences userInfo = ctx.getSharedPreferences("userInfo", 0);
   userName = userInfo.getString("username", null);
 }
  @Override
  public void onCreate() {

    super.onCreate();
    /** IMKit SDK调用第一步 初始化 context上下文 */
    RongIM.init(this);
    /** d 融云SDK事件监听处理 */
    RongCloudEvent.init(this);

    DemoContext.init(this);

    // 注册消息类型的时候判断当前的进程是否在主进程
    if ("io.rong.app".equals(getCurProcessName(getApplicationContext()))) {
      try {
        // 注册自定义消息,注册完消息后可以收到自定义消息
        RongIM.registerMessageType(DeAgreedFriendRequestMessage.class);
        // 注册消息模板,注册完消息模板可以在会话列表上展示
        RongIM.registerMessageTemplate(new DeContactNotificationMessageProvider());
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    // Crash 日志
    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler(this));
  }
    @Override
    protected Void doInBackground(Void... params) {
      // arraylist = new ArrayList<HashMap<String, String>>();
      // JSONFunctions a=new JSONFunctions();

      jsonarray = JSONFunctions.getJSONfromURL(ArtURL);
      JSONObject js;
      try {
        for (int i = 0; i < jsonarray.length(); i++) {
          js = jsonarray.getJSONObject(i);

          JSONItem a = new JSONItem();
          a.setDate(js.getString("updatedtime"));
          a.setImage(js.getString("articleimage"));
          a.setTitle(js.getString("articletitle"));
          a.setAuthorName(js.getString("authorname"));
          a.setDescription(js.getString("articledescription"));

          db.openToWrite();
          db.createArticle(a);
          feed.addItem(a);

          // arraylist.add(map);
        }
      } catch (JSONException e) {
        Log.e("Error", e.getMessage());
        Log.d("Error", "" + feed);
        Thread.setDefaultUncaughtExceptionHandler(null);
      }

      return null;
    }
  /**
   * 初始化
   *
   * @param context
   */
  public void initialize(Context context) {

    if (mInitialized) {
      return;
    }

    Set<String> neededPermissions = new TreeSet<>();
    neededPermissions.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);

    if (!checkPermissions(context, neededPermissions)) {
      StringBuilder sb = new StringBuilder();
      for (String permission : neededPermissions) {
        sb.append(permission).append("\n");
      }
      throw new IllegalArgumentException("Permissions needed:\n " + sb.toString());
    }

    // 在单例中使用全局Application Context
    mContext = context.getApplicationContext();

    // 获取系统默认的UncaughtException处理器
    mLocalExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();

    // 设置该CrashHandler为程序的默认处理器
    Thread.setDefaultUncaughtExceptionHandler(this);

    mInitialized = true;
  }
Beispiel #18
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    try {
      HaiManager.initHaiList();
      //            Initilizar.initApp(this);

      int width = ConfigManager.getWidth();
      int heigt = ConfigManager.getHeight();

      HaiManager.setHaiWidth(width / 14);
      HaiManager.setHaiHeight((int) (HaiManager.HAI_WIDTH * 1.4d));

      super.onCreate(savedInstanceState);
      CustomUncaughtExceptionHandler customUncaughtExceptionHandler =
          new CustomUncaughtExceptionHandler(getApplicationContext());
      Thread.setDefaultUncaughtExceptionHandler(customUncaughtExceptionHandler);

      setContentView(new HaipaiView(this));

      //        mainView.setOnItemClickListener(this);

    } catch (Exception e) {
      Log.e("Exception", e.getMessage(), e);
    }
  }
 /**
  * Het startpunt van de applicatie.
  *
  * @param args command-line argumenten
  */
 public static void main(String[] args) {
   ShutdownHandler handler = new ShutdownHandler();
   Thread.setDefaultUncaughtExceptionHandler(handler);
   Runtime.getRuntime().addShutdownHook(handler);
   try {
     Configuration configuration = readConfiguration();
     String ppaBus = configuration.getPpaBus();
     if (!ppaBus.endsWith("/")) {
       ppaBus += "/";
     }
     logger.debug("Gevonden PPA-bus URL: {}", ppaBus);
     DataProcessor.setBaseURL(ppaBus);
     Collection<File> directories = new HashSet<File>();
     for (SystemData data : configuration.getData()) {
       File directory = data.getDirectory();
       if (!directory.exists() || !directory.isDirectory()) {
         throw new IllegalArgumentException(directory + " bestaat niet");
       } else if (directories.contains(directory)) {
         throw new IllegalArgumentException(directory + " is al geconfigureerd");
       }
       logger.debug("Nieuwe directory bewaker voor {} op {}", data.getIdentification(), directory);
       WATCHERS.add(new DirectoryWatcher(data));
     }
   } catch (Exception ex) {
     onError("Fout tijdens het initialiseren van de applicaie", ex);
   }
   logger.info("Starten van de applicatie");
   ApplicationIcon.notifyState(-1);
   startup();
 }
Beispiel #20
0
 @Override
 public void onCreate() {
   super.onCreate();
   // 捕获异常
   Thread.setDefaultUncaughtExceptionHandler(
       MyExceptionHandler.getInstance(getApplicationContext()));
 }
  /**
   * Creates a new proxy server.
   *
   * @param port The port the server should run on.
   * @param responseFilters The {@link Map} of request domains to match with associated {@link
   *     HttpFilter}s for filtering responses to those requests.
   * @param chainProxyManager The proxy to send requests to if chaining proxies. Typically <code>
   *     null</code>.
   * @param ksm The key manager if running the proxy over SSL.
   * @param requestFilter Optional filter for modifying incoming requests. Often <code>null</code>.
   * @param clientChannelFactory The factory for creating outgoing client connections.
   * @param timer The idle timeout timer.
   * @param serverChannelFactory The factory for creating listening channels.
   */
  public StatsTrackingDefaultHttpProxyServer(
      final int port,
      final HttpResponseFilters responseFilters,
      final ChainProxyManager chainProxyManager,
      final HttpRequestFilter requestFilter,
      final ClientSocketChannelFactory clientChannelFactory,
      final Timer timer,
      final ServerSocketChannelFactory serverChannelFactory,
      final KeyStoreManager ksm,
      final Stats stats,
      final GlobalLanternServerTrafficShapingHandler serverTrafficHandler) {
    this.port = port;
    this.responseFilters = responseFilters;
    this.requestFilter = requestFilter;
    this.chainProxyManager = chainProxyManager;
    this.clientChannelFactory = clientChannelFactory;
    this.timer = timer;
    this.serverChannelFactory = serverChannelFactory;
    this.ksm = ksm;
    this.stats = stats;
    this.serverTrafficHandler = serverTrafficHandler;
    Thread.setDefaultUncaughtExceptionHandler(
        new UncaughtExceptionHandler() {
          @Override
          public void uncaughtException(final Thread t, final Throwable e) {
            log.error("Uncaught throwable", e);
          }
        });

    this.serverBootstrap = new ServerBootstrap(this.serverChannelFactory);
  }
Beispiel #22
0
 private void setUncaughtExceptionHandler() {
   Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
   if (!(handler instanceof SubsonicActivity.SubsonicUncaughtExceptionHandler)) {
     Thread.setDefaultUncaughtExceptionHandler(
         new SubsonicActivity.SubsonicUncaughtExceptionHandler(this));
   }
 }
  public void onCreate() {
    super.onCreate();

    _instance = this;

    Thread.setDefaultUncaughtExceptionHandler(new XbmcExceptionHandler());
  }
Beispiel #24
0
  public static void main(String[] args) throws SkypeException, InterruptedException {
    Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());

    final ContactListFrame contactListFrame = new ContactListFrame(SkypeApp.getContacts());

    final Application application = SkypeApp.getApp();
    final SkypeBridge skypeBridge = new SkypeBridge(SkypeApp.getOwnId());

    contactListFrame.setContactListSelectedListener(
        new ContactListSelected() {
          @Override
          public void selected(List<String> selectedValuesList) {
            if (selectedValuesList.size() == 0) {
              JOptionPane.showMessageDialog(null, "Select at least one contact.");
              return;
            }
            contactListFrame.close();
            skypeBridge.setServer();
            skypeBridge.setInvited(selectedValuesList);
            SkypeApp.connectToIds(selectedValuesList);
          }
        });

    application.addApplicationListener(skypeBridge);
  }
  @Override
  public void onCreate() {
    super.onCreate();

    Thread.setDefaultUncaughtExceptionHandler(
        new MyUncaughtExceptionHandler(Thread.getDefaultUncaughtExceptionHandler()));
  }
  public void create() {
    Thread.setDefaultUncaughtExceptionHandler(
        new UncaughtExceptionHandler() {
          public void uncaughtException(Thread thread, Throwable ex) {
            ex.printStackTrace();
            Runtime.getRuntime().halt(0); // Prevent Swing from keeping JVM alive.
          }
        });

    prefs = Gdx.app.getPreferences("spine-skeletonviewer");
    ui = new UI();
    batch = new PolygonSpriteBatch();
    renderer = new SkeletonMeshRenderer();
    debugRenderer = new SkeletonRendererDebug();
    skeletonX = (int) (ui.window.getWidth() + (Gdx.graphics.getWidth() - ui.window.getWidth()) / 2);
    skeletonY = Gdx.graphics.getHeight() / 4;
    ui.loadPrefs();

    loadSkeleton(
        Gdx.files.internal(
            Gdx.app
                .getPreferences("spine-skeletonviewer")
                .getString("lastFile", "spineboy/spineboy.json")));

    ui.loadPrefs();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
    setContentView(R.layout.new_card);
    gson = new Gson();
    user = gson.fromJson(new StoreData(getApplicationContext()).getUserDataAsString(), User.class);

    type = getIntent().getExtras().getString("type");
    if (getIntent().getExtras() != null) {
      if (getIntent().getExtras().containsKey("share")) {
        setShareHolder((ShareOwnership) getIntent().getExtras().get("share"));
        setInsertedServiceId(getShareHolder().getID());

      } else ShareHolder = new ShareOwnership();
      if (getIntent().getExtras().containsKey("shareHolders")) {
        setShareHolders((ArrayList<Object>) getIntent().getExtras().get("shareHolders"));
      }
    } else {
      ShareHolder = new ShareOwnership();
    }

    if (type.equals("1")) {
      fragmentManager = getSupportFragmentManager();
      fragmentManager
          .beginTransaction()
          .replace(R.id.content_frame, MainShareHolderFragment.newInstance("NewShareHolder"))
          .commit();
    }
  }
Beispiel #28
0
  public static void main(String[] args) throws Exception {
    Thread.setDefaultUncaughtExceptionHandler(new LlapDaemonUncaughtExceptionHandler());
    LlapDaemon llapDaemon = null;
    try {
      // Cache settings will need to be setup in llap-daemon-site.xml - since the daemons don't read
      // hive-site.xml
      // Ideally, these properties should be part of LlapDameonConf rather than HiveConf
      LlapConfiguration daemonConf = new LlapConfiguration();
      int numExecutors =
          daemonConf.getInt(
              LlapConfiguration.LLAP_DAEMON_NUM_EXECUTORS,
              LlapConfiguration.LLAP_DAEMON_NUM_EXECUTORS_DEFAULT);

      String[] localDirs = daemonConf.getTrimmedStrings(LlapConfiguration.LLAP_DAEMON_WORK_DIRS);
      int rpcPort =
          daemonConf.getInt(
              LlapConfiguration.LLAP_DAEMON_RPC_PORT,
              LlapConfiguration.LLAP_DAEMON_RPC_PORT_DEFAULT);
      int shufflePort =
          daemonConf.getInt(
              ShuffleHandler.SHUFFLE_PORT_CONFIG_KEY, ShuffleHandler.DEFAULT_SHUFFLE_PORT);
      long executorMemoryBytes =
          daemonConf.getInt(
                  LlapConfiguration.LLAP_DAEMON_MEMORY_PER_INSTANCE_MB,
                  LlapConfiguration.LLAP_DAEMON_MEMORY_PER_INSTANCE_MB_DEFAULT)
              * 1024l
              * 1024l;
      long cacheMemoryBytes =
          HiveConf.getLongVar(daemonConf, HiveConf.ConfVars.LLAP_ORC_CACHE_MAX_SIZE);
      boolean isDirectCache =
          HiveConf.getBoolVar(daemonConf, HiveConf.ConfVars.LLAP_ORC_CACHE_ALLOCATE_DIRECT);
      boolean llapIoEnabled = HiveConf.getBoolVar(daemonConf, HiveConf.ConfVars.LLAP_IO_ENABLED);
      llapDaemon =
          new LlapDaemon(
              daemonConf,
              numExecutors,
              executorMemoryBytes,
              llapIoEnabled,
              isDirectCache,
              cacheMemoryBytes,
              localDirs,
              rpcPort,
              shufflePort);

      LOG.info("Adding shutdown hook for LlapDaemon");
      ShutdownHookManager.addShutdownHook(new CompositeServiceShutdownHook(llapDaemon), 1);

      llapDaemon.init(daemonConf);
      llapDaemon.start();
      LOG.info("Started LlapDaemon");
      // Relying on the RPC threads to keep the service alive.
    } catch (Throwable t) {
      // TODO Replace this with a ExceptionHandler / ShutdownHook
      LOG.warn("Failed to start LLAP Daemon with exception", t);
      if (llapDaemon != null) {
        llapDaemon.shutdown();
      }
      System.exit(-1);
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    Thread.setDefaultUncaughtExceptionHandler(
        new Thread.UncaughtExceptionHandler() {
          @Override
          public void uncaughtException(Thread thread, final Throwable ex) {

            LPluginBug bug = new LPluginBug();
            bug.error = ex;
            bug.errorTime = System.currentTimeMillis();
            bug.errorThread = thread;
            bug.errorPlugin = remotePlugin;
            bug.processId = android.os.Process.myPid();
            LPluginBugManager.callAllBugListener(bug);
          }
        });
    super.onCreate(savedInstanceState);
    final Bundle pluginMessage = getIntent().getExtras();

    String pluginActivityName;
    String pluginDexPath;
    if (pluginMessage != null) {
      pluginActivityName =
          pluginMessage.getString(
              LPluginConfig.KEY_PLUGIN_ACT_NAME, LPluginConfig.DEF_PLUGIN_CLASS_NAME);
      pluginDexPath =
          pluginMessage.getString(
              LPluginConfig.KEY_PLUGIN_DEX_PATH, LPluginConfig.DEF_PLUGIN_DEX_PATH);
    } else {
      throw new PluginCreateFailedException("Please put the Plugin Path!");
    }
    if (pluginDexPath == LPluginConfig.DEF_PLUGIN_DEX_PATH) {
      throw new PluginCreateFailedException("Please put the Plugin Path!");
    }

    remotePlugin = loadPlugin(LActivityProxy.this, pluginDexPath);

    if (pluginActivityName != LPluginConfig.DEF_PLUGIN_CLASS_NAME) {
      remotePlugin.setTopActivityName(pluginActivityName);
    }

    fillPlugin(remotePlugin);
    // remotePlugin.from().debug();

    PluginActivityControl control =
        new PluginActivityControl(
            LActivityProxy.this,
            remotePlugin.getCurrentPluginActivity(),
            remotePlugin.from().pluginApplication);
    remotePlugin.setControl(control);
    control.dispatchProxyToPlugin();
    try {
      control.callOnCreate(savedInstanceState);
      LCallbackManager.callAllOnCreate(savedInstanceState);
    } catch (Exception e) {
      processError(e);
    }
  }
 public void onCreate() {
   super.onCreate();
   Thread.setDefaultUncaughtExceptionHandler(PersistentUncaughtExceptionHandler.getInstance());
   props = new PropertyUtil(getResources());
   downloadExecutor =
       new ThreadPoolExecutor(
           1, 3, 5000, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
 }