Bug 858689 - Sending an SMS fails on Android. r=mounir

This commit is contained in:
Brad Lassey 2013-04-08 10:29:34 -04:00
parent 9b3c9bf246
commit dee3a4a2f3
2 changed files with 8 additions and 20 deletions

View File

@ -58,8 +58,6 @@ class AndroidRefable {
// This isn't in AndroidBridge.h because including StrongPointer.h there is gross // This isn't in AndroidBridge.h because including StrongPointer.h there is gross
static android::sp<AndroidRefable> (*android_SurfaceTexture_getNativeWindow)(JNIEnv* env, jobject surfaceTexture) = nullptr; static android::sp<AndroidRefable> (*android_SurfaceTexture_getNativeWindow)(JNIEnv* env, jobject surfaceTexture) = nullptr;
/* static */ StaticAutoPtr<nsTArray<nsCOMPtr<nsIMobileMessageCallback> > > AndroidBridge::sSmsRequests;
void void
AndroidBridge::ConstructBridge(JNIEnv *jEnv, AndroidBridge::ConstructBridge(JNIEnv *jEnv,
jclass jGeckoAppShellClass) jclass jGeckoAppShellClass)
@ -1773,21 +1771,16 @@ AndroidBridge::QueueSmsRequest(nsIMobileMessageCallback* aRequest, uint32_t* aRe
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
MOZ_ASSERT(aRequest && aRequestIdOut); MOZ_ASSERT(aRequest && aRequestIdOut);
if (!sSmsRequests) { const uint32_t length = mSmsRequests.Length();
// Probably shutting down.
return false;
}
const uint32_t length = sSmsRequests->Length();
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
if (!(*sSmsRequests)[i]) { if (!(mSmsRequests)[i]) {
(*sSmsRequests)[i] = aRequest; (mSmsRequests)[i] = aRequest;
*aRequestIdOut = i; *aRequestIdOut = i;
return true; return true;
} }
} }
sSmsRequests->AppendElement(aRequest); mSmsRequests.AppendElement(aRequest);
// After AppendElement(), previous `length` points to the new tail element. // After AppendElement(), previous `length` points to the new tail element.
*aRequestIdOut = length; *aRequestIdOut = length;
@ -1799,17 +1792,12 @@ AndroidBridge::DequeueSmsRequest(uint32_t aRequestId)
{ {
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
if (!sSmsRequests) { MOZ_ASSERT(aRequestId < mSmsRequests.Length());
// Probably shutting down. if (aRequestId >= mSmsRequests.Length()) {
return nullptr; return nullptr;
} }
MOZ_ASSERT(aRequestId < sSmsRequests->Length()); return mSmsRequests[aRequestId].forget();
if (aRequestId >= sSmsRequests->Length()) {
return nullptr;
}
return (*sSmsRequests)[aRequestId].forget();
} }
void void

View File

@ -367,7 +367,7 @@ public:
nsACString & aResult); nsACString & aResult);
protected: protected:
static AndroidBridge *sBridge; static AndroidBridge *sBridge;
static StaticAutoPtr<nsTArray<nsCOMPtr<nsIMobileMessageCallback> > > sSmsRequests; nsTArray<nsCOMPtr<nsIMobileMessageCallback> > mSmsRequests;
// the global JavaVM // the global JavaVM
JavaVM *mJavaVM; JavaVM *mJavaVM;