From e7be7692a8908e037293ecfc71fd9321ae62855b Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 7 Apr 2022 18:09:09 +0000 Subject: [PATCH 1/3] Handle pre-release tag --- src/Helpers/Build.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Helpers/Build.php b/src/Helpers/Build.php index e873d83..937582b 100644 --- a/src/Helpers/Build.php +++ b/src/Helpers/Build.php @@ -71,12 +71,12 @@ LINEAGE => [SIGNED] (ex. signed) ) */ - preg_match_all('/(cm|lineage|eelo|e)-([0-9\.]+)-\D?-?([\d_]+)?-([\w+]+)-([A-Za-z0-9]+)?-?([\w+]+)?/', $fileName, $tokens); + preg_match_all('/(e)-([0-9\.]+)-?((alpha|beta|rc)(\.\d)?)?-\D-?([\d_]+)?-([\w+]+)-([A-Za-z0-9]+)?-?([\w+]+)?/', $fileName, $tokens); $this->filePath = (substr($physicalPath, -1) === '/') ? $physicalPath . $fileName : $physicalPath . '/' . $fileName; $tokens = $this->formatTokens($tokens); $this->migrationFilePath = $physicalPath . '/migration_paths.json'; - $this->channel = $this->_getChannel(str_replace(range(0, 9), '', $tokens[4]), $tokens[1], $tokens[2]); + $this->channel = $this->_getChannel(str_replace(range(0, 9), '', $tokens[7]), $tokens[1], $tokens[2]); $this->filename = $fileName; // Try to load the build.prop from two possible paths: @@ -88,7 +88,7 @@ $this->timestamp = intval($this->getBuildPropValue('ro.build.date.utc') ?? filemtime($this->filePath)); $this->incremental = $this->getBuildPropValue('ro.build.version.incremental') ?? ''; $this->apiLevel = $this->getBuildPropValue('ro.build.version.sdk') ?? ''; - $this->model = $this->getBuildPropValue('ro.lineage.device') ?? $this->getBuildPropValue('ro.cm.device') ?? ($tokens[1] == 'cm' ? $tokens[6] : $tokens[5]); + $this->model = $this->getBuildPropValue('ro.lineage.device') ?? $this->getBuildPropValue('ro.cm.device') ?? ($tokens[1] == 'cm' ? $tokens[9] : $tokens[8]); $this->version = $tokens[2]; $this->displayVersion = $this->getBuildPropValue('ro.cm.display.version') ?? $this->getBuildPropValue('ro.lineage.display.version') ?? ''; $this->androidVersion = $this->getBuildPropValue('ro.build.version.release') ?? ''; @@ -172,7 +172,7 @@ return $ret; } - + /** * Check version of current build against given build(returns false if lesser version) * @param object An object representing current build @@ -183,7 +183,7 @@ if (empty($currentBuild)) { return true; } // Valid build if no current build specified - + if ($currentBuild->getTimestamp() >= $this->getTimestamp()) { return false; // Invalid build if timestamp older or equal(same build invalid) } @@ -230,7 +230,7 @@ return $this->size; } - + /** * Get isUpgradeSupported parameter * @return boolean @@ -246,7 +246,7 @@ } */ public function getIsUpgradeSupported($compareVersion) - { + { $thisMajorVersion = explode(".", $this->androidVersion)[0]; $compareMajorVersion = explode(".", $compareVersion)[0]; $isSameVersion = boolval(!strcmp($thisMajorVersion, $compareMajorVersion)); // Check if Android version is same @@ -254,18 +254,18 @@ if($isSameVersion) { return true; } - + else if(file_exists($this->migrationFilePath)) { $migrationContents = file_get_contents($this->migrationFilePath); if (!empty($migrationContents)) { $migrations = json_decode($migrationContents, true); // Contains migration rules - + if (!empty($migrations[$compareMajorVersion]) && is_array($migrations[$compareMajorVersion])) { return in_array(intval($thisMajorVersion), $migrations[$compareMajorVersion]); } } } - + return false; } /** @@ -557,4 +557,4 @@ } return TRUE; } - } \ No newline at end of file + } -- GitLab From de627e04084d4688b04a108342d6b98e173b5a73 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Thu, 21 Apr 2022 15:06:53 +0000 Subject: [PATCH 2/3] Adding preversion support to json answer --- src/Helpers/Build.php | 10 ++++++++++ src/Helpers/Builds.php | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Helpers/Build.php b/src/Helpers/Build.php index 937582b..376dbc9 100644 --- a/src/Helpers/Build.php +++ b/src/Helpers/Build.php @@ -90,6 +90,7 @@ $this->apiLevel = $this->getBuildPropValue('ro.build.version.sdk') ?? ''; $this->model = $this->getBuildPropValue('ro.lineage.device') ?? $this->getBuildPropValue('ro.cm.device') ?? ($tokens[1] == 'cm' ? $tokens[9] : $tokens[8]); $this->version = $tokens[2]; + $this->preversion = $tokens[3]; $this->displayVersion = $this->getBuildPropValue('ro.cm.display.version') ?? $this->getBuildPropValue('ro.lineage.display.version') ?? ''; $this->androidVersion = $this->getBuildPropValue('ro.build.version.release') ?? ''; $this->uid = hash('sha256', $this->timestamp.$this->model.$this->apiLevel, false); @@ -349,6 +350,15 @@ return $this->version; } + /** + * Get the preversion of the current build (alpha, beta.3, etc) + * @return string the preversion value + */ + public function getPreversion() + { + return $this->preversion; + } + /** * Get the version of the current build * @return string the version value diff --git a/src/Helpers/Builds.php b/src/Helpers/Builds.php index f4cdbe6..fc9d7f0 100644 --- a/src/Helpers/Builds.php +++ b/src/Helpers/Builds.php @@ -100,6 +100,7 @@ 'romtype' => $build->getChannel(), 'datetime' => $build->getTimestamp(), 'version' => $build->getVersion(), + 'pre_version' => $build->getPreversion(), 'display_version' => $build->getDisplayVersion(), 'android_version' => $build->getAndroidVersion(), 'id' => $build->getUid(), @@ -219,4 +220,4 @@ $this->logger->debug('Total execution time of getBuilds in seconds'); } -} \ No newline at end of file +} -- GitLab From e51926ecf3241026c7983424d5db09018f2a6005 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez?= Date: Fri, 22 Apr 2022 08:14:21 +0000 Subject: [PATCH 3/3] Allow 0 rollout percentage that disables a build --- src/Helpers/Build.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helpers/Build.php b/src/Helpers/Build.php index 376dbc9..78663e2 100644 --- a/src/Helpers/Build.php +++ b/src/Helpers/Build.php @@ -558,7 +558,7 @@ public function checkRollout() { $rolloutpercentage = isset($this->confProp['rollout']['percentage']) ? (int) $this->confProp['rollout']['percentage'] : 100; - if ($rolloutpercentage <= 0 || $rolloutpercentage > 100) { + if ($rolloutpercentage < 0 || $rolloutpercentage > 100) { return TRUE; } $rand_number = rand(1, 100); -- GitLab