version:2.0.2.1

update:2020.08.14
fix:修复管控日历隐藏失效,优化待机亮屏卡顿
add:
This commit is contained in:
2020-08-14 18:29:41 +08:00
parent c803fd6353
commit 0dc74d4c41
9 changed files with 455 additions and 38 deletions

View File

@@ -38,8 +38,8 @@ android {
productFlavors {
official {
flavorDimensions "default"
versionCode 1020
versionName "2.0.2.0"// 正式jiaoguanyi.com 双数正式 单数测试
versionCode 1021
versionName "2.0.2.1"// 正式jiaoguanyi.com 双数正式 单数测试
/*********************************极光推送************************************/
manifestPlaceholders = [
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
@@ -69,6 +69,23 @@ android {
buildConfigField "String", "WebsocketURL", '"ws://47.107.133.19:2345"'
}
//中优
zhongyou {
flavorDimensions "default"
versionCode 1100
versionName "1.0.0.0"//测试jiaoguanyi.cn
/*********************************极光推送************************************/
manifestPlaceholders = [
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
JPUSH_APPKEY : "a98c8a210687b4bb43c39c39", //JPush上注册的包名对应的appkey.
JPUSH_CHANNEL: "developer-default", //暂时填写默认值即可.
]
signingConfig signingConfigs.debug
/*********************************极光推送end************************************/
buildConfigField "String", "ROOT_URL", '"https://jgy.jundunxueyuan.com/api/"'
buildConfigField "String", "WebsocketURL", '"ws://39.98.59.202:2345"'
}
}
sourceSets {
beta.res.srcDirs = ['src/beta/res']
@@ -127,7 +144,7 @@ android {
variant.outputs.each { output ->
def outputFile = ""
if (outputFile != null) {
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${productFlavors[0].name}-${buildType.name}.apk"
output.outputFileName = new File(outputFile, fileName)
}
@@ -140,7 +157,6 @@ android {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:multidex:1.0.1'

View File

@@ -8,6 +8,7 @@
<uses-permission android:name="android.permission.DELETE_PACKAGES" />
<uses-permission android:name="android.permission.MASTER_CLEAR" />
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />

View File

@@ -104,7 +104,7 @@ public class MyApplication extends MultiDexApplication {
private Calendar mCurrentCalendar = null;
private SimpleDateFormat mDateFormat = null;
private static List<Activity> activityList = new LinkedList();
private Handler mHandler;
public static Context getAppContext() {
return context;
@@ -161,6 +161,7 @@ public class MyApplication extends MultiDexApplication {
if (!BuildConfig.DEBUG) {
catchException();
}
mHandler = new Handler();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// 8.0之后需要在
registmNewAppReceiver();
@@ -193,6 +194,8 @@ public class MyApplication extends MultiDexApplication {
}
}
}
private NewAppReceiver mNewAppReceiver;
private void registmNewAppReceiver() {
@@ -215,6 +218,8 @@ public class MyApplication extends MultiDexApplication {
filter.addAction(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_USER_UNLOCKED);
filter.addAction("android.intent.action.FACTORY_RESET");
filter.addAction("android.intent.action.MASTER_CLEAR");
registerReceiver(receiver, filter);
}
@@ -223,10 +228,13 @@ public class MyApplication extends MultiDexApplication {
Long time1 = 0L;
Long time2 = 0L;
Long time3 = 0L;
Long time4 = 0L;
public class receiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
public void onReceive(final Context context, Intent intent) {
String action = intent.getAction();
Log.e("fht", "receiver action:" + action);
if (action.equals(Intent.ACTION_SCREEN_ON)) {
@@ -237,32 +245,54 @@ public class MyApplication extends MultiDexApplication {
/*在8.0以上 除了开机广播其他广播基本上没有用
*当静默安装升级时app不会被唤醒只有通过显示广播唤醒
* */
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
// 携带数据
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
// 携带数据
// intent1.putExtra("test", "我是来测 A 应用的Android 8.0 系统静态广播的测试数据");
// 启动发送广播
sendBroadcast(intent1);
// 启动发送广播
sendBroadcast(intent1);
time2 = System.currentTimeMillis();
if ((time2 - time1) > 60 * 1000) {
//可能会多次触发1分钟之内不执行
//application中启动服务,startcommand执行会两次
startService(new Intent(context, InitJpushServer.class));
startService(new Intent(context, StepService.class));
startService(new Intent(context, GuardService.class));
time1 = time2;
}
}
}, 5000);
time2 = System.currentTimeMillis();
if ((time2 - time1) > 60 * 1000) {
//可能会多次触发1分钟之内不执行
//application中启动服务,startcommand执行会两次
startService(new Intent(context, InitJpushServer.class));
startService(new Intent(context, StepService.class));
startService(new Intent(context, GuardService.class));
time1 = time2;
}
}
} else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
long time = System.currentTimeMillis();
getLockState("1", String.valueOf(time));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
sendBroadcast(intent1);
}
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
long time = System.currentTimeMillis();
getLockState("1", String.valueOf(time));
if (time3 - System.currentTimeMillis() >= 10000) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Intent intent1 = new Intent(BootReceiver.BOOT_COMPLETED);
intent1.setComponent(new ComponentName("com.jiaoguanyi.store", "com.mjsheng.myappstore.receiver.BootReceiver"));
sendBroadcast(intent1);
}
}
time3 = System.currentTimeMillis();
}
}, 10000);
} else if (action.equals("android.intent.action.FACTORY_RESET")
|| action.equals("android.intent.action.MASTER_CLEAR")
//MASTER_CLEAR 7.0可以监听
|| action.equals("android.intent.action.MASTER_CLEAR_NOTIFICATION")
|| action.equals("android.intent.action.FORCE_FACTORY_RESET")
) {
Log.e("receiver", "MASTER_CLEAR");
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
}

View File

@@ -70,7 +70,10 @@ import com.mjsheng.myappstore.network.api.ForceDownloadApi;
import com.mjsheng.myappstore.network.api.NetAndLaunchApi;
import com.mjsheng.myappstore.network.api.SystemSettingApi;
import com.mjsheng.myappstore.network.api.UploadAppInfoApi;
import com.mjsheng.myappstore.server.InitJpushServer;
import com.mjsheng.myappstore.server.MyDownloadService;
import com.mjsheng.myappstore.utils.ApkUtils;
import com.mjsheng.myappstore.utils.CmdUtil;
import com.mjsheng.myappstore.utils.Configure;
import com.mjsheng.myappstore.utils.ExampleUtil;
import com.mjsheng.myappstore.utils.MySQLData;
@@ -108,6 +111,7 @@ import rx.functions.Action1;
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.ACTION_SET;
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.TagAliasBean;
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence;
import static com.mjsheng.myappstore.utils.Utils.shotScreen;
public class MainActivity extends AppCompatActivity {
@@ -732,6 +736,7 @@ public class MainActivity extends AppCompatActivity {
getLockedState();
// MyApplication.getInstance().getWhitePackageList();
getInfo(mHandler);
// CmdUtil.execute(" screencap -p /sdcard/" + "screen" + System.currentTimeMillis() + ".png");
}
private void getInfo(final Handler handler) {
@@ -1093,7 +1098,7 @@ public class MainActivity extends AppCompatActivity {
JSONObject data = jsonObject.getJSONObject("data");
String ids = data.optString("ids");
String packages = data.optString("package");
writeDeselectIDtoSystem(ids,packages);
writeDeselectIDtoSystem(ids, packages);
break;
default:
Log.e("mjhseng", "getDeselectID---code is -200");
@@ -1682,6 +1687,8 @@ public class MainActivity extends AppCompatActivity {
//摄像头开关
int setting_camera = changeNum(data.optInt("setting_camera"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_camera", setting_camera);
ApkUtils.hideSystemSettingAPP(MainActivity.this, "com.mediatek.camera");
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
String cameraStatus = "";
switch (setting_camera) {
@@ -1700,18 +1707,22 @@ public class MainActivity extends AppCompatActivity {
//时钟
int deskclock = changeNum(data.optInt("setting_clock"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_deskclock", deskclock);
ApkUtils.hideSystemSettingAPP(MainActivity.this, "com.android.deskclock");
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(data.optInt("setting_recording"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
ApkUtils.hideSystemSettingAPP(MainActivity.this, "com.android.soundrecorder");
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(data.optInt("setting_music"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_music", music);
ApkUtils.hideSystemSettingAPP(MainActivity.this, "com.android.music");
Log.e("SystemSetting", "qch_app_music" + music);
//图库
int gallery = changeNum(data.optInt("setting_picture"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_gallery", gallery);
ApkUtils.hideSystemSettingAPP(MainActivity.this, "com.android.gallery3d");
Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(data.optInt("setting_wallpaper"));
@@ -1720,6 +1731,11 @@ public class MainActivity extends AppCompatActivity {
//文件管理器
int filemanager = changeNum(data.optInt("setting_file"));
Settings.System.putInt(MainActivity.this.getContentResolver(), "qch_app_filemanager", filemanager);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
ApkUtils.hideSystemSettingAPP(MainActivity.this, "com.mediatek.filemanager");
} else {
ApkUtils.hideSystemSettingAPP(MainActivity.this, "com.android.documentsui");
}
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
// } catch (Exception e) {

View File

@@ -24,9 +24,13 @@ import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.PathUtils;
import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.MyApplication;
import com.mjsheng.myappstore.activity.MainActivity;
import com.mjsheng.myappstore.bean.ForceDownloadBean;
import com.mjsheng.myappstore.bean.ForceDownloadData;
import com.mjsheng.myappstore.comm.CommonDatas;
import com.mjsheng.myappstore.network.HTTPInterface;
import com.mjsheng.myappstore.network.Network;
import com.mjsheng.myappstore.network.api.ForceDownloadApi;
import com.mjsheng.myappstore.server.InitJpushServer;
import com.mjsheng.myappstore.utils.ApkUtils;
import com.mjsheng.myappstore.utils.Configure;
@@ -91,6 +95,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
private final String DISABLE_APP_SLIDE = "19";//禁止滑动
private final String UPDATE_INFO = "20";//禁止滑动
private Context mContext;
private int changeNum(int paramInt) {
@@ -232,7 +238,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
// .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(url) + ".apk", true)
// .setExtendField(packageObj.toJSONString())
// .create(); //启动下载}
Utils.ariaDownload(mContext, url,packageObj);
Utils.ariaDownload(mContext, url, packageObj);
break;
@@ -253,6 +259,10 @@ public class MyJPushReceiver extends BroadcastReceiver {
case DISABLE_APP_SLIDE:
setDisableSlideList(extras);
break;
case UPDATE_INFO:
getAppLimitApi();
break;
}
}
@@ -369,6 +379,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
//摄像头开关
int setting_camera = changeNum(data.optInt("setting_camera"));
Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_camera", setting_camera);
ApkUtils.hideSystemSettingAPP(this.mContext,"com.mediatek.camera");
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
String cameraStatus = "";
switch (setting_camera) {
@@ -417,18 +429,22 @@ public class MyJPushReceiver extends BroadcastReceiver {
//时钟
int deskclock = changeNum(data.optInt("setting_clock"));
Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_deskclock", deskclock);
ApkUtils.hideSystemSettingAPP(this.mContext,"com.android.deskclock");
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(data.optInt("setting_recording"));
Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
ApkUtils.hideSystemSettingAPP(this.mContext,"com.android.soundrecorder");
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(data.optInt("setting_music"));
Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_music", music);
ApkUtils.hideSystemSettingAPP(this.mContext,"com.android.music");
Log.e("SystemSetting", "qch_app_music" + music);
//图库
int gallery = changeNum(data.optInt("setting_picture"));
Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_gallery", gallery);
ApkUtils.hideSystemSettingAPP(this.mContext,"com.android.gallery3d");
Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(data.optInt("setting_wallpaper"));
@@ -437,6 +453,11 @@ public class MyJPushReceiver extends BroadcastReceiver {
//文件管理器
int filemanager = changeNum(data.optInt("setting_file"));
Settings.System.putInt(this.mContext.getContentResolver(), "qch_app_filemanager", filemanager);
if (Build.VERSION.SDK_INT<Build.VERSION_CODES.O){
ApkUtils.hideSystemSettingAPP(this.mContext,"com.mediatek.filemanager");
}else {
ApkUtils.hideSystemSettingAPP(this.mContext,"com.android.documentsui");
}
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
} catch (Exception e) {
e.printStackTrace();
@@ -476,7 +497,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
// .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(s) + ".apk", true)
// .setExtendField(packageObj.toJSONString())
// .create();
Utils.ariaDownload(mContext, app_url,packageObj);
Utils.ariaDownload(mContext, app_url, packageObj);
}
} else {
long appVersionCode;
@@ -492,7 +513,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
// .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(s) + ".apk", true)
// .setExtendField(packageObj.toJSONString())
// .create();
Utils.ariaDownload(mContext, app_url,packageObj);
Utils.ariaDownload(mContext, app_url, packageObj);
}
}
@@ -542,6 +563,111 @@ public class MyJPushReceiver extends BroadcastReceiver {
});
}
// private void getForceDownload() {
// ForceDownloadApi forceDownloadApi = Network.getForceDownloadApi();
// forceDownloadApi.getForceDownloadApi(Configure.HTTP_KEY, Utils.getSerial())
// .subscribeOn(Schedulers.io())
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(new Observer<ForceDownloadBean>() {
// @Override
// public void onSubscribe(Disposable d) {
// Log.e("getForceDownload", "forceDownloadApi---onSubscribe");
//
// }
//
// @Override
// public void onNext(ForceDownloadBean forceDownloadBean) {
// switch (forceDownloadBean.getCode()) {
// case 200:
// Log.e("getForceDownload", "isDownloading=" + MyApplication.getInstance().isDownloading());
// MyApplication.getInstance().checkIsDownloading();
// if (!MyApplication.getInstance().isDownloading()) {
// forceDownload(forceDownloadBean.getData());
// } else {
// }
// case -200:
// boolean qch_force_app = Settings.System.putString(MainActivity.this.getContentResolver(), "qch_force_app", "invalid");
// Log.e("fht", "qch_force_app:" + qch_force_app);
// break;
// default:
// LogUtils.e("getForceDownload is error:" + forceDownloadBean.getMsg());
// }
// }
//
// @Override
// public void onError(Throwable e) {
// Log.e("getForceDownload", "forceDownloadApi=onError:");
// }
//
// @Override
// public void onComplete() {
// Log.e("getForceDownload", "forceDownloadApi---onComplete");
// }
// });
// }
// private void forceDownload(List<ForceDownloadData> data) {
// if (data == null || data.size() <= 0) {
// return;
// }
// List<String> list = new ArrayList<>();
// for (int i = 0; i < data.size(); i++) {
// ForceDownloadData forceDownloadData = data.get(i);
// String app_name = forceDownloadData.getApp_name();
// String app_package = forceDownloadData.getApp_package();
// String app_url = forceDownloadData.getApp_url();
// com.alibaba.fastjson.JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
// jsonObject.put("app_name", app_name);
// jsonObject.put("app_package", app_package);
// int app_version_code = forceDownloadData.getApp_version_code();
// Log.e("fht ", "packageName=" + app_package + ",URL= " + app_url + ",app_version_code=" + app_version_code);
// if (data.get(i).getApp_package().equals("com.jiaoguanyi.appstore")) {
// continue;//为自身的跳过下载
// }
// if (!list.contains(app_package)) {
// list.add(app_package);
// }
// PackageManager pm = getPackageManager();
// PackageInfo packageInfo = null;
// try {
// packageInfo = pm.getPackageInfo(app_package, 0);
// } catch (PackageManager.NameNotFoundException e) {
// e.printStackTrace();
// Log.e("fht", "forceDownload=" + e.getMessage());
// }
// if (packageInfo != null) {
// long appVersionCode;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// appVersionCode = packageInfo.getLongVersionCode();
// } else {
// appVersionCode = packageInfo.versionCode;
// }
// if (app_version_code > appVersionCode) {
// Log.e("fht ", "download URL " + app_url);
//// Aria.download(this)
//// .load(app_url) //读取下载地址
//// .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
//// .setExtendField(jsonObject.toJSONString())
//// .create(); //启动下载}
// Utils.ariaDownload(this, app_url, jsonObject);
// }
// } else {
// Log.e("fht ", "download URL " + app_url);
//// if (!SaveListUtils.isDownLoading(app_package)) {
//// Aria.download(this)
//// .load(app_url) //读取下载地址
//// .setFilePath(PathUtils.getExternalDownloadsPath() + "/jgy/" + EncryptUtils.encryptMD5ToString(app_package) + ".apk", true)
//// .setExtendField(jsonObject.toJSONString())
//// .create(); //启动下载}
// Utils.ariaDownload(this, app_url, jsonObject);
//
//// SaveListUtils.addDownLoadList(app_package);
//// }
// }
// }
// SaveListUtils.setList(list);
// SaveListUtils.sendForceAPP(this);
// }
private int getBatteryLevel() {
if (Build.VERSION.SDK_INT >= 21) {
return ((BatteryManager) this.mContext.getSystemService(Context.BATTERY_SERVICE)).getIntProperty(4);

View File

@@ -962,6 +962,8 @@ public class InitJpushServer extends Service {
//摄像头开关
int setting_camera = changeNum(data.optInt("setting_camera"));
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_camera", setting_camera);
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.mediatek.camera");
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
String cameraStatus = "";
switch (setting_camera) {
@@ -1020,18 +1022,22 @@ public class InitJpushServer extends Service {
//时钟
int deskclock = changeNum(data.optInt("setting_clock"));
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_deskclock", deskclock);
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.deskclock");
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
//录音机
int soundrecorder = changeNum(data.optInt("setting_recording"));
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.soundrecorder");
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
//音乐
int music = changeNum(data.optInt("setting_music"));
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_music", music);
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.music");
Log.e("SystemSetting", "qch_app_music" + music);
//图库
int gallery = changeNum(data.optInt("setting_picture"));
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_gallery", gallery);
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.gallery3d");
Log.e("SystemSetting", "qch_app_gallery" + gallery);
//壁纸
int wallpaper = changeNum(data.optInt("setting_wallpaper"));
@@ -1040,6 +1046,11 @@ public class InitJpushServer extends Service {
//文件管理器
int filemanager = changeNum(data.optInt("setting_file"));
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_filemanager", filemanager);
if (Build.VERSION.SDK_INT<Build.VERSION_CODES.O){
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.mediatek.filemanager");
}else {
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.documentsui");
}
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -601,6 +601,14 @@ public class ApkUtils {
this.add("com.android.musicfx");
this.add("com.android.email");
}};
public static List<String> show_canremove_systemapp = new ArrayList<String>() {{
//需要管控的系统可以卸载的应用
this.add("com.android.calendar");
this.add("com.android.email");
}};
public static List<String> systemapp = new ArrayList<String>() {{
//需要管控的系统应用
this.add("com.android.gallery3d");//图库
@@ -622,21 +630,72 @@ public class ApkUtils {
// 查询所有已经安装的应用程序
List<PackageInfo> packages = pm.getInstalledPackages(0);
for (PackageInfo packageInfo : packages) {
if (ApkUtils.canremove_systemapp.contains(packageInfo.packageName)) {
//如果是自带可以卸载的,除开不需要管控的
if (canremove_systemapp.contains(packageInfo.packageName)
&& !show_canremove_systemapp.contains(packageInfo.packageName)
) {
continue;
}
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1
&& !systemapp.contains(packageInfo.packageName)
) {
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1 && !systemapp.contains(packageInfo.packageName)) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
//10.0上日历和电子邮件是可卸载的
//7.0是系统应用
if (show_canremove_systemapp.contains(packageInfo.packageName)) {
Log.e("showAllAPP2", "packageName:" + packageInfo.packageName);
pm.setApplicationEnabledSetting(packageInfo.packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
}
}
} else {
Log.e("showAllAPP", "packageName:" + packageInfo.applicationInfo.packageName);
pm.setApplicationEnabledSetting(packageInfo.applicationInfo.packageName, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
Log.e("showAllAPP", "packageName:" + packageInfo.packageName);
hideSystemSettingAPP(context, packageInfo.packageName);
}
}
}
public static void hideSystemSettingAPP(Context context, String pkage) {
int hide = 0;
//后台0显示1隐藏
try {
if (pkage.equalsIgnoreCase("com.mediatek.camera")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_camera") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.deskclock")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_deskclock") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.soundrecorder")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_soundrecorder") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.music")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_music") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.gallery3d")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_gallery") == 1) {
hide = 1;
}
} else if (pkage.equalsIgnoreCase("com.android.documentsui")
|| pkage.equalsIgnoreCase("com.mediatek.filemanager")) {
if (Settings.System.getInt(context.getContentResolver(), "qch_app_filemanager") == 1) {
hide = 1;
}
}
} catch (Settings.SettingNotFoundException e) {
e.printStackTrace();
}
PackageManager pm = context.getPackageManager();
if (hide == 0) {
pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
} else {
pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
}
}
public static synchronized void uninstallAllApp(Context context) {
List<String> appList = ApkUtils.queryFilterAppInfo(context);

View File

@@ -0,0 +1,103 @@
package com.mjsheng.myappstore.utils;
import android.text.TextUtils;
import android.util.Log;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class CmdUtil {
private static final String TAG = "CmdUtil";
private static final String COMMAND_SH = "sh";
private static final String COMMAND_EXIT = "exit\n";
private static final String COMMAND_LINE_END = "\n";
/**
* 运行命令
*
* @param command 命令
* @return 结果
*/
public static Result execute(String command) {
Log.i(TAG, "execute() command = " + command);
Result result = new Result();
if (TextUtils.isEmpty(command)) {
Log.w(TAG, "WARNING: command should not be null or empty");
return result;
}
Process process = null;
DataOutputStream dos = null;
try {
process = Runtime.getRuntime().exec(COMMAND_SH);
dos = new DataOutputStream(process.getOutputStream());
dos.write(command.trim().getBytes());
dos.writeBytes(COMMAND_LINE_END);
dos.flush();
dos.writeBytes(COMMAND_EXIT);
dos.flush();
result.code = process.waitFor();
result.success = readBuffer(new BufferedReader(new InputStreamReader(process.getInputStream())));
result.error = readBuffer(new BufferedReader(new InputStreamReader(process.getErrorStream())));
Log.i(TAG, "result = " + result);
} catch (IOException ioe) {
ioe.printStackTrace();
Log.e(TAG, ioe.getMessage());
} catch (InterruptedException ie) {
ie.printStackTrace();
Log.e(TAG, ie.getMessage());
} finally {
try {
if (null != dos) {
dos.close();
}
} catch (IOException ioe) {
ioe.printStackTrace();
Log.e(TAG, ioe.getMessage());
}
if (null != process) {
process.destroy();
}
}
return result;
}
private static String readBuffer(BufferedReader bufferedReader) throws IOException {
StringBuilder sb = new StringBuilder();
String s;
while ((s = bufferedReader.readLine()) != null) {
sb.append(s);
}
return sb.toString();
}
/**
* Command执行结果
*/
public static final class Result {
public static final int SUCCESS = 0;
public static final int ERROR = -1;
public int code = ERROR;
String error;
String success;
@Override
public String toString() {
return "Result{" +
"code=" + code +
", error='" + error + '\'' +
", success='" + success + '\'' +
'}';
}
}
}

View File

@@ -54,8 +54,10 @@ import com.mjsheng.myappstore.R;
import com.mjsheng.myappstore.MyApplication;
import com.mjsheng.myappstore.comm.CommonDatas;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
@@ -1025,5 +1027,58 @@ public class Utils {
}
}
/**
* 屏幕截图
* 适用于lanucher版
*/
public static void shotScreen() {
//adb截图方法
new Thread(new Runnable() {
@Override
public void run() {
Log.e("whh0914", "开始屏幕截图...");
String filepath = "/sdcard/screenShot.png";
try {
execRootCmdSilent("screencap -p " + filepath);
} catch (Exception e) {
Log.e("whh0914", "屏幕截图出现异常:" + e.toString());
}
}
}).start();
}
/**
* 执行命令但不关注结果输出
*/
public static int execRootCmdSilent(String cmd) {
int result = -1;
DataOutputStream dos = null;
try {
Process p = Runtime.getRuntime().exec("su");
dos = new DataOutputStream(p.getOutputStream());
dos.writeBytes(cmd + "\n");
dos.flush();
dos.writeBytes("exit\n");
dos.flush();
p.waitFor();
result = p.exitValue();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (dos != null) {
try {
dos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}
}