プリインストールテーブルが存在しない場合にエラー表示するように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@606 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2012-01-26 05:26:07 +00:00
parent b9c1d2e6a2
commit 20a7e8bd75
5 changed files with 104 additions and 30 deletions

View File

@ -1705,8 +1705,9 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
if (s_PreparePreinstallTitleDownloadRetryCount++ < RETRY_MAX)
{
COMMON_LOGGER_RESULT_IF_FAILED(GetTitleDownloadResult());
if(GetTitleDownloadResult() == nn::MakePermanentResult(nn::Result::SUMMARY_OUT_OF_RESOURCE,
nn::Result::MODULE_APPLICATION, nn::Result::DESCRIPTION_OUT_OF_MEMORY))
if (GetTitleDownloadResult()
== nn::MakePermanentResult(nn::Result::SUMMARY_OUT_OF_RESOURCE,
nn::Result::MODULE_APPLICATION, nn::Result::DESCRIPTION_OUT_OF_MEMORY))
{
// SDカード容量不足
s_RestoreState = PREINSTALL_DOWNLOAD_APP_NOT_ENOUGH_SPACE;
@ -1718,13 +1719,22 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
COMMON_LOGGER_RESULT_IF_FAILED(nn::fs::DeleteSdmcRoot());
s_RestoreState = PREINSTALL_DOWNLOAD_APP_NOT_ENOUGH_SPACE;
}
else if(GetTitleDownloadResult() == nn::MakePermanentResult(nn::Result::SUMMARY_INVALID_STATE,
nn::Result::MODULE_APPLICATION, nn::Result::DESCRIPTION_ALREADY_INITIALIZED))
else if (GetTitleDownloadResult()
== nn::MakePermanentResult(nn::Result::SUMMARY_INVALID_STATE,
nn::Result::MODULE_APPLICATION, nn::Result::DESCRIPTION_ALREADY_INITIALIZED))
{
// ユーザSDが初期化済み
s_RestoreState = PREINSTALL_CHECK_SD_FAIL;
}
else if (GetTitleDownloadResult()
== nn::MakePermanentResult(nn::Result::SUMMARY_NOT_FOUND,
nn::Result::MODULE_APPLICATION, nn::Result::DESCRIPTION_NOT_FOUND))
{
// プリインストールテーブルが無い
COMMON_LOGGER("No PreInstalled Application Found\n");
s_RestoreState = PREINSTALL_CHECK_SD_FAIL;
}
else
{
// エラーのためやり直す
@ -1759,7 +1769,7 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
if (ExistsAPSetting())
{
NN_LOG("AP Setting Exists. OK\n");
COMMON_LOGGER("Download Preinstall failed\n");
COMMON_LOGGER("Download PreInstalled Application failed\n");
ChangeState(saved, s_RestoreState, FAIL);
}
else
@ -1776,14 +1786,14 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
{
if (!s_ExecutePreinstallTitleDownload)
{
COMMON_LOGGER("Download PreInstall Application\n");
COMMON_LOGGER("Download PreInstalled Application\n");
s_ExecutePreinstallTitleDownload = true;
StartPreinstallTitleDownload();
}
// 動いていることを表示
{
PutAliveMessage(operationMessage, "Download PreInstall Title");
PutAliveMessage(operationMessage, "Download PreInstalled Title");
}
if (IsDownloadTitleFinished())
@ -1809,7 +1819,7 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
}
else
{
COMMON_LOGGER("Download PreInstall Title Failed. Retrying... %d\n", s_PreinstallTitleDownloadRetryCount);
COMMON_LOGGER("Download PreInstalled Title Failed. Retrying... %d\n", s_PreinstallTitleDownloadRetryCount);
s_ExecutePreinstallTitleDownload = false;
}
@ -1850,12 +1860,12 @@ void ControlState(common::HardwareStateManager& manager, ::std::vector<std::stri
NN_LOG("AP Setting Exists. OK\n");
if(s_PreinstallTitleDownloadSuccess)
{
COMMON_LOGGER("Download Preinstall done\n");
COMMON_LOGGER("Download PreInstalled Application done\n");
ChangeState(saved, s_RestoreState, WAIT_SD_EJECT);
}
else
{
COMMON_LOGGER("Download Preinstall failed\n");
COMMON_LOGGER("Download PreInstalled Application failed\n");
ChangeState(saved, s_RestoreState, FAIL);
}
}

View File

@ -126,6 +126,14 @@ nn::Result PreinstallImporter::ParseXmlData(void* buf, nn::ProgramId* list, size
SetNodetoTitleIds(simpleXmlParser, xmlResult, &pTaskIdNode)
);
*num = 0;
// プリインストールタイトルが無ければ終了
if(!pTaskIdNode)
{
return nn::MakePermanentResult(nn::Result::SUMMARY_NOT_FOUND, nn::Result::MODULE_APPLICATION,
nn::Result::DESCRIPTION_NOT_FOUND);
}
// タイトルIDリストをコピーする
common::HeapManager xmlHeap(pTaskIdNode->contentSize);
void* titleIdBuffer = xmlHeap.GetAddr();
@ -191,7 +199,6 @@ void PreinstallImporter::SplitTextAndSetupList(nn::ProgramId* list, size_t* num,
const char* token = ",";
char* cutout;
*num = 0;
cutout = std::strtok(text, token);
if(!cutout)
{

View File

@ -45,6 +45,8 @@ private:
nn::Result GetHtmlBodyAndParseXmlData(BgsCommunicator& comm, nn::ProgramId* list, size_t* num);
//! @brief 受信したXMLデータを解析してタイトルIDリストを設定します
//! @return プリインストールアプリが存在しない場合、(Level=Status, Summary=NotFound, Module=Application, Description=NotFound)<BR/>
//! のResultを返します
nn::Result ParseXmlData(void* buf, nn::ProgramId* list, size_t* num);
//! @brief SimpleXmlパーサの解析をTitleIdードまで進めます

View File

@ -103,13 +103,22 @@ void PreinstallImporterTest::ListUp()
size_t num;
nn::ProgramId list[256];
NN_TEST_ASSERT_RESULT_SUCCESS(
importer.ListTitles(list, &num, 17179924184, reinterpret_cast<u8*>(const_cast<char*>("EJA20305940"))));
nn::Result result;
result = importer.ListTitles(list, &num, 17179924184, reinterpret_cast<u8*>(const_cast<char*>("EJA20305940")));
NN_LOG("Preinstalled num = %d\n", num);
for(u32 i = 0; i < num; i++)
if(result == nn::MakePermanentResult(nn::Result::SUMMARY_NOT_FOUND,
nn::Result::MODULE_APPLICATION, nn::Result::DESCRIPTION_NOT_FOUND))
{
NN_LOG("%016llx\n", list[i]);
NN_LOG("No PreInstalled Application found\n");
NN_TEST_ASSERT(num == 0);
}
else
{
NN_LOG("Preinstalled num = %d\n", num);
for (u32 i = 0; i < num; i++)
{
NN_LOG("%016llx\n", list[i]);
}
}
}

View File

@ -39,9 +39,11 @@ class SimpleXmlParserTest : public Suite {
public:
SimpleXmlParserTest() {
TEST_ADD(SimpleXmlParserTest::Find);
TEST_ADD(SimpleXmlParserTest::NotFound);
}
private:
void Find();
void NotFound();
};
namespace
@ -84,6 +86,25 @@ const char* SimpleXmlParserGetter::GetContent(const nn::xml::simple::SimpleXmlPa
char SimpleXmlParserGetter::m_Buf[SimpleXmlParserGetter::BUF_SIZE];
nn::Result SetNodetoPreinstalledInfo(nn::xml::simple::SimpleXmlParser& parser, std::string& xmlData, const nn::xml::simple::SimpleXmlParser::Node** pNode)
{
parser.parse(reinterpret_cast<u8*>(const_cast<char*>(xmlData.c_str())), xmlData.size());
NN_TEST_ASSERT(!parser.isError());
const nn::xml::simple::SimpleXmlParser::Node* pRootNode = parser.getRootNode();
const nn::xml::simple::SimpleXmlParser::Node* pTargetNode = pRootNode->firstChild;
// 欲しい情報がある場所まで階層を掘り下げる
const nn::xml::simple::SimpleXmlParser::Node* pPriorityNode = nn::xml::simple::SimpleXmlParser::FindNextNode(
pTargetNode, "Body");
pPriorityNode = nn::xml::simple::SimpleXmlParser::FindNextNode(pPriorityNode->firstChild,
"GetPreInstalledInfoResponse");
pPriorityNode = nn::xml::simple::SimpleXmlParser::FindNextNode(pPriorityNode->firstChild,
"GetPreInstalledInfoResponse");
*pNode = nn::xml::simple::SimpleXmlParser::FindNextNode(pPriorityNode->firstChild, "PreinstalledInfo");
return nn::ResultSuccess();
}
}
//------------------------------------------------------------------
@ -117,20 +138,9 @@ const char testText[] = "\
nn::fnd::IAllocator* pAllocator = nn::init::GetAllocator();
nn::xml::simple::SimpleXmlParser simpleXmlParser(pAllocator);
simpleXmlParser.parse(reinterpret_cast<u8*>(const_cast<char*>(testText)), sizeof(testText) - 1);
NN_TEST_ASSERT(!simpleXmlParser.isError());
const nn::xml::simple::SimpleXmlParser::Node* pRootNode = simpleXmlParser.getRootNode();
const nn::xml::simple::SimpleXmlParser::Node* pTargetNode = pRootNode->firstChild;
// 欲しい情報がある場所まで階層を掘り下げる
const nn::xml::simple::SimpleXmlParser::Node* pPriorityNode = nn::xml::simple::SimpleXmlParser::FindNextNode(
pTargetNode, "Body");
pPriorityNode = nn::xml::simple::SimpleXmlParser::FindNextNode(pPriorityNode->firstChild,
"GetPreInstalledInfoResponse");
pPriorityNode = nn::xml::simple::SimpleXmlParser::FindNextNode(pPriorityNode->firstChild,
"GetPreInstalledInfoResponse");
pPriorityNode = nn::xml::simple::SimpleXmlParser::FindNextNode(pPriorityNode->firstChild, "PreinstalledInfo");
const nn::xml::simple::SimpleXmlParser::Node* pPriorityNode;
std::string xmlData(testText);
SetNodetoPreinstalledInfo(simpleXmlParser, xmlData, &pPriorityNode);
{
const nn::xml::simple::SimpleXmlParser::Node* pTaskIdNode = nn::xml::simple::SimpleXmlParser::FindNextNode(
@ -158,6 +168,42 @@ const char testText[] = "\
}
void SimpleXmlParserTest::NotFound()
{
const char testText[] = \
"<Envelope>\
<Body>\
<GetPreInstalledInfoResponse>\
<GetPreInstalledInfoResponse>\
<Version></Version>\
<MessageId></MessageId>\
<TimeStamp>1327551124393</TimeStamp>\
<ErrorCode>0</ErrorCode>\
<ListResultTotalSize>1</ListResultTotalSize>\
<PreinstalledInfo>\
<DeviceId>17179924184</DeviceId>\
<SerialNo>EJA20305940</SerialNo>\
<Region>JPN</Region>\
<ManufactureDate>1327545997000</ManufactureDate>\
</PreinstalledInfo>\
</GetPreInstalledInfoResponse>\
</GetPreInstalledInfoResponse>\
</Body>\
</Envelope>";
nn::fnd::IAllocator* pAllocator = nn::init::GetAllocator();
nn::xml::simple::SimpleXmlParser simpleXmlParser(pAllocator);
const nn::xml::simple::SimpleXmlParser::Node* pPriorityNode;
std::string xmlData(testText);
SetNodetoPreinstalledInfo(simpleXmlParser, xmlData, &pPriorityNode);
{
const nn::xml::simple::SimpleXmlParser::Node* pTaskIdNode = nn::xml::simple::SimpleXmlParser::FindNextNode(
pPriorityNode->firstChild, "TitleIds");
NN_TEST_ASSERT(!pTaskIdNode);
}
}
NN_TEST_DEFINE_MAIN(SimpleXmlParserTest)
/*---------------------------------------------------------------------------*