Esempio n. 1
0
 /**
  * @depends testUnpackAPK
  *
  * @param ApkParser $parser
  */
 public function testGetVersionName(ApkParser $parser)
 {
     $this->assertEquals('1.2.0', $parser->getVersionName());
 }
 /**
  * @param $path
  *
  * @return array
  */
 private function parse_apk($path)
 {
     $full_path = UPLOAD_BASE . $path;
     try {
         $apk = new ApkParser($full_path);
     } catch (Exception $e) {
         return array('form' => array('ad_size' => Utils::format_file_size(filesize($full_path))));
     }
     $permission = $apk->getPermissions();
     $package = array('pack_name' => $apk->getPackageName(), 'ad_lib' => $apk->getVersionName(), 'ad_size' => Utils::format_file_size(filesize($full_path)), 'permission' => $this->get_permission_id(array_keys($permission)));
     // 从数据库读相同包名的广告有哪些可以直接用的数据
     $ad_service = new AD();
     $info = $ad_service->get_ad_info_by_pack_name($package['pack_name']);
     if (!$info && !defined('DEBUG')) {
         // 没有同包名的广告,再试试应用雷达
         try {
             $info = json_decode(file_get_contents('http://192.168.0.165/apk_info.php?pack_name=' . $package['pack_name']), true);
         } catch (Exception $e) {
         }
         if ($info) {
             foreach ($this->radar_map as $key => $value) {
                 $info[$key] = $info[$value];
             }
         }
     }
     if ($info) {
         $info = $this->addPrefixToAssets($info);
     }
     // 记录不良SDK
     if ($apk->has_sm) {
         $enemy = new Enemy();
         $enemy->log_sm($this->id, $path, $package['pack_name'], $apk->getAppName());
     }
     return array('form' => array_merge((array) $info, $package));
 }