Bug 839622 - Move websms backend JNI bindings so that they are not built if websms is not enabled. r=blassey
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 08 Feb 2013 16:42:14 -0500
changeset 121387 15c4a08c03d7446554f249a86768032a707b1d0c
parent 121386 2a0f174d19f51b5ac47039b929d27ad9856ca611
child 121388 cff2fa8176048ba12bf46bc91361373b4a66b4f2
push idunknown
push userunknown
push dateunknown
reviewersblassey
bugs839622
milestone21.0a1
Bug 839622 - Move websms backend JNI bindings so that they are not built if websms is not enabled. r=blassey
mobile/android/base/GeckoAppShell.java
mobile/android/base/GeckoSmsManager.java
mobile/android/base/Makefile.in
mozglue/android/jni-stubs.inc
widget/android/AndroidJNI.cpp
widget/android/Makefile.in
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -212,29 +212,16 @@ public class GeckoAppShell
     public static void notifyUriVisited(String uri) {
         sendEventToGecko(GeckoEvent.createVisitedEvent(uri));
     }
 
     public static native void processNextNativeEvent();
 
     public static native void notifyBatteryChange(double aLevel, boolean aCharging, double aRemainingTime);
 
-    public static native void notifySmsReceived(String aSender, String aBody, int aMessageClass, long aTimestamp);
-    public static native void notifySmsSent(int aId, String aReceiver, String aBody, long aTimestamp, int aRequestId);
-    public static native void notifySmsDelivery(int aId, int aDeliveryStatus, String aReceiver, String aBody, long aTimestamp);
-    public static native void notifySmsSendFailed(int aError, int aRequestId);
-    public static native void notifyGetSms(int aId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
-    public static native void notifyGetSmsFailed(int aError, int aRequestId);
-    public static native void notifySmsDeleted(boolean aDeleted, int aRequestId);
-    public static native void notifySmsDeleteFailed(int aError, int aRequestId);
-    public static native void notifyNoMessageInList(int aRequestId);
-    public static native void notifyListCreated(int aListId, int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
-    public static native void notifyGotNextMessage(int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
-    public static native void notifyReadingMessageListFailed(int aError, int aRequestId);
-
     public static native void scheduleComposite();
 
     // Resuming the compositor is a synchronous request, so be
     // careful of possible deadlock. Resuming the compositor will also cause
     // a composition, so there is no need to schedule a composition after
     // resuming.
     public static native void scheduleResumeComposition(int width, int height);
 
--- a/mobile/android/base/GeckoSmsManager.java
+++ b/mobile/android/base/GeckoSmsManager.java
@@ -375,20 +375,20 @@ public class GeckoSmsManager
         return;
       }
 
       Object[] pdus = (Object[]) bundle.get("pdus");
 
       for (int i=0; i<pdus.length; ++i) {
         SmsMessage msg = SmsMessage.createFromPdu((byte[])pdus[i]);
 
-        GeckoAppShell.notifySmsReceived(msg.getDisplayOriginatingAddress(),
-                                        msg.getDisplayMessageBody(),
-                                        getGeckoMessageClass(msg.getMessageClass()),
-                                        System.currentTimeMillis());
+        notifySmsReceived(msg.getDisplayOriginatingAddress(),
+                          msg.getDisplayMessageBody(),
+                          getGeckoMessageClass(msg.getMessageClass()),
+                          System.currentTimeMillis());
       }
 
       return;
     }
 
     if (intent.getAction().equals(ACTION_SMS_SENT) ||
         intent.getAction().equals(ACTION_SMS_DELIVERED)) {
       Bundle bundle = intent.getExtras();
@@ -434,48 +434,47 @@ public class GeckoSmsManager
       }
 
       if (envelope.arePartsRemaining(part)) {
         return;
       }
 
       if (envelope.isFailing(part)) {
         if (part == Envelope.SubParts.SENT_PART) {
-          GeckoAppShell.notifySmsSendFailed(envelope.getError(),
-                                            bundle.getInt("requestId"));
+          notifySmsSendFailed(envelope.getError(), bundle.getInt("requestId"));
           Log.i("GeckoSmsManager", "SMS sending failed!");
         } else {
-          GeckoAppShell.notifySmsDelivery(envelope.getMessageId(),
-                                          kDeliveryStatusError,
-                                          bundle.getString("number"),
-                                          bundle.getString("message"),
-                                          envelope.getMessageTimestamp());
+          notifySmsDelivery(envelope.getMessageId(),
+                            kDeliveryStatusError,
+                            bundle.getString("number"),
+                            bundle.getString("message"),
+                            envelope.getMessageTimestamp());
           Log.i("GeckoSmsManager", "SMS delivery failed!");
         }
       } else {
         if (part == Envelope.SubParts.SENT_PART) {
           String number = bundle.getString("number");
           String message = bundle.getString("message");
           long timestamp = System.currentTimeMillis();
 
           int id = saveSentMessage(number, message, timestamp);
 
-          GeckoAppShell.notifySmsSent(id, number, message, timestamp,
-                                      bundle.getInt("requestId"));
+          notifySmsSent(id, number, message, timestamp,
+                        bundle.getInt("requestId"));
 
           envelope.setMessageId(id);
           envelope.setMessageTimestamp(timestamp);
 
           Log.i("GeckoSmsManager", "SMS sending was successfull!");
         } else {
-          GeckoAppShell.notifySmsDelivery(envelope.getMessageId(),
-                                          kDeliveryStatusSuccess,
-                                          bundle.getString("number"),
-                                          bundle.getString("message"),
-                                          envelope.getMessageTimestamp());
+          notifySmsDelivery(envelope.getMessageId(),
+                            kDeliveryStatusSuccess,
+                            bundle.getString("number"),
+                            bundle.getString("message"),
+                            envelope.getMessageTimestamp());
           Log.i("GeckoSmsManager", "SMS successfully delivered!");
         }
       }
 
       // Destroy the envelope object only if the SMS has been sent and delivered.
       if (!envelope.arePartsRemaining(Envelope.SubParts.SENT_PART) &&
           !envelope.arePartsRemaining(Envelope.SubParts.DELIVERED_PART)) {
         postman.destroyEnvelope(envelopeId);
@@ -561,17 +560,17 @@ public class GeckoSmsManager
       }
     } catch (Exception e) {
       Log.e("GeckoSmsManager", "Failed to send an SMS: ", e);
 
       if (envelopeId != Postman.kUnknownEnvelopeId) {
         Postman.getInstance().destroyEnvelope(envelopeId);
       }
 
-      GeckoAppShell.notifySmsSendFailed(kUnknownError, aRequestId);
+      notifySmsSendFailed(kUnknownError, aRequestId);
     }
   }
 
   public int saveSentMessage(String aRecipient, String aBody, long aDate) {
     try {
       ContentValues values = new ContentValues();
       values.put("address", aRecipient);
       values.put("body", aBody);
@@ -643,49 +642,49 @@ public class GeckoSmsManager
             sender = cursor.getString(cursor.getColumnIndex("address"));
           } else if (type == kSmsTypeSentbox) {
             deliveryStatus = getGeckoDeliveryStatus(cursor.getInt(cursor.getColumnIndex("status")));
             receiver = cursor.getString(cursor.getColumnIndex("address"));
           } else {
             throw new InvalidTypeException();
           }
 
-          GeckoAppShell.notifyGetSms(cursor.getInt(cursor.getColumnIndex("_id")),
-                                     deliveryStatus,
-                                     receiver, sender,
-                                     cursor.getString(cursor.getColumnIndex("body")),
-                                     cursor.getLong(cursor.getColumnIndex("date")),
-                                     mRequestId);
+          notifyGetSms(cursor.getInt(cursor.getColumnIndex("_id")),
+                       deliveryStatus,
+                       receiver, sender,
+                       cursor.getString(cursor.getColumnIndex("body")),
+                       cursor.getLong(cursor.getColumnIndex("date")),
+                       mRequestId);
         } catch (NotFoundException e) {
           Log.i("GeckoSmsManager", "Message id " + mMessageId + " not found");
-          GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId);
+          notifyGetSmsFailed(kNotFoundError, mRequestId);
         } catch (UnmatchingIdException e) {
           Log.e("GeckoSmsManager", "Requested message id (" + mMessageId +
                                    ") is different from the one we got.");
-          GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
+          notifyGetSmsFailed(kUnknownError, mRequestId);
         } catch (TooManyResultsException e) {
           Log.e("GeckoSmsManager", "Get too many results for id " + mMessageId);
-          GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
+          notifyGetSmsFailed(kUnknownError, mRequestId);
         } catch (InvalidTypeException e) {
           Log.i("GeckoSmsManager", "Message has an invalid type, we ignore it.");
-          GeckoAppShell.notifyGetSmsFailed(kNotFoundError, mRequestId);
+          notifyGetSmsFailed(kNotFoundError, mRequestId);
         } catch (Exception e) {
           Log.e("GeckoSmsManager", "Error while trying to get message", e);
-          GeckoAppShell.notifyGetSmsFailed(kUnknownError, mRequestId);
+          notifyGetSmsFailed(kUnknownError, mRequestId);
         } finally {
           if (cursor != null) {
             cursor.close();
           }
         }
       }
     }
 
     if (!SmsIOThread.getInstance().execute(new GetMessageRunnable(aMessageId, aRequestId))) {
       Log.e("GeckoSmsManager", "Failed to add GetMessageRunnable to the SmsIOThread");
-      GeckoAppShell.notifyGetSmsFailed(kUnknownError, aRequestId);
+      notifyGetSmsFailed(kUnknownError, aRequestId);
     }
   }
 
   public void deleteMessage(int aMessageId, int aRequestId) {
     class DeleteMessageRunnable implements Runnable {
       private int mMessageId;
       private int mRequestId;
 
@@ -701,30 +700,30 @@ public class GeckoSmsManager
           Uri message = ContentUris.withAppendedId(kSmsContentUri, mMessageId);
 
           int count = cr.delete(message, null, null);
 
           if (count > 1) {
             throw new TooManyResultsException();
           }
 
-          GeckoAppShell.notifySmsDeleted(count == 1, mRequestId);
+          notifySmsDeleted(count == 1, mRequestId);
         } catch (TooManyResultsException e) {
           Log.e("GeckoSmsManager", "Delete more than one message?", e);
-          GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId);
+          notifySmsDeleteFailed(kUnknownError, mRequestId);
         } catch (Exception e) {
           Log.e("GeckoSmsManager", "Error while trying to delete a message", e);
-          GeckoAppShell.notifySmsDeleteFailed(kUnknownError, mRequestId);
+          notifySmsDeleteFailed(kUnknownError, mRequestId);
         }
       }
     }
 
     if (!SmsIOThread.getInstance().execute(new DeleteMessageRunnable(aMessageId, aRequestId))) {
       Log.e("GeckoSmsManager", "Failed to add GetMessageRunnable to the SmsIOThread");
-      GeckoAppShell.notifySmsDeleteFailed(kUnknownError, aRequestId);
+      notifySmsDeleteFailed(kUnknownError, aRequestId);
     }
   }
 
   public void createMessageList(long aStartDate, long aEndDate, String[] aNumbers, int aNumbersCount, int aDeliveryState, boolean aReverse, int aRequestId) {
     class CreateMessageListRunnable implements Runnable {
       private long     mStartDate;
       private long     mEndDate;
       private String[] mNumbers;
@@ -787,17 +786,17 @@ public class GeckoSmsManager
             restrictionText += " AND " + restrictions.get(i);
           }
 
           ContentResolver cr = GeckoApp.mAppContext.getContentResolver();
           cursor = cr.query(kSmsContentUri, kRequiredMessageRows, restrictionText, null,
                             mReverse ? "date DESC" : "date ASC");
 
           if (cursor.getCount() == 0) {
-            GeckoAppShell.notifyNoMessageInList(mRequestId);
+            notifyNoMessageInList(mRequestId);
             return;
           }
 
           cursor.moveToFirst();
 
           int type = cursor.getInt(cursor.getColumnIndex("type"));
           int deliveryStatus;
           String sender = "";
@@ -810,43 +809,43 @@ public class GeckoSmsManager
             deliveryStatus = getGeckoDeliveryStatus(cursor.getInt(cursor.getColumnIndex("status")));
             receiver = cursor.getString(cursor.getColumnIndex("address"));
           } else {
             throw new UnexpectedDeliveryStateException();
           }
 
           int listId = MessagesListManager.getInstance().add(cursor);
           closeCursor = false;
-          GeckoAppShell.notifyListCreated(listId,
-                                          cursor.getInt(cursor.getColumnIndex("_id")),
-                                          deliveryStatus,
-                                          receiver, sender,
-                                          cursor.getString(cursor.getColumnIndex("body")),
-                                          cursor.getLong(cursor.getColumnIndex("date")),
-                                          mRequestId);
+          notifyListCreated(listId,
+                            cursor.getInt(cursor.getColumnIndex("_id")),
+                            deliveryStatus,
+                            receiver, sender,
+                            cursor.getString(cursor.getColumnIndex("body")),
+                            cursor.getLong(cursor.getColumnIndex("date")),
+                            mRequestId);
         } catch (UnexpectedDeliveryStateException e) {
           Log.e("GeckoSmsManager", "Unexcepted delivery state type", e);
-          GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
+          notifyReadingMessageListFailed(kUnknownError, mRequestId);
         } catch (Exception e) {
           Log.e("GeckoSmsManager", "Error while trying to create a message list cursor", e);
-          GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
+          notifyReadingMessageListFailed(kUnknownError, mRequestId);
         } finally {
           // Close the cursor if MessagesListManager isn't taking care of it.
           // We could also just check if it is in the MessagesListManager list but
           // that would be less efficient.
           if (cursor != null && closeCursor) {
             cursor.close();
           }
         }
       }
     }
 
     if (!SmsIOThread.getInstance().execute(new CreateMessageListRunnable(aStartDate, aEndDate, aNumbers, aNumbersCount, aDeliveryState, aReverse, aRequestId))) {
       Log.e("GeckoSmsManager", "Failed to add CreateMessageListRunnable to the SmsIOThread");
-      GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId);
+      notifyReadingMessageListFailed(kUnknownError, aRequestId);
     }
   }
 
   public void getNextMessageInList(int aListId, int aRequestId) {
     class GetNextMessageInListRunnable implements Runnable {
       private int mListId;
       private int mRequestId;
 
@@ -857,17 +856,17 @@ public class GeckoSmsManager
 
       @Override
       public void run() {
         try {
           Cursor cursor = MessagesListManager.getInstance().get(mListId);
 
           if (!cursor.moveToNext()) {
             MessagesListManager.getInstance().remove(mListId);
-            GeckoAppShell.notifyNoMessageInList(mRequestId);
+            notifyNoMessageInList(mRequestId);
             return;
           }
 
           int type = cursor.getInt(cursor.getColumnIndex("type"));
           int deliveryStatus;
           String sender = "";
           String receiver = "";
 
@@ -877,35 +876,35 @@ public class GeckoSmsManager
           } else if (type == kSmsTypeSentbox) {
             deliveryStatus = getGeckoDeliveryStatus(cursor.getInt(cursor.getColumnIndex("status")));
             receiver = cursor.getString(cursor.getColumnIndex("address"));
           } else {
             throw new UnexpectedDeliveryStateException();
           }
 
           int listId = MessagesListManager.getInstance().add(cursor);
-          GeckoAppShell.notifyGotNextMessage(cursor.getInt(cursor.getColumnIndex("_id")),
-                                             deliveryStatus,
-                                             receiver, sender,
-                                             cursor.getString(cursor.getColumnIndex("body")),
-                                             cursor.getLong(cursor.getColumnIndex("date")),
-                                             mRequestId);
+          notifyGotNextMessage(cursor.getInt(cursor.getColumnIndex("_id")),
+                               deliveryStatus,
+                               receiver, sender,
+                               cursor.getString(cursor.getColumnIndex("body")),
+                               cursor.getLong(cursor.getColumnIndex("date")),
+                               mRequestId);
         } catch (UnexpectedDeliveryStateException e) {
           Log.e("GeckoSmsManager", "Unexcepted delivery state type", e);
-          GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
+          notifyReadingMessageListFailed(kUnknownError, mRequestId);
         } catch (Exception e) {
           Log.e("GeckoSmsManager", "Error while trying to get the next message of a list", e);
-          GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, mRequestId);
+          notifyReadingMessageListFailed(kUnknownError, mRequestId);
         }
       }
     }
 
     if (!SmsIOThread.getInstance().execute(new GetNextMessageInListRunnable(aListId, aRequestId))) {
       Log.e("GeckoSmsManager", "Failed to add GetNextMessageInListRunnable to the SmsIOThread");
-      GeckoAppShell.notifyReadingMessageListFailed(kUnknownError, aRequestId);
+      notifyReadingMessageListFailed(kUnknownError, aRequestId);
     }
   }
 
   public void clearMessageList(int aListId) {
     MessagesListManager.getInstance().remove(aListId);
   }
 
   public void stop() {
@@ -963,9 +962,22 @@ public class GeckoSmsManager
 
   class UnexpectedDeliveryStateException extends Exception {
     private static final long serialVersionUID = 494122763684005716L;
   }
 
   class UnmatchingIdException extends Exception {
     private static final long serialVersionUID = 158467542575633280L;
   }
+
+  private static native void notifySmsReceived(String aSender, String aBody, int aMessageClass, long aTimestamp);
+  private static native void notifySmsSent(int aId, String aReceiver, String aBody, long aTimestamp, int aRequestId);
+  private static native void notifySmsDelivery(int aId, int aDeliveryStatus, String aReceiver, String aBody, long aTimestamp);
+  private static native void notifySmsSendFailed(int aError, int aRequestId);
+  private static native void notifyGetSms(int aId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
+  private static native void notifyGetSmsFailed(int aError, int aRequestId);
+  private static native void notifySmsDeleted(boolean aDeleted, int aRequestId);
+  private static native void notifySmsDeleteFailed(int aError, int aRequestId);
+  private static native void notifyNoMessageInList(int aRequestId);
+  private static native void notifyListCreated(int aListId, int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
+  private static native void notifyGotNextMessage(int aMessageId, int aDeliveryStatus, String aReceiver, String aSender, String aBody, long aTimestamp, int aRequestId);
+  private static native void notifyReadingMessageListFailed(int aError, int aRequestId);
 }
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -1182,18 +1182,31 @@ jars/sync-thirdparty.jar: $(addprefix $(
 	$(NSINSTALL) -D classes/sync-thirdparty
 	$(JAVAC) $(JAVAC_FLAGS) -d classes/sync-thirdparty $(addprefix $(srcdir)/,$(SYNC_THIRDPARTY_JAVA_FILES))
 	$(JAR) cMf jars/sync-thirdparty.jar -C classes/sync-thirdparty .
 
 jars:
 	@echo "MKDIR jars"
 	$(NSINSTALL) -D jars
 
+CLASSES_WITH_JNI= \
+    org.mozilla.gecko.GeckoAppShell \
+    $(NULL)
+
+ifdef MOZ_WEBSMS_BACKEND
+# Note: if you are building with MOZ_WEBSMS_BACKEND turned on, then
+# you will get a build error because the generated jni-stubs.inc will
+# be different than the one checked in (i.e. it will have the sms-related
+# JNI stubs as well). Just copy the generated file to mozglue/android/
+# like the error message says and rebuild. All should be well after that.
+CLASSES_WITH_JNI += org.mozilla.gecko.GeckoSmsManager
+endif
+
 jni-stubs.inc: jars/gecko-browser.jar jars/gecko-mozglue.jar jars/gecko-util.jar jars/sync-thirdparty.jar
-	$(JAVAH) -o javah.out -bootclasspath $(JAVA_BOOTCLASSPATH) -classpath $(subst $(NULL) $(NULL),:,$^) org.mozilla.gecko.GeckoAppShell
+	$(JAVAH) -o javah.out -bootclasspath $(JAVA_BOOTCLASSPATH) -classpath $(subst $(NULL) $(NULL),:,$^) $(CLASSES_WITH_JNI)
 	$(PYTHON) $(topsrcdir)/mobile/android/base/jni-generator.py javah.out $@
 
 PP_RES_XML= \
   $(SYNC_PP_RES_XML) \
   $(FENNEC_PP_XML_FILES) \
   $(NULL)
 
 # This is kinda awful; if any of the source files change, we remake them all.
--- a/mozglue/android/jni-stubs.inc
+++ b/mozglue/android/jni-stubs.inc
@@ -224,244 +224,16 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 #endif
 
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange);
 #endif
 
 #ifdef JNI_STUBS
 
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived_t)(JNIEnv *, jclass, jstring, jstring, jint, jlong);
-static Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived_t f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived(JNIEnv * arg0, jclass arg1, jstring arg2, jstring arg3, jint arg4, jlong arg5) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived(arg0, arg1, arg2, arg3, arg4, arg5);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived", &f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent_t)(JNIEnv *, jclass, jint, jstring, jstring, jlong, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent_t f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent(JNIEnv * arg0, jclass arg1, jint arg2, jstring arg3, jstring arg4, jlong arg5, jint arg6) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent", &f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery_t)(JNIEnv *, jclass, jint, jint, jstring, jstring, jlong);
-static Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery_t f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3, jstring arg4, jstring arg5, jlong arg6) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery(arg0, arg1, arg2, arg3, arg4, arg5, arg6);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery", &f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed_t)(JNIEnv *, jclass, jint, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed_t f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed(arg0, arg1, arg2, arg3);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed", &f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms_t)(JNIEnv *, jclass, jint, jint, jstring, jstring, jstring, jlong, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3, jstring arg4, jstring arg5, jstring arg6, jlong arg7, jint arg8) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed_t)(JNIEnv *, jclass, jint, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed(arg0, arg1, arg2, arg3);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted_t)(JNIEnv *, jclass, jboolean, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted_t f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted(JNIEnv * arg0, jclass arg1, jboolean arg2, jint arg3) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted(arg0, arg1, arg2, arg3);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted", &f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed_t)(JNIEnv *, jclass, jint, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed_t f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed(arg0, arg1, arg2, arg3);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed", &f_Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList_t)(JNIEnv *, jclass, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList(JNIEnv * arg0, jclass arg1, jint arg2) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList(arg0, arg1, arg2);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated_t)(JNIEnv *, jclass, jint, jint, jint, jstring, jstring, jstring, jlong, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3, jint arg4, jstring arg5, jstring arg6, jstring arg7, jlong arg8, jint arg9) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage_t)(JNIEnv *, jclass, jint, jint, jstring, jstring, jstring, jlong, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3, jstring arg4, jstring arg5, jstring arg6, jlong arg7, jint arg8) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage);
-#endif
-
-#ifdef JNI_STUBS
-
-typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed_t)(JNIEnv *, jclass, jint, jint);
-static Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed;
-extern "C" NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3) {
-    if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed) {
-        arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
-                       "JNI Function called before it was loaded");
-        return ;
-    }
-     f_Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(arg0, arg1, arg2, arg3);
-}
-#endif
-
-#ifdef JNI_BINDINGS
-  xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed);
-#endif
-
-#ifdef JNI_STUBS
-
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite_t f_Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite;
 extern "C" NS_EXPORT void JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
--- a/widget/android/AndroidJNI.cpp
+++ b/widget/android/AndroidJNI.cpp
@@ -170,22 +170,24 @@ Java_org_mozilla_gecko_GeckoAppShell_not
       bool   mCharging;
       double mRemainingTime;
     };
 
     nsCOMPtr<nsIRunnable> runnable = new NotifyBatteryChangeRunnable(aLevel, aCharging, aRemainingTime);
     NS_DispatchToMainThread(runnable);
 }
 
+#ifdef MOZ_WEBSMS_BACKEND
+
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsReceived(JNIEnv* jenv, jclass,
-                                                       jstring aSender,
-                                                       jstring aBody,
-                                                       jint aMessageClass,
-                                                       jlong aTimestamp)
+Java_org_mozilla_gecko_GeckoSmsManager_notifySmsReceived(JNIEnv* jenv, jclass,
+                                                         jstring aSender,
+                                                         jstring aBody,
+                                                         jint aMessageClass,
+                                                         jlong aTimestamp)
 {
     class NotifySmsReceivedRunnable : public nsRunnable {
     public:
       NotifySmsReceivedRunnable(const SmsMessageData& aMessageData)
         : mMessageData(aMessageData)
       {}
 
       NS_IMETHODIMP Run() {
@@ -209,22 +211,22 @@ Java_org_mozilla_gecko_GeckoAppShell_not
                            static_cast<MessageClass>(aMessageClass),
                            aTimestamp, false);
 
     nsCOMPtr<nsIRunnable> runnable = new NotifySmsReceivedRunnable(message);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsSent(JNIEnv* jenv, jclass,
-                                                   jint aId,
-                                                   jstring aReceiver,
-                                                   jstring aBody,
-                                                   jlong aTimestamp,
-                                                   jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifySmsSent(JNIEnv* jenv, jclass,
+                                                     jint aId,
+                                                     jstring aReceiver,
+                                                     jstring aBody,
+                                                     jlong aTimestamp,
+                                                     jint aRequestId)
 {
     class NotifySmsSentRunnable : public nsRunnable {
     public:
       NotifySmsSentRunnable(const SmsMessageData& aMessageData,
                             int32_t aRequestId)
         : mMessageData(aMessageData)
         , mRequestId(aRequestId)
       {}
@@ -261,22 +263,22 @@ Java_org_mozilla_gecko_GeckoAppShell_not
                            nsJNIString(aBody, jenv), eMessageClass_Normal,
                            aTimestamp, true);
 
     nsCOMPtr<nsIRunnable> runnable = new NotifySmsSentRunnable(message, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsDelivery(JNIEnv* jenv, jclass,
-                                                       jint aId,
-                                                       jint aDeliveryStatus,
-                                                       jstring aReceiver,
-                                                       jstring aBody,
-                                                       jlong aTimestamp)
+Java_org_mozilla_gecko_GeckoSmsManager_notifySmsDelivery(JNIEnv* jenv, jclass,
+                                                         jint aId,
+                                                         jint aDeliveryStatus,
+                                                         jstring aReceiver,
+                                                         jstring aBody,
+                                                         jlong aTimestamp)
 {
     class NotifySmsDeliveredRunnable : public nsRunnable {
     public:
       NotifySmsDeliveredRunnable(const SmsMessageData& aMessageData)
         : mMessageData(aMessageData)
       {}
 
       NS_IMETHODIMP Run() {
@@ -305,19 +307,19 @@ Java_org_mozilla_gecko_GeckoAppShell_not
                            nsJNIString(aBody, jenv), eMessageClass_Normal,
                            aTimestamp, true);
 
     nsCOMPtr<nsIRunnable> runnable = new NotifySmsDeliveredRunnable(message);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsSendFailed(JNIEnv* jenv, jclass,
-                                                         jint aError,
-                                                         jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifySmsSendFailed(JNIEnv* jenv, jclass,
+                                                           jint aError,
+                                                           jint aRequestId)
 {
     class NotifySmsSendFailedRunnable : public nsRunnable {
     public:
       NotifySmsSendFailedRunnable(int32_t aError,
                                   int32_t aRequestId)
         : mError(aError)
         , mRequestId(aRequestId)
       {}
@@ -338,24 +340,24 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 
 
     nsCOMPtr<nsIRunnable> runnable =
       new NotifySmsSendFailedRunnable(aError, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyGetSms(JNIEnv* jenv, jclass,
-                                                  jint aId,
-                                                  jint aDeliveryStatus,
-                                                  jstring aReceiver,
-                                                  jstring aSender,
-                                                  jstring aBody,
-                                                  jlong aTimestamp,
-                                                  jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifyGetSms(JNIEnv* jenv, jclass,
+                                                    jint aId,
+                                                    jint aDeliveryStatus,
+                                                    jstring aReceiver,
+                                                    jstring aSender,
+                                                    jstring aBody,
+                                                    jlong aTimestamp,
+                                                    jint aRequestId)
 {
     class NotifyGetSmsRunnable : public nsRunnable {
     public:
       NotifyGetSmsRunnable(const SmsMessageData& aMessageData,
                            int32_t aRequestId)
         : mMessageData(aMessageData)
         , mRequestId(aRequestId)
       {}
@@ -387,19 +389,19 @@ Java_org_mozilla_gecko_GeckoAppShell_not
                            nsJNIString(aBody, jenv), eMessageClass_Normal,
                            aTimestamp, true);
 
     nsCOMPtr<nsIRunnable> runnable = new NotifyGetSmsRunnable(message, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyGetSmsFailed(JNIEnv* jenv, jclass,
-                                                        jint aError,
-                                                        jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifyGetSmsFailed(JNIEnv* jenv, jclass,
+                                                          jint aError,
+                                                          jint aRequestId)
 {
     class NotifyGetSmsFailedRunnable : public nsRunnable {
     public:
       NotifyGetSmsFailedRunnable(int32_t aError,
                                  int32_t aRequestId)
         : mError(aError)
         , mRequestId(aRequestId)
       {}
@@ -420,19 +422,19 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 
 
     nsCOMPtr<nsIRunnable> runnable =
       new NotifyGetSmsFailedRunnable(aError, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleted(JNIEnv* jenv, jclass,
-                                                      jboolean aDeleted,
-                                                      jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifySmsDeleted(JNIEnv* jenv, jclass,
+                                                        jboolean aDeleted,
+                                                        jint aRequestId)
 {
     class NotifySmsDeletedRunnable : public nsRunnable {
     public:
       NotifySmsDeletedRunnable(bool aDeleted, int32_t aRequestId)
         : mDeleted(aDeleted)
         , mRequestId(aRequestId)
       {}
 
@@ -452,19 +454,19 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 
 
     nsCOMPtr<nsIRunnable> runnable =
       new NotifySmsDeletedRunnable(aDeleted, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifySmsDeleteFailed(JNIEnv* jenv, jclass,
-                                                           jint aError,
-                                                           jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifySmsDeleteFailed(JNIEnv* jenv, jclass,
+                                                             jint aError,
+                                                             jint aRequestId)
 {
     class NotifySmsDeleteFailedRunnable : public nsRunnable {
     public:
       NotifySmsDeleteFailedRunnable(int32_t aError,
                                     int32_t aRequestId)
         : mError(aError)
         , mRequestId(aRequestId)
       {}
@@ -485,18 +487,18 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 
 
     nsCOMPtr<nsIRunnable> runnable =
       new NotifySmsDeleteFailedRunnable(aError, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyNoMessageInList(JNIEnv* jenv, jclass,
-                                                           jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifyNoMessageInList(JNIEnv* jenv, jclass,
+                                                             jint aRequestId)
 {
     class NotifyNoMessageInListRunnable : public nsRunnable {
     public:
       NotifyNoMessageInListRunnable(int32_t aRequestId)
         : mRequestId(aRequestId)
       {}
 
       NS_IMETHODIMP Run() {
@@ -514,25 +516,25 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 
 
     nsCOMPtr<nsIRunnable> runnable =
       new NotifyNoMessageInListRunnable(aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyListCreated(JNIEnv* jenv, jclass,
-                                                       jint aListId,
-                                                       jint aMessageId,
-                                                       jint aDeliveryStatus,
-                                                       jstring aReceiver,
-                                                       jstring aSender,
-                                                       jstring aBody,
-                                                       jlong aTimestamp,
-                                                       jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifyListCreated(JNIEnv* jenv, jclass,
+                                                         jint aListId,
+                                                         jint aMessageId,
+                                                         jint aDeliveryStatus,
+                                                         jstring aReceiver,
+                                                         jstring aSender,
+                                                         jstring aBody,
+                                                         jlong aTimestamp,
+                                                         jint aRequestId)
 {
     class NotifyCreateMessageListRunnable : public nsRunnable {
     public:
       NotifyCreateMessageListRunnable(int32_t aListId,
                                       const SmsMessageData& aMessageData,
                                       int32_t aRequestId)
         : mListId(aListId)
         , mMessageData(aMessageData)
@@ -569,24 +571,24 @@ Java_org_mozilla_gecko_GeckoAppShell_not
                            aTimestamp, true);
 
     nsCOMPtr<nsIRunnable> runnable =
       new NotifyCreateMessageListRunnable(aListId, message, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyGotNextMessage(JNIEnv* jenv, jclass,
-                                                          jint aMessageId,
-                                                          jint aDeliveryStatus,
-                                                          jstring aReceiver,
-                                                          jstring aSender,
-                                                          jstring aBody,
-                                                          jlong aTimestamp,
-                                                          jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifyGotNextMessage(JNIEnv* jenv, jclass,
+                                                            jint aMessageId,
+                                                            jint aDeliveryStatus,
+                                                            jstring aReceiver,
+                                                            jstring aSender,
+                                                            jstring aBody,
+                                                            jlong aTimestamp,
+                                                            jint aRequestId)
 {
     class NotifyGotNextMessageRunnable : public nsRunnable {
     public:
       NotifyGotNextMessageRunnable(const SmsMessageData& aMessageData,
                                    int32_t aRequestId)
         : mMessageData(aMessageData)
         , mRequestId(aRequestId)
       {}
@@ -620,19 +622,19 @@ Java_org_mozilla_gecko_GeckoAppShell_not
                            aTimestamp, true);
 
     nsCOMPtr<nsIRunnable> runnable =
       new NotifyGotNextMessageRunnable(message, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
 NS_EXPORT void JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(JNIEnv* jenv, jclass,
-                                                                    jint aError,
-                                                                    jint aRequestId)
+Java_org_mozilla_gecko_GeckoSmsManager_notifyReadingMessageListFailed(JNIEnv* jenv, jclass,
+                                                                      jint aError,
+                                                                      jint aRequestId)
 {
     class NotifyReadListFailedRunnable : public nsRunnable {
     public:
       NotifyReadListFailedRunnable(int32_t aError,
                                    int32_t aRequestId)
         : mError(aError)
         , mRequestId(aRequestId)
       {}
@@ -652,16 +654,18 @@ Java_org_mozilla_gecko_GeckoAppShell_not
     };
 
 
     nsCOMPtr<nsIRunnable> runnable =
       new NotifyReadListFailedRunnable(aError, aRequestId);
     NS_DispatchToMainThread(runnable);
 }
 
+#endif  // MOZ_WEBSMS_BACKEND
+
 #ifdef MOZ_ANDROID_OMTC
 
 NS_EXPORT void JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite(JNIEnv*, jclass)
 {
     nsWindow::ScheduleComposite();
 }
 
--- a/widget/android/Makefile.in
+++ b/widget/android/Makefile.in
@@ -17,16 +17,19 @@ IS_COMPONENT    = 1
 MODULE_NAME     = nsWidgetAndroidModule
 GRE_MODULE      = 1
 LIBXUL_LIBRARY  = 1
 FAIL_ON_WARNINGS := 1
 
 ifdef MOZ_ONLY_TOUCH_EVENTS
 DEFINES += -DMOZ_ONLY_TOUCH_EVENTS
 endif
+ifdef MOZ_WEBSMS_BACKEND
+DEFINES += -DMOZ_WEBSMS_BACKEND
+endif
 
 CPPSRCS	= \
 	GfxInfo.cpp \
 	nsWidgetFactory.cpp \
 	nsAppShell.cpp \
 	AndroidJavaWrappers.cpp \
 	AndroidBridge.cpp \
 	AndroidDirectTexture.cpp \