mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 887118 - Cannot update an preinstalled packaged app (signed or otherwise) to a signed packaged app. r=ferjm
This commit is contained in:
parent
a392d9e690
commit
604b8e6a46
@ -79,6 +79,13 @@ XPCOMUtils.defineLazyGetter(this, "updateSvc", function() {
|
|||||||
const DIRECTORY_NAME = WEBAPP_RUNTIME ? "WebappRegD" : "ProfD";
|
const DIRECTORY_NAME = WEBAPP_RUNTIME ? "WebappRegD" : "ProfD";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We'll use this to identify privileged apps that have been preinstalled
|
||||||
|
// For those apps we'll set
|
||||||
|
// STORE_ID_PENDING_PREFIX + installOrigin
|
||||||
|
// as the storeID. This ensures it's unique and can't be set from a legit
|
||||||
|
// store even by error.
|
||||||
|
const STORE_ID_PENDING_PREFIX = "#unknownID#";
|
||||||
|
|
||||||
this.DOMApplicationRegistry = {
|
this.DOMApplicationRegistry = {
|
||||||
appsFile: null,
|
appsFile: null,
|
||||||
webapps: { },
|
webapps: { },
|
||||||
@ -346,6 +353,11 @@ this.DOMApplicationRegistry = {
|
|||||||
|
|
||||||
app.origin = "app://" + aId;
|
app.origin = "app://" + aId;
|
||||||
|
|
||||||
|
// Do this for all preinstalled apps... we can't know at this
|
||||||
|
// point if the updates will be signed or not and it doesn't
|
||||||
|
// hurt to have it always.
|
||||||
|
app.storeId = STORE_ID_PENDING_PREFIX + app.installOrigin;
|
||||||
|
|
||||||
// Extract the manifest.webapp file from application.zip.
|
// Extract the manifest.webapp file from application.zip.
|
||||||
let zipFile = baseDir.clone();
|
let zipFile = baseDir.clone();
|
||||||
zipFile.append("application.zip");
|
zipFile.append("application.zip");
|
||||||
@ -2253,7 +2265,8 @@ this.DOMApplicationRegistry = {
|
|||||||
function checkForStoreIdMatch(aStoreId, aStoreVersion) {
|
function checkForStoreIdMatch(aStoreId, aStoreVersion) {
|
||||||
// Things to check:
|
// Things to check:
|
||||||
// 1. if it's a update:
|
// 1. if it's a update:
|
||||||
// a. We should already have this storeId
|
// a. We should already have this storeId, or the original storeId must start
|
||||||
|
// with STORE_ID_PENDING_PREFIX
|
||||||
// b. The manifestURL for the stored app should be the same one we're
|
// b. The manifestURL for the stored app should be the same one we're
|
||||||
// updating
|
// updating
|
||||||
// c. And finally the version of the update should be higher than the one
|
// c. And finally the version of the update should be higher than the one
|
||||||
@ -2267,14 +2280,17 @@ this.DOMApplicationRegistry = {
|
|||||||
let appId = self.getAppLocalIdByStoreId(aStoreId);
|
let appId = self.getAppLocalIdByStoreId(aStoreId);
|
||||||
let isInstalled = appId != Ci.nsIScriptSecurityManager.NO_APP_ID;
|
let isInstalled = appId != Ci.nsIScriptSecurityManager.NO_APP_ID;
|
||||||
if (aIsUpdate) {
|
if (aIsUpdate) {
|
||||||
if (!isInstalled || (app.localId !== appId)) {
|
let isDifferent = app.localId !== appId;
|
||||||
// If we don't have the storeId on track already, this
|
let isPending = app.storeId.indexOf(STORE_ID_PENDING_PREFIX) == 0;
|
||||||
// cannot be an update
|
|
||||||
|
if ((!isInstalled && !isPending) || (isInstalled && isDifferent)) {
|
||||||
throw "WRONG_APP_STORE_ID";
|
throw "WRONG_APP_STORE_ID";
|
||||||
}
|
}
|
||||||
if (app.storeVersion >= aStoreVersion) {
|
|
||||||
|
if (!isPending && (app.storeVersion >= aStoreVersion)) {
|
||||||
throw "APP_STORE_VERSION_ROLLBACK";
|
throw "APP_STORE_VERSION_ROLLBACK";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (isInstalled) {
|
} else if (isInstalled) {
|
||||||
throw "WRONG_APP_STORE_ID";
|
throw "WRONG_APP_STORE_ID";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user