Loading services/surfaceflinger/TimeStats/TimeStats.cpp +19 −16 Original line number Original line Diff line number Diff line Loading @@ -145,14 +145,15 @@ static int32_t msBetween(nsecs_t start, nsecs_t end) { return static_cast<int32_t>(delta); return static_cast<int32_t>(delta); } } static std::string getPackageName(const std::string& layerName) { // This regular expression captures the following for instance: // This regular expression captures the following for instance: // StatusBar in StatusBar#0 // StatusBar in StatusBar#0 // com.appname in com.appname/com.appname.activity#0 // com.appname in com.appname/com.appname.activity#0 // com.appname in SurfaceView - com.appname/com.appname.activity#0 // com.appname in SurfaceView - com.appname/com.appname.activity#0 const std::regex re("(?:SurfaceView[-\\s\\t]+)?([^/]+).*#\\d+"); static const std::regex packageNameRegex("(?:SurfaceView[-\\s\\t]+)?([^/]+).*#\\d+"); static std::string getPackageName(const std::string& layerName) { std::smatch match; std::smatch match; if (std::regex_match(layerName.begin(), layerName.end(), match, re)) { if (std::regex_match(layerName.begin(), layerName.end(), match, packageNameRegex)) { // There must be a match for group 1 otherwise the whole string is not // There must be a match for group 1 otherwise the whole string is not // matched and the above will return false // matched and the above will return false return match[1]; return match[1]; Loading Loading @@ -223,7 +224,6 @@ void TimeStats::flushAvailableRecordsToStatsLocked(const std::string& layerName) } } } } static bool layerNameIsValid(const std::string& layerName) { // This regular expression captures the following layer names for instance: // This regular expression captures the following layer names for instance: // 1) StatusBat#0 // 1) StatusBat#0 // 2) NavigationBar#1 // 2) NavigationBar#1 Loading @@ -232,8 +232,11 @@ static bool layerNameIsValid(const std::string& layerName) { // Using [-\\s\t]+ for the conjunction part between SurfaceView and co(m).* // Using [-\\s\t]+ for the conjunction part between SurfaceView and co(m).* // is a bit more robust in case there's a slight change. // is a bit more robust in case there's a slight change. // The layer name would only consist of . / $ _ 0-9 a-z A-Z in most cases. // The layer name would only consist of . / $ _ 0-9 a-z A-Z in most cases. std::regex re("(((SurfaceView[-\\s\\t]+)?com?\\.[./$\\w]+)|((Status|Navigation)Bar))#\\d+"); static const std::regex layerNameRegex( return std::regex_match(layerName.begin(), layerName.end(), re); "(((SurfaceView[-\\s\\t]+)?com?\\.[./$\\w]+)|((Status|Navigation)Bar))#\\d+"); static bool layerNameIsValid(const std::string& layerName) { return std::regex_match(layerName.begin(), layerName.end(), layerNameRegex); } } void TimeStats::setPostTime(const std::string& layerName, uint64_t frameNumber, nsecs_t postTime) { void TimeStats::setPostTime(const std::string& layerName, uint64_t frameNumber, nsecs_t postTime) { Loading Loading
services/surfaceflinger/TimeStats/TimeStats.cpp +19 −16 Original line number Original line Diff line number Diff line Loading @@ -145,14 +145,15 @@ static int32_t msBetween(nsecs_t start, nsecs_t end) { return static_cast<int32_t>(delta); return static_cast<int32_t>(delta); } } static std::string getPackageName(const std::string& layerName) { // This regular expression captures the following for instance: // This regular expression captures the following for instance: // StatusBar in StatusBar#0 // StatusBar in StatusBar#0 // com.appname in com.appname/com.appname.activity#0 // com.appname in com.appname/com.appname.activity#0 // com.appname in SurfaceView - com.appname/com.appname.activity#0 // com.appname in SurfaceView - com.appname/com.appname.activity#0 const std::regex re("(?:SurfaceView[-\\s\\t]+)?([^/]+).*#\\d+"); static const std::regex packageNameRegex("(?:SurfaceView[-\\s\\t]+)?([^/]+).*#\\d+"); static std::string getPackageName(const std::string& layerName) { std::smatch match; std::smatch match; if (std::regex_match(layerName.begin(), layerName.end(), match, re)) { if (std::regex_match(layerName.begin(), layerName.end(), match, packageNameRegex)) { // There must be a match for group 1 otherwise the whole string is not // There must be a match for group 1 otherwise the whole string is not // matched and the above will return false // matched and the above will return false return match[1]; return match[1]; Loading Loading @@ -223,7 +224,6 @@ void TimeStats::flushAvailableRecordsToStatsLocked(const std::string& layerName) } } } } static bool layerNameIsValid(const std::string& layerName) { // This regular expression captures the following layer names for instance: // This regular expression captures the following layer names for instance: // 1) StatusBat#0 // 1) StatusBat#0 // 2) NavigationBar#1 // 2) NavigationBar#1 Loading @@ -232,8 +232,11 @@ static bool layerNameIsValid(const std::string& layerName) { // Using [-\\s\t]+ for the conjunction part between SurfaceView and co(m).* // Using [-\\s\t]+ for the conjunction part between SurfaceView and co(m).* // is a bit more robust in case there's a slight change. // is a bit more robust in case there's a slight change. // The layer name would only consist of . / $ _ 0-9 a-z A-Z in most cases. // The layer name would only consist of . / $ _ 0-9 a-z A-Z in most cases. std::regex re("(((SurfaceView[-\\s\\t]+)?com?\\.[./$\\w]+)|((Status|Navigation)Bar))#\\d+"); static const std::regex layerNameRegex( return std::regex_match(layerName.begin(), layerName.end(), re); "(((SurfaceView[-\\s\\t]+)?com?\\.[./$\\w]+)|((Status|Navigation)Bar))#\\d+"); static bool layerNameIsValid(const std::string& layerName) { return std::regex_match(layerName.begin(), layerName.end(), layerNameRegex); } } void TimeStats::setPostTime(const std::string& layerName, uint64_t frameNumber, nsecs_t postTime) { void TimeStats::setPostTime(const std::string& layerName, uint64_t frameNumber, nsecs_t postTime) { Loading