From cc403ee5536e775445ef5c897ca9c89c13c8fa8a Mon Sep 17 00:00:00 2001 From: Simo Kinnunen Date: Fri, 5 Sep 2014 15:32:21 +0900 Subject: [PATCH] Update bluebird because the deprecated features are still available. Use same bluebird in browser. --- bower.json | 1 - .../stf/install/install-error-filter.js | 88 +++++++++++++++++-- .../stf/install/response-codes.json | 40 --------- .../stf/transaction/transaction-error.js | 12 ++- webpack.config.js | 6 +- 5 files changed, 93 insertions(+), 54 deletions(-) delete mode 100644 res/app/components/stf/install/response-codes.json diff --git a/bower.json b/bower.json index 25a50c32..054f6574 100644 --- a/bower.json +++ b/bower.json @@ -24,7 +24,6 @@ "angular-dialog-service": "~5.1.1", "ng-file-upload": "~1.6.5", "angular-growl-v2": "JanStevens/angular-growl-2#~0.7.0", - "bluebird": "~2.1.3", "angular-tree-control": "~0.2.2", "angular-loading-bar": "~0.5.1", "underscore.string": "~2.3.3", diff --git a/res/app/components/stf/install/install-error-filter.js b/res/app/components/stf/install/install-error-filter.js index a226c66c..1e38300f 100644 --- a/res/app/components/stf/install/install-error-filter.js +++ b/res/app/components/stf/install/install-error-filter.js @@ -1,17 +1,93 @@ -// From here: https://github.com/android/platform_frameworks_base/blob/ -// master/core/java/android/content/pm/PackageManager.java#L371 - -var responses = require('./response-codes.json') - module.exports = function installErrorFilter(gettext) { + /*jshint maxlen:200*/ return function (text) { switch (text) { + // Our error codes. + case "INSTALL_SUCCEEDED": + return gettext("Installation succeeded.") case 'INSTALL_ERROR_UNKNOWN': return gettext('Installation failed due to an unknown error.') case 'INSTALL_ERROR_TIMEOUT': return gettext('Installation timed out.') + // Android PackageManager error codes from [1]. + // [1] https://github.com/android/platform_frameworks_base/blob/ + // master/core/java/android/content/pm/PackageManager.java + case "INSTALL_FAILED_ALREADY_EXISTS": + return gettext("The package is already installed.") + case "INSTALL_FAILED_INVALID_APK": + return gettext("The package archive file is invalid.") + case "INSTALL_FAILED_INVALID_URI": + return gettext("The URI passed in is invalid.") + case "INSTALL_FAILED_INSUFFICIENT_STORAGE": + return gettext("The package manager service found that the device didn't have enough storage space to install the app.") + case "INSTALL_FAILED_DUPLICATE_PACKAGE": + return gettext("A package is already installed with the same name.") + case "INSTALL_FAILED_NO_SHARED_USER": + return gettext("The requested shared user does not exist.") + case "INSTALL_FAILED_UPDATE_INCOMPATIBLE": + return gettext("A previously installed package of the same name has a different signature than the new package (and the old package's data was not removed).") + case "INSTALL_FAILED_MISSING_SHARED_LIBRARY": + return gettext("The new package uses a shared library that is not available.") + case "INSTALL_FAILED_REPLACE_COULDNT_DELETE": + return gettext("The existing package could not be deleted.") + case "INSTALL_FAILED_DEXOPT": + return gettext("The new package failed while optimizing and validating its dex files, either because there was not enough storage or the validation failed.") + case "INSTALL_FAILED_OLDER_SDK": + return gettext("The new package failed because the current SDK version is older than that required by the package.") + case "INSTALL_FAILED_CONFLICTING_PROVIDER": + return gettext("The new package failed because it contains a content provider with thesame authority as a provider already installed in the system.") + case "INSTALL_FAILED_NEWER_SDK": + return gettext("The new package failed because the current SDK version is newer than that required by the package.") + case "INSTALL_FAILED_TEST_ONLY": + return gettext("The new package failed because it has specified that it is a test-only package and the caller has not supplied the INSTALL_ALLOW_TEST flag.") + case "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE": + return gettext("The package being installed contains native code, but none that is compatible with the device's CPU_ABI.") + case "INSTALL_FAILED_MISSING_FEATURE": + return gettext("The new package uses a feature that is not available.") + case "INSTALL_FAILED_CONTAINER_ERROR": + return gettext("A secure container mount point couldn't be accessed on external media.") + case "INSTALL_FAILED_INVALID_INSTALL_LOCATION": + return gettext("The new package couldn't be installed in the specified install location.") + case "INSTALL_FAILED_MEDIA_UNAVAILABLE": + return gettext("The new package couldn't be installed in the specified install location because the media is not available.") + case "INSTALL_FAILED_VERIFICATION_TIMEOUT": + return gettext("The new package couldn't be installed because the verification timed out.") + case "INSTALL_FAILED_VERIFICATION_FAILURE": + return gettext("The new package couldn't be installed because the verification did not succeed.") + case "INSTALL_FAILED_PACKAGE_CHANGED": + return gettext("The package changed from what the calling program expected.") + case "INSTALL_FAILED_UID_CHANGED": + return gettext("The new package is assigned a different UID than it previously held.") + case "INSTALL_FAILED_VERSION_DOWNGRADE": + return gettext("The new package has an older version code than the currently installed package.") + case "INSTALL_PARSE_FAILED_NOT_APK": + return gettext("The parser was given a path that is not a file, or does not end with the expected '.apk' extension.") + case "INSTALL_PARSE_FAILED_BAD_MANIFEST": + return gettext("The parser was unable to retrieve the AndroidManifest.xml file.") + case "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION": + return gettext("The parser encountered an unexpected exception.") + case "INSTALL_PARSE_FAILED_NO_CERTIFICATES": + return gettext("The parser did not find any certificates in the .apk.") + case "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES": + return gettext("The parser found inconsistent certificates on the files in the .apk.") + case "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING": + return gettext("The parser encountered a CertificateEncodingException in one of the files in the .apk.") + case "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME": + return gettext("The parser encountered a bad or missing package name in the manifest.") + case "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID": + return gettext("The parser encountered a bad shared user id name in the manifest.") + case "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED": + return gettext("The parser encountered some structural problem in the manifest.") + case "INSTALL_PARSE_FAILED_MANIFEST_EMPTY": + return gettext("The parser did not find any actionable tags (instrumentation or application) in the manifest.") + case "INSTALL_FAILED_INTERNAL_ERROR": + return gettext("The system failed to install the package because of system issues.") + case "INSTALL_FAILED_USER_RESTRICTED": + return gettext("The system failed to install the package because the user is restricted from installing apps.") + case "INSTALL_FAILED_NO_MATCHING_ABIS": + return gettext("The system failed to install the package because its packaged native code did not match any of the ABIs supported by the system.") default: - return gettext(responses[text] || text) + return gettext(text) } } } diff --git a/res/app/components/stf/install/response-codes.json b/res/app/components/stf/install/response-codes.json deleted file mode 100644 index 4e2f332b..00000000 --- a/res/app/components/stf/install/response-codes.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "INSTALL_SUCCEEDED": "Installation succeeded.", - "INSTALL_FAILED_ALREADY_EXISTS": "The package is already installed.", - "INSTALL_FAILED_INVALID_APK": "The package archive file is invalid.", - "INSTALL_FAILED_INVALID_URI": "The URI passed in is invalid.", - "INSTALL_FAILED_INSUFFICIENT_STORAGE": "The package manager service found that the device didn't have enough storage space to install the app.", - "INSTALL_FAILED_DUPLICATE_PACKAGE": "A package is already installed with the same name.", - "INSTALL_FAILED_NO_SHARED_USER": "The requested shared user does not exist.", - "INSTALL_FAILED_UPDATE_INCOMPATIBLE": "A previously installed package of the same name has a different signature than the new package (and the old package's data was not removed).", - "INSTALL_FAILED_MISSING_SHARED_LIBRARY": "The new package uses a shared library that is not available.", - "INSTALL_FAILED_REPLACE_COULDNT_DELETE": "The existing package could not be deleted.", - "INSTALL_FAILED_DEXOPT": "The new package failed while optimizing and validating its dex files, either because there was not enough storage or the validation failed.", - "INSTALL_FAILED_OLDER_SDK": "The new package failed because the current SDK version is older than that required by the package.", - "INSTALL_FAILED_CONFLICTING_PROVIDER": "The new package failed because it contains a content provider with thesame authority as a provider already installed in the system.", - "INSTALL_FAILED_NEWER_SDK": "The new package failed because the current SDK version is newer than that required by the package.", - "INSTALL_FAILED_TEST_ONLY": "The new package failed because it has specified that it is a test-only package and the caller has not supplied the INSTALL_ALLOW_TEST flag.", - "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE": "The package being installed contains native code, but none that is compatible with the device's CPU_ABI.", - "INSTALL_FAILED_MISSING_FEATURE": "The new package uses a feature that is not available.", - "INSTALL_FAILED_CONTAINER_ERROR": "A secure container mount point couldn't be accessed on external media.", - "INSTALL_FAILED_INVALID_INSTALL_LOCATION": "The new package couldn't be installed in the specified install location.", - "INSTALL_FAILED_MEDIA_UNAVAILABLE": "The new package couldn't be installed in the specified install location because the media is not available.", - "INSTALL_FAILED_VERIFICATION_TIMEOUT": "The new package couldn't be installed because the verification timed out.", - "INSTALL_FAILED_VERIFICATION_FAILURE": "The new package couldn't be installed because the verification did not succeed.", - "INSTALL_FAILED_PACKAGE_CHANGED": "The package changed from what the calling program expected.", - "INSTALL_FAILED_UID_CHANGED": "The new package is assigned a different UID than it previously held.", - "INSTALL_FAILED_VERSION_DOWNGRADE": "The new package has an older version code than the currently installed package.", - "INSTALL_PARSE_FAILED_NOT_APK": "The parser was given a path that is not a file, or does not end with the expected '.apk' extension.", - "INSTALL_PARSE_FAILED_BAD_MANIFEST": "The parser was unable to retrieve the AndroidManifest.xml file.", - "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION": "The parser encountered an unexpected exception.", - "INSTALL_PARSE_FAILED_NO_CERTIFICATES": "The parser did not find any certificates in the .apk.", - "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES": "The parser found inconsistent certificates on the files in the .apk.", - "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING": "The parser encountered a CertificateEncodingException in one of the files in the .apk.", - "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME": "The parser encountered a bad or missing package name in the manifest.", - "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID": "The parser encountered a bad shared user id name in the manifest.", - "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED": "The parser encountered some structural problem in the manifest.", - "INSTALL_PARSE_FAILED_MANIFEST_EMPTY": "The parser did not find any actionable tags (instrumentation or application) in the manifest.", - "INSTALL_FAILED_INTERNAL_ERROR": "The system failed to install the package because of system issues.", - "INSTALL_FAILED_USER_RESTRICTED": "The system failed to install the package because the user is restricted from installing apps.", - "INSTALL_FAILED_NO_MATCHING_ABIS": "The system failed to install the package because its packaged native code did not match any of the ABIs supported by the system." -} diff --git a/res/app/components/stf/transaction/transaction-error.js b/res/app/components/stf/transaction/transaction-error.js index eff2e950..a0b9cb30 100644 --- a/res/app/components/stf/transaction/transaction-error.js +++ b/res/app/components/stf/transaction/transaction-error.js @@ -1,4 +1,10 @@ -module.exports = function TransactionError(result) { - this.message = this.code = result.error - this.result = result +function TransactionError(result) { + this.code = this.message = result.error + this.name = 'TransactionError' + Error.captureStackTrace(this, TransactionError) } + +TransactionError.prototype = Object.create(Error.prototype); +TransactionError.prototype.constructor = TransactionError; + +module.exports = TransactionError diff --git a/webpack.config.js b/webpack.config.js index 410c3ca9..59dd7354 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -30,8 +30,7 @@ module.exports = { 'angular-bootstrap': 'angular-bootstrap/ui-bootstrap-tpls', 'localforage': 'localforage/dist/localforage.js', 'socket.io': 'socket.io-client', - 'oboe': 'oboe/dist/oboe-browser', - 'bluebird': 'bluebird/js/browser/bluebird' + 'oboe': 'oboe/dist/oboe-browser' } }, module: { @@ -57,8 +56,7 @@ module.exports = { { test: /oboe-browser\.js$/, loader: 'imports?define=>false!exports?oboe'}, { test: /uuid\.js$/, loader: 'imports?require=>undefined'}, //{ test: /ui-bootstrap-tpls\.js$/, loader: 'script'}, - { test: /dialogs\.js$/, loader: 'script'}, - { test: /bluebird\.js$/, loader: 'imports?require=>undefined'} + { test: /dialogs\.js$/, loader: 'script'} ], preLoaders: [ {