adb: static constexpr.

Also inline some single-use constants.

Bug: N/A
Test: ran tests
Change-Id: I1ac028667772599291da402120a270d0667fed04
This commit is contained in:
Elliott Hughes 2018-09-05 12:13:11 -07:00
parent f33d19ff21
commit 86ab9ff8a2
5 changed files with 11 additions and 18 deletions

View file

@ -49,9 +49,9 @@
#if defined(_WIN32)
constexpr char kNullFileName[] = "NUL";
static constexpr char kNullFileName[] = "NUL";
#else
constexpr char kNullFileName[] = "/dev/null";
static constexpr char kNullFileName[] = "/dev/null";
#endif
void close_stdin() {

View file

@ -354,8 +354,7 @@ static void stdinout_raw_epilogue(int inFd, int outFd, int old_stdin_mode, int o
}
void copy_to_file(int inFd, int outFd) {
constexpr size_t BUFSIZE = 32 * 1024;
std::vector<char> buf(BUFSIZE);
std::vector<char> buf(32 * 1024);
int len;
long total = 0;
int old_stdin_mode = -1;
@ -367,9 +366,9 @@ void copy_to_file(int inFd, int outFd) {
while (true) {
if (inFd == STDIN_FILENO) {
len = unix_read(inFd, buf.data(), BUFSIZE);
len = unix_read(inFd, buf.data(), buf.size());
} else {
len = adb_read(inFd, buf.data(), BUFSIZE);
len = adb_read(inFd, buf.data(), buf.size());
}
if (len == 0) {
D("copy_to_file() : read 0 bytes; exiting");

View file

@ -25,9 +25,9 @@
#include "fastdeploycallbacks.h"
#include "utils/String16.h"
const long kRequiredAgentVersion = 0x00000001;
static constexpr long kRequiredAgentVersion = 0x00000001;
const char* kDeviceAgentPath = "/data/local/tmp/";
static constexpr const char* kDeviceAgentPath = "/data/local/tmp/";
long get_agent_version() {
std::vector<char> versionOutputBuffer;

View file

@ -1040,12 +1040,6 @@ size_t atransport::get_max_payload() const {
return max_payload;
}
namespace {
constexpr char kFeatureStringDelimiter = ',';
} // namespace
const FeatureSet& supported_features() {
// Local static allocation to avoid global non-POD variables.
static const FeatureSet* features = new FeatureSet{
@ -1059,7 +1053,7 @@ const FeatureSet& supported_features() {
}
std::string FeatureSetToString(const FeatureSet& features) {
return android::base::Join(features, kFeatureStringDelimiter);
return android::base::Join(features, ',');
}
FeatureSet StringToFeatureSet(const std::string& features_string) {
@ -1067,7 +1061,7 @@ FeatureSet StringToFeatureSet(const std::string& features_string) {
return FeatureSet();
}
auto names = android::base::Split(features_string, {kFeatureStringDelimiter});
auto names = android::base::Split(features_string, ",");
return FeatureSet(names.begin(), names.end());
}

View file

@ -187,8 +187,8 @@ static void PollAllLocalPortsForEmulator() {
}
// Retry the disconnected local port for 60 times, and sleep 1 second between two retries.
constexpr uint32_t LOCAL_PORT_RETRY_COUNT = 60;
constexpr auto LOCAL_PORT_RETRY_INTERVAL = 1s;
static constexpr uint32_t LOCAL_PORT_RETRY_COUNT = 60;
static constexpr auto LOCAL_PORT_RETRY_INTERVAL = 1s;
struct RetryPort {
int port;