update:2021.03.19
fix:修改上传应用信息为排除出厂的app和三方app
add:
This commit is contained in:
FHT
2021-03-19 16:05:19 +08:00
parent f114b27606
commit 602cd1c0ee
18 changed files with 215 additions and 382 deletions

View File

@@ -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);

View File

@@ -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;
}
}

View File

@@ -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);
}
}
}

View File

@@ -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();
}
}

View File

@@ -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("下载失败");
}
}

View File

@@ -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();
}
});
}
}