version:
update:2021.03.19 fix:修改上传应用信息为排除出厂的app和三方app add:
This commit is contained in:
@@ -192,15 +192,15 @@ dependencies {
|
||||
implementation 'com.lzy.net:okrx:0.1.2'
|
||||
implementation 'com.lzy.net:okserver:1.1.3'
|
||||
implementation 'com.squareup.okhttp3:okhttp:4.6.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
implementation 'cn.jiguang.sdk:jpush:3.8.6' // 此处以JPush 3.5.6 版本为例。
|
||||
implementation 'cn.jiguang.sdk:jcore:2.6.0' // 此处以JCore 2.2.8 版本为例。
|
||||
implementation "com.github.yjfnypeu:UpdatePlugin:3.0.1"
|
||||
// implementation "com.github.yjfnypeu:UpdatePlugin:3.0.1"
|
||||
implementation 'com.blankj:utilcode:1.23.7'
|
||||
implementation 'com.arialyy.aria:core:3.8.15'
|
||||
annotationProcessor 'com.arialyy.aria:compiler:3.8.15'
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.mjsheng.myappstore"
|
||||
android:sharedUserId="android.uid.system">
|
||||
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
|
||||
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
|
||||
@@ -93,10 +94,18 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:launchMode="singleTop"/>
|
||||
android:launchMode="singleTop" />
|
||||
<activity android:name=".activity.MainTestActivity" >
|
||||
<!-- <intent-filter>-->
|
||||
<!-- <action android:name="android.intent.action.MAIN" />-->
|
||||
|
||||
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
|
||||
<!-- </intent-filter>-->
|
||||
</activity>
|
||||
|
||||
<service android:name=".server.MyDownloadService" />
|
||||
<service android:name=".server.GuardService" />
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.nfc.Tag;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
@@ -37,8 +36,8 @@ import com.lzy.okgo.cache.CacheMode;
|
||||
import com.lzy.okgo.callback.StringCallback;
|
||||
import com.lzy.okgo.cookie.store.PersistentCookieStore;
|
||||
import com.lzy.okserver.download.DownloadService;
|
||||
import com.mjsheng.myappstore.Statistics.AppInformation;
|
||||
import com.mjsheng.myappstore.Statistics.StatisticsInfo;
|
||||
import com.mjsheng.myappstore.statistics.AppInformation;
|
||||
import com.mjsheng.myappstore.statistics.StatisticsInfo;
|
||||
import com.mjsheng.myappstore.activity.MainActivity;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper;
|
||||
@@ -57,13 +56,9 @@ import com.mjsheng.myappstore.utils.SPUtils;
|
||||
import com.mjsheng.myappstore.utils.SystemUtils;
|
||||
import com.mjsheng.myappstore.utils.ToastUtil;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
import com.mjsheng.myappstore.utils.update.ToastTool;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.lzh.framework.updatepluginlib.UpdateConfig;
|
||||
import org.lzh.framework.updatepluginlib.base.UpdateParser;
|
||||
import org.lzh.framework.updatepluginlib.model.CheckEntity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -71,10 +66,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@@ -161,9 +154,6 @@ public class MyApplication extends MultiDexApplication {
|
||||
mDateFormat = new SimpleDateFormat("HH:mm");
|
||||
initOKHttp();
|
||||
|
||||
//初始化升级框架
|
||||
ToastTool.init(context);
|
||||
initUpdatePulgin(context);
|
||||
|
||||
Aria.init(this);
|
||||
Aria.get(this).getDownloadConfig().setMaxTaskNum(1);
|
||||
@@ -682,50 +672,6 @@ public class MyApplication extends MultiDexApplication {
|
||||
downloadManager.getThreadPool().setCorePoolSize(5);
|
||||
}
|
||||
|
||||
private void initUpdatePulgin(Context context) {
|
||||
CheckEntity checkEntity = new CheckEntity();
|
||||
checkEntity.setMethod("POST");
|
||||
checkEntity.setUrl(CommonDatas.UPDATE_URL);
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("package_name", CommonDatas.UPDATE_PKG);
|
||||
params.put("key", Configure.HTTP_KEY);
|
||||
checkEntity.setParams(params);
|
||||
UpdateConfig.getConfig()
|
||||
.setCheckEntity(checkEntity)
|
||||
.setUpdateParser(new UpdateParser() {
|
||||
@Override
|
||||
public org.lzh.framework.updatepluginlib.model.Update parse(String response) throws Exception {
|
||||
// Log.e("mjsehng", "下载嘻嘻嘻嘻嘻"+response);
|
||||
org.lzh.framework.updatepluginlib.model.Update update = new org.lzh.framework.updatepluginlib.model.Update();
|
||||
try {
|
||||
JSONObject object = new JSONObject(response);
|
||||
Integer code = object.optInt("code");
|
||||
if (code == 200) {
|
||||
JSONObject jsonObject = object.getJSONObject("data");
|
||||
// 此apk包的下载地址
|
||||
update.setUpdateUrl(jsonObject.optString("url"));
|
||||
// 此apk包的版本号
|
||||
update.setVersionCode(jsonObject.optInt("version_code"));
|
||||
// 此apk包的版本名称
|
||||
update.setVersionName(jsonObject.optString("version_name"));
|
||||
// 此apk包的更新内容
|
||||
update.setUpdateContent(jsonObject.optString("desc"));
|
||||
//强制更新内容
|
||||
if (jsonObject.optString("forced_update").equals("1")) {
|
||||
update.setForced(true);
|
||||
} else {
|
||||
update.setForced(false);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return update;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 添加Activity到容器中
|
||||
public static void addActivity(Activity activity) {
|
||||
|
||||
@@ -80,14 +80,9 @@ import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.SysSettingUtils;
|
||||
import com.mjsheng.myappstore.utils.ToastUtil;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
import com.mjsheng.myappstore.utils.update.AllDialogShowStrategy;
|
||||
import com.mjsheng.myappstore.utils.update.NotificationDownloadCreator;
|
||||
import com.mjsheng.myappstore.utils.update.OkhttpCheckWorker;
|
||||
import com.mjsheng.myappstore.utils.update.ToastCallback;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.lzh.framework.updatepluginlib.UpdateBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -113,7 +108,6 @@ import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence;
|
||||
|
||||
public class MainActivity extends AppCompatActivity implements AMapLocationListener {
|
||||
|
||||
private ToastCallback callback;
|
||||
private long mPreClickTime;
|
||||
private Context mContext;
|
||||
private final String ACTION_HrReceiver_JGY_DIS = "qch_jgy_network_disallow";
|
||||
@@ -160,7 +154,6 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
|
||||
|
||||
// Aria.download(this).removeAllTask(false);
|
||||
|
||||
callback = new ToastCallback(this);
|
||||
initView();
|
||||
initData();
|
||||
|
||||
@@ -1086,16 +1079,6 @@ public class MainActivity extends AppCompatActivity implements AMapLocationListe
|
||||
});
|
||||
}
|
||||
|
||||
private void update() {
|
||||
UpdateBuilder updateBuilder = UpdateBuilder.create();
|
||||
// 配置toast通知的回调
|
||||
updateBuilder.setDownloadCallback(callback);
|
||||
// updateBuilder.setCheckCallback(callback);
|
||||
updateBuilder.setDownloadNotifier(new NotificationDownloadCreator());
|
||||
updateBuilder.setUpdateStrategy(new AllDialogShowStrategy());
|
||||
updateBuilder.setCheckWorker(OkhttpCheckWorker.class);
|
||||
updateBuilder.check();
|
||||
}
|
||||
|
||||
// 用来计算返回键的点击间隔时间
|
||||
private long exitTime = 0;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mjsheng.myappstore.jpush.Invalid;
|
||||
package com.mjsheng.myappstore.jpush.invalid;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mjsheng.myappstore.jpush.Invalid;
|
||||
package com.mjsheng.myappstore.jpush.invalid;
|
||||
|
||||
|
||||
//public class MainActivity extends InstrumentedActivity implements OnClickListener{
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mjsheng.myappstore.jpush.Invalid;
|
||||
package com.mjsheng.myappstore.jpush.invalid;
|
||||
|
||||
//public class PushSetActivity extends InstrumentedActivity implements OnClickListener {
|
||||
// private static final String TAG = "JIGUANG-Example";
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mjsheng.myappstore.jpush.Invalid;
|
||||
package com.mjsheng.myappstore.jpush.invalid;
|
||||
|
||||
//public class SettingActivity extends InstrumentedActivity implements OnClickListener {
|
||||
// TimePicker startTime;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mjsheng.myappstore.jpush.Invalid;
|
||||
package com.mjsheng.myappstore.jpush.invalid;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
@@ -260,6 +260,10 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
MyApplication.sendAppUsedTime(random, sendType);
|
||||
break;
|
||||
case GET_FORCEDOWNLOADURL:
|
||||
File file = new File(PathUtils.getExternalDownloadsPath() + "/jgy/");
|
||||
if (!file.exists()){
|
||||
file.mkdirs();
|
||||
}
|
||||
if (TextUtils.isEmpty(extras)) {
|
||||
Log.e("mjsheng", "settingNetControl extras is null");
|
||||
return;
|
||||
@@ -642,6 +646,10 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private void doDownloadAndInstall(String s) {
|
||||
File file = new File(PathUtils.getExternalDownloadsPath() + "/jgy/");
|
||||
if (!file.exists()){
|
||||
file.mkdirs();
|
||||
}
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
Log.e("mjsheng", "doDownloadAndInstall extras is null");
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mjsheng.myappstore.Statistics;
|
||||
package com.mjsheng.myappstore.statistics;
|
||||
|
||||
import android.app.usage.UsageStats;
|
||||
import android.content.Context;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mjsheng.myappstore.Statistics;
|
||||
package com.mjsheng.myappstore.statistics;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.usage.UsageEvents;
|
||||
@@ -13,7 +13,7 @@ import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.mjsheng.myappstore.Statistics.AppInformation.bootTime;
|
||||
import static com.mjsheng.myappstore.statistics.AppInformation.bootTime;
|
||||
|
||||
|
||||
public class StatisticsInfo {
|
||||
@@ -17,8 +17,10 @@ import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -652,6 +654,177 @@ public class ApkUtils {
|
||||
this.add("com.jiaoguanyi.store");//教官壹
|
||||
}};
|
||||
|
||||
public static List<String> factoryapp = new ArrayList<String>() {{
|
||||
this.add("com.android.fmradio");
|
||||
this.add("com.mediatek.gba");
|
||||
this.add("com.mediatek.ims");
|
||||
this.add("com.mediatek.ppl");
|
||||
this.add("com.android.cts.priv.ctsshim");
|
||||
this.add("com.android.internal.display.cutout.emulation.corner");
|
||||
this.add("com.android.internal.display.cutout.emulation.double");
|
||||
this.add("com.mediatek.autobootcontroller");
|
||||
this.add("com.android.providers.telephony");
|
||||
this.add("com.android.dynsystem");
|
||||
this.add("com.mediatek.camera");
|
||||
this.add("com.android.providers.calendar");
|
||||
this.add("com.mediatek.telephony");
|
||||
this.add("com.android.providers.media");
|
||||
this.add("com.android.theme.icon.square");
|
||||
this.add("com.android.internal.systemui.navbar.gestural_wide_back");
|
||||
this.add("com.mediatek.location.lppe.main");
|
||||
this.add("com.android.wallpapercropper");
|
||||
this.add("com.android.theme.color.cinnamon");
|
||||
this.add("com.mediatek.gnss.nonframeworklbs");
|
||||
this.add("com.verizon.remoteSimlock");
|
||||
this.add("com.android.protips");
|
||||
this.add("com.android.theme.icon_pack.rounded.systemui");
|
||||
this.add("com.android.documentsui");
|
||||
this.add("com.android.externalstorage");
|
||||
this.add("com.mediatek.ygps");
|
||||
this.add("com.mediatek.simprocessor");
|
||||
this.add("com.android.htmlviewer");
|
||||
this.add("com.mediatek.autodialer");
|
||||
this.add("com.mediatek.mms.appservice");
|
||||
this.add("com.android.companiondevicemanager");
|
||||
this.add("com.android.quicksearchbox");
|
||||
this.add("com.android.mms.service");
|
||||
this.add("com.android.providers.downloads");
|
||||
this.add("com.adups.fota");
|
||||
this.add("com.mediatek.engineermode");
|
||||
this.add("com.android.theme.icon_pack.rounded.android");
|
||||
this.add("com.example.hragingtest");
|
||||
this.add("com.mediatek.omacp");
|
||||
this.add("com.bsm_wqy.validationtools");
|
||||
this.add("com.android.browser");
|
||||
this.add("com.android.theme.icon_pack.circular.themepicker");
|
||||
this.add("com.android.soundrecorder");
|
||||
this.add("com.android.providers.downloads.ui");
|
||||
this.add("com.android.pacprocessor");
|
||||
this.add("com.android.simappdialog");
|
||||
this.add("com.android.networkstack");
|
||||
this.add("com.android.internal.display.cutout.emulation.tall");
|
||||
this.add("com.android.modulemetadata");
|
||||
this.add("com.android.certinstaller");
|
||||
this.add("com.android.theme.color.black");
|
||||
this.add("com.android.carrierconfig");
|
||||
this.add("com.android.theme.color.green");
|
||||
this.add("com.android.theme.color.ocean");
|
||||
this.add("com.android.theme.color.space");
|
||||
this.add("com.android.internal.systemui.navbar.threebutton");
|
||||
this.add("android");
|
||||
this.add("com.android.contacts");
|
||||
this.add("com.mediatek.emcamera");
|
||||
this.add("com.android.theme.icon_pack.rounded.launcher");
|
||||
this.add("com.st.nfc.dta.mobile");
|
||||
this.add("com.android.egg");
|
||||
this.add("com.android.mms");
|
||||
this.add("com.android.mtp");
|
||||
this.add("com.android.nfc");
|
||||
this.add("com.android.ons");
|
||||
this.add("com.android.stk");
|
||||
this.add("com.android.launcher3");
|
||||
this.add("com.android.backupconfirm");
|
||||
this.add("com.mediatek.security");
|
||||
this.add("com.android.internal.systemui.navbar.twobutton");
|
||||
this.add("com.android.provision");
|
||||
this.add("com.android.statementservice");
|
||||
this.add("com.android.hotspot2");
|
||||
this.add("com.mediatek.mdmlsample");
|
||||
this.add("com.android.settings.intelligence");
|
||||
this.add("com.android.calendar");
|
||||
this.add("com.mediatek.frameworkresoverlay");
|
||||
this.add("com.debug.loggerui");
|
||||
this.add("com.android.internal.systemui.navbar.gestural_extra_wide_back");
|
||||
this.add("com.android.providers.settings");
|
||||
this.add("com.android.sharedstoragebackup");
|
||||
this.add("com.mediatek.batterywarning");
|
||||
this.add("com.android.printspooler");
|
||||
this.add("com.android.theme.icon_pack.filled.settings");
|
||||
this.add("com.android.dreams.basic");
|
||||
this.add("com.android.webview");
|
||||
this.add("com.android.se");
|
||||
this.add("com.android.inputdevices");
|
||||
this.add("com.chartcross.gpstest");
|
||||
this.add("com.android.bips");
|
||||
this.add("com.mediatek");
|
||||
this.add("com.android.theme.icon_pack.circular.settings");
|
||||
this.add("com.android.musicfx");
|
||||
this.add("com.android.cellbroadcastreceiver");
|
||||
this.add("com.android.theme.icon.teardrop");
|
||||
this.add("android.ext.shared");
|
||||
this.add("com.android.onetimeinitializer");
|
||||
this.add("com.android.server.telecom");
|
||||
this.add("com.android.keychain");
|
||||
this.add("com.mediatek.security.service");
|
||||
this.add("com.android.printservice.recommendation");
|
||||
this.add("com.android.dialer");
|
||||
this.add("com.android.gallery3d");
|
||||
this.add("com.android.theme.icon_pack.filled.systemui");
|
||||
this.add("android.ext.services");
|
||||
this.add("com.android.calllogbackup");
|
||||
this.add("com.hr.factorytesting");
|
||||
this.add("com.android.localtransport");
|
||||
this.add("com.android.packageinstaller");
|
||||
this.add("com.android.carrierdefaultapp");
|
||||
this.add("com.mediatek.atmwifimeta");
|
||||
this.add("com.android.theme.font.notoserifsource");
|
||||
this.add("com.android.theme.icon_pack.filled.android");
|
||||
this.add("com.android.proxyhandler");
|
||||
this.add("com.android.theme.icon_pack.circular.systemui");
|
||||
this.add("com.android.inputmethod.latin");
|
||||
this.add("com.android.managedprovisioning");
|
||||
this.add("com.mediatek.capctrl.service");
|
||||
this.add("com.mediatek.callrecorder");
|
||||
this.add("com.android.wallpaper.livepicker");
|
||||
this.add("com.android.apps.tag");
|
||||
this.add("com.mediatek.gnssdebugreport");
|
||||
this.add("com.android.theme.icon.squircle");
|
||||
this.add("com.android.storagemanager");
|
||||
this.add("com.android.bookmarkprovider");
|
||||
this.add("com.android.settings");
|
||||
this.add("com.google.android.inputmethod.pinyin");
|
||||
this.add("com.android.theme.icon_pack.filled.launcher");
|
||||
this.add("com.android.networkstack.permissionconfig");
|
||||
this.add("com.mediatek.mdmconfig");
|
||||
this.add("com.mediatek.lbs.em2.ui");
|
||||
this.add("com.android.cts.ctsshim");
|
||||
this.add("com.android.theme.icon_pack.circular.launcher");
|
||||
this.add("com.android.vpndialogs");
|
||||
this.add("com.android.email");
|
||||
this.add("com.android.music");
|
||||
this.add("com.android.phone");
|
||||
this.add("com.android.shell");
|
||||
this.add("com.android.theme.icon_pack.filled.themepicker");
|
||||
this.add("com.android.wallpaperbackup");
|
||||
this.add("com.android.providers.blockednumber");
|
||||
this.add("com.android.providers.userdictionary");
|
||||
this.add("com.android.emergency");
|
||||
this.add("com.android.internal.systemui.navbar.gestural");
|
||||
this.add("com.android.location.fused");
|
||||
this.add("com.android.theme.color.orchid");
|
||||
this.add("com.android.deskclock");
|
||||
this.add("com.android.systemui");
|
||||
this.add("com.android.theme.color.purple");
|
||||
this.add("com.android.bluetoothmidiservice");
|
||||
this.add("com.android.permissioncontroller");
|
||||
this.add("com.android.traceur");
|
||||
this.add("com.mediatek.sensorhub.ui");
|
||||
this.add("android.auto_generated_rro_product__");
|
||||
this.add("com.android.bluetooth");
|
||||
this.add("com.android.wallpaperpicker");
|
||||
this.add("com.android.providers.contacts");
|
||||
this.add("com.android.captiveportallogin");
|
||||
this.add("com.android.theme.icon.roundedrect");
|
||||
this.add("com.android.internal.systemui.navbar.gestural_narrow_back");
|
||||
this.add("com.android.theme.icon_pack.rounded.settings");
|
||||
this.add("com.mediatek.dataprotection");
|
||||
this.add("com.wapi.wapicertmanager");
|
||||
this.add("android.auto_generated_rro_vendor__");
|
||||
this.add("com.android.theme.icon_pack.circular.android");
|
||||
this.add("com.jiaoguanyi.appstore");
|
||||
this.add("com.jiaoguanyi.store");
|
||||
}};
|
||||
|
||||
|
||||
public static void showAllAPP(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
@@ -868,10 +1041,16 @@ public class ApkUtils {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) && factoryapp.contains(packageInfo.packageName)) {
|
||||
//如果是系统应用且包名属于出厂app 跳过
|
||||
continue;
|
||||
}
|
||||
|
||||
UploadAppInfo uploadAppInfo = new UploadAppInfo();
|
||||
|
||||
uploadAppInfo.setApp_name(packageInfo.applicationInfo.loadLabel(context.getPackageManager()).toString());
|
||||
uploadAppInfo.setPackage_name(packageInfo.packageName);
|
||||
Log.e("getAppInfo", "getAppInfo:" + packageInfo.packageName);
|
||||
uploadAppInfo.setId(i);
|
||||
String firstInstallTime = Utils.transferLongToDate(packageInfo.firstInstallTime);
|
||||
uploadAppInfo.setInstall_time(firstInstallTime);
|
||||
@@ -879,22 +1058,15 @@ public class ApkUtils {
|
||||
uploadAppInfo.setState(0);
|
||||
uploadAppInfo.setVersionName(packageInfo.versionName);
|
||||
|
||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
} else {
|
||||
for (ActivityManager.RunningServiceInfo info : infoList) {
|
||||
if (info.process.contains(packageInfo.packageName)) {
|
||||
uploadAppInfo.setState(1);
|
||||
Log.e("fht", "getAppInfo running: " + packageInfo.packageName);
|
||||
}
|
||||
for (ActivityManager.RunningServiceInfo info : infoList) {
|
||||
if (info.process.contains(packageInfo.packageName)) {
|
||||
uploadAppInfo.setState(1);
|
||||
Log.e("fht", "getAppInfo running: " + packageInfo.packageName);
|
||||
}
|
||||
appList.add(uploadAppInfo);
|
||||
}
|
||||
|
||||
|
||||
appList.add(uploadAppInfo);
|
||||
}
|
||||
|
||||
// Log.e("mjsheng", "UploadAppInfo========" + appList.toString());
|
||||
|
||||
Gson gson = new Gson();
|
||||
String jsonString = gson.toJson(appList);
|
||||
// Log.e("mjsheng", "json========" + jsonString);
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mjsheng.myappstore.utils.update;
|
||||
|
||||
import org.lzh.framework.updatepluginlib.base.UpdateStrategy;
|
||||
import org.lzh.framework.updatepluginlib.impl.WifiFirstStrategy;
|
||||
import org.lzh.framework.updatepluginlib.model.Update;
|
||||
|
||||
/**
|
||||
* 自定义强制显示所有Dialog策略,
|
||||
* 默认使用参考 {@link WifiFirstStrategy}
|
||||
*/
|
||||
public class AllDialogShowStrategy implements UpdateStrategy {
|
||||
/** 指定是否在判断出有需要更新的版本时。弹出更新提醒弹窗
|
||||
* @param update 需要更新的版本信息
|
||||
* @return true 显示弹窗
|
||||
*/
|
||||
@Override
|
||||
public boolean isShowUpdateDialog(Update update) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定是否下载完成后自动进行安装页不显示弹窗
|
||||
* @return true 直接安装,不显示弹窗
|
||||
*/
|
||||
@Override
|
||||
public boolean isAutoInstall() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定是否在下载的时候显示下载进度弹窗
|
||||
* @return true 显示弹窗
|
||||
*/
|
||||
@Override
|
||||
public boolean isShowDownloadDialog() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.mjsheng.myappstore.utils.update;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
|
||||
import org.lzh.framework.updatepluginlib.base.DownloadCallback;
|
||||
import org.lzh.framework.updatepluginlib.base.DownloadNotifier;
|
||||
import org.lzh.framework.updatepluginlib.impl.DefaultDownloadNotifier;
|
||||
import org.lzh.framework.updatepluginlib.model.Update;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 很多小伙伴提意见说需要一个下载时在通知栏进行进度条显示更新的功能。
|
||||
* 此类用于提供此种需求的解决方案。以及如何对其进行定制。满足任意场景使用
|
||||
* 默认使用参考:{@link DefaultDownloadNotifier}
|
||||
* </p>
|
||||
*/
|
||||
public class NotificationDownloadCreator implements DownloadNotifier {
|
||||
@Override
|
||||
public DownloadCallback create(Update update, Activity activity) {
|
||||
// 返回一个UpdateDownloadCB对象用于下载时使用来更新界面。
|
||||
return new NotificationCB(activity);
|
||||
}
|
||||
|
||||
private static class NotificationCB implements DownloadCallback {
|
||||
|
||||
NotificationManager manager;
|
||||
NotificationCompat.Builder builder;
|
||||
int id;
|
||||
int preProgress;
|
||||
|
||||
NotificationCB (Activity activity) {
|
||||
this.manager = (NotificationManager) activity.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
builder = new NotificationCompat.Builder(activity);
|
||||
builder.setProgress(100, 0, false)
|
||||
.setSmallIcon(activity.getApplicationInfo().icon)
|
||||
.setAutoCancel(false)
|
||||
.setContentText("下载中...")
|
||||
.setContentText("正在下载")
|
||||
.build();
|
||||
|
||||
id = Math.abs(UUID.randomUUID().hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadStart() {
|
||||
CommonDatas.IS_UPDATE_DOLOADING = true;
|
||||
// 下载开始时的通知回调。运行于主线程
|
||||
manager.notify(id,builder.build());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadComplete(File file) {
|
||||
CommonDatas.IS_UPDATE_DOLOADING = false;
|
||||
// 下载完成的回调。运行于主线程
|
||||
manager.cancel(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(long current, long total) {
|
||||
// 下载过程中的进度信息。在此获取进度信息。运行于主线程
|
||||
int progress = (int) (current * 1f / total * 100);
|
||||
// 过滤不必要的刷新进度
|
||||
if (preProgress < progress) {
|
||||
preProgress = progress;
|
||||
builder.setProgress(100,progress,false);
|
||||
manager.notify(id,builder.build());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadError(Throwable t) {
|
||||
// 下载时出错。运行于主线程
|
||||
manager.cancel(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.mjsheng.myappstore.utils.update;
|
||||
|
||||
import org.lzh.framework.updatepluginlib.base.CheckWorker;
|
||||
import org.lzh.framework.updatepluginlib.impl.DefaultCheckWorker;
|
||||
import org.lzh.framework.updatepluginlib.model.CheckEntity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 定制一个简单的使用okHttp做更新接口检查的网络任务。
|
||||
* 框架默认使用参考:{@link DefaultCheckWorker}
|
||||
* </p>
|
||||
*/
|
||||
public class OkhttpCheckWorker extends CheckWorker {
|
||||
|
||||
private static OkHttpClient sOkClient;
|
||||
@Override
|
||||
protected String check(CheckEntity entity) throws Exception {
|
||||
// 自定网络任务。在此通过同步请求的方式调用即可
|
||||
Request.Builder builder = new Request.Builder().url(entity.getUrl());
|
||||
if ("GET".equalsIgnoreCase(entity.getMethod())) {
|
||||
builder.method("GET",null);
|
||||
} else {
|
||||
FormBody.Builder bodyBuilder = new FormBody.Builder();
|
||||
Map<String, String> params = entity.getParams();
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
Set<String> keys = params.keySet();
|
||||
for (String key : keys) {
|
||||
bodyBuilder.add(key,params.get(key));
|
||||
}
|
||||
builder.method("POST",bodyBuilder.build());
|
||||
}
|
||||
Request request = builder.build();
|
||||
Call call = sOkClient.newCall(request);
|
||||
|
||||
return call.execute().body().string();
|
||||
}
|
||||
|
||||
static {
|
||||
sOkClient = new OkHttpClient();
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.mjsheng.myappstore.utils.update;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.lzh.framework.updatepluginlib.base.CheckCallback;
|
||||
import org.lzh.framework.updatepluginlib.base.DownloadCallback;
|
||||
import org.lzh.framework.updatepluginlib.model.Update;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author haoge on 2018/1/9.
|
||||
*/
|
||||
|
||||
public class ToastCallback implements CheckCallback, DownloadCallback {
|
||||
|
||||
Toast mToast;
|
||||
|
||||
public ToastCallback(Context context) {
|
||||
this.mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
|
||||
}
|
||||
|
||||
private void show(String message) {
|
||||
mToast.setText(message);
|
||||
mToast.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckStart() {
|
||||
show("启动更新任务");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hasUpdate(Update update) {
|
||||
show("检测到有更新");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noUpdate() {
|
||||
show("检测到没有更新");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckError(Throwable t) {
|
||||
show("更新检查失败:" + t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserCancel() {
|
||||
show("用户取消更新");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckIgnore(Update update) {
|
||||
show("用户忽略此版本更新");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadStart() {
|
||||
show("开始下载");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadComplete(File file) {
|
||||
show("下载完成");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadProgress(long current, long total) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDownloadError(Throwable t) {
|
||||
show("下载失败");
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.mjsheng.myappstore.utils.update;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* Created by haoge on 2017/3/2.
|
||||
*/
|
||||
|
||||
public class ToastTool {
|
||||
static Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
static Toast toast;
|
||||
@SuppressLint("ShowToast")
|
||||
public static void init(Context context) {
|
||||
toast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
|
||||
}
|
||||
|
||||
public static void show (final String msg) {
|
||||
mainHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user