mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 713377 - Part 2 - Don't build GeckoSmsManager.java when WebSMS backend is disabled. r=dougt,cjones
This commit is contained in:
parent
02eca2001b
commit
7bb7d516d6
@ -88,7 +88,6 @@ abstract public class GeckoApp
|
||||
private IntentFilter mConnectivityFilter;
|
||||
private BroadcastReceiver mConnectivityReceiver;
|
||||
private BroadcastReceiver mBatteryReceiver;
|
||||
private BroadcastReceiver mSmsReceiver;
|
||||
|
||||
enum LaunchState {PreLaunch, Launching, WaitForDebugger,
|
||||
Launched, GeckoRunning, GeckoExiting};
|
||||
@ -414,14 +413,9 @@ abstract public class GeckoApp
|
||||
mBatteryReceiver = new GeckoBatteryManager();
|
||||
registerReceiver(mBatteryReceiver, batteryFilter);
|
||||
|
||||
IntentFilter smsFilter = new IntentFilter();
|
||||
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_RECEIVED);
|
||||
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_SENT);
|
||||
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_DELIVERED);
|
||||
mSmsReceiver = new GeckoSmsManager();
|
||||
registerReceiver(mSmsReceiver, smsFilter);
|
||||
|
||||
GeckoSmsManager.init();
|
||||
if (SmsManager.getInstance() != null) {
|
||||
SmsManager.getInstance().init();
|
||||
}
|
||||
|
||||
if (!checkAndSetLaunchState(LaunchState.PreLaunch,
|
||||
LaunchState.Launching))
|
||||
@ -576,16 +570,17 @@ abstract public class GeckoApp
|
||||
{
|
||||
Log.i(LOG_FILE_NAME, "destroy");
|
||||
|
||||
GeckoSmsManager.shutdown();
|
||||
|
||||
// Tell Gecko to shutting down; we'll end up calling System.exit()
|
||||
// in onXreExit.
|
||||
if (isFinishing())
|
||||
GeckoAppShell.sendEventToGecko(new GeckoEvent(GeckoEvent.ACTIVITY_SHUTDOWN));
|
||||
|
||||
if (SmsManager.getInstance() != null) {
|
||||
SmsManager.getInstance().shutdown();
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
|
||||
unregisterReceiver(mSmsReceiver);
|
||||
unregisterReceiver(mBatteryReceiver);
|
||||
}
|
||||
|
||||
|
@ -1701,35 +1701,67 @@ public class GeckoAppShell
|
||||
* WebSMS related methods.
|
||||
*/
|
||||
public static int getNumberOfMessagesForText(String aText) {
|
||||
return GeckoSmsManager.getNumberOfMessagesForText(aText);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SmsManager.getInstance().getNumberOfMessagesForText(aText);
|
||||
}
|
||||
|
||||
public static void sendMessage(String aNumber, String aMessage, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.send(aNumber, aMessage, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().send(aNumber, aMessage, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static int saveSentMessage(String aRecipient, String aBody, long aDate) {
|
||||
return GeckoSmsManager.saveSentMessage(aRecipient, aBody, aDate);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return SmsManager.getInstance().saveSentMessage(aRecipient, aBody, aDate);
|
||||
}
|
||||
|
||||
public static void getMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.getMessage(aMessageId, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().getMessage(aMessageId, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.deleteMessage(aMessageId, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().deleteMessage(aMessageId, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.getNextMessageInList(aListId, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().getNextMessageInList(aListId, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static void clearMessageList(int aListId) {
|
||||
GeckoSmsManager.clearMessageList(aListId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().clearMessageList(aListId);
|
||||
}
|
||||
|
||||
public static boolean isTablet() {
|
||||
|
@ -48,6 +48,7 @@ import android.app.Activity;
|
||||
import android.database.Cursor;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.ContentResolver;
|
||||
@ -319,6 +320,7 @@ class MessagesListManager
|
||||
|
||||
public class GeckoSmsManager
|
||||
extends BroadcastReceiver
|
||||
implements ISmsManager
|
||||
{
|
||||
public final static String ACTION_SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
|
||||
public final static String ACTION_SMS_SENT = "org.mozilla.gecko.SMS_SENT";
|
||||
@ -354,7 +356,14 @@ public class GeckoSmsManager
|
||||
|
||||
private final static String[] kRequiredMessageRows = new String[] { "_id", "address", "body", "date", "type" };
|
||||
|
||||
public static void init() {
|
||||
public void init() {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -480,11 +489,11 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNumberOfMessagesForText(String aText) {
|
||||
public int getNumberOfMessagesForText(String aText) {
|
||||
return SmsManager.getDefault().divideMessage(aText).size();
|
||||
}
|
||||
|
||||
public static void send(String aNumber, String aMessage, int aRequestId, long aProcessId) {
|
||||
public void send(String aNumber, String aMessage, int aRequestId, long aProcessId) {
|
||||
int envelopeId = Postman.kUnknownEnvelopeId;
|
||||
|
||||
try {
|
||||
@ -518,12 +527,12 @@ public class GeckoSmsManager
|
||||
* generated by GetPendingIntentUID().
|
||||
*/
|
||||
PendingIntent sentPendingIntent =
|
||||
PendingIntent.getBroadcast(GeckoApp.surfaceView.getContext(),
|
||||
PendingIntent.getBroadcast(GeckoApp.mAppContext,
|
||||
PendingIntentUID.generate(), sentIntent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
PendingIntent deliveredPendingIntent =
|
||||
PendingIntent.getBroadcast(GeckoApp.surfaceView.getContext(),
|
||||
PendingIntent.getBroadcast(GeckoApp.mAppContext,
|
||||
PendingIntentUID.generate(), deliveredIntent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
@ -544,13 +553,13 @@ public class GeckoSmsManager
|
||||
|
||||
for (int i=0; i<parts.size(); ++i) {
|
||||
sentPendingIntents.add(
|
||||
PendingIntent.getBroadcast(GeckoApp.surfaceView.getContext(),
|
||||
PendingIntent.getBroadcast(GeckoApp.mAppContext,
|
||||
PendingIntentUID.generate(), sentIntent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
);
|
||||
|
||||
deliveredPendingIntents.add(
|
||||
PendingIntent.getBroadcast(GeckoApp.surfaceView.getContext(),
|
||||
PendingIntent.getBroadcast(GeckoApp.mAppContext,
|
||||
PendingIntentUID.generate(), deliveredIntent,
|
||||
PendingIntent.FLAG_CANCEL_CURRENT)
|
||||
);
|
||||
@ -570,7 +579,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static int saveSentMessage(String aRecipient, String aBody, long aDate) {
|
||||
public int saveSentMessage(String aRecipient, String aBody, long aDate) {
|
||||
class IdTooHighException extends Exception { }
|
||||
|
||||
try {
|
||||
@ -579,7 +588,7 @@ public class GeckoSmsManager
|
||||
values.put("body", aBody);
|
||||
values.put("date", aDate);
|
||||
|
||||
ContentResolver cr = GeckoApp.surfaceView.getContext().getContentResolver();
|
||||
ContentResolver cr = GeckoApp.mAppContext.getContentResolver();
|
||||
Uri uri = cr.insert(kSmsSentContentUri, values);
|
||||
|
||||
long id = ContentUris.parseId(uri);
|
||||
@ -600,7 +609,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void getMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
public void getMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
class GetMessageRunnable implements Runnable {
|
||||
private int mMessageId;
|
||||
private int mRequestId;
|
||||
@ -622,7 +631,7 @@ public class GeckoSmsManager
|
||||
Cursor cursor = null;
|
||||
|
||||
try {
|
||||
ContentResolver cr = GeckoApp.surfaceView.getContext().getContentResolver();
|
||||
ContentResolver cr = GeckoApp.mAppContext.getContentResolver();
|
||||
Uri message = ContentUris.withAppendedId(kSmsContentUri, mMessageId);
|
||||
|
||||
cursor = cr.query(message, kRequiredMessageRows, null, null, null);
|
||||
@ -687,7 +696,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
public void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
class DeleteMessageRunnable implements Runnable {
|
||||
private int mMessageId;
|
||||
private int mRequestId;
|
||||
@ -704,7 +713,7 @@ public class GeckoSmsManager
|
||||
class TooManyResultsException extends Exception { }
|
||||
|
||||
try {
|
||||
ContentResolver cr = GeckoApp.surfaceView.getContext().getContentResolver();
|
||||
ContentResolver cr = GeckoApp.mAppContext.getContentResolver();
|
||||
Uri message = ContentUris.withAppendedId(kSmsContentUri, mMessageId);
|
||||
|
||||
int count = cr.delete(message, null, null);
|
||||
@ -730,7 +739,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
|
||||
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
|
||||
class CreateMessageListRunnable implements Runnable {
|
||||
private long mStartDate;
|
||||
private long mEndDate;
|
||||
@ -799,7 +808,7 @@ public class GeckoSmsManager
|
||||
restrictionText += " AND " + restrictions.get(i);
|
||||
}
|
||||
|
||||
ContentResolver cr = GeckoApp.surfaceView.getContext().getContentResolver();
|
||||
ContentResolver cr = GeckoApp.mAppContext.getContentResolver();
|
||||
cursor = cr.query(kSmsContentUri, kRequiredMessageRows, restrictionText, null,
|
||||
mReverse ? "date DESC" : "date ASC");
|
||||
|
||||
@ -853,7 +862,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
|
||||
public void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
|
||||
class GetNextMessageInListRunnable implements Runnable {
|
||||
private int mListId;
|
||||
private int mRequestId;
|
||||
@ -912,11 +921,13 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearMessageList(int aListId) {
|
||||
public void clearMessageList(int aListId) {
|
||||
MessagesListManager.getInstance().remove(aListId);
|
||||
}
|
||||
|
||||
public static void shutdown() {
|
||||
public void shutdown() {
|
||||
GeckoApp.mAppContext.unregisterReceiver(this);
|
||||
|
||||
SmsIOThread.getInstance().interrupt();
|
||||
MessagesListManager.getInstance().clear();
|
||||
}
|
||||
|
@ -55,15 +55,19 @@ JAVAFILES = \
|
||||
AlertNotification.java \
|
||||
SurfaceInfo.java \
|
||||
GeckoBatteryManager.java \
|
||||
GeckoSmsManager.java \
|
||||
VideoPlayer.java \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_WEBSMS_BACKEND
|
||||
JAVAFILES += GeckoSmsManager.java
|
||||
endif
|
||||
|
||||
PROCESSEDJAVAFILES = \
|
||||
App.java \
|
||||
Restarter.java \
|
||||
NotificationHandler.java \
|
||||
LauncherShortcuts.java \
|
||||
SmsManager.java \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
71
embedding/android/SmsManager.java.in
Normal file
71
embedding/android/SmsManager.java.in
Normal file
@ -0,0 +1,71 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Android code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2012
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
#ifdef MOZ_WEBSMS_BACKEND
|
||||
import org.mozilla.gecko.GeckoSmsManager;
|
||||
#endif
|
||||
|
||||
class SmsManager
|
||||
{
|
||||
static private ISmsManager sInstance = null;
|
||||
|
||||
static public ISmsManager getInstance() {
|
||||
#ifdef MOZ_WEBSMS_BACKEND
|
||||
if (sInstance == null) {
|
||||
sInstance = new GeckoSmsManager();
|
||||
}
|
||||
#endif
|
||||
return sInstance;
|
||||
}
|
||||
}
|
||||
|
||||
interface ISmsManager
|
||||
{
|
||||
public void init();
|
||||
public void shutdown();
|
||||
|
||||
public int getNumberOfMessagesForText(String aText);
|
||||
public void send(String aNumber, String aMessage, int aRequestId, long aProcessId);
|
||||
public int saveSentMessage(String aRecipient, String aBody, long aDate);
|
||||
public void getMessage(int aMessageId, int aRequestId, long aProcessId);
|
||||
public void deleteMessage(int aMessageId, int aRequestId, long aProcessId);
|
||||
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId);
|
||||
public void getNextMessageInList(int aListId, int aRequestId, long aProcessId);
|
||||
public void clearMessageList(int aListId);
|
||||
}
|
@ -121,7 +121,6 @@ abstract public class GeckoApp
|
||||
private IntentFilter mBatteryFilter;
|
||||
|
||||
private BroadcastReceiver mConnectivityReceiver;
|
||||
private BroadcastReceiver mSmsReceiver;
|
||||
private BroadcastReceiver mBatteryReceiver;
|
||||
|
||||
public static BrowserToolbar mBrowserToolbar;
|
||||
@ -1571,14 +1570,9 @@ abstract public class GeckoApp
|
||||
mBatteryReceiver = new GeckoBatteryManager();
|
||||
registerReceiver(mBatteryReceiver, batteryFilter);
|
||||
|
||||
IntentFilter smsFilter = new IntentFilter();
|
||||
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_RECEIVED);
|
||||
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_SENT);
|
||||
smsFilter.addAction(GeckoSmsManager.ACTION_SMS_DELIVERED);
|
||||
mSmsReceiver = new GeckoSmsManager();
|
||||
registerReceiver(mSmsReceiver, smsFilter);
|
||||
|
||||
GeckoSmsManager.init();
|
||||
if (SmsManager.getInstance() != null) {
|
||||
SmsManager.getInstance().init();
|
||||
}
|
||||
|
||||
final GeckoApp self = this;
|
||||
|
||||
@ -1804,11 +1798,12 @@ abstract public class GeckoApp
|
||||
|
||||
mFavicons.close();
|
||||
|
||||
GeckoSmsManager.shutdown();
|
||||
if (SmsManager.getInstance() != null) {
|
||||
SmsManager.getInstance().shutdown();
|
||||
}
|
||||
|
||||
super.onDestroy();
|
||||
|
||||
unregisterReceiver(mSmsReceiver);
|
||||
unregisterReceiver(mBatteryReceiver);
|
||||
}
|
||||
|
||||
|
@ -1644,35 +1644,67 @@ public class GeckoAppShell
|
||||
* WebSMS related methods.
|
||||
*/
|
||||
public static int getNumberOfMessagesForText(String aText) {
|
||||
return GeckoSmsManager.getNumberOfMessagesForText(aText);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return SmsManager.getInstance().getNumberOfMessagesForText(aText);
|
||||
}
|
||||
|
||||
public static void sendMessage(String aNumber, String aMessage, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.send(aNumber, aMessage, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().send(aNumber, aMessage, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static int saveSentMessage(String aRecipient, String aBody, long aDate) {
|
||||
return GeckoSmsManager.saveSentMessage(aRecipient, aBody, aDate);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return SmsManager.getInstance().saveSentMessage(aRecipient, aBody, aDate);
|
||||
}
|
||||
|
||||
public static void getMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.getMessage(aMessageId, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().getMessage(aMessageId, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.deleteMessage(aMessageId, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().deleteMessage(aMessageId, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().createMessageList(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
|
||||
GeckoSmsManager.getNextMessageInList(aListId, aRequestId, aProcessId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().getNextMessageInList(aListId, aRequestId, aProcessId);
|
||||
}
|
||||
|
||||
public static void clearMessageList(int aListId) {
|
||||
GeckoSmsManager.clearMessageList(aListId);
|
||||
if (SmsManager.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SmsManager.getInstance().clearMessageList(aListId);
|
||||
}
|
||||
|
||||
public static boolean isTablet() {
|
||||
|
@ -48,6 +48,7 @@ import android.app.Activity;
|
||||
import android.database.Cursor;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.ContentResolver;
|
||||
@ -319,6 +320,7 @@ class MessagesListManager
|
||||
|
||||
public class GeckoSmsManager
|
||||
extends BroadcastReceiver
|
||||
implements ISmsManager
|
||||
{
|
||||
public final static String ACTION_SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
|
||||
public final static String ACTION_SMS_SENT = "org.mozilla.gecko.SMS_SENT";
|
||||
@ -354,7 +356,14 @@ public class GeckoSmsManager
|
||||
|
||||
private final static String[] kRequiredMessageRows = new String[] { "_id", "address", "body", "date", "type" };
|
||||
|
||||
public static void init() {
|
||||
public void init() {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -480,11 +489,11 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static int getNumberOfMessagesForText(String aText) {
|
||||
public int getNumberOfMessagesForText(String aText) {
|
||||
return SmsManager.getDefault().divideMessage(aText).size();
|
||||
}
|
||||
|
||||
public static void send(String aNumber, String aMessage, int aRequestId, long aProcessId) {
|
||||
public void send(String aNumber, String aMessage, int aRequestId, long aProcessId) {
|
||||
int envelopeId = Postman.kUnknownEnvelopeId;
|
||||
|
||||
try {
|
||||
@ -570,7 +579,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static int saveSentMessage(String aRecipient, String aBody, long aDate) {
|
||||
public int saveSentMessage(String aRecipient, String aBody, long aDate) {
|
||||
class IdTooHighException extends Exception { }
|
||||
|
||||
try {
|
||||
@ -600,7 +609,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void getMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
public void getMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
class GetMessageRunnable implements Runnable {
|
||||
private int mMessageId;
|
||||
private int mRequestId;
|
||||
@ -687,7 +696,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
public void deleteMessage(int aMessageId, int aRequestId, long aProcessId) {
|
||||
class DeleteMessageRunnable implements Runnable {
|
||||
private int mMessageId;
|
||||
private int mRequestId;
|
||||
@ -730,7 +739,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
|
||||
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId) {
|
||||
class CreateMessageListRunnable implements Runnable {
|
||||
private long mStartDate;
|
||||
private long mEndDate;
|
||||
@ -853,7 +862,7 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
|
||||
public void getNextMessageInList(int aListId, int aRequestId, long aProcessId) {
|
||||
class GetNextMessageInListRunnable implements Runnable {
|
||||
private int mListId;
|
||||
private int mRequestId;
|
||||
@ -912,11 +921,13 @@ public class GeckoSmsManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearMessageList(int aListId) {
|
||||
public void clearMessageList(int aListId) {
|
||||
MessagesListManager.getInstance().remove(aListId);
|
||||
}
|
||||
|
||||
public static void shutdown() {
|
||||
public void shutdown() {
|
||||
GeckoApp.mAppContext.unregisterReceiver(this);
|
||||
|
||||
SmsIOThread.getInstance().interrupt();
|
||||
MessagesListManager.getInstance().clear();
|
||||
}
|
||||
|
@ -83,7 +83,6 @@ FENNEC_JAVA_FILES = \
|
||||
GeckoEventListener.java \
|
||||
GeckoInputConnection.java \
|
||||
GeckoPreferences.java \
|
||||
GeckoSmsManager.java \
|
||||
GeckoStateListDrawable.java \
|
||||
GeckoThread.java \
|
||||
GlobalHistory.java \
|
||||
@ -126,6 +125,10 @@ FENNEC_JAVA_FILES = \
|
||||
ui/SubdocumentScrollHelper.java \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_WEBSMS_BACKEND
|
||||
FENNEC_JAVA_FILES += GeckoSmsManager.java
|
||||
endif
|
||||
|
||||
FENNEC_PP_JAVA_FILES = \
|
||||
App.java \
|
||||
LauncherShortcuts.java \
|
||||
@ -133,6 +136,7 @@ FENNEC_PP_JAVA_FILES = \
|
||||
Restarter.java \
|
||||
db/BrowserContract.java \
|
||||
db/BrowserProvider.java \
|
||||
SmsManager.java \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
71
mobile/android/base/SmsManager.java.in
Normal file
71
mobile/android/base/SmsManager.java.in
Normal file
@ -0,0 +1,71 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Android code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2012
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mounir Lamouri <mounir.lamouri@mozilla.com> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
package org.mozilla.gecko;
|
||||
|
||||
#ifdef MOZ_WEBSMS_BACKEND
|
||||
import org.mozilla.gecko.GeckoSmsManager;
|
||||
#endif
|
||||
|
||||
class SmsManager
|
||||
{
|
||||
static private ISmsManager sInstance = null;
|
||||
|
||||
static public ISmsManager getInstance() {
|
||||
#ifdef MOZ_WEBSMS_BACKEND
|
||||
if (sInstance == null) {
|
||||
sInstance = new GeckoSmsManager();
|
||||
}
|
||||
#endif
|
||||
return sInstance;
|
||||
}
|
||||
}
|
||||
|
||||
interface ISmsManager
|
||||
{
|
||||
public void init();
|
||||
public void shutdown();
|
||||
|
||||
public int getNumberOfMessagesForText(String aText);
|
||||
public void send(String aNumber, String aMessage, int aRequestId, long aProcessId);
|
||||
public int saveSentMessage(String aRecipient, String aBody, long aDate);
|
||||
public void getMessage(int aMessageId, int aRequestId, long aProcessId);
|
||||
public void deleteMessage(int aMessageId, int aRequestId, long aProcessId);
|
||||
public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId, long aProcessId);
|
||||
public void getNextMessageInList(int aListId, int aRequestId, long aProcessId);
|
||||
public void clearMessageList(int aListId);
|
||||
}
|
Loading…
Reference in New Issue
Block a user