Преглед изворни кода

review代码:
删除无用代码

zengjiebin пре 7 година
родитељ
комит
36ea284530

+ 4 - 1
app/src/main/AndroidManifest.xml

@@ -120,7 +120,10 @@
 
         <service android:name=".service.DownloadService" />
         <service
-            android:name=".service.AutoCheckService"/>
+            android:name=".service.AutoCheckService"
+            android:priority="1000"
+            android:exported="false"
+            android:process=":auto_check"/>
         <service
             android:name=".service.FloatShotScreenService" />
         <service

+ 0 - 45
app/src/main/java/com/sheep/gamegroup/receiver/AppAddOrDelReceiver.java

@@ -7,16 +7,10 @@ import android.os.Handler;
 import android.os.Looper;
 import android.text.TextUtils;
 
-import com.alibaba.fastjson.JSONObject;
 import com.kfzs.duanduan.utils.ApkUtils;
-import com.sheep.gamegroup.greendao.DDProviderHelper;
-import com.sheep.gamegroup.greendao.download.DownLoadInfo;
-import com.sheep.gamegroup.util.DeviceUtil;
-import com.sheep.gamegroup.util.NetUtil;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 
-
 import org.greenrobot.eventbus.EventBus;
 
 
@@ -27,44 +21,6 @@ import org.greenrobot.eventbus.EventBus;
 public class AppAddOrDelReceiver extends BroadcastReceiver {
     @Override
     public void onReceive(final Context context, final Intent intent) {
-        if(Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())){
-            try {
-
-                new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
-                    @Override
-                    public void run() {
-                        String dataString = intent.getDataString();
-                        if(TextUtils.isEmpty(dataString)){
-                            return;
-                        }
-                        String packages = dataString.replace("package:","");
-                        final DownLoadInfo downLoadInfo = DDProviderHelper.getInstance()
-                                .getDownloadTaskToPackname(context, packages);
-                        if(downLoadInfo == null){
-                            return;
-                        }
-                        new Thread(){
-                            @Override
-                            public void run() {
-                                super.run();
-                                try {
-                                    JSONObject jsonObject = new JSONObject();
-                                    jsonObject.put("device_id",DeviceUtil.getDeviceId(SheepApp.getInstance())+"");
-                                    jsonObject.put("id",downLoadInfo.getMGameID());
-                                    NetUtil.getNetUtil().sendAppDownload(context, jsonObject);
-
-                                } catch (Exception e) {
-                                    e.printStackTrace();
-                                }
-                            }
-                        }.start();
-                    }
-                }, 0);
-            } catch (Exception e1) {
-                e1.printStackTrace();
-            }
-        }
-
         if(Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction()) || Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction()) || Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())){
             ApkUtils.getInstance().clear();
             EventBus.getDefault().post(intent);
@@ -75,7 +31,6 @@ public class AppAddOrDelReceiver extends BroadcastReceiver {
          */
         if(Intent.ACTION_INSTALL_FAILURE.equals(intent.getAction())){
             try {
-
                 new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
                     @Override
                     public void run() {

+ 0 - 30
app/src/main/java/com/sheep/gamegroup/util/NetUtil.java

@@ -7,15 +7,8 @@ import android.content.Intent;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 
-import com.alibaba.fastjson.JSONObject;
-import com.sheep.gamegroup.model.api.ApiService;
-import com.sheep.gamegroup.model.entity.BaseMessage;
-import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 
-import rx.android.schedulers.AndroidSchedulers;
-import rx.schedulers.Schedulers;
-
 /**
  * Created by ljy on 2018/3/8.
  */
@@ -95,27 +88,4 @@ public class NetUtil {
         intent.setAction("android.intent.action.VIEW");
         activity.startActivityForResult(intent, 0);
     }
-
-    /**
-     * 应用下载,接口请求
-     */
-    public void sendAppDownload(Context context, JSONObject o){
-        ApiService apiService = SheepApp.getInstance().getNetComponent().getApiService();
-
-        apiService.taskDownloadNotify(o)
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-                    @Override
-                    public void onError(BaseMessage baseMessage) {
-
-                    }
-
-                    @Override
-                    public void onNext(BaseMessage baseMessage) {
-
-                    }
-                });
-
-    }
 }

+ 1 - 1
app/src/main/java/com/sheep/jiuyan/samllsheep/service/AutoCheckService.java

@@ -98,7 +98,7 @@ public class AutoCheckService extends Service {
     public static final String EXTRA_KEY_TASK_LIST = "task_list";
     public static final String EXTRA_KEY_USER_ID = "user_id";
     //是否采用该方案
-    public static final boolean IS_USE_THIS_SERVICE = android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP;
+    public static final boolean IS_USE_THIS_SERVICE = /*BuildConfig.DEBUG || */android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP;
     //登录的用户id
     private String userId;
     @Override