mobile/android/base/Restarter.java

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
     2  * This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 package org.mozilla.gecko;
     8 import android.app.Activity;
     9 import android.content.Intent;
    10 import android.os.Bundle;
    11 import android.util.Log;
    13 public class Restarter extends Activity {
    14     private static final String LOGTAG = "GeckoRestarter";
    16     @Override
    17     public void onCreate(Bundle savedInstanceState) {
    18         super.onCreate(savedInstanceState);
    20         Log.i(LOGTAG, "Trying to restart " + AppConstants.MOZ_APP_NAME);
    21         try {
    22             int countdown = 40;
    23             while (GeckoAppShell.checkForGeckoProcs() &&  --countdown > 0) {
    24                 // Wait for the old process to die before we continue
    25                 try {
    26                     Thread.sleep(100);
    27                 } catch (InterruptedException ie) {}
    28             }
    30             if (countdown <= 0) {
    31                 // if the countdown expired, something is hung
    32                 GeckoAppShell.killAnyZombies();
    33                 countdown = 10;
    34                 // wait for the kill to take effect
    35                 while (GeckoAppShell.checkForGeckoProcs() &&  --countdown > 0) {
    36                     try {
    37                         Thread.sleep(100);
    38                     } catch (InterruptedException ie) {}
    39                 }
    40             }
    41         } catch (Exception e) {
    42             Log.i(LOGTAG, e.toString());
    43         }
    44         try {
    45             Intent intent = new Intent(Intent.ACTION_MAIN);
    46             intent.setClassName(AppConstants.ANDROID_PACKAGE_NAME,
    47                                 AppConstants.BROWSER_INTENT_CLASS_NAME);
    48             Bundle b = getIntent().getExtras();
    49             if (b != null)
    50                 intent.putExtras(b);
    51             Log.i(LOGTAG, intent.toString());
    52             startActivity(intent);
    53         } catch (Exception e) {
    54             Log.i(LOGTAG, e.toString());
    55         }
    56     }
    57 }

mercurial