Disable deadline file in Android.
The deadline file is used to notify chrome the deadline string sent by
the server. This message allows chrome to take a different action based
on the urgency of the update. While we would like to provide a proper
API for this mechanism, it is rarely used in Chrome OS and doesn't work
on Android, so we disable it for now.
Bug: 24868621
Test: Unittest pass. No error message when tested on a dragonboard.
Change-Id: I77fc5b55e1c6ec79f12d88be40426058b8aa4d02
diff --git a/omaha_response_handler_action.cc b/omaha_response_handler_action.cc
index e512d13..9ad73d6 100644
--- a/omaha_response_handler_action.cc
+++ b/omaha_response_handler_action.cc
@@ -35,12 +35,10 @@
namespace chromeos_update_engine {
-const char OmahaResponseHandlerAction::kDeadlineFile[] =
- "/tmp/update-check-response-deadline";
-
OmahaResponseHandlerAction::OmahaResponseHandlerAction(
SystemState* system_state)
- : OmahaResponseHandlerAction(system_state, kDeadlineFile) {}
+ : OmahaResponseHandlerAction(system_state,
+ constants::kOmahaResponseDeadlineFile) {}
OmahaResponseHandlerAction::OmahaResponseHandlerAction(
SystemState* system_state, const string& deadline_file)
@@ -127,10 +125,12 @@
// file. Ideally, we would include this information in D-Bus's GetStatus
// method and UpdateStatus signal. A potential issue is that update_engine may
// be unresponsive during an update download.
- utils::WriteFile(deadline_file_.c_str(),
- response.deadline.data(),
- response.deadline.size());
- chmod(deadline_file_.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (!deadline_file_.empty()) {
+ utils::WriteFile(deadline_file_.c_str(),
+ response.deadline.data(),
+ response.deadline.size());
+ chmod(deadline_file_.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ }
completer.set_code(ErrorCode::kSuccess);
}
diff --git a/omaha_response_handler_action.h b/omaha_response_handler_action.h
index 5611375..3cdeb67 100644
--- a/omaha_response_handler_action.h
+++ b/omaha_response_handler_action.h
@@ -42,8 +42,6 @@
class OmahaResponseHandlerAction : public Action<OmahaResponseHandlerAction> {
public:
- static const char kDeadlineFile[];
-
explicit OmahaResponseHandlerAction(SystemState* system_state);
typedef ActionTraits<OmahaResponseHandlerAction>::InputObjectType
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index c97ef9e..d103cbc 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -112,7 +112,7 @@
OmahaResponseHandlerAction response_handler_action(
&fake_system_state_,
(test_deadline_file.empty() ?
- OmahaResponseHandlerAction::kDeadlineFile : test_deadline_file));
+ constants::kOmahaResponseDeadlineFile : test_deadline_file));
BondActions(&feeder_action, &response_handler_action);
ObjectCollectorAction<InstallPlan> collector_action;
BondActions(&response_handler_action, &collector_action);
diff --git a/platform_constants.h b/platform_constants.h
index 0c832c9..189d134 100644
--- a/platform_constants.h
+++ b/platform_constants.h
@@ -38,6 +38,10 @@
// whole payload.
extern const char kUpdatePayloadPublicKeyPath[];
+// Path to the file used to notify chrome about the deadline of the last omaha
+// response. Empty if not supported.
+extern const char kOmahaResponseDeadlineFile[];
+
} // namespace constants
} // namespace chromeos_update_engine
diff --git a/platform_constants_android.cc b/platform_constants_android.cc
index be0329b..b6ee29f 100644
--- a/platform_constants_android.cc
+++ b/platform_constants_android.cc
@@ -27,6 +27,8 @@
const char kOmahaPlatformName[] = "Brillo";
const char kUpdatePayloadPublicKeyPath[] =
"/etc/update_engine/update-payload-key.pub.pem";
+// No deadline file API support on Android.
+const char kOmahaResponseDeadlineFile[] = "";
} // namespace constants
} // namespace chromeos_update_engine
diff --git a/platform_constants_chromeos.cc b/platform_constants_chromeos.cc
index 2a6ce12..d7aeca5 100644
--- a/platform_constants_chromeos.cc
+++ b/platform_constants_chromeos.cc
@@ -27,6 +27,8 @@
const char kOmahaPlatformName[] = "Chrome OS";
const char kUpdatePayloadPublicKeyPath[] =
"/usr/share/update_engine/update-payload-key.pub.pem";
+const char kOmahaResponseDeadlineFile[] =
+ "/tmp/update-check-response-deadline";
} // namespace constants
} // namespace chromeos_update_engine