Loading src/Helpers/Build.php +41 −3 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ * @param type $fileName The current filename of the build * @param type $physicalPath The current path where the build lives */ public function __construct($fileName, $physicalPath, $logger) public function __construct($fileName, $physicalPath, $logger, $shouldDisplayPatch = false) { $this->logger = $logger; Loading Loading @@ -90,6 +90,9 @@ $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]; if(substr_count($this->version, ".") > 1 && !$shouldDisplayPatch) { $this->version = substr($this->version, 0, strrpos($this->version, '.'));//remove maintenance number when using an old updater to avoid crash } $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') ?? ''; Loading Loading @@ -400,6 +403,15 @@ private function parseSemVer($versionString) { $versionArray = explode(".", $versionString); if(empty($versionArray[0])) { $versionArray[0] = 0; } if(empty($versionArray[1])) { $versionArray[1] = 0; } if(empty($versionArray[2])) { $versionArray[2] = 0; } return array_map("intval", $versionArray); } Loading Loading @@ -529,9 +541,9 @@ * @param type $params The params dictionary inside the current POST request * @return boolean True if valid, False if not. */ public function includeInResults($params) public function includeInResults($params, $currenteOSVersion) { return $this->isValid($params) && $this->checkRollout() && $this->getSize() > 0; return $this->isValid($params) && $this->checkRollout() && $this->checkRequirements($currenteOSVersion) && $this->getSize() > 0; } /** Loading @@ -552,10 +564,36 @@ return ($configFilePath) ? json_decode( file_get_contents($configFilePath) , true) : array(); } /** * Return if requirements are met or not for a build * @return boolean */ public function checkRequirements($currenteOSVersion="") { $minimalVersion = isset($this->confProp['requirements']) ? $this->confProp['requirements']['minOSVersion'] : null; $isCompatible = true; if(isset($minimalVersion)){ $currenteOSVersionSemantic = $this->parseSemVer($currenteOSVersion); $minimalSemanticVersion = $this->parseSemVer($minimalVersion); $isCompatible = false; if($currenteOSVersionSemantic[0] == $minimalSemanticVersion[0]){ if($currenteOSVersionSemantic[1] == $minimalSemanticVersion[1]){ $isCompatible = $currenteOSVersionSemantic[2] >= $minimalSemanticVersion[2]; } else $isCompatible = $currenteOSVersionSemantic[1] > $minimalSemanticVersion[1]; } else $isCompatible = $currenteOSVersionSemantic[0] > $minimalSemanticVersion[0]; } return $isCompatible; } /** * Return if rollout successful or not for a build * @return boolean */ public function checkRollout() { $rolloutpercentage = isset($this->confProp['rollout']['percentage']) ? (int) $this->confProp['rollout']['percentage'] : 100; Loading src/Helpers/Builds.php +12 −4 Original line number Diff line number Diff line Loading @@ -160,7 +160,15 @@ private function getBuilds() { $params = $this->postData['params']; preg_match_all('/.*(eOS) v([0-9\.]+)-?((alpha|beta|rc)(\.\d)?)?.*/', $_SERVER['HTTP_USER_AGENT'], $currentTokens); $shouldDisplayPatch=false; $this->currenteOSVersion = -1; if(isset($currentTokens[2]) && count($currentTokens[2])>0){ $this->currenteOSVersion = $currentTokens[2][0]; $versionArray = explode(".", $this->currenteOSVersion); if($versionArray[0] > 1 || $versionArray[0] == 1 && $versionArray[1] > 5) $shouldDisplayPatch = true; } $device = isset($params['device']) ? $params['device'] : ''; $channels = isset($params['channels']) ? $params['channels'][0] : ''; Loading Loading @@ -189,15 +197,15 @@ // If not found there, we have to find it with the old fashion method... if ($build === false) { $build = new Build($file, $dir, $this->logger); $build = new Build($file, $dir, $this->logger, $shouldDisplayPatch); // ...and then save it for 72h until it expires again apcu_store($file, $build, 72*60*60); } } else { $build = new Build($file, $dir, $this->logger); $build = new Build($file, $dir, $this->logger, $shouldDisplayPatch); } if ($build->includeInResults($this->postData['params'])) { if ($build->includeInResults($this->postData['params'], $this->currenteOSVersion)) { array_push($this->builds, $build); } Loading Loading
src/Helpers/Build.php +41 −3 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ * @param type $fileName The current filename of the build * @param type $physicalPath The current path where the build lives */ public function __construct($fileName, $physicalPath, $logger) public function __construct($fileName, $physicalPath, $logger, $shouldDisplayPatch = false) { $this->logger = $logger; Loading Loading @@ -90,6 +90,9 @@ $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]; if(substr_count($this->version, ".") > 1 && !$shouldDisplayPatch) { $this->version = substr($this->version, 0, strrpos($this->version, '.'));//remove maintenance number when using an old updater to avoid crash } $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') ?? ''; Loading Loading @@ -400,6 +403,15 @@ private function parseSemVer($versionString) { $versionArray = explode(".", $versionString); if(empty($versionArray[0])) { $versionArray[0] = 0; } if(empty($versionArray[1])) { $versionArray[1] = 0; } if(empty($versionArray[2])) { $versionArray[2] = 0; } return array_map("intval", $versionArray); } Loading Loading @@ -529,9 +541,9 @@ * @param type $params The params dictionary inside the current POST request * @return boolean True if valid, False if not. */ public function includeInResults($params) public function includeInResults($params, $currenteOSVersion) { return $this->isValid($params) && $this->checkRollout() && $this->getSize() > 0; return $this->isValid($params) && $this->checkRollout() && $this->checkRequirements($currenteOSVersion) && $this->getSize() > 0; } /** Loading @@ -552,10 +564,36 @@ return ($configFilePath) ? json_decode( file_get_contents($configFilePath) , true) : array(); } /** * Return if requirements are met or not for a build * @return boolean */ public function checkRequirements($currenteOSVersion="") { $minimalVersion = isset($this->confProp['requirements']) ? $this->confProp['requirements']['minOSVersion'] : null; $isCompatible = true; if(isset($minimalVersion)){ $currenteOSVersionSemantic = $this->parseSemVer($currenteOSVersion); $minimalSemanticVersion = $this->parseSemVer($minimalVersion); $isCompatible = false; if($currenteOSVersionSemantic[0] == $minimalSemanticVersion[0]){ if($currenteOSVersionSemantic[1] == $minimalSemanticVersion[1]){ $isCompatible = $currenteOSVersionSemantic[2] >= $minimalSemanticVersion[2]; } else $isCompatible = $currenteOSVersionSemantic[1] > $minimalSemanticVersion[1]; } else $isCompatible = $currenteOSVersionSemantic[0] > $minimalSemanticVersion[0]; } return $isCompatible; } /** * Return if rollout successful or not for a build * @return boolean */ public function checkRollout() { $rolloutpercentage = isset($this->confProp['rollout']['percentage']) ? (int) $this->confProp['rollout']['percentage'] : 100; Loading
src/Helpers/Builds.php +12 −4 Original line number Diff line number Diff line Loading @@ -160,7 +160,15 @@ private function getBuilds() { $params = $this->postData['params']; preg_match_all('/.*(eOS) v([0-9\.]+)-?((alpha|beta|rc)(\.\d)?)?.*/', $_SERVER['HTTP_USER_AGENT'], $currentTokens); $shouldDisplayPatch=false; $this->currenteOSVersion = -1; if(isset($currentTokens[2]) && count($currentTokens[2])>0){ $this->currenteOSVersion = $currentTokens[2][0]; $versionArray = explode(".", $this->currenteOSVersion); if($versionArray[0] > 1 || $versionArray[0] == 1 && $versionArray[1] > 5) $shouldDisplayPatch = true; } $device = isset($params['device']) ? $params['device'] : ''; $channels = isset($params['channels']) ? $params['channels'][0] : ''; Loading Loading @@ -189,15 +197,15 @@ // If not found there, we have to find it with the old fashion method... if ($build === false) { $build = new Build($file, $dir, $this->logger); $build = new Build($file, $dir, $this->logger, $shouldDisplayPatch); // ...and then save it for 72h until it expires again apcu_store($file, $build, 72*60*60); } } else { $build = new Build($file, $dir, $this->logger); $build = new Build($file, $dir, $this->logger, $shouldDisplayPatch); } if ($build->includeInResults($this->postData['params'])) { if ($build->includeInResults($this->postData['params'], $this->currenteOSVersion)) { array_push($this->builds, $build); } Loading