mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1062112: Part 1b: Cleanup singleton use in SmsManager. r=nalexander
This commit is contained in:
parent
883d50d60d
commit
fbcb7a7595
@ -45,6 +45,7 @@ import org.mozilla.gecko.mozglue.GeckoLoader;
|
||||
import org.mozilla.gecko.preferences.ClearOnShutdownPref;
|
||||
import org.mozilla.gecko.preferences.GeckoPreferences;
|
||||
import org.mozilla.gecko.prompts.PromptService;
|
||||
import org.mozilla.gecko.SmsManager;
|
||||
import org.mozilla.gecko.updater.UpdateService;
|
||||
import org.mozilla.gecko.updater.UpdateServiceHelper;
|
||||
import org.mozilla.gecko.util.ActivityResultHandler;
|
||||
@ -1544,9 +1545,8 @@ public abstract class GeckoApp
|
||||
mWebappEventListener.registerEvents();
|
||||
}
|
||||
|
||||
|
||||
if (SmsManager.getInstance() != null) {
|
||||
SmsManager.getInstance().start();
|
||||
if (SmsManager.isEnabled()) {
|
||||
SmsManager.getInstance().start();
|
||||
}
|
||||
|
||||
mContactService = new ContactService(EventDispatcher.getInstance(), this);
|
||||
@ -2079,10 +2079,11 @@ public abstract class GeckoApp
|
||||
IntentHelper.destroy();
|
||||
GeckoNetworkManager.destroy();
|
||||
|
||||
if (SmsManager.getInstance() != null) {
|
||||
if (SmsManager.isEnabled()) {
|
||||
SmsManager.getInstance().stop();
|
||||
if (isFinishing())
|
||||
if (isFinishing()) {
|
||||
SmsManager.getInstance().shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
final HealthRecorder rec = mHealthRecorder;
|
||||
|
@ -48,6 +48,7 @@ import org.mozilla.gecko.mozglue.RobocopTarget;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.OptionalGeneratedParameter;
|
||||
import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
|
||||
import org.mozilla.gecko.prompts.PromptService;
|
||||
import org.mozilla.gecko.SmsManager;
|
||||
import org.mozilla.gecko.util.EventCallback;
|
||||
import org.mozilla.gecko.util.GeckoRequest;
|
||||
import org.mozilla.gecko.util.HardwareUtils;
|
||||
@ -2352,7 +2353,7 @@ public class GeckoAppShell
|
||||
*/
|
||||
@WrapElementForJNI(stubName = "SendMessageWrapper")
|
||||
public static void sendMessage(String aNumber, String aMessage, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
if (!SmsManager.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2361,7 +2362,7 @@ public class GeckoAppShell
|
||||
|
||||
@WrapElementForJNI(stubName = "GetMessageWrapper")
|
||||
public static void getMessage(int aMessageId, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
if (!SmsManager.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2370,7 +2371,7 @@ public class GeckoAppShell
|
||||
|
||||
@WrapElementForJNI(stubName = "DeleteMessageWrapper")
|
||||
public static void deleteMessage(int aMessageId, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
if (!SmsManager.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2379,7 +2380,7 @@ public class GeckoAppShell
|
||||
|
||||
@WrapElementForJNI(stubName = "CreateMessageListWrapper")
|
||||
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, String aDelivery, boolean aHasRead, boolean aRead, long aThreadId, boolean aReverse, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
if (!SmsManager.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2388,7 +2389,7 @@ public class GeckoAppShell
|
||||
|
||||
@WrapElementForJNI(stubName = "GetNextMessageInListWrapper")
|
||||
public static void getNextMessageInList(int aListId, int aRequestId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
if (!SmsManager.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2397,7 +2398,7 @@ public class GeckoAppShell
|
||||
|
||||
@WrapElementForJNI
|
||||
public static void clearMessageList(int aListId) {
|
||||
if (SmsManager.getInstance() == null) {
|
||||
if (!SmsManager.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6,17 +6,23 @@
|
||||
package org.mozilla.gecko;
|
||||
|
||||
public class SmsManager {
|
||||
static private ISmsManager sInstance;
|
||||
|
||||
static public ISmsManager getInstance() {
|
||||
private static final ISmsManager sInstance;
|
||||
static {
|
||||
if (AppConstants.MOZ_WEBSMS_BACKEND) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new GeckoSmsManager();
|
||||
}
|
||||
sInstance = new GeckoSmsManager();
|
||||
} else {
|
||||
sInstance = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ISmsManager getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return AppConstants.MOZ_WEBSMS_BACKEND;
|
||||
}
|
||||
|
||||
public interface ISmsManager {
|
||||
public void start();
|
||||
public void stop();
|
||||
|
Loading…
Reference in New Issue
Block a user