Bug 719795 - Crash when GeckoSmsManager.init is called more than once [r=blassey,mounir]

This commit is contained in:
Matt Brubeck 2012-01-24 08:06:47 -08:00
parent d4c1ba6a7a
commit 1ea391744d
6 changed files with 29 additions and 15 deletions

View File

@ -414,7 +414,7 @@ abstract public class GeckoApp
registerReceiver(mBatteryReceiver, batteryFilter);
if (SmsManager.getInstance() != null) {
SmsManager.getInstance().init();
SmsManager.getInstance().start();
}
GeckoNetworkManager.getInstance().init();
@ -580,7 +580,9 @@ abstract public class GeckoApp
GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.ACTIVITY_SHUTDOWN));
if (SmsManager.getInstance() != null) {
SmsManager.getInstance().shutdown();
SmsManager.getInstance().stop();
if (isFinishing())
SmsManager.getInstance().shutdown();
}
GeckoNetworkManager.getInstance().stop();

View File

@ -356,15 +356,17 @@ public class GeckoSmsManager
private final static String[] kRequiredMessageRows = new String[] { "_id", "address", "body", "date", "type" };
public void init() {
public GeckoSmsManager() {
SmsIOThread.getInstance().start();
}
public void start() {
IntentFilter smsFilter = new IntentFilter();
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_RECEIVED);
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_SENT);
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_DELIVERED);
GeckoApp.mAppContext.registerReceiver(this, smsFilter);
SmsIOThread.getInstance().start();
}
@Override
@ -925,9 +927,11 @@ public class GeckoSmsManager
MessagesListManager.getInstance().remove(aListId);
}
public void shutdown() {
public void stop() {
GeckoApp.mAppContext.unregisterReceiver(this);
}
public void shutdown() {
SmsIOThread.getInstance().interrupt();
MessagesListManager.getInstance().clear();
}

View File

@ -57,7 +57,8 @@ class SmsManager
interface ISmsManager
{
public void init();
public void start();
public void stop();
public void shutdown();
public int getNumberOfMessagesForText(String aText);

View File

@ -1693,13 +1693,13 @@ abstract public class GeckoApp
registerReceiver(mBatteryReceiver, batteryFilter);
if (SmsManager.getInstance() != null) {
SmsManager.getInstance().init();
SmsManager.getInstance().start();
}
GeckoNetworkManager.getInstance().init();
final GeckoApp self = this;
GeckoAppShell.getHandler().postDelayed(new Runnable() {
public void run() {
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - pre checkLaunchState");
@ -2016,7 +2016,9 @@ abstract public class GeckoApp
mFavicons.close();
if (SmsManager.getInstance() != null) {
SmsManager.getInstance().shutdown();
SmsManager.getInstance().stop();
if (isFinishing())
SmsManager.getInstance().shutdown();
}
GeckoNetworkManager.getInstance().stop();

View File

@ -356,15 +356,17 @@ public class GeckoSmsManager
private final static String[] kRequiredMessageRows = new String[] { "_id", "address", "body", "date", "type" };
public void init() {
public GeckoSmsManager() {
SmsIOThread.getInstance().start();
}
public void start() {
IntentFilter smsFilter = new IntentFilter();
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_RECEIVED);
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_SENT);
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_DELIVERED);
GeckoApp.mAppContext.registerReceiver(this, smsFilter);
SmsIOThread.getInstance().start();
}
@Override
@ -925,9 +927,11 @@ public class GeckoSmsManager
MessagesListManager.getInstance().remove(aListId);
}
public void shutdown() {
public void stop() {
GeckoApp.mAppContext.unregisterReceiver(this);
}
public void shutdown() {
SmsIOThread.getInstance().interrupt();
MessagesListManager.getInstance().clear();
}

View File

@ -57,7 +57,8 @@ class SmsManager
interface ISmsManager
{
public void init();
public void start();
public void stop();
public void shutdown();
public int getNumberOfMessagesForText(String aText);