Index: sources/device/DeviceController.cpp =================================================================== diff -u -r9171bf54844dcec41ee5e6feb7ee4d87ef5ebbb4 -rd8c73c14f41d548e3ffecdb6948e6b7bb54523f2 --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 9171bf54844dcec41ee5e6feb7ee4d87ef5ebbb4) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision d8c73c14f41d548e3ffecdb6948e6b7bb54523f2) @@ -645,35 +645,54 @@ */ void DeviceController::onProcessCryptSetupExitCode(int vExitCode, QProcess::ExitStatus vStatus) { + const int ERR_CRYPTSETUP_MOUNT_ISMOUNT=134; // is used in crypt_setup.sh do not modify + // The Exit code in this script is not used. // any other checking is done by UI Software at the moment this script is called. // The only thing matters is the pared device info in text and it will be empty string if error happens. MDeviceCryptSetupResponse model; - QByteArray deviceInfo = _processCryptSetup.readAll(); + QByteArray deviceInfo; if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; else deviceInfo = _processCryptSetup.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); // DEBUG: qDebug() << model._data.mEchoInfo; emit didAttributeResponse(model.data()); LOG_APPED_UI(model.data().mMessage); - if ( _deviceCryptSetupRequest._data.mCommand == "mount" ) emit didCryptSetupMount(model._data.mAccepted); + bool isSetup = _deviceCryptSetupRequest._data.mCommand == "setup"; + bool isMount = _deviceCryptSetupRequest._data.mCommand == "mount"; + bool isMounted = isMount && ( + vExitCode == ERR_CRYPTSETUP_MOUNT_ISMOUNT || // is already mounted + vExitCode == 0 // successful mount + ); + bool isUpdate = gEnableUpdating && isMounted; - // move the configuration files if the encrypted partition creation was successful. - if ( _deviceCryptSetupRequest._data.mCommand != "setup" ) return; - if ( ! model._data.mAccepted ) return; + if ( isMount ) emit didCryptSetupMount(model._data.mAccepted); + QString msg = ""; int err = 0 ; //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. Storage::Settings settings; - err = settings.configurationsMove(&msg); + // moving the configuration files if the encrypted partition creation was successful. + if ( isUpdate ) goto lMove; // if it is gEnableUpdating, bypass the mAccepted for already mounted. + if ( ! model._data.mAccepted ) goto lErr ; // any other case goto error + if ( ! isSetup ) goto lOut ; // if not setup do NOT continue to move configurations + +lMove: + err = settings.configurationsMove(&msg, isUpdate); if ( err ) { model._data.mAccepted = false ; model._data.mReason = err ; model._data.mMessage = msg ; emit didAttributeResponse(model.data()); LOG_APPED_UI(model.data().mMessage); } + +lOut: + return; + +lErr: + LOG_DEBUG(QString("Encrypted Partition %1 failed").arg(_deviceCryptSetupRequest._data.mCommand)); } ///////////////////////////////////////////// DeviceBluetoothPaired @@ -860,11 +879,11 @@ */ void DeviceController::checkConfugurationMountReady() { - /// in manufacturing the system is logged with root and configurations are in /home/root + /// in manufacturing or updating the system is logged with root and configurations are in /home/root /// therefore no need to mount the cononfiguraiton partition. - /// also for in manufacturing the partition is being set up + /// also for manufacturing the partition is being set up /// and is less steps for setup if the partition is not mounted. - if ( gEnableManufacturing ) return; + if ( gEnableManufacturing ) return; // it should do the mount when gEnableUpdating, therefore here should not add gEnableUpdating. if ( ! ( _hasThread && _hasSalt ) ) return; DeviceCryptSetupRequestData data; @@ -926,7 +945,7 @@ // any other checking is done by UI Software at the moment this script is called. // The only thing matters is the paired device info in text and it will be empty string if error happens. MDeviceFactoryResetResponse model; - QByteArray deviceInfo = _processFactoryReset.readAll(); + QByteArray deviceInfo; if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; else deviceInfo = _processFactoryReset.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); @@ -975,7 +994,7 @@ // any other checking is done by UI Software at the moment this script is called. // The only thing matters is the paired device info in text and it will be empty string if error happens. MDeviceDecommissionResponse model; - QByteArray deviceInfo = _processDecommission.readAll(); + QByteArray deviceInfo; if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; else deviceInfo = _processDecommission.readAll(); model.fromByteArray( deviceInfo, &vExitCode ); @@ -1033,7 +1052,7 @@ void DeviceController::onProcessUSBMountExitCode(int vExitCode, QProcess::ExitStatus vStatus) { MDeviceUSBMountResponse model; - QByteArray deviceInfo = _processUSBMount.readAll(); + QByteArray deviceInfo; if ( vStatus ) vExitCode = Device::DeviceError::eDevice_Scripts_Error_Status; else deviceInfo = _processUSBMount.readAll(); model.fromByteArray( deviceInfo, &vExitCode );