Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 }