Browse Source

优化添加启动图逻辑

yhz 5 years ago
parent
commit
a797d08e5c

+ 7 - 2
package_utils.py

@@ -503,8 +503,13 @@ def addLauncher(game, sdk, subChannel, config):
         return 0
 
     print('add launcher...')
-    # 添加关联资源
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
+    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activity = xml_utils.getLauncherActivityName(manifest)
+    if activity == 'com.jmhy.sdk.template.LauncherActivity':
+        print('add launcher already exist...')
+        return 1
+    # 添加关联资源
     internalPath = file_utils.getFullInternalPath()
     ret = copyAppResWithType(decompliePath, internalPath, 'launcher_res')
     if ret:
@@ -520,7 +525,7 @@ def addLauncher(game, sdk, subChannel, config):
 
     # 修改主文件信息
     print('change launcher config...')
-    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    
     orientation = xml_utils.getScreenOrientation(manifest)
     activity = xml_utils.removeLauncherActivity(manifest)
     xml_utils.addLauncherActivity(manifest, orientation, 'com.jmhy.sdk.template.LauncherActivity')

+ 7 - 2
package_utils_record.py

@@ -506,8 +506,14 @@ def addLauncher(game, sdk, subChannel, config):
         return 0
 
     print('add launcher...')
-    # 添加关联资源
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
+    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activity = xml_utils.getLauncherActivityName(manifest)
+    if activity == 'com.shanshen.sdk.template.LauncherActivity':
+        print('add launcher already exist...')
+        return 1
+
+    # 添加关联资源
     internalPath = os.path.join(file_utils.getCurrentPath(), 'internal_shanshen')
     ret = copyAppResWithType(decompliePath, internalPath, 'launcher_res')
     if ret:
@@ -523,7 +529,6 @@ def addLauncher(game, sdk, subChannel, config):
 
     # 修改主文件信息
     print('change launcher config...')
-    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
     orientation = xml_utils.getScreenOrientation(manifest)
     activity = xml_utils.removeLauncherActivity(manifest)
     xml_utils.addLauncherActivity(manifest, orientation, 'com.shanshen.sdk.template.LauncherActivity')

+ 7 - 2
package_utils_shanshen.py

@@ -477,8 +477,14 @@ def addLauncher(game, sdk, subChannel, config):
         return 0
 
     print('add launcher...')
-    # 添加关联资源
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
+    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activity = xml_utils.getLauncherActivityName(manifest)
+    if activity == 'com.shanshen.sdk.template.LauncherActivity':
+        print('add launcher already exist...')
+        return 1
+    
+    # 添加关联资源
     internalPath = os.path.join(file_utils.getCurrentPath(), 'internal_shanshen')
     ret = copyAppResWithType(decompliePath, internalPath, 'launcher_res')
     if ret:
@@ -494,7 +500,6 @@ def addLauncher(game, sdk, subChannel, config):
 
     # 修改主文件信息
     print('change launcher config...')
-    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
     orientation = xml_utils.getScreenOrientation(manifest)
     activity = xml_utils.removeLauncherActivity(manifest)
     xml_utils.addLauncherActivity(manifest, orientation, 'com.shanshen.sdk.template.LauncherActivity')

+ 5 - 0
sdk/jm_beiyu/script/sdk_script.py

@@ -63,6 +63,11 @@ def addLauncher(game, sdk, subChannel, config):
     # 修改主文件信息
     print('change launcher config...')
     manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activity = xml_utils.getLauncherActivityName(manifest)
+    if activity == 'com.beiyu.anycore.SplashScreenActivity':
+        print('add launcher already exist...')
+        return 1
+
     activity = xml_utils.removeLauncherActivity(manifest)
     addLauncherActivity(manifest, activity)
 

+ 5 - 0
sdk/jm_quick/script/sdk_script.py

@@ -62,6 +62,11 @@ def addLauncher(game, sdk, subChannel, config):
     # 修改主文件信息
     print('change launcher config...')
     manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activity = xml_utils.getLauncherActivityName(manifest)
+    if activity == 'com.inner.sdk.ui.LauncherActivity':
+        print('add launcher already exist...')
+        return 1
+
     orientation = xml_utils.getScreenOrientation(manifest)
     activity = xml_utils.removeLauncherActivity(manifest)
     addLauncherActivity(manifest, orientation)

+ 5 - 0
sdk/jm_xq_jrtt/script/sdk_script.py

@@ -57,6 +57,11 @@ def addLauncher(game, sdk, subChannel, config):
     # 修改主文件信息
     print('change launcher config...')
     manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activity = xml_utils.getLauncherActivityName(manifest)
+    if activity == 'com.xunqu.sdk.union.ui.SplashScreenActivity':
+        print('add launcher already exist...')
+        return 1
+
     orientation = xml_utils.getScreenOrientation(manifest)
     activity = xml_utils.removeLauncherActivity(manifest)
     addLauncherActivity(manifest, activity, orientation)

+ 5 - 0
sdk/jm_yijie/script/sdk_script.py

@@ -62,6 +62,11 @@ def addLauncher(game, sdk, subChannel, config):
     # 修改主文件信息
     print('change launcher config...')
     manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activity = xml_utils.getLauncherActivityName(manifest)
+    if activity == 'com.inner.sdk.ui.LauncherActivity':
+        print('add launcher already exist...')
+        return 1
+
     orientation = xml_utils.getScreenOrientation(manifest)
     activity = xml_utils.removeLauncherActivity(manifest)
     addLauncherActivity(manifest, orientation)

+ 6 - 2
sdk/jm_ysdk/script/sdk_script.py

@@ -119,8 +119,13 @@ def addLauncher(game, sdk, subChannel, config):
         return 0
 
     print('add launcher...')
-    # 添加关联资源
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
+    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activity = xml_utils.getLauncherActivityName(manifest)
+    if activity == 'com.inner.sdk.ui.YsdkLauncherActivity':
+        print('add launcher already exist...')
+        return 1
+    # 添加关联资源
     internalPath = file_utils.getFullInternalPath()
     ret = package_utils.copyAppResWithType(decompliePath, internalPath, 'launcher_res')
     if ret:
@@ -128,7 +133,6 @@ def addLauncher(game, sdk, subChannel, config):
 
     # 修改主文件信息
     print('change launcher config...')
-    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
     activity = xml_utils.removeLauncherActivity(manifest)
     xml_utils.addLauncherActivity(manifest, config['screenOrientation'], 'com.inner.sdk.ui.YsdkLauncherActivity')
 

+ 15 - 0
xml_utils.py

@@ -143,6 +143,21 @@ def getLauncherActivity(root):
 
     return None
 
+def getLauncherActivityName(manifest):
+    '''
+    获取启动的activity
+    '''
+    for key in namespaces:
+        ET.register_namespace(key, namespaces[key])
+
+    tree = ET.parse(manifest)
+    root = tree.getroot()
+
+    launcherActivity = getLauncherActivity(root)
+    attrName = getNamespacesFormat('android:name', namespaces)
+    activityName = launcherActivity.attrib[attrName]
+    return activityName
+
 def addMoreIcon(manifest, icon, switchIcon):
     '''
     添加多图标