Bug 903403 - [sms][mms] Make getSegmentInfoForText() Asynchronous to Improve Typing Performance. r=vicamo, sr=mounir
This commit is contained in:
@@ -1658,16 +1658,18 @@ AndroidBridge::SetURITitle(const nsAString& aURI, const nsAString& aTitle)
|
||||
|
||||
nsresult
|
||||
AndroidBridge::GetSegmentInfoForText(const nsAString& aText,
|
||||
dom::mobilemessage::SmsSegmentInfoData* aData)
|
||||
nsIMobileMessageCallback* aRequest)
|
||||
{
|
||||
#ifndef MOZ_WEBSMS_BACKEND
|
||||
return NS_ERROR_FAILURE;
|
||||
#else
|
||||
ALOG_BRIDGE("AndroidBridge::GetSegmentInfoForText");
|
||||
|
||||
aData->segments() = 0;
|
||||
aData->charsPerSegment() = 0;
|
||||
aData->charsAvailableInLastSegment() = 0;
|
||||
dom::mobilemessage::SmsSegmentInfoData data;
|
||||
|
||||
data.segments() = 0;
|
||||
data.charsPerSegment() = 0;
|
||||
data.charsAvailableInLastSegment() = 0;
|
||||
|
||||
JNIEnv *env = GetJNIEnv();
|
||||
if (!env)
|
||||
@@ -1686,13 +1688,17 @@ AndroidBridge::GetSegmentInfoForText(const nsAString& aText,
|
||||
|
||||
jint* info = env->GetIntArrayElements(arr, JNI_FALSE);
|
||||
|
||||
aData->segments() = info[0]; // msgCount
|
||||
aData->charsPerSegment() = info[2]; // codeUnitsRemaining
|
||||
data.segments() = info[0]; // msgCount
|
||||
data.charsPerSegment() = info[2]; // codeUnitsRemaining
|
||||
// segmentChars = (codeUnitCount + codeUnitsRemaining) / msgCount
|
||||
aData->charsAvailableInLastSegment() = (info[1] + info[2]) / info[0];
|
||||
data.charsAvailableInLastSegment() = (info[1] + info[2]) / info[0];
|
||||
|
||||
env->ReleaseIntArrayElements(arr, info, JNI_ABORT);
|
||||
return NS_OK;
|
||||
|
||||
// TODO Bug 908598 - Should properly use |QueueSmsRequest(...)| to queue up
|
||||
// the nsIMobileMessageCallback just like other functions.
|
||||
nsCOMPtr<nsIDOMMozSmsSegmentInfo> info = new SmsSegmentInfo(data);
|
||||
return aRequest->NotifySegmentInfoForTextGot(info);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user