| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008-2009 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 // ======================================================================== | |
| 15 | |
| 16 #include "omaha/tools/goopdump/data_dumper_app_manager.h" | |
| 17 | |
| 18 #include <vector> | |
| 19 | |
| 20 #include "omaha/common/reg_key.h" | |
| 21 #include "omaha/common/utils.h" | |
| 22 #include "omaha/goopdate/config_manager.h" | |
| 23 #include "omaha/worker/application_data.h" | |
| 24 #include "omaha/worker/application_manager.h" | |
| 25 #include "omaha/tools/goopdump/dump_log.h" | |
| 26 #include "omaha/tools/goopdump/goopdump_cmd_line_parser.h" | |
| 27 | |
| 28 namespace omaha { | |
| 29 | |
| 30 namespace { | |
| 31 | |
| 32 CString ActiveStateToString(omaha::AppData::ActiveStates state) { | |
| 33 CString str = _T("UNDEFINED"); | |
| 34 switch (state) { | |
| 35 case omaha::AppData::ACTIVE_NOTRUN: | |
| 36 str = _T("NOT RUN"); | |
| 37 break; | |
| 38 case omaha::AppData::ACTIVE_RUN: | |
| 39 str = _T("RUN"); | |
| 40 break; | |
| 41 case omaha::AppData::ACTIVE_UNKNOWN: | |
| 42 str = _T("UNKNOWN"); | |
| 43 break; | |
| 44 default: | |
| 45 ASSERT1(false); | |
| 46 break; | |
| 47 } | |
| 48 return str; | |
| 49 } | |
| 50 | |
| 51 CString BoolToString(bool val) { | |
| 52 return val ? _T("TRUE") : _T("FALSE"); | |
| 53 } | |
| 54 | |
| 55 // TODO(omaha): This should use display_name if available. Only Omaha needs to | |
| 56 // be hard-coded. Maybe write its name during Setup instead. | |
| 57 CString GuidToFriendlyAppName(const GUID& guid) { | |
| 58 struct MapGuidToName { | |
| 59 const TCHAR* guid; | |
| 60 const TCHAR* name; | |
| 61 }; | |
| 62 | |
| 63 // IMPORTANT: Only put released products in this list since this tool will go | |
| 64 // to customers. | |
| 65 MapGuidToName guid_to_name[] = { | |
| 66 {_T("{283EAF47-8817-4c2b-A801-AD1FADFB7BAA}"), _T("Gears")}, | |
| 67 {_T("{430FD4D0-B729-4F61-AA34-91526481799D}"), _T("Google Update")}, | |
| 68 {_T("{8A69D345-D564-463C-AFF1-A69D9E530F96}"), _T("Chrome")}, | |
| 69 }; | |
| 70 | |
| 71 CString str = _T("unknown"); | |
| 72 | |
| 73 for (int i = 0; i < arraysize(guid_to_name); ++i) { | |
| 74 if (::IsEqualGUID(guid, StringToGuid(guid_to_name[i].guid))) { | |
| 75 str = guid_to_name[i].name; | |
| 76 break; | |
| 77 } | |
| 78 } | |
| 79 | |
| 80 return str; | |
| 81 } | |
| 82 | |
| 83 } // namespace | |
| 84 | |
| 85 DataDumperAppManager::DataDumperAppManager() { | |
| 86 } | |
| 87 | |
| 88 DataDumperAppManager::~DataDumperAppManager() { | |
| 89 } | |
| 90 | |
| 91 HRESULT DataDumperAppManager::Process(const DumpLog& dump_log, | |
| 92 const GoopdumpCmdLineArgs& args) { | |
| 93 UNREFERENCED_PARAMETER(args); | |
| 94 | |
| 95 DumpHeader header(dump_log, _T("AppManager Data")); | |
| 96 | |
| 97 if (args.is_machine) { | |
| 98 dump_log.WriteLine(_T("--- MACHINE APPMANAGER DATA ---")); | |
| 99 AppManager app_manager(true); | |
| 100 DumpAppManagerData(dump_log, app_manager); | |
| 101 DumpRawRegistryData(dump_log, true); | |
| 102 } | |
| 103 | |
| 104 if (args.is_user) { | |
| 105 dump_log.WriteLine(_T("--- USER APPMANAGER DATA ---")); | |
| 106 AppManager app_manager(false); | |
| 107 DumpAppManagerData(dump_log, app_manager); | |
| 108 DumpRawRegistryData(dump_log, false); | |
| 109 } | |
| 110 | |
| 111 return S_OK; | |
| 112 } | |
| 113 | |
| 114 void DataDumperAppManager::DumpAppManagerData(const DumpLog& dump_log, | |
| 115 const AppManager& app_manager) { | |
| 116 ProductDataVector products; | |
| 117 HRESULT hr = app_manager.GetRegisteredProducts(&products); | |
| 118 if (FAILED(hr)) { | |
| 119 dump_log.WriteLine(_T("Failed GetRegisteredProducts() hr=0x%x"), hr); | |
| 120 return; | |
| 121 } | |
| 122 | |
| 123 for (size_t i = 0; i < products.size(); ++i) { | |
| 124 const ProductData& product_data = products[i]; | |
| 125 const AppData& data = product_data.app_data(); | |
| 126 | |
| 127 dump_log.WriteLine(_T("---------- APP ----------")); | |
| 128 dump_log.WriteLine(_T("app name:\t%s"), | |
| 129 GuidToFriendlyAppName(data.app_guid())); | |
| 130 dump_log.WriteLine(_T("guid:\t\t%s"), GuidToString(data.app_guid())); | |
| 131 // parent_app_guid is not displayed. | |
| 132 dump_log.WriteLine(_T("is_machine_app:\t%s"), | |
| 133 BoolToString(data.is_machine_app())); | |
| 134 dump_log.WriteLine(_T("version:\t%s"), data.version()); | |
| 135 dump_log.WriteLine(_T("prev_version:\t%s"), data.previous_version()); | |
| 136 dump_log.WriteLine(_T("language:\t%s"), data.language()); | |
| 137 dump_log.WriteLine(_T("ap:\t\t%s"), data.ap()); | |
| 138 dump_log.WriteLine(_T("ttt:\t\t%s"), data.tt_token()); | |
| 139 dump_log.WriteLine(_T("iid:\t\t%s"), GuidToString(data.iid())); | |
| 140 dump_log.WriteLine(_T("brand:\t\t%s"), data.brand_code()); | |
| 141 dump_log.WriteLine(_T("client:\t\t%s"), data.client_id()); | |
| 142 dump_log.WriteLine(_T("referral:\t\t%s"), data.referral_id()); | |
| 143 dump_log.WriteLine(_T("install_time_diff_sec:\t%u"), | |
| 144 data.install_time_diff_sec()); | |
| 145 dump_log.WriteLine(_T("is_oem_install:\t%s"), | |
| 146 BoolToString(data.is_oem_install())); | |
| 147 dump_log.WriteLine(_T("is_eula_accepted:\t%s"), | |
| 148 BoolToString(data.is_eula_accepted())); | |
| 149 // TODO(omaha): Use display_name above and note its use on this line. | |
| 150 dump_log.WriteLine(_T("browser_type:\t\t%u"), data.browser_type()); | |
| 151 | |
| 152 // The following are not saved and thus should always have default values. | |
| 153 dump_log.WriteLine(_T("install_source:\t\t%s"), data.install_source()); | |
| 154 dump_log.WriteLine(_T("encoded_installer_data:\t\t%s"), | |
| 155 data.encoded_installer_data()); | |
| 156 dump_log.WriteLine(_T("install_data_index:\t\t%s"), | |
| 157 data.install_data_index()); | |
| 158 | |
| 159 dump_log.WriteLine(_T("usage_stats_enable:\t\t%u"), | |
| 160 data.usage_stats_enable()); | |
| 161 dump_log.WriteLine(_T("did_run:\t%s"), | |
| 162 ActiveStateToString(data.did_run())); | |
| 163 | |
| 164 // The following are not saved and thus should always have default values. | |
| 165 dump_log.WriteLine(_T("is_uninstalled:\t%s"), | |
| 166 BoolToString(data.is_uninstalled())); | |
| 167 dump_log.WriteLine(_T("is_update_disabled:\t%s"), | |
| 168 BoolToString(data.is_update_disabled())); | |
| 169 dump_log.WriteLine(_T("")); | |
| 170 } | |
| 171 } | |
| 172 | |
| 173 void DataDumperAppManager::DumpRawRegistryData(const DumpLog& dump_log, | |
| 174 bool is_machine) { | |
| 175 dump_log.WriteLine(_T("--- RAW REGISTRY DATA ---")); | |
| 176 CString key_name = ConfigManager::Instance()->registry_clients(is_machine); | |
| 177 DumpRegistryKeyData(dump_log, key_name); | |
| 178 } | |
| 179 | |
| 180 } // namespace omaha | |
| 181 | |
| OLD | NEW |