ソースを参照

添加通过zip注释中获取渠道的方式。但是作为备用方案

zengjiebin 7 年 前
コミット
68a36c290b
共有1 個のファイルを変更した16 個の追加0 個の削除を含む
  1. 16 0
      app/src/main/java/com/sheep/gamegroup/util/ChannelContent.java

+ 16 - 0
app/src/main/java/com/sheep/gamegroup/util/ChannelContent.java

@@ -2,9 +2,14 @@ package com.sheep.gamegroup.util;
 
 import android.content.Context;
 import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
 import android.text.TextUtils;
 
+import com.kfzs.duanduan.utils.ApkUtils;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.Enumeration;
@@ -93,6 +98,17 @@ public class ChannelContent {
                 }
             }
         }
+        if(!hasChannelFile){//zip方式获取渠道
+            try {
+                PackageInfo packageInfo = ApkUtils.getPackageInfo(SheepApp.getInstance().getPackageName());
+                if(packageInfo != null && !TextUtils.isEmpty(packageInfo.applicationInfo.sourceDir)) {
+                    channel_name = ZipChannelUtil.readQUA(new File(packageInfo.applicationInfo.sourceDir));
+                    hasChannelFile = !TextUtils.isEmpty(channel_name);
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
         return hasChannelFile;
     }
     public String getChannel_name() {