|
|
@@ -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() {
|