bug 607387 - android restarter spins for ever waiting for fennec to die r=mwu a=blocking-fennec

This commit is contained in:
Brad Lassey 2010-10-26 21:57:29 -04:00
parent 97a46aa911
commit 5afc1bb7db
3 changed files with 17 additions and 9 deletions

View File

@ -72,11 +72,12 @@
</intent-filter>
</activity>
<receiver android:enabled="true" android:name="Restarter">
<activity android:enabled="true" android:name="Restarter">
<intent-filter>
<action android:name="org.mozilla.gecko.restart@MOZ_APP_NAME@" />
<action android:name="org.mozilla.gecko.restart@MOZ_APP_NAME@"
android:process="@MOZ_APP_NAME@Restarter"/>
</intent-filter>
</receiver>
</activity>
#if MOZ_CRASHREPORTER
<activity android:name="CrashReporter"
android:label="@MOZ_APP_DISPLAYNAME@ Crash Reporter"

View File

@ -447,8 +447,9 @@ abstract public class GeckoApp
intent.setClassName("org.mozilla." + getAppName(),
"org.mozilla." + getAppName() + ".Restarter");
addEnvToIntent(intent);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.i("GeckoAppJava", intent.toString());
sendBroadcast(intent);
startActivity(intent);
} catch (Exception e) {
Log.i("GeckoAppJava", e.toString());
}

View File

@ -38,17 +38,19 @@
#filter substitution
package org.mozilla.@MOZ_APP_NAME@;
import android.app.*;
import android.content.*;
import android.util.*;
import android.os.*;
import java.io.*;
public class Restarter extends BroadcastReceiver {
public class Restarter extends Activity {
@Override
public void onReceive(Context aContext, Intent aIntent) {
public void onCreate(Bundle savedInstanceState) {
Log.i("Restarter", "trying to restart @MOZ_APP_NAME@");
try {
boolean stillRunning;
int spinCountdown = 8;
do {
stillRunning = false;
java.lang.Process p = Runtime.getRuntime().exec("/system/bin/ps");
@ -68,7 +70,11 @@ public class Restarter extends BroadcastReceiver {
}
}
}
} while(stillRunning);
if (stillRunning)
spinCountdown--;
else
spinCountdown = 0;
} while(spinCountdown != 0);
} catch (Exception e) {
Log.i("Restarter", e.toString());
}
@ -77,12 +83,12 @@ public class Restarter extends BroadcastReceiver {
Intent intent = new Intent(action);
intent.setClassName("org.mozilla.@MOZ_APP_NAME@",
"org.mozilla.@MOZ_APP_NAME@.App");
Bundle b = aIntent.getExtras();
Bundle b = getIntent().getExtras();
if (b != null)
intent.putExtras(b);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.i("GeckoAppJava", intent.toString());
aContext.startActivity(intent);
startActivity(intent);
} catch (Exception e) {
Log.i("Restarter", e.toString());
}