Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2013-05-15 08:36:44 -04:00
commit ea3d49228d
14 changed files with 176 additions and 21 deletions

View File

@ -256,6 +256,13 @@ bool OmxDecoder::Init() {
// for (h.264). So if we don't get a hardware decoder, just give
// up.
int flags = kHardwareCodecsOnly;
char propQemu[PROPERTY_VALUE_MAX];
property_get("ro.kernel.qemu", propQemu, "");
if (!strncmp(propQemu, "1", 1)) {
// If we are in emulator, allow to fall back to software.
flags = 0;
}
videoSource = OMXCodec::Create(omx,
videoTrack->getFormat(),
false, // decoder

View File

@ -202,6 +202,8 @@
#include "nsIAppShellService.h"
#include "nsAppShellCID.h"
#include "nsIAppsService.h"
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
@ -6438,6 +6440,30 @@ nsDocShell::OnRedirectStateChange(nsIChannel* aOldChannel,
if (!oldURI || !newURI) {
return;
}
// Check if we have a redirect registered for this url.
uint32_t appId;
nsresult rv = GetAppId(&appId);
if (NS_FAILED(rv)) {
return;
}
if (appId != nsIScriptSecurityManager::NO_APP_ID &&
appId != nsIScriptSecurityManager::UNKNOWN_APP_ID) {
nsCOMPtr<nsIAppsService> appsService =
do_GetService(APPS_SERVICE_CONTRACTID);
NS_ASSERTION(appsService, "No AppsService available");
nsCOMPtr<nsIURI> redirect;
rv = appsService->GetRedirect(appId, newURI, getter_AddRefs(redirect));
if (NS_SUCCEEDED(rv) && redirect) {
aNewChannel->Cancel(NS_BINDING_ABORTED);
rv = LoadURI(redirect, nullptr, 0, false);
if (NS_SUCCEEDED(rv)) {
return;
}
}
}
// On session restore we get a redirect from page to itself. Don't count it.
bool equals = false;
if (mTiming &&

View File

@ -13,6 +13,7 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
const APPS_SERVICE_CID = Components.ID("{05072afa-92fe-45bf-ae22-39b69c117058}");
@ -78,6 +79,42 @@ AppsService.prototype = {
return DOMApplicationRegistry.getAppInfo(aAppId);
},
getRedirect: function getRedirect(aLocalId, aURI) {
debug("getRedirect for " + aLocalId + " " + aURI.spec);
if (aLocalId == Ci.nsIScriptSecurityManager.NO_APP_ID ||
aLocalId == Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID) {
return null;
}
let app = DOMApplicationRegistry.getAppByLocalId(aLocalId);
if (app && app.redirects) {
let spec = aURI.spec;
for (let i = 0; i < app.redirects.length; i++) {
let redirect = app.redirects[i];
if (spec.startsWith(redirect.from)) {
// Prepend the app origin to the redirection. We need that since
// the origin of packaged apps is a uuid created at install time.
let to = app.origin + redirect.to;
// If we have a ? or a # in the current URL, add this part to the
// redirection.
let index = -1;
index = spec.indexOf('?');
if (index == -1) {
index = spec.indexOf('#');
}
if (index != -1) {
to += spec.substring(index);
}
debug('App specific redirection from ' + spec + ' to ' + to);
return Services.io.newURI(to, null, null);
}
}
} else {
return null;
}
},
classID : APPS_SERVICE_CID,
QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
}

View File

@ -20,13 +20,13 @@ XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
// Shared code for AppsServiceChild.jsm, Webapps.jsm and Webapps.js
this.EXPORTED_SYMBOLS = ["AppsUtils", "ManifestHelper"];
this.EXPORTED_SYMBOLS = ["AppsUtils", "ManifestHelper", "isAbsoluteURI"];
function debug(s) {
//dump("-*- AppsUtils.jsm: " + s + "\n");
}
function isAbsoluteURI(aURI) {
this.isAbsoluteURI = function(aURI) {
let foo = Services.io.newURI("http://foo", null, null);
let bar = Services.io.newURI("http://bar", null, null);
return Services.io.newURI(aURI, null, foo).prePath != foo.prePath ||
@ -92,7 +92,8 @@ this.AppsUtils = {
installerAppId: aApp.installerAppId || Ci.nsIScriptSecurityManager.NO_APP_ID,
installerIsBrowser: !!aApp.installerIsBrowser,
storeId: aApp.storeId || "",
storeVersion: aApp.storeVersion || 0
storeVersion: aApp.storeVersion || 0,
redirects: aApp.redirects
};
},

View File

@ -196,6 +196,24 @@ this.DOMApplicationRegistry = {
this._saveApps();
},
// Ensure that the .to property in redirects is a relative URL.
sanitizeRedirects: function sanitizeRedirects(aSource) {
if (!aSource) {
return null;
}
let res = [];
for (let i = 0; i < aSource.length; i++) {
let redirect = aSource[i];
if (redirect.from && redirect.to &&
isAbsoluteURI(redirect.from) &&
!isAbsoluteURI(redirect.to)) {
res.push(redirect);
}
}
return res.length > 0 ? res : null;
},
// Registers all the activities and system messages.
registerAppsHandlers: function registerAppsHandlers(aRunUpdate) {
this.notifyAppsRegistryStart();
@ -211,7 +229,11 @@ this.DOMApplicationRegistry = {
// twice
this._readManifests(ids, (function readCSPs(aResults) {
aResults.forEach(function registerManifest(aResult) {
this.webapps[aResult.id].csp = aResult.manifest.csp || "";
let app = this.webapps[aResult.id];
app.csp = aResult.manifest.csp || "";
if (app.appStatus >= Ci.nsIPrincipal.APP_STATUS_PRIVILEGED) {
app.redirects = this.sanitizeRedirects(aResult.redirects);
}
}, this);
}).bind(this));
@ -673,6 +695,9 @@ this.DOMApplicationRegistry = {
let manifest = aResult.manifest;
app.name = manifest.name;
app.csp = manifest.csp || "";
if (app.appStatus >= Ci.nsIPrincipal.APP_STATUS_PRIVILEGED) {
app.redirects = this.sanitizeRedirects(manifest.redirects);
}
this._registerSystemMessages(manifest, app);
appsToRegister.push({ manifest: manifest, app: app });
}, this);
@ -1327,11 +1352,14 @@ this.DOMApplicationRegistry = {
return [toHexString(hash.charCodeAt(i)) for (i in hash)].join("");
},
// Updates the activities and system message handlers.
// Updates the redirect mapping, activities and system message handlers.
// aOldManifest can be null if we don't have any handler to unregister.
updateAppHandlers: function(aOldManifest, aNewManifest, aApp) {
debug("updateAppHandlers: old=" + aOldManifest + " new=" + aNewManifest);
this.notifyAppsRegistryStart();
if (aApp.appStatus >= Ci.nsIPrincipal.APP_STATUS_PRIVILEGED) {
aApp.redirects = this.sanitizeRedirects(aNewManifest.redirects);
}
if (supportSystemMessages()) {
if (aOldManifest) {

View File

@ -658,6 +658,19 @@ BluetoothHfpManager::HandleVoiceConnectionChanged()
NS_ENSURE_TRUE(network, NS_ERROR_FAILURE);
network->GetLongName(mOperatorName);
// According to GSM 07.07, "<format> indicates if the format is alphanumeric
// or numeric; long alphanumeric format can be upto 16 characters long and
// short format up to 8 characters (refer GSM MoU SE.13 [9])..."
// However, we found that the operator name may sometimes be longer than 16
// characters. After discussion, we decided to fix this here but not in RIL
// or modem.
//
// Please see Bug 871366 for more information.
if (mOperatorName.Length() > 16) {
NS_WARNING("The operator name was longer than 16 characters. We cut it.");
mOperatorName.Left(mOperatorName, 16);
}
return NS_OK;
}

View File

@ -750,16 +750,17 @@ DeviceStorageFile::CreateUnique(nsAString& aFileName,
NS_ENSURE_SUCCESS(rv, nullptr);
// CreateUnique may cause the filename to change. So we need to update mPath to reflect that.
int32_t lastSlashIndex = dsf->mPath.RFindChar('/');
if (lastSlashIndex == kNotFound) {
dsf->mPath.AssignLiteral("");
} else {
dsf->mPath = Substring(dsf->mPath, 0, lastSlashIndex);
}
nsString leafName;
dsf->mFile->GetLeafName(leafName);
dsf->AppendRelativePath(leafName);
int32_t lastSlashIndex = dsf->mPath.RFindChar('/');
if (lastSlashIndex == kNotFound) {
dsf->mPath.Assign(leafName);
} else {
// Include the last '/'
dsf->mPath = Substring(dsf->mPath, 0, lastSlashIndex + 1);
dsf->mPath.Append(leafName);
}
return dsf.forget();
}

View File

@ -6,6 +6,7 @@
interface mozIDOMApplication;
interface mozIApplication;
interface nsIURI;
%{C++
#define APPS_SERVICE_CID { 0x05072afa, 0x92fe, 0x45bf, { 0xae, 0x22, 0x39, 0xb6, 0x9c, 0x11, 0x70, 0x58 } }
@ -16,7 +17,7 @@ interface mozIApplication;
* This service allows accessing some DOMApplicationRegistry methods from
* non-javascript code.
*/
[scriptable, uuid(1113c6e3-28a2-4315-be10-8b3230eecc0f)]
[scriptable, uuid(27b995cf-bec8-47de-aa48-6117c950fce3)]
interface nsIAppsService : nsISupports
{
mozIDOMApplication getAppByManifestURL(in DOMString manifestURL);
@ -63,6 +64,12 @@ interface nsIAppsService : nsISupports
jsval getAppInfo(in DOMString appId);
/**
* Returns a URI to redirect to when we get a redirection to 'uri'.
* Returns null if no redirection is declared for this uri.
*/
nsIURI getRedirect(in unsigned long localId, in nsIURI uri);
/**
* Returns the localId if the app was installed from a store
*/

View File

@ -61,6 +61,7 @@ MmsMessage::MmsMessage(int32_t aId,
MmsMessage::MmsMessage(const mobilemessage::MmsMessageData& aData)
: mId(aData.id())
, mThreadId(aData.threadId())
, mDelivery(aData.delivery())
, mDeliveryStatus(aData.deliveryStatus())
, mSender(aData.sender())
@ -281,6 +282,7 @@ MmsMessage::GetData(ContentParent* aParent,
NS_ASSERTION(aParent, "aParent is null");
aData.id() = mId;
aData.threadId() = mThreadId;
aData.delivery() = mDelivery;
aData.deliveryStatus() = mDeliveryStatus;
aData.sender().Assign(mSender);

View File

@ -48,6 +48,7 @@ struct MmsAttachmentData
struct MmsMessageData
{
int32_t id;
uint64_t threadId;
DeliveryState delivery;
DeliveryStatus[] deliveryStatus;
nsString sender;

View File

@ -401,6 +401,10 @@ NetworkManager.prototype = {
debug("NetworkManager received message from worker: " + JSON.stringify(e.data));
let response = e.data;
let id = response.id;
if (id == 'broadcast') {
Services.obs.notifyObservers(null, response.topic, response.reason);
return;
}
let callback = this.controlCallbacks[id];
if (callback) {
callback.call(this, response);

View File

@ -24,6 +24,9 @@ const SYS_USB_STATE_PROPERTY = "sys.usb.state";
const USB_FUNCTION_RNDIS = "rndis";
const USB_FUNCTION_ADB = "adb";
const kNetdInterfaceChangedTopic = "netd-interface-change";
const kNetdBandwidthControlTopic = "netd-bandwidth-control";
// Retry 20 times (2 seconds) for usb state transition.
const USB_FUNCTION_RETRY_TIMES = 20;
// Check "sys.usb.state" every 100ms.
@ -41,12 +44,21 @@ const NETD_COMMAND_ERROR = 500;
// 6xx - Unsolicited broadcasts
const NETD_COMMAND_UNSOLICITED = 600;
// Broadcast messages
const NETD_COMMAND_INTERFACE_CHANGE = 600;
const NETD_COMMAND_BANDWIDTH_CONTROLLER = 601;
importScripts("systemlibs.js");
function netdResponseType(code) {
return Math.floor(code/100)*100;
}
function isBroadcastMessage(code) {
let type = netdResponseType(code);
return (type == NETD_COMMAND_UNSOLICITED);
}
function isError(code) {
let type = netdResponseType(code);
return (type != NETD_COMMAND_PROCEEDING && type != NETD_COMMAND_OKAY);
@ -57,6 +69,22 @@ function isComplete(code) {
return (type != NETD_COMMAND_PROCEEDING);
}
function sendBroadcastMessage(code, reason) {
let topic = null;
switch (code) {
case NETD_COMMAND_INTERFACE_CHANGE:
topic = "netd-interface-change";
break;
case NETD_COMMAND_BANDWIDTH_CONTROLLER:
topic = "netd-bandwidth-control";
break;
}
if (topic) {
postMessage({id: 'broadcast', topic: topic, reason: reason});
}
}
let gWifiFailChain = [stopSoftAP,
setIpForwardingEnabled,
stopTethering];
@ -253,6 +281,12 @@ function onNetdMessage(data) {
// 1xx response code regards as command is proceeding, we need to wait for
// final response code such as 2xx, 4xx and 5xx before sending next command.
if (isBroadcastMessage(code)) {
sendBroadcastMessage(code, reason);
nextNetdCommand();
return;
}
if (isComplete(code)) {
gPending = false;
}

View File

@ -99,11 +99,6 @@ function check_geolocation(location) {
function toggleGeolocationSetting(value, callback) {
var mozSettings = window.navigator.mozSettings;
if (!mozSettings) {
addLoadEvent(toggleGeolocationSetting.bind(null, value, callback));
return;
}
var lock = mozSettings.createLock();
var geoenabled = {"geolocation.enabled": value};

View File

@ -156,8 +156,7 @@ void NetdClient::OnLineRead(int aFd, nsDependentCSubstring& aMessage)
// integer response code followed by the rest of the line.
// Fish out the response code.
int responseCode = strtol(aMessage.Data(), nullptr, 10);
// TODO, Bug 783966, handle InterfaceChange(600) and BandwidthControl(601).
if (!errno && responseCode < 600) {
if (!errno) {
NetdCommand* response = new NetdCommand();
// Passing all the response message, including the line terminator.
response->mSize = aMessage.Length();