From ec61380fccaedc2bdec9c4af4635944674d065cc Mon Sep 17 00:00:00 2001 From: Administrator <981964879@qq.com> Date: Mon, 17 Aug 2020 18:42:43 +0800 Subject: [PATCH] =?UTF-8?q?version:2.0.2.1=20update:2020.08.17=20fix:?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E9=9A=90=E8=97=8F=E6=A1=8C=E9=9D=A2=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E7=9A=84=E5=BA=94=E7=94=A8=E6=9C=AA=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E7=AE=A1=E6=8E=A7=E5=A4=B1=E6=95=88=20add:?= =?UTF-8?q?=E6=8A=93=E5=8F=96log=EF=BC=8C=E9=9D=99=E9=BB=98=E6=88=AA?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +- app/src/main/AndroidManifest.xml | 14 ++ .../com/mjsheng/myappstore/MyApplication.java | 59 ++++++ .../myappstore/activity/MainActivity.java | 1 + .../mjsheng/myappstore/log/LogReceiver.java | 48 +++++ .../myappstore/log/ReceiverHandler.java | 174 ++++++++++++++++++ .../myappstore/network/HTTPInterface.java | 8 +- .../mjsheng/myappstore/utils/ApkUtils.java | 1 + 8 files changed, 305 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/com/mjsheng/myappstore/log/LogReceiver.java create mode 100644 app/src/main/java/com/mjsheng/myappstore/log/ReceiverHandler.java diff --git a/app/build.gradle b/app/build.gradle index 0b207c0..974452c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -73,8 +73,8 @@ android { //中优 zhongyou { flavorDimensions "default" - versionCode 1100 - versionName "1.0.0.0"//测试jiaoguanyi.cn + versionCode 1 + versionName "1.0"//测试jiaoguanyi.cn /*********************************极光推送************************************/ manifestPlaceholders = [ JPUSH_PKGNAME: "com.jiaoguanyi.appstore", diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e1760a2..0167c99 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,6 +8,8 @@ + + @@ -132,6 +134,18 @@ + + + + + + + + + + + + diff --git a/app/src/main/java/com/mjsheng/myappstore/MyApplication.java b/app/src/main/java/com/mjsheng/myappstore/MyApplication.java index 82bf583..50166bc 100644 --- a/app/src/main/java/com/mjsheng/myappstore/MyApplication.java +++ b/app/src/main/java/com/mjsheng/myappstore/MyApplication.java @@ -58,7 +58,10 @@ 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.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; @@ -173,7 +176,63 @@ public class MyApplication extends MultiDexApplication { } registerTimeReceiver(); // ignoreBatteryOptimization(this); +// try { +// Process exec = Runtime.getRuntime().exec(running); +// final InputStream is = exec.getInputStream(); +// new LogThread(is).start(); +// } catch (IOException e) { +//// e.printStackTrace(); +// Log.e("第一个是Logcat", e.getMessage()); +// } + } + //第一个是Logcat ,也就是我们想要获取的log日志 +//第二个是 -s 也就是表示过滤的意思 +//第三个就是 我们要过滤的类型 W表示warm ,我们也可以换成 D :debug, I:info,E:error等等 +// String[] running = new String[]{"logcat", "-s", "adb logcat *: W"}; + String[] running = new String[]{"logcat"}; + String filePath = "/sdcard/Log/Log.txt"; + + class LogThread extends Thread { + InputStream is; + + LogThread(InputStream inputStream) { + super(); + this.is = inputStream; + } + + @Override + public void run() { + FileOutputStream os = null; + try { + //新建一个路径信息 + File file = new File(filePath); + if (!file.exists()) { + file.getParentFile().mkdirs(); + file.createNewFile(); + } + os = new FileOutputStream(filePath); + int len = 0; + byte[] buf = new byte[1024]; + while (-1 != (len = is.read(buf))) { + os.write(buf, 0, len); + os.flush(); + } + } catch (Exception e) { + Log.e("writelog", "read logcat process failed. message: " + + e.getMessage()); + } finally { + if (null != os) { + try { + os.close(); + os = null; + + } catch (IOException e) { + // Do nothing + } + } + } + } } /** diff --git a/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java b/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java index 966c4b6..6c49833 100644 --- a/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java +++ b/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java @@ -227,6 +227,7 @@ public class MainActivity extends AppCompatActivity { Intent allIntent = new Intent(); allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION); sendBroadcast(allIntent); +// CmdUtil.execute(" screencap -p /sdcard/" + "screen" + System.currentTimeMillis() + ".png"); } diff --git a/app/src/main/java/com/mjsheng/myappstore/log/LogReceiver.java b/app/src/main/java/com/mjsheng/myappstore/log/LogReceiver.java new file mode 100644 index 0000000..9d64828 --- /dev/null +++ b/app/src/main/java/com/mjsheng/myappstore/log/LogReceiver.java @@ -0,0 +1,48 @@ +package com.mjsheng.myappstore.log; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +/** + * @author MTK81255 + */ +public class LogReceiver extends BroadcastReceiver { + private static final String TAG = "/LogReceiver"; + public static final String ACTION_ADB_CMD = "com.debug.loggerui.ADB_CMD"; + public static final String ACTION_MDLOGGER_RESTART_DONE = "com.mediatek.mdlogger.AUTOSTART_COMPLETE"; + public static final String ACTION_EXP_HAPPENED = "com.mediatek.log2server.EXCEPTION_HAPPEND"; + public static final String ACTION_FROM_BYPASS = "com.debug.loggerui.bypass"; + + + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + Log.e(TAG, " -->onReceive(), action=" + action); +// if (Utils.isServiceOnDestroying()) { +// Utils.logw(TAG, "Service is On Destroying, juet do nothing for " + action); +// return; +// } + ReceiverHandler receiverHandler = ReceiverHandler.getDefaultInstance(); + if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { + receiverHandler.obtainMessage(ReceiverHandler.MSG_RECEIVER_BOOT_COMPLETED, + intent).sendToTarget(); + } else if (ACTION_ADB_CMD.equals(action)) { + receiverHandler.obtainMessage(ReceiverHandler.MSG_RECEIVER_ADB_CMD, + intent).sendToTarget(); + } else if (ACTION_MDLOGGER_RESTART_DONE.equals(action)) { + receiverHandler.obtainMessage( + ReceiverHandler.MSG_RECEIVER_MDLOGGER_RESTART_DONE, + intent).sendToTarget(); + } else if (ACTION_EXP_HAPPENED.equals(action)) { + receiverHandler.obtainMessage(ReceiverHandler.MSG_RECEIVER_EXP_HAPPENED, + intent).sendToTarget(); + } else if (ACTION_FROM_BYPASS.equals(action)) { + receiverHandler.obtainMessage(ReceiverHandler.MSG_RECEIVER_FROM_BYPASS, + intent).sendToTarget(); + } + Log.e(TAG, " OnReceive function exit."); + } + +} diff --git a/app/src/main/java/com/mjsheng/myappstore/log/ReceiverHandler.java b/app/src/main/java/com/mjsheng/myappstore/log/ReceiverHandler.java new file mode 100644 index 0000000..e088632 --- /dev/null +++ b/app/src/main/java/com/mjsheng/myappstore/log/ReceiverHandler.java @@ -0,0 +1,174 @@ +package com.mjsheng.myappstore.log; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Handler; +import android.os.HandlerThread; +import android.os.Looper; +import android.os.Message; +import android.os.Process; + + + +/** + * @author MTK81255 + * + */ +public class ReceiverHandler extends Handler { + private static final String TAG ="/ReceiverHandler"; + + public static final int MSG_KILL_SELF = 1; + public static final int MSG_RECEIVER_BOOT_COMPLETED = 2; + public static final int MSG_RECEIVER_ADB_CMD = 3; + public static final int MSG_RECEIVER_MDLOGGER_RESTART_DONE = 4; + public static final int MSG_RECEIVER_EXP_HAPPENED = 5; + public static final int MSG_RECEIVER_FROM_BYPASS = 6; + // After receiver a kill self command, wait this time(ms) to avoid + // duplicated kill in short time + public static final int DELAY_KILL_SELF = 2000; + public static final int DELAY_WAITING_BOOT_COMPLETE_DONE = 5000; + + /* + * If true, the service will always start. + */ + private static final boolean ALWAYS_START_SERVICE = false; + private static ReceiverHandler sDefaultInstance; + + /** + * @param looper Looper + */ + public ReceiverHandler(Looper looper) { + super(looper); + } + + /** + * @return ReceiverHandler + */ + public static ReceiverHandler getDefaultInstance() { + if (sDefaultInstance == null) { + synchronized (ReceiverHandler.class) { + if (sDefaultInstance == null) { + HandlerThread handlerThread = new HandlerThread("ReceiverHandlerThread"); + handlerThread.start(); + sDefaultInstance = new ReceiverHandler(handlerThread.getLooper()); + } + } + } + return sDefaultInstance; + } + +// private SharedPreferences mDefaultSharedPreferences = +// MyApplication.getInstance().getDefaultSharedPreferences(); + + @Override + public void handleMessage(Message msg) { + int what = msg.what; +// if (what == MSG_KILL_SELF) { +// Utils.logi(TAG, "Get a self-kill command. Need to kill me now"); +// if (!DebugLoggerUIServiceManager.getInstance().isServiceUsed()) { +// Process.killProcess(Process.myPid()); +// } else { +// Utils.logi(TAG, "But Log service was started already, maybe user enter UI." +// + "Do not kill self any more."); +// } +// return; +// } + try { + Intent intent = new Intent(); + if (msg.obj instanceof Intent) { + intent = (Intent) msg.obj; + } + if (what == MSG_RECEIVER_BOOT_COMPLETED) { +// dealWithBootcomplete(intent); + } else if (what == MSG_RECEIVER_ADB_CMD) { +// if (!Utils.isDeviceOwner()) { +// Utils.logi(TAG, "It is not device owner, ignore dealWithADBCommand()"); +// return; +// } + dealWithADBCommand(intent); + } else if (what == MSG_RECEIVER_MDLOGGER_RESTART_DONE) { + dealWithMDLoggerRestart(intent); + } else if (what == MSG_RECEIVER_EXP_HAPPENED) { + dealWithExcptionHappend(intent); + } else if (what == MSG_RECEIVER_FROM_BYPASS) { + dealWithBypassAction(intent); + } + } catch (ServiceNullException e) { + return; + } + }; + +// private void dealWithBootcomplete(Intent intent) throws ServiceNullException { +// LogConfig.getInstance().checkConfig(); +// // Now start log service or just remove log process manually +// if (Utils.isTaglogEnable() || needStartLogAtBootTime() || ALWAYS_START_SERVICE) { +// if (SecurityWarning.isNeedAlert()) { +// SecurityWarning.DialogExcute dialogExcute = new SecurityWarning.DialogExcute() { +// @Override +// public void okButtonClicked() { +// DebugLoggerUIServiceManager.getInstance().initService(); +// } +// +// @Override +// public void cancelButtonClicked() { +// getDefaultInstance().removeMessages(MSG_KILL_SELF); +// getDefaultInstance().sendMessageDelayed( +// getDefaultInstance().obtainMessage(MSG_KILL_SELF), DELAY_KILL_SELF); +// } +// +// }; +// SecurityWarning.getInstance().getAlertHander() +// .obtainMessage(SecurityWarning.MSG_BOOT_COMPLETE, dialogExcute) +// .sendToTarget(); +// } else { +// DebugLoggerUIServiceManager.getInstance().initService(); +// } +// } else { +// getDefaultInstance().removeMessages(MSG_KILL_SELF); +// getDefaultInstance().sendMessageDelayed( +// getDefaultInstance().obtainMessage(MSG_KILL_SELF), DELAY_KILL_SELF); +// } +// } + + private void dealWithADBCommand(Intent intent) throws ServiceNullException { +// DebugLoggerUIServiceManager.getInstance().getService().daelWithADBCommand(intent); + } + + private void dealWithMDLoggerRestart(Intent intent) throws ServiceNullException { +// DebugLoggerUIServiceManager.getInstance().getService().dealWithMDLoggerRestart(intent); + } + + private void dealWithExcptionHappend(Intent intent) throws ServiceNullException { +// DebugLoggerUIServiceManager.getInstance().getService().doTagLogForManually(intent); + } + + private void dealWithBypassAction(Intent intent) throws ServiceNullException { +// DebugLoggerUIServiceManager.getInstance().getService().dealWithBypassAction(intent); + } + + /** + * Judge whether need to start up DebugLoggerUI service at boot time. If none log instance was + * set to start automatically when boot up, just remove this process to avoid confuse user + */ +// private boolean needStartLogAtBootTime() { +// boolean needStart = false; +// for (Integer logType : Utils.LOG_TYPE_SET) { +// if (logType == Utils.LOG_TYPE_MET) { +// continue; +// } +// if (Utils.VALUE_START_AUTOMATIC_ON == mDefaultSharedPreferences.getBoolean( +// Utils.KEY_START_AUTOMATIC_MAP.get(logType), +// Utils.DEFAULT_CONFIG_LOG_AUTO_START_MAP.get(logType))) { +// needStart = true; +// break; +// } +// } +// Utils.logd(TAG, "-->needStartLogAtBootTime(), needStart=" + needStart); +// return needStart; +// } + + + public class ServiceNullException extends Exception { + private static final long serialVersionUID = -430298482097527072L; + } +} diff --git a/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java b/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java index 4f9c3fa..cc01f88 100644 --- a/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java +++ b/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java @@ -570,8 +570,12 @@ public class HTTPInterface { List newList = Arrays.asList(data.split(","));//新的list PackageManager pm = context.getPackageManager(); for (String pack : newList) { - pm.setApplicationEnabledSetting(pack, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); - Log.e("setHideDesktopIcon", pack); + try { + pm.setApplicationEnabledSetting(pack, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0); + Log.e("setHideDesktopIcon", pack); + } catch (Exception e) { + Log.e("setHideDesktopIcon", "Exception:" + e.getMessage()); + } } } } else { diff --git a/app/src/main/java/com/mjsheng/myappstore/utils/ApkUtils.java b/app/src/main/java/com/mjsheng/myappstore/utils/ApkUtils.java index 753a188..e262706 100644 --- a/app/src/main/java/com/mjsheng/myappstore/utils/ApkUtils.java +++ b/app/src/main/java/com/mjsheng/myappstore/utils/ApkUtils.java @@ -616,6 +616,7 @@ public class ApkUtils { this.add("com.android.music");//音乐 this.add("com.mediatek.camera");//相机 this.add("com.android.documentsui");//文件 + this.add("com.mediatek.filemanager");//文件 this.add("com.android.soundrecorder");//录音机 this.add("com.android.browser");//浏览器 this.add("com.android.mms");//信息