version:
update:2021.04.07 fix: add:增加xapk安装,增加导航栏按钮管控
This commit is contained in:
@@ -191,7 +191,9 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
// implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
|
compileOnly files('src/main/libs/classes.jar')
|
||||||
|
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||||
implementation 'androidx.cardview:cardview:1.0.0'
|
implementation 'androidx.cardview:cardview:1.0.0'
|
||||||
@@ -226,4 +228,27 @@ dependencies {
|
|||||||
annotationProcessor 'com.arialyy.aria:compiler:3.8.15'
|
annotationProcessor 'com.arialyy.aria:compiler:3.8.15'
|
||||||
implementation 'com.amap.api:location:5.1.0'
|
implementation 'com.amap.api:location:5.1.0'
|
||||||
//高德地图定位
|
//高德地图定位
|
||||||
|
implementation 'org.zeroturnaround:zt-zip:1.13'
|
||||||
|
//压缩文件解压
|
||||||
|
}
|
||||||
|
|
||||||
|
preBuild {
|
||||||
|
doLast {
|
||||||
|
def imlFile = file( project.name + ".iml")
|
||||||
|
println 'Change ' + project.name + '.iml order'
|
||||||
|
try {
|
||||||
|
def parsedXml = (new XmlParser()).parse(imlFile)
|
||||||
|
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
|
||||||
|
parsedXml.component[1].remove(jdkNode)
|
||||||
|
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
|
||||||
|
println 'what' + sdkString
|
||||||
|
new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
|
||||||
|
groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
// nop, iml not found
|
||||||
|
println "no iml found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//https://www.pianshen.com/article/93481144911/
|
||||||
|
//使用系统编译后的framework.jar
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jiaoguanyi.appstore.activity;
|
package com.jiaoguanyi.appstore.activity;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.StatusBarManager;
|
import android.app.StatusBarManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -51,8 +52,20 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private void DebugTest() {
|
private void DebugTest() {
|
||||||
// Utils.getHardware(this);
|
// Utils.getHardware(this);
|
||||||
hookWebView();
|
// hookWebView();
|
||||||
setWebView();
|
// setWebView();
|
||||||
|
// hideStatusBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
private void hideStatusBar() {
|
||||||
|
StatusBarManager mStatusBarManager = (StatusBarManager) getApplicationContext().getSystemService(Context.STATUS_BAR_SERVICE);
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_HOME);//隐藏home键
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_BACK);//隐藏返回键
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_BACK | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME);
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_RECENT);//隐藏recent键
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bootanimotion() {
|
private void bootanimotion() {
|
||||||
@@ -102,6 +115,7 @@ public class SplashActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hookWebView() {
|
public static void hookWebView() {
|
||||||
int sdkInt = Build.VERSION.SDK_INT;
|
int sdkInt = Build.VERSION.SDK_INT;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.alibaba.fastjson.JSON;
|
|||||||
import com.amap.api.location.AMapLocationClient;
|
import com.amap.api.location.AMapLocationClient;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
|
import com.jiaoguanyi.appstore.utils.XAPKUtils;
|
||||||
import com.lzy.okgo.OkGo;
|
import com.lzy.okgo.OkGo;
|
||||||
import com.lzy.okgo.cache.CacheEntity;
|
import com.lzy.okgo.cache.CacheEntity;
|
||||||
import com.lzy.okgo.cache.CacheMode;
|
import com.lzy.okgo.cache.CacheMode;
|
||||||
@@ -106,6 +107,7 @@ public class BaseApplication extends MultiDexApplication{
|
|||||||
private void init() {
|
private void init() {
|
||||||
NetInterfaceManager.init(this);
|
NetInterfaceManager.init(this);
|
||||||
JGYUtils.init(this);
|
JGYUtils.init(this);
|
||||||
|
XAPKUtils.init(this);
|
||||||
Configuration config = getResources().getConfiguration();
|
Configuration config = getResources().getConfiguration();
|
||||||
int smallestScreenWidthDp = config.smallestScreenWidthDp;
|
int smallestScreenWidthDp = config.smallestScreenWidthDp;
|
||||||
Log.e("mjsheng", "smallestScreenWidthDp=" + smallestScreenWidthDp);
|
Log.e("mjsheng", "smallestScreenWidthDp=" + smallestScreenWidthDp);
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.jiaoguanyi.appstore.bean;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Expansions implements Serializable {
|
||||||
|
private String file;
|
||||||
|
//包内文件地址
|
||||||
|
private String install_location;
|
||||||
|
//安装位置
|
||||||
|
private String install_path;
|
||||||
|
//安装地址
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFile(String file) {
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInstall_location() {
|
||||||
|
return install_location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstall_location(String install_location) {
|
||||||
|
this.install_location = install_location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInstall_path() {
|
||||||
|
return install_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstall_path(String install_path) {
|
||||||
|
this.install_path = install_path;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,8 @@ public class NewAppground implements Serializable {
|
|||||||
private static final long serialVersionUID = -2071117846816082338L;
|
private static final long serialVersionUID = -2071117846816082338L;
|
||||||
private String packages;
|
private String packages;
|
||||||
private String address;
|
private String address;
|
||||||
private String type;
|
private int type;
|
||||||
|
//type=1白 =0黑
|
||||||
|
|
||||||
public String getPackages() {
|
public String getPackages() {
|
||||||
return packages;
|
return packages;
|
||||||
@@ -24,11 +25,11 @@ public class NewAppground implements Serializable {
|
|||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public int getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(int type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.jiaoguanyi.appstore.bean;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class SplitApks implements Serializable {
|
||||||
|
private String file;
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
public String getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFile(String file) {
|
||||||
|
this.file = file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ import com.arialyy.aria.core.Aria;
|
|||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.task.DownloadTask;
|
import com.arialyy.aria.core.task.DownloadTask;
|
||||||
import com.jiaoguanyi.appstore.utils.JGYUtils;
|
import com.jiaoguanyi.appstore.utils.JGYUtils;
|
||||||
|
import com.jiaoguanyi.appstore.utils.XAPKUtils;
|
||||||
import com.lzy.okgo.OkGo;
|
import com.lzy.okgo.OkGo;
|
||||||
import com.lzy.okgo.callback.StringCallback;
|
import com.lzy.okgo.callback.StringCallback;
|
||||||
import com.jiaoguanyi.appstore.KeepAliveConnection;
|
import com.jiaoguanyi.appstore.KeepAliveConnection;
|
||||||
@@ -114,7 +115,7 @@ public class GuardService extends Service {
|
|||||||
//第三个就是 我们要过滤的类型 W表示warm ,我们也可以换成 D :debug, I:info,E:error等等
|
//第三个就是 我们要过滤的类型 W表示warm ,我们也可以换成 D :debug, I:info,E:error等等
|
||||||
// String[] running = new String[]{"logcat", "-s", "adb logcat *: W"};
|
// String[] running = new String[]{"logcat", "-s", "adb logcat *: W"};
|
||||||
String[] running = new String[]{"logcat"};
|
String[] running = new String[]{"logcat"};
|
||||||
String filePath = "/sdcard/Log/Log.txt";
|
String logFilePath = "/sdcard/Log/Log.txt";
|
||||||
|
|
||||||
class LogThread extends Thread {
|
class LogThread extends Thread {
|
||||||
InputStream is;
|
InputStream is;
|
||||||
@@ -129,12 +130,12 @@ public class GuardService extends Service {
|
|||||||
FileOutputStream os = null;
|
FileOutputStream os = null;
|
||||||
try {
|
try {
|
||||||
//新建一个路径信息
|
//新建一个路径信息
|
||||||
File file = new File(filePath);
|
File file = new File(logFilePath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
}
|
}
|
||||||
os = new FileOutputStream(filePath);
|
os = new FileOutputStream(logFilePath);
|
||||||
int len = 0;
|
int len = 0;
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
while (-1 != (len = is.read(buf))) {
|
while (-1 != (len = is.read(buf))) {
|
||||||
@@ -285,7 +286,7 @@ public class GuardService extends Service {
|
|||||||
void taskComplete(DownloadTask task) {
|
void taskComplete(DownloadTask task) {
|
||||||
//在这里处理任务完成的状态
|
//在这里处理任务完成的状态
|
||||||
final String filepath = task.getFilePath();
|
final String filepath = task.getFilePath();
|
||||||
if (filepath.endsWith("apk")) {
|
if (filepath.endsWith(".apk")) {
|
||||||
final String packageName = task.getExtendField();
|
final String packageName = task.getExtendField();
|
||||||
Log.e("aria", "downloadPath::" + filepath);
|
Log.e("aria", "downloadPath::" + filepath);
|
||||||
Log.e("aria", "extendField::" + packageName);
|
Log.e("aria", "extendField::" + packageName);
|
||||||
@@ -342,9 +343,12 @@ public class GuardService extends Service {
|
|||||||
BaseApplication.getInstance().setDownloadState(false);
|
BaseApplication.getInstance().setDownloadState(false);
|
||||||
Log.e("aria", "isDownloading=" + BaseApplication.getInstance().isDownloading());
|
Log.e("aria", "isDownloading=" + BaseApplication.getInstance().isDownloading());
|
||||||
}
|
}
|
||||||
} else if (filepath.endsWith("zip")) {
|
} else if (filepath.endsWith(".zip")) {
|
||||||
Log.e("aria", "下载完成:" + task.getPercent() + ":" + task.getExtendField());
|
Log.e("aria", "下载完成:" + task.getPercent() + ":" + task.getExtendField());
|
||||||
JGYUtils.getInstance().setBootanimation(task.getFilePath());
|
JGYUtils.getInstance().setBootanimation(task.getFilePath());
|
||||||
|
} else if (filepath.endsWith(".xapk")) {
|
||||||
|
XAPKUtils.getInstance().installXAPK(filepath);
|
||||||
|
Log.e(TAG, "taskComplete: " + filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ public class StepService extends Service {
|
|||||||
// Log.e("fht", e.getMessage());
|
// Log.e("fht", e.getMessage());
|
||||||
// }
|
// }
|
||||||
//初始化websocket
|
//初始化websocket
|
||||||
|
Log.e(TAG, "onStartCommand: ");
|
||||||
initSocketClient();
|
initSocketClient();
|
||||||
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测
|
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);//开启心跳检测
|
||||||
bindService(new Intent(this, GuardService.class), mServiceConnection, Context.BIND_IMPORTANT);
|
bindService(new Intent(this, GuardService.class), mServiceConnection, Context.BIND_IMPORTANT);
|
||||||
|
|||||||
@@ -823,6 +823,8 @@ public class ApkUtils {
|
|||||||
this.add("com.android.theme.icon_pack.circular.android");
|
this.add("com.android.theme.icon_pack.circular.android");
|
||||||
this.add("com.jiaoguanyi.appstore");
|
this.add("com.jiaoguanyi.appstore");
|
||||||
this.add("com.jiaoguanyi.store");
|
this.add("com.jiaoguanyi.store");
|
||||||
|
this.add("com.example.eyeshielyplus");
|
||||||
|
this.add("cn.com.bifa.eyeshiely");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|
||||||
@@ -1118,7 +1120,6 @@ public class ApkUtils {
|
|||||||
Log.e("RemoveTask", "subscribe: " + "删除文件:" + entity.getFilePath());
|
Log.e("RemoveTask", "subscribe: " + "删除文件:" + entity.getFilePath());
|
||||||
Aria.download(this).load(id).cancel(true);
|
Aria.download(this).load(id).cancel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
e.onComplete();
|
e.onComplete();
|
||||||
}
|
}
|
||||||
@@ -1128,19 +1129,16 @@ public class ApkUtils {
|
|||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(Disposable d) {
|
||||||
Log.e("RemoveTask", "onSubscribe: ");
|
Log.e("RemoveTask", "onSubscribe: ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(String s) {
|
public void onNext(String s) {
|
||||||
Log.e("RemoveTask", "onNext: ");
|
Log.e("RemoveTask", "onNext: ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
Log.e("RemoveTask", "onError: ");
|
Log.e("RemoveTask", "onError: ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.jiaoguanyi.appstore.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class FileUtils {
|
||||||
|
public static String getFileNoExName(String filePath) {
|
||||||
|
|
||||||
|
String fileNameEx = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
||||||
|
String fileName = fileNameEx.substring(0,fileNameEx.lastIndexOf("."));
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -283,13 +283,19 @@ public class JGYUtils {
|
|||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
List<Appground> appgrounds = response.data;
|
List<Appground> appgrounds = response.data;
|
||||||
if (appgrounds != null && appgrounds.size() > 0) {
|
if (appgrounds != null && appgrounds.size() > 0) {
|
||||||
String strings = "";
|
StringBuilder strings = new StringBuilder();
|
||||||
String packageList = "";//单条管控名单
|
StringBuilder packageList = new StringBuilder();//单条管控名单
|
||||||
for (Appground appground : appgrounds) {
|
for (Appground appground : appgrounds) {
|
||||||
if (TextUtils.isEmpty(appground.getAddress())) {
|
if (TextUtils.isEmpty(appground.getAddress())) {
|
||||||
packageList += appground.getPackages() + ",";
|
if (packageList.length() > 0) {
|
||||||
|
packageList.append(",");
|
||||||
|
}
|
||||||
|
packageList.append(appground.getPackages());
|
||||||
} else {
|
} else {
|
||||||
strings += appground.toString() + ";";
|
if (strings.length() > 0) {
|
||||||
|
strings.append(";");
|
||||||
|
}
|
||||||
|
strings.append(appground.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (packageList.length() > 0) {
|
if (packageList.length() > 0) {
|
||||||
@@ -299,7 +305,7 @@ public class JGYUtils {
|
|||||||
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
||||||
Intent qch_app_website = new Intent("qch_app_website")
|
Intent qch_app_website = new Intent("qch_app_website")
|
||||||
.setPackage("com.android.settings");
|
.setPackage("com.android.settings");
|
||||||
qch_app_website.putExtra("package_name", packageList);
|
qch_app_website.putExtra("package_name", packageList.toString());
|
||||||
mContext.sendBroadcast(qch_app_website);
|
mContext.sendBroadcast(qch_app_website);
|
||||||
} else {
|
} else {
|
||||||
sendAllweb(mContext);
|
sendAllweb(mContext);
|
||||||
@@ -311,7 +317,7 @@ public class JGYUtils {
|
|||||||
Log.e("setAppinsideWeb ", "strings:" + strings);
|
Log.e("setAppinsideWeb ", "strings:" + strings);
|
||||||
Intent intent = new Intent("qch_app_inside_website")
|
Intent intent = new Intent("qch_app_inside_website")
|
||||||
.setPackage("com.android.settings");
|
.setPackage("com.android.settings");
|
||||||
intent.putExtra("websitelist", strings);
|
intent.putExtra("websitelist", strings.toString());
|
||||||
mContext.sendBroadcast(intent);
|
mContext.sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
sendwebUrl(mContext);
|
sendwebUrl(mContext);
|
||||||
@@ -329,40 +335,68 @@ public class JGYUtils {
|
|||||||
public void setNewAppinsideWeb(BaseResponse<List<NewAppground>> response) {
|
public void setNewAppinsideWeb(BaseResponse<List<NewAppground>> response) {
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
List<NewAppground> appgrounds = response.data;
|
List<NewAppground> appgrounds = response.data;
|
||||||
|
StringBuilder whiteList = new StringBuilder();
|
||||||
|
StringBuilder blackList = new StringBuilder();
|
||||||
|
StringBuilder packageList = new StringBuilder();//单条管控名单
|
||||||
if (appgrounds != null && appgrounds.size() > 0) {
|
if (appgrounds != null && appgrounds.size() > 0) {
|
||||||
String strings = "";
|
|
||||||
String packageList = "";//单条管控名单
|
|
||||||
for (NewAppground appground : appgrounds) {
|
for (NewAppground appground : appgrounds) {
|
||||||
|
if (appground.getType() == 1) {
|
||||||
if (TextUtils.isEmpty(appground.getAddress())) {
|
if (TextUtils.isEmpty(appground.getAddress())) {
|
||||||
packageList += appground.getPackages() + ",";
|
return;
|
||||||
} else {
|
} else {
|
||||||
strings += appground.toString() + ";";
|
if (whiteList.length() > 0) {
|
||||||
|
whiteList.append(",");
|
||||||
|
}
|
||||||
|
whiteList.append(appground.getAddress());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (TextUtils.isEmpty(appground.getAddress())) {
|
||||||
|
if (packageList.length() > 0) {
|
||||||
|
packageList.append(",");
|
||||||
|
}
|
||||||
|
packageList.append(appground.getPackages());
|
||||||
|
} else {
|
||||||
|
if (blackList.length() > 0) {
|
||||||
|
blackList.append(";");
|
||||||
|
}
|
||||||
|
blackList.append(appground.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (whiteList.length() > 0) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction("黑名单key");
|
||||||
|
intent.putExtra("package_name", "应用包名");
|
||||||
|
intent.setPackage("com.android.settings");
|
||||||
|
mContext.sendBroadcast(intent);
|
||||||
|
android.provider.Settings.System.putString(mContext.getContentResolver(), "黑名单网址key", "黑名单网址");
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//old
|
||||||
if (packageList.length() > 0) {
|
if (packageList.length() > 0) {
|
||||||
//app内所有的网页禁止
|
//app内所有的网页禁止
|
||||||
//packageList = packageList.substring(0, packageList.length() - 1);
|
|
||||||
//去掉多余的,
|
|
||||||
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
||||||
Intent qch_app_website = new Intent("qch_app_website")
|
Intent qch_app_website = new Intent("qch_app_website")
|
||||||
.setPackage("com.android.settings");
|
.setPackage("com.android.settings");
|
||||||
qch_app_website.putExtra("package_name", packageList);
|
qch_app_website.putExtra("package_name", packageList.toString());
|
||||||
mContext.sendBroadcast(qch_app_website);
|
mContext.sendBroadcast(qch_app_website);
|
||||||
} else {
|
} else {
|
||||||
sendAllweb(mContext);
|
sendAllweb(mContext);
|
||||||
}
|
}
|
||||||
if (strings.length() > 0) {
|
if (blackList.length() > 0) {
|
||||||
//app内单个网页地址禁止打开
|
//app内单个网页地址禁止打开
|
||||||
//strings = strings.substring(0, strings.length() - 1);
|
Log.e("setAppinsideWeb ", "blackList:" + blackList);
|
||||||
//去掉多余的;
|
|
||||||
Log.e("setAppinsideWeb ", "strings:" + strings);
|
|
||||||
Intent intent = new Intent("qch_app_inside_website")
|
Intent intent = new Intent("qch_app_inside_website")
|
||||||
.setPackage("com.android.settings");
|
.setPackage("com.android.settings");
|
||||||
intent.putExtra("websitelist", strings);
|
intent.putExtra("websitelist", blackList.toString());
|
||||||
mContext.sendBroadcast(intent);
|
mContext.sendBroadcast(intent);
|
||||||
} else {
|
} else {
|
||||||
sendwebUrl(mContext);
|
sendwebUrl(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (response.code == 400) {
|
} else if (response.code == 400) {
|
||||||
//列表为空的情况
|
//列表为空的情况
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.jiaoguanyi.appstore.utils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public class JsonUtils {
|
||||||
|
/**
|
||||||
|
* 读取json文件,返回json串
|
||||||
|
* @param fileName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String readJsonFile(String fileName) {
|
||||||
|
String jsonStr = "";
|
||||||
|
try {
|
||||||
|
File jsonFile = new File(fileName);
|
||||||
|
FileReader fileReader = new FileReader(jsonFile);
|
||||||
|
|
||||||
|
Reader reader = new InputStreamReader(new FileInputStream(jsonFile), StandardCharsets.UTF_8);
|
||||||
|
int ch = 0;
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
while ((ch = reader.read()) != -1) {
|
||||||
|
sb.append((char) ch);
|
||||||
|
}
|
||||||
|
fileReader.close();
|
||||||
|
reader.close();
|
||||||
|
jsonStr = sb.toString();
|
||||||
|
return jsonStr;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jiaoguanyi.appstore.utils;
|
package com.jiaoguanyi.appstore.utils;
|
||||||
|
|
||||||
|
import android.app.StatusBarManager;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -13,6 +14,9 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jiaoguanyi.appstore.BuildConfig;
|
import com.jiaoguanyi.appstore.BuildConfig;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class SysSettingUtils {
|
public class SysSettingUtils {
|
||||||
private static final String TAG = "SysSettingUtils";
|
private static final String TAG = "SysSettingUtils";
|
||||||
@@ -29,21 +33,22 @@ public class SysSettingUtils {
|
|||||||
return status == 0 ? 1 : 0;
|
return status == 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSystemSetting(Context mContext, String jsonObj) {
|
public static void setSystemSetting(Context context, String jsonObj) {
|
||||||
if (null == mContext) {
|
if (null == context) {
|
||||||
throw new RuntimeException("Context it's null");
|
throw new RuntimeException("Context it's null");
|
||||||
}
|
}
|
||||||
JSONObject jsonObject = JSON.parseObject(jsonObj);
|
JSONObject jsonObject = JSON.parseObject(jsonObj);
|
||||||
setPhoneList(mContext, jsonObject);
|
setPhoneList(context, jsonObject);
|
||||||
setUSBstate(mContext, jsonObject);
|
setUSBstate(context, jsonObject);
|
||||||
setBluetooth(mContext, jsonObject);
|
setBluetooth(context, jsonObject);
|
||||||
setHotspot(mContext, jsonObject);
|
setHotspot(context, jsonObject);
|
||||||
setBar(mContext, jsonObject);
|
setBar(context, jsonObject);
|
||||||
setCamera(mContext, jsonObject);
|
setCamera(context, jsonObject);
|
||||||
setTF(mContext, jsonObject);
|
setTF(context, jsonObject);
|
||||||
setIcon(mContext, jsonObject);
|
setIcon(context, jsonObject);
|
||||||
setCanReset(mContext, jsonObject);
|
setCanReset(context, jsonObject);
|
||||||
setAutoTime(mContext, jsonObject);
|
setAutoTime(context, jsonObject);
|
||||||
|
setStatusBar(context, jsonObject);
|
||||||
//otg开关
|
//otg开关
|
||||||
// int setting_otg = changeNum(jsonObject.getInteger("setting_otg"));
|
// int setting_otg = changeNum(jsonObject.getInteger("setting_otg"));
|
||||||
// Log.e("SystemSetting", "setting_otg---------" + setting_otg);
|
// Log.e("SystemSetting", "setting_otg---------" + setting_otg);
|
||||||
@@ -60,95 +65,95 @@ public class SysSettingUtils {
|
|||||||
// sendBroadcast(otgIntent);
|
// sendBroadcast(otgIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDisableSetting(Context mContext) {
|
public static void setDisableSetting(Context context) {
|
||||||
setPhoneList(mContext,1);
|
setPhoneList(context, 1);
|
||||||
setUSBstate(mContext,1);
|
setUSBstate(context, 1);
|
||||||
setBluetooth(mContext,1);
|
setBluetooth(context, 1);
|
||||||
setHotspot(mContext,1);
|
setHotspot(context, 1);
|
||||||
setBar(mContext,1);
|
setBar(context, 1);
|
||||||
setCamera(mContext,1);
|
setCamera(context, 1);
|
||||||
setTF(mContext,1);
|
setTF(context, 1);
|
||||||
setIcon(mContext,1);
|
setIcon(context, 1);
|
||||||
setCanReset(mContext,1);
|
setCanReset(context, 1);
|
||||||
setAutoTime(mContext,1);
|
setAutoTime(context, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setEnableSetting(Context mContext) {
|
public static void setEnableSetting(Context context) {
|
||||||
setPhoneList(mContext,0);
|
setPhoneList(context, 0);
|
||||||
// setUSBstate(mContext,0);
|
// setUSBstate(context,0);
|
||||||
setBluetooth(mContext,0);
|
setBluetooth(context, 0);
|
||||||
setHotspot(mContext,0);
|
setHotspot(context, 0);
|
||||||
setBar(mContext,0);
|
setBar(context, 0);
|
||||||
setCamera(mContext,0);
|
setCamera(context, 0);
|
||||||
setTF(mContext,0);
|
setTF(context, 0);
|
||||||
setIcon(mContext,0);
|
setIcon(context, 0);
|
||||||
setCanReset(mContext,0);
|
setCanReset(context, 0);
|
||||||
setAutoTime(mContext,0);
|
setAutoTime(context, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setPhoneList(Context mContext,int state) {
|
private static void setPhoneList(Context context, int state) {
|
||||||
try {
|
try {
|
||||||
//设置电话功能,电话白名单
|
//设置电话功能,电话白名单
|
||||||
boolean qch_call_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_call_forbid", state);
|
boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", state);
|
||||||
Log.e("SystemSetting", "qch_call_forbid:" + qch_call_forbid);
|
Log.e("SystemSetting", "qch_call_forbid:" + qch_call_forbid);
|
||||||
|
|
||||||
boolean qch_white_list_on = Settings.System.putInt(mContext.getContentResolver(), "qch_white_list_on", state);
|
boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", state);
|
||||||
Log.e("SystemSetting", "qch_white_list_on:" + qch_white_list_on);
|
Log.e("SystemSetting", "qch_white_list_on:" + qch_white_list_on);
|
||||||
|
|
||||||
boolean qch_white_list_Array = Settings.System.putString(mContext.getContentResolver(), "qch_white_list_Array", "");
|
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", "");
|
||||||
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
||||||
Log.e("SystemSetting", "qch_white_list_Array:" + qch_white_list_Array + "---" + qch_white_list_Array);
|
Log.e("SystemSetting", "qch_white_list_Array:" + qch_white_list_Array + "---" + qch_white_list_Array);
|
||||||
|
|
||||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_sdcard_forbid_on", state);
|
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", state);
|
||||||
Log.e("SystemSetting", "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
Log.e("SystemSetting", "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setPhoneList(Context mContext, JSONObject jsonObject) {
|
private static void setPhoneList(Context context, JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
//设置电话功能,电话白名单
|
//设置电话功能,电话白名单
|
||||||
int setting_call = changeNum(jsonObject.getInteger("setting_call"));
|
int setting_call = changeNum(jsonObject.getInteger("setting_call"));
|
||||||
boolean qch_call_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_call_forbid", setting_call);
|
boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", setting_call);
|
||||||
Log.e("SystemSetting", "qch_call_forbid:" + qch_call_forbid);
|
Log.e("SystemSetting", "qch_call_forbid:" + qch_call_forbid);
|
||||||
|
|
||||||
int setting_phone = changeNum(jsonObject.getInteger("setting_phone"));
|
int setting_phone = changeNum(jsonObject.getInteger("setting_phone"));
|
||||||
boolean qch_white_list_on = Settings.System.putInt(mContext.getContentResolver(), "qch_white_list_on", setting_phone);
|
boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", setting_phone);
|
||||||
Log.e("SystemSetting", "qch_white_list_on:" + qch_white_list_on);
|
Log.e("SystemSetting", "qch_white_list_on:" + qch_white_list_on);
|
||||||
|
|
||||||
String setting_phones = jsonObject.getString("setting_phones");
|
String setting_phones = jsonObject.getString("setting_phones");
|
||||||
boolean qch_white_list_Array = Settings.System.putString(mContext.getContentResolver(), "qch_white_list_Array", setting_phones);
|
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", setting_phones);
|
||||||
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
// ToastTool.show("qch_call_forbid::"+setting_call+"----setting_phones::"+setting_phones+"----"+qch_white_list_Array+"---"+qch_call_forbid);
|
||||||
Log.e("SystemSetting", "qch_white_list_Array:" + qch_white_list_Array + "---" + setting_phones);
|
Log.e("SystemSetting", "qch_white_list_Array:" + qch_white_list_Array + "---" + setting_phones);
|
||||||
|
|
||||||
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
|
int setting_memory = changeNum(jsonObject.getInteger("setting_memory"));
|
||||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
|
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", setting_memory);
|
||||||
Log.e("SystemSetting", "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
Log.e("SystemSetting", "qch_sdcard_forbid_on:" + qch_sdcard_forbid_on);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
Log.e(TAG, "setPhoneList: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setUSBstate(Context mContext,int state) {
|
private static void setUSBstate(Context context, int state) {
|
||||||
//USB数据功能管控
|
//USB数据功能管控
|
||||||
//仅充电:usb_charge
|
//仅充电:usb_charge
|
||||||
//MTP模式:usb_mtp
|
//MTP模式:usb_mtp
|
||||||
//Midi模式:usb_midi
|
//Midi模式:usb_midi
|
||||||
if (!BuildConfig.DEBUG) {
|
if (!BuildConfig.DEBUG) {
|
||||||
try {
|
try {
|
||||||
boolean qch_usb_choose = Settings.System.putString(mContext.getContentResolver(), "qch_usb_choose", "usb_charge");
|
boolean qch_usb_choose = Settings.System.putString(context.getContentResolver(), "qch_usb_choose", "usb_charge");
|
||||||
Log.e("SystemSetting", "qch_usb_choose:" + qch_usb_choose);
|
Log.e("SystemSetting", "qch_usb_choose:" + qch_usb_choose);
|
||||||
String usbStatus = "qch_action_usb_usb_charge";
|
String usbStatus = "qch_action_usb_usb_charge";
|
||||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||||
mContext.sendBroadcast(usbIntent);
|
context.sendBroadcast(usbIntent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setUSBstate: " + e.getMessage());
|
Log.e(TAG, "setUSBstate: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setUSBstate(Context mContext, JSONObject jsonObject) {
|
private static void setUSBstate(Context context, JSONObject jsonObject) {
|
||||||
//USB数据功能管控
|
//USB数据功能管控
|
||||||
//仅充电:usb_charge
|
//仅充电:usb_charge
|
||||||
//MTP模式:usb_mtp
|
//MTP模式:usb_mtp
|
||||||
@@ -156,7 +161,7 @@ public class SysSettingUtils {
|
|||||||
String setting_usb = jsonObject.getString("setting_usb");
|
String setting_usb = jsonObject.getString("setting_usb");
|
||||||
if (!BuildConfig.DEBUG) {
|
if (!BuildConfig.DEBUG) {
|
||||||
try {
|
try {
|
||||||
boolean qch_usb_choose = Settings.System.putString(mContext.getContentResolver(), "qch_usb_choose", setting_usb);
|
boolean qch_usb_choose = Settings.System.putString(context.getContentResolver(), "qch_usb_choose", setting_usb);
|
||||||
Log.e("SystemSetting", "qch_usb_choose---------" + qch_usb_choose);
|
Log.e("SystemSetting", "qch_usb_choose---------" + qch_usb_choose);
|
||||||
String usbStatus = "";
|
String usbStatus = "";
|
||||||
switch (setting_usb) {
|
switch (setting_usb) {
|
||||||
@@ -172,16 +177,16 @@ public class SysSettingUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||||
mContext.sendBroadcast(usbIntent);
|
context.sendBroadcast(usbIntent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setUSBstate: " + e.getMessage());
|
Log.e(TAG, "setUSBstate: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setBluetooth(Context mContext,int state) {
|
private static void setBluetooth(Context context, int state) {
|
||||||
try {
|
try {
|
||||||
boolean qch_bht_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_bht_forbid_on", state);
|
boolean qch_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", state);
|
||||||
//写入系统数据库
|
//写入系统数据库
|
||||||
Log.e("SystemSetting", "qch_bht_forbid_on:" + qch_bht_forbid_on);
|
Log.e("SystemSetting", "qch_bht_forbid_on:" + qch_bht_forbid_on);
|
||||||
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
@@ -192,8 +197,8 @@ public class SysSettingUtils {
|
|||||||
//获取默认蓝牙适配器
|
//获取默认蓝牙适配器
|
||||||
}
|
}
|
||||||
//蓝牙总开关开启
|
//蓝牙总开关开启
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_bt_forbid_on", state);
|
Settings.System.putInt(context.getContentResolver(), "qch_bt_forbid_on", state);
|
||||||
mBluetoothAdapter.disable();
|
mBluetoothAdapter.disable();
|
||||||
//设置关闭时关闭蓝牙
|
//设置关闭时关闭蓝牙
|
||||||
}
|
}
|
||||||
@@ -202,7 +207,7 @@ public class SysSettingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setBluetooth(Context mContext, JSONObject jsonObject) {
|
private static void setBluetooth(Context context, JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
//蓝牙开关
|
//蓝牙开关
|
||||||
int setting_bht = changeNum(jsonObject.getInteger("setting_bht"));
|
int setting_bht = changeNum(jsonObject.getInteger("setting_bht"));
|
||||||
@@ -211,7 +216,7 @@ public class SysSettingUtils {
|
|||||||
//蓝牙音频开关
|
//蓝牙音频开关
|
||||||
int setting_bluetooth = changeNum(jsonObject.getInteger("setting_bluetooth"));
|
int setting_bluetooth = changeNum(jsonObject.getInteger("setting_bluetooth"));
|
||||||
//蓝牙传输开关
|
//蓝牙传输开关
|
||||||
boolean qch_bht_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_bht_forbid_on", setting_bht);
|
boolean qch_bht_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", setting_bht);
|
||||||
//写入系统数据库
|
//写入系统数据库
|
||||||
Log.e("SystemSetting", "qch_bht_forbid_on:" + qch_bht_forbid_on);
|
Log.e("SystemSetting", "qch_bht_forbid_on:" + qch_bht_forbid_on);
|
||||||
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
@@ -227,14 +232,14 @@ public class SysSettingUtils {
|
|||||||
if (setting_bhtvideo == 0) {
|
if (setting_bhtvideo == 0) {
|
||||||
if (null != setting_context && !setting_context.equals("") && !setting_context.equals(" ") && !setting_context.equals("null")) {
|
if (null != setting_context && !setting_context.equals("") && !setting_context.equals(" ") && !setting_context.equals("null")) {
|
||||||
Log.e("SystemSetting", "setting_context:" + setting_context);
|
Log.e("SystemSetting", "setting_context:" + setting_context);
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", setting_context);
|
Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", setting_context);
|
||||||
} else {
|
} else {
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||||
}
|
}
|
||||||
} else if (setting_bhtvideo == 1) {
|
} else if (setting_bhtvideo == 1) {
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
Settings.System.putString(context.getContentResolver(), "qch_bhtvideo_forbid_on", "Empty");
|
||||||
}
|
}
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
|
Settings.System.putInt(context.getContentResolver(), "qch_bt_forbid_on", setting_bluetooth);
|
||||||
} else {
|
} else {
|
||||||
mBluetoothAdapter.disable();
|
mBluetoothAdapter.disable();
|
||||||
//设置关闭时关闭蓝牙
|
//设置关闭时关闭蓝牙
|
||||||
@@ -245,29 +250,29 @@ public class SysSettingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setHotspot(Context mContext,int state) {
|
private static void setHotspot(Context context, int state) {
|
||||||
try {
|
try {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction("qch_hotspot_close");
|
intent.setAction("qch_hotspot_close");
|
||||||
intent.setPackage("com.android.settings");
|
intent.setPackage("com.android.settings");
|
||||||
mContext.sendStickyBroadcast(intent);
|
context.sendStickyBroadcast(intent);
|
||||||
boolean qch_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_hotspot_forbid_on", state);//写入系统数据库
|
boolean qch_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_hotspot_forbid_on", state);//写入系统数据库
|
||||||
Log.e("SystemSetting", "qch_hotspot_forbid_on:" + qch_hotspot_forbid_on);
|
Log.e("SystemSetting", "qch_hotspot_forbid_on:" + qch_hotspot_forbid_on);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setHotspot: " + e.getMessage());
|
Log.e(TAG, "setHotspot: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setHotspot(Context mContext, JSONObject jsonObject) {
|
private static void setHotspot(Context context, JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
int setting_hotspot = changeNum(jsonObject.getInteger("setting_hotspot"));//热点
|
int setting_hotspot = changeNum(jsonObject.getInteger("setting_hotspot"));//热点
|
||||||
if (setting_hotspot == 1) {
|
if (setting_hotspot == 1) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction("qch_hotspot_close");
|
intent.setAction("qch_hotspot_close");
|
||||||
intent.setPackage("com.android.settings");
|
intent.setPackage("com.android.settings");
|
||||||
mContext.sendStickyBroadcast(intent);
|
context.sendStickyBroadcast(intent);
|
||||||
}
|
}
|
||||||
boolean qch_hotspot_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_hotspot_forbid_on", setting_hotspot);//写入系统数据库
|
boolean qch_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_hotspot_forbid_on", setting_hotspot);//写入系统数据库
|
||||||
Log.e("SystemSetting", "qch_hotspot_forbid_on---------" + setting_hotspot);
|
Log.e("SystemSetting", "qch_hotspot_forbid_on---------" + setting_hotspot);
|
||||||
Log.e("SystemSetting", "qch_hotspot_forbid_on---------" + qch_hotspot_forbid_on);
|
Log.e("SystemSetting", "qch_hotspot_forbid_on---------" + qch_hotspot_forbid_on);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -275,10 +280,10 @@ public class SysSettingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setBar(Context mContext,int state) {
|
private static void setBar(Context context, int state) {
|
||||||
//系统导航条显示开关
|
//系统导航条显示开关
|
||||||
int setting_navigation = 0;
|
int setting_navigation = 0;
|
||||||
boolean qch_hide_navigationBar = Settings.System.putInt(mContext.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
|
boolean qch_hide_navigationBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
|
||||||
Log.e("SystemSetting", "qch_hide_navigationBar---------" + qch_hide_navigationBar);
|
Log.e("SystemSetting", "qch_hide_navigationBar---------" + qch_hide_navigationBar);
|
||||||
|
|
||||||
String navigationStatus = "";
|
String navigationStatus = "";
|
||||||
@@ -292,14 +297,14 @@ public class SysSettingUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
||||||
mContext.sendBroadcast(navIntent);
|
context.sendBroadcast(navIntent);
|
||||||
|
|
||||||
|
|
||||||
//状态栏显示开关
|
//状态栏显示开关
|
||||||
int setting_statusbar = 0;
|
int setting_statusbar = 0;
|
||||||
int oldNum = Settings.System.getInt(mContext.getContentResolver(), "qch_hide_statusBar", 0);
|
int oldNum = Settings.System.getInt(context.getContentResolver(), "qch_hide_statusBar", 0);
|
||||||
if (oldNum != setting_statusbar) {
|
if (oldNum != setting_statusbar) {
|
||||||
boolean qch_hide_statusBar = Settings.System.putInt(mContext.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
|
boolean qch_hide_statusBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
|
||||||
Log.e("SystemSetting", "qch_hide_statusBar---------" + qch_hide_statusBar);
|
Log.e("SystemSetting", "qch_hide_statusBar---------" + qch_hide_statusBar);
|
||||||
String statusbarStatus = "";
|
String statusbarStatus = "";
|
||||||
switch (setting_statusbar) {
|
switch (setting_statusbar) {
|
||||||
@@ -311,14 +316,14 @@ public class SysSettingUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
||||||
mContext.sendBroadcast(statusIntent);
|
context.sendBroadcast(statusIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setBar(Context mContext, JSONObject jsonObject) {
|
private static void setBar(Context context, JSONObject jsonObject) {
|
||||||
//系统导航条显示开关
|
//系统导航条显示开关
|
||||||
int setting_navigation = changeNum(jsonObject.getInteger("setting_navigation"));
|
int setting_navigation = changeNum(jsonObject.getInteger("setting_navigation"));
|
||||||
boolean qch_hide_navigationBar = Settings.System.putInt(mContext.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
|
boolean qch_hide_navigationBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_NavigationBar", setting_navigation);
|
||||||
Log.e("SystemSetting", "qch_hide_navigationBar---------" + qch_hide_navigationBar);
|
Log.e("SystemSetting", "qch_hide_navigationBar---------" + qch_hide_navigationBar);
|
||||||
|
|
||||||
String navigationStatus = "";
|
String navigationStatus = "";
|
||||||
@@ -332,14 +337,14 @@ public class SysSettingUtils {
|
|||||||
|
|
||||||
}
|
}
|
||||||
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
Intent navIntent = new Intent(navigationStatus).setPackage("com.android.systemui");
|
||||||
mContext.sendBroadcast(navIntent);
|
context.sendBroadcast(navIntent);
|
||||||
|
|
||||||
|
|
||||||
//状态栏显示开关
|
//状态栏显示开关
|
||||||
int setting_statusbar = changeNum(jsonObject.getInteger("setting_statusbar"));
|
int setting_statusbar = changeNum(jsonObject.getInteger("setting_statusbar"));
|
||||||
int oldNum = Settings.System.getInt(mContext.getContentResolver(), "qch_hide_statusBar", 0);
|
int oldNum = Settings.System.getInt(context.getContentResolver(), "qch_hide_statusBar", 0);
|
||||||
if (oldNum != setting_statusbar) {
|
if (oldNum != setting_statusbar) {
|
||||||
boolean qch_hide_statusBar = Settings.System.putInt(mContext.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
|
boolean qch_hide_statusBar = Settings.System.putInt(context.getContentResolver(), "qch_hide_statusBar", setting_statusbar);
|
||||||
Log.e("SystemSetting", "qch_hide_statusBar---------" + qch_hide_statusBar);
|
Log.e("SystemSetting", "qch_hide_statusBar---------" + qch_hide_statusBar);
|
||||||
String statusbarStatus = "";
|
String statusbarStatus = "";
|
||||||
switch (setting_statusbar) {
|
switch (setting_statusbar) {
|
||||||
@@ -351,16 +356,16 @@ public class SysSettingUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
Intent statusIntent = new Intent(statusbarStatus).setPackage("com.android.systemui");
|
||||||
mContext.sendBroadcast(statusIntent);
|
context.sendBroadcast(statusIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setCamera(Context mContext,int state) {
|
private static void setCamera(Context context, int state) {
|
||||||
try {
|
try {
|
||||||
//摄像头开关
|
//摄像头开关
|
||||||
boolean qch_app_camera = Settings.System.putInt(mContext.getContentResolver(), "qch_app_camera", state);
|
boolean qch_app_camera = Settings.System.putInt(context.getContentResolver(), "qch_app_camera", state);
|
||||||
Log.e("SystemSetting", "qch_app_camera1:" + state);
|
Log.e("SystemSetting", "qch_app_camera1:" + state);
|
||||||
// ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.camera");
|
// ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera");
|
||||||
Log.e("SystemSetting", "setting_camera---------" + qch_app_camera);
|
Log.e("SystemSetting", "setting_camera---------" + qch_app_camera);
|
||||||
String cameraStatus = "qch_camera_forbid";
|
String cameraStatus = "qch_camera_forbid";
|
||||||
switch (state) {
|
switch (state) {
|
||||||
@@ -372,19 +377,19 @@ public class SysSettingUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
|
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
|
||||||
mContext.sendBroadcast(cameraIntent);
|
context.sendBroadcast(cameraIntent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setCamera: " + e.getMessage());
|
Log.e(TAG, "setCamera: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setCamera(Context mContext, JSONObject jsonObject) {
|
private static void setCamera(Context context, JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
//摄像头开关
|
//摄像头开关
|
||||||
int setting_camera = changeNum(jsonObject.getInteger("setting_camera"));
|
int setting_camera = changeNum(jsonObject.getInteger("setting_camera"));
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_camera", setting_camera);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_camera", setting_camera);
|
||||||
Log.e("SystemSetting", "qch_app_camera2:" + setting_camera);
|
Log.e("SystemSetting", "qch_app_camera2:" + setting_camera);
|
||||||
// ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.camera");
|
// ApkUtils.hideSystemSettingAPP(context, "com.mediatek.camera");
|
||||||
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
|
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
|
||||||
String cameraStatus = "";
|
String cameraStatus = "";
|
||||||
switch (setting_camera) {
|
switch (setting_camera) {
|
||||||
@@ -396,17 +401,17 @@ public class SysSettingUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
|
Intent cameraIntent = new Intent(cameraStatus).setPackage("com.android.settings");
|
||||||
mContext.sendBroadcast(cameraIntent);
|
context.sendBroadcast(cameraIntent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setCamera: " + e.getMessage());
|
Log.e(TAG, "setCamera: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setTF(Context mContext,int state) {
|
private static void setTF(Context context, int state) {
|
||||||
try {
|
try {
|
||||||
//tfmedia开关
|
//tfmedia开关
|
||||||
// int setting_tfmedia = 1;
|
// int setting_tfmedia = 1;
|
||||||
boolean qch_tfmedia_forbid = Settings.System.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", state);
|
boolean qch_tfmedia_forbid = Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", state);
|
||||||
Log.e("SystemSetting", "setting_tfmedia---------" + qch_tfmedia_forbid);
|
Log.e("SystemSetting", "setting_tfmedia---------" + qch_tfmedia_forbid);
|
||||||
String tfmediaStatus = "";
|
String tfmediaStatus = "";
|
||||||
switch (state) {
|
switch (state) {
|
||||||
@@ -418,23 +423,23 @@ public class SysSettingUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
|
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
|
||||||
mContext.sendBroadcast(tfmediaIntent);
|
context.sendBroadcast(tfmediaIntent);
|
||||||
if (state == 1) {
|
if (state == 1) {
|
||||||
boolean qch_tfmedia_filetypes = Settings.System.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", "Empty");//影音管控
|
boolean qch_tfmedia_filetypes = Settings.System.putString(context.getContentResolver(), "qch_tfmedia_filetypes", "Empty");//影音管控
|
||||||
Log.e("SystemSetting", "qch_tfmedia_filetypes:" + qch_tfmedia_filetypes);
|
Log.e("SystemSetting", "qch_tfmedia_filetypes:" + qch_tfmedia_filetypes);
|
||||||
} else {
|
} else {
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", 0);
|
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "setTF: " + e.getMessage());
|
Log.e(TAG, "setTF: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setTF(Context mContext, JSONObject jsonObject) {
|
private static void setTF(Context context, JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
//tfmedia开关
|
//tfmedia开关
|
||||||
int setting_tfmedia = changeNum(jsonObject.getInteger("setting_tfmedia"));
|
int setting_tfmedia = changeNum(jsonObject.getInteger("setting_tfmedia"));
|
||||||
boolean qch_tfmedia_forbid = Settings.System.putInt(mContext.getContentResolver(),
|
boolean qch_tfmedia_forbid = Settings.System.putInt(context.getContentResolver(),
|
||||||
"qch_tfmedia_forbid", setting_tfmedia);
|
"qch_tfmedia_forbid", setting_tfmedia);
|
||||||
Log.e("SystemSetting", "setting_tfmedia---------" + qch_tfmedia_forbid);
|
Log.e("SystemSetting", "setting_tfmedia---------" + qch_tfmedia_forbid);
|
||||||
String tfmediaStatus = "";
|
String tfmediaStatus = "";
|
||||||
@@ -447,7 +452,7 @@ public class SysSettingUtils {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
|
Intent tfmediaIntent = new Intent(tfmediaStatus).setPackage("com.android.settings");
|
||||||
mContext.sendBroadcast(tfmediaIntent);
|
context.sendBroadcast(tfmediaIntent);
|
||||||
if (setting_tfmedia == 1) {
|
if (setting_tfmedia == 1) {
|
||||||
JSONArray jSONArray = null;
|
JSONArray jSONArray = null;
|
||||||
jSONArray = jsonObject.getJSONArray("setting_tfmedia_format");
|
jSONArray = jsonObject.getJSONArray("setting_tfmedia_format");
|
||||||
@@ -458,51 +463,51 @@ public class SysSettingUtils {
|
|||||||
stringBuffer.append(",");
|
stringBuffer.append(",");
|
||||||
}
|
}
|
||||||
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
||||||
Settings.System.putString(mContext.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控
|
Settings.System.putString(context.getContentResolver(), "qch_tfmedia_filetypes", stringBuffer.toString());//影音管控
|
||||||
Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + stringBuffer.toString());
|
Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + stringBuffer.toString());
|
||||||
} else {
|
} else {
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_tfmedia_forbid", 0);
|
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("SystemSetting", "setTF: " + e.getMessage());
|
Log.e("SystemSetting", "setTF: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setIcon(Context mContext,int state) {
|
private static void setIcon(Context context, int state) {
|
||||||
try {
|
try {
|
||||||
//added:2019.12.6
|
//added:2019.12.6
|
||||||
//设置5个app的开关
|
//设置5个app的开关
|
||||||
//时钟
|
//时钟
|
||||||
// int deskclock = 1;
|
// int deskclock = 1;
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_deskclock", state);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", state);
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.deskclock");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.deskclock");
|
||||||
Log.e("SystemSetting", "qch_app_deskclock" + state);
|
Log.e("SystemSetting", "qch_app_deskclock" + state);
|
||||||
//录音机
|
//录音机
|
||||||
// int soundrecorder = 1;
|
// int soundrecorder = 1;
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_soundrecorder", state);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", state);
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.soundrecorder");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.soundrecorder");
|
||||||
Log.e("SystemSetting", "qch_app_soundrecorder" + state);
|
Log.e("SystemSetting", "qch_app_soundrecorder" + state);
|
||||||
//音乐
|
//音乐
|
||||||
// int music = 1;
|
// int music = 1;
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_music", state);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_music", state);
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.music");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.music");
|
||||||
Log.e("SystemSetting", "qch_app_music" + state);
|
Log.e("SystemSetting", "qch_app_music" + state);
|
||||||
//图库
|
//图库
|
||||||
// int gallery = 1;
|
// int gallery = 1;
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_gallery", state);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", state);
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.gallery3d");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d");
|
||||||
Log.e("SystemSetting", "qch_app_gallery" + state);
|
Log.e("SystemSetting", "qch_app_gallery" + state);
|
||||||
//壁纸
|
//壁纸
|
||||||
// int wallpaper = 1;
|
// int wallpaper = 1;
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_wallpaper", state);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_wallpaper", state);
|
||||||
Log.e("SystemSetting", "qch_app_wallpaper" + state);
|
Log.e("SystemSetting", "qch_app_wallpaper" + state);
|
||||||
//文件管理器
|
//文件管理器
|
||||||
// int filemanager = 1;
|
// int filemanager = 1;
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_filemanager", state);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", state);
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.filemanager");
|
ApkUtils.hideSystemSettingAPP(context, "com.mediatek.filemanager");
|
||||||
} else {
|
} else {
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.documentsui");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.documentsui");
|
||||||
}
|
}
|
||||||
Log.e("SystemSetting", "qch_app_filemanager" + state);
|
Log.e("SystemSetting", "qch_app_filemanager" + state);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -510,41 +515,41 @@ public class SysSettingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setIcon(Context mContext, JSONObject jsonObject) {
|
private static void setIcon(Context context, JSONObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
//added:2019.12.6
|
//added:2019.12.6
|
||||||
//设置5个app的开关
|
//设置5个app的开关
|
||||||
//时钟
|
//时钟
|
||||||
int deskclock = changeNum(jsonObject.getInteger("setting_clock"));
|
int deskclock = changeNum(jsonObject.getInteger("setting_clock"));
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_deskclock", deskclock);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", deskclock);
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.deskclock");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.deskclock");
|
||||||
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
|
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
|
||||||
//录音机
|
//录音机
|
||||||
int soundrecorder = changeNum(jsonObject.getInteger("setting_recording"));
|
int soundrecorder = changeNum(jsonObject.getInteger("setting_recording"));
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.soundrecorder");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.soundrecorder");
|
||||||
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
|
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
|
||||||
//音乐
|
//音乐
|
||||||
int music = changeNum(jsonObject.getInteger("setting_music"));
|
int music = changeNum(jsonObject.getInteger("setting_music"));
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_music", music);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_music", music);
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.music");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.music");
|
||||||
Log.e("SystemSetting", "qch_app_music" + music);
|
Log.e("SystemSetting", "qch_app_music" + music);
|
||||||
//图库
|
//图库
|
||||||
int gallery = changeNum(jsonObject.getInteger("setting_picture"));
|
int gallery = changeNum(jsonObject.getInteger("setting_picture"));
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_gallery", gallery);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_gallery", gallery);
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.gallery3d");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.gallery3d");
|
||||||
Log.e("SystemSetting", "qch_app_gallery" + gallery);
|
Log.e("SystemSetting", "qch_app_gallery" + gallery);
|
||||||
//壁纸
|
//壁纸
|
||||||
int wallpaper = changeNum(jsonObject.getInteger("setting_wallpaper"));
|
int wallpaper = changeNum(jsonObject.getInteger("setting_wallpaper"));
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_wallpaper", wallpaper);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_wallpaper", wallpaper);
|
||||||
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
|
Log.e("SystemSetting", "qch_app_wallpaper" + wallpaper);
|
||||||
//文件管理器
|
//文件管理器
|
||||||
int filemanager = changeNum(jsonObject.getInteger("setting_file"));
|
int filemanager = changeNum(jsonObject.getInteger("setting_file"));
|
||||||
Settings.System.putInt(mContext.getContentResolver(), "qch_app_filemanager", filemanager);
|
Settings.System.putInt(context.getContentResolver(), "qch_app_filemanager", filemanager);
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.mediatek.filemanager");
|
ApkUtils.hideSystemSettingAPP(context, "com.mediatek.filemanager");
|
||||||
} else {
|
} else {
|
||||||
ApkUtils.hideSystemSettingAPP(mContext, "com.android.documentsui");
|
ApkUtils.hideSystemSettingAPP(context, "com.android.documentsui");
|
||||||
}
|
}
|
||||||
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
|
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -552,21 +557,21 @@ public class SysSettingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setCanReset(Context mContext,int state) {
|
private static void setCanReset(Context context, int state) {
|
||||||
boolean qch_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_restore_forbid_on", 0);
|
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||||
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||||
//默认打开
|
//默认打开
|
||||||
}
|
}
|
||||||
|
|
||||||
//qch_restore_forbid_on=1,禁止恢复出厂设置
|
//qch_restore_forbid_on=1,禁止恢复出厂设置
|
||||||
//qch_restore_forbid_on=0,允许恢复出厂设置
|
//qch_restore_forbid_on=0,允许恢复出厂设置
|
||||||
private static void setCanReset(Context mContext, JSONObject jsonObject) {
|
private static void setCanReset(Context context, JSONObject jsonObject) {
|
||||||
int mode = jsonObject.getInteger("qch_restore");
|
int mode = jsonObject.getInteger("qch_restore");
|
||||||
if (mode == 1) {
|
if (mode == 1) {
|
||||||
boolean qch_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_restore_forbid_on", 0);
|
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 0);
|
||||||
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||||
} else {
|
} else {
|
||||||
boolean qch_restore_forbid_on = Settings.System.putInt(mContext.getContentResolver(), "qch_restore_forbid_on", 1);
|
boolean qch_restore_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_restore_forbid_on", 1);
|
||||||
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
Log.e("SystemSetting", "qch_restore_forbid_on:" + qch_restore_forbid_on);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,7 +593,7 @@ public class SysSettingUtils {
|
|||||||
//intent34.setPackage("com.android.settings");
|
//intent34.setPackage("com.android.settings");
|
||||||
//sendBroadcast(intent34);
|
//sendBroadcast(intent34);
|
||||||
|
|
||||||
private static void setAutoTime(Context mContext, JSONObject jsonObject) {
|
private static void setAutoTime(Context context, JSONObject jsonObject) {
|
||||||
String autoTime = jsonObject.getString("setting_autotime");
|
String autoTime = jsonObject.getString("setting_autotime");
|
||||||
String action = "qch_autotime_network";
|
String action = "qch_autotime_network";
|
||||||
if (TextUtils.isEmpty(autoTime)) {
|
if (TextUtils.isEmpty(autoTime)) {
|
||||||
@@ -613,15 +618,55 @@ public class SysSettingUtils {
|
|||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(action);
|
intent.setAction(action);
|
||||||
intent.setPackage("com.android.settings");
|
intent.setPackage("com.android.settings");
|
||||||
mContext.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setAutoTime(Context mContext,int state) {
|
private static void setAutoTime(Context context, int state) {
|
||||||
Log.e("SystemSetting", "setAutoTime: " + "default");
|
Log.e("SystemSetting", "setAutoTime: " + "default");
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction("qch_autotime_network");
|
intent.setAction("qch_autotime_network");
|
||||||
intent.setPackage("com.android.settings");
|
intent.setPackage("com.android.settings");
|
||||||
mContext.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void setStatusBar(Context context, JSONObject jsonObject) {
|
||||||
|
JSONObject navJson = jsonObject.getJSONObject("setting_nav");
|
||||||
|
if (null != navJson) {
|
||||||
|
int whole = navJson.getInteger("whole");
|
||||||
|
if (whole == 1) {
|
||||||
|
setStatusBar(context, 0);
|
||||||
|
} else {
|
||||||
|
List<Integer> disableWhat = new ArrayList<>();
|
||||||
|
int home = navJson.getInteger("home");
|
||||||
|
if (home == 1) {
|
||||||
|
disableWhat.add(StatusBarManager.DISABLE_HOME);
|
||||||
|
}
|
||||||
|
int returnKey = navJson.getInteger("returnKey");
|
||||||
|
if (returnKey == 1) {
|
||||||
|
disableWhat.add(StatusBarManager.DISABLE_BACK);
|
||||||
|
}
|
||||||
|
int taskbar = navJson.getInteger("taskbar");
|
||||||
|
if (taskbar == 1) {
|
||||||
|
disableWhat.add(StatusBarManager.DISABLE_RECENT);
|
||||||
|
}
|
||||||
|
int what = 0;
|
||||||
|
for (Integer integer : disableWhat) {
|
||||||
|
if (what == 0) {
|
||||||
|
what = integer;
|
||||||
|
}
|
||||||
|
what |= integer;
|
||||||
|
}
|
||||||
|
StatusBarManager mStatusBarManager = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
|
||||||
|
mStatusBarManager.disable(what);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setStatusBar(Context context, int state) {
|
||||||
|
StatusBarManager mStatusBarManager = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
|
||||||
|
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,407 @@
|
|||||||
package com.jiaoguanyi.appstore.utils;
|
package com.jiaoguanyi.appstore.utils;
|
||||||
|
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageInstaller;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import com.jiaoguanyi.appstore.bean.Expansions;
|
||||||
|
import com.jiaoguanyi.appstore.bean.SplitApks;
|
||||||
|
|
||||||
|
import org.zeroturnaround.zip.ZipUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import io.reactivex.ObservableEmitter;
|
||||||
|
import io.reactivex.ObservableOnSubscribe;
|
||||||
|
import io.reactivex.Observer;
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.Disposable;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
*/
|
||||||
public class XAPKUtils {
|
public class XAPKUtils {
|
||||||
|
//https://my.oschina.net/fxc0719/blog/4445198
|
||||||
|
//https://www.jianshu.com/p/cd10d5278ebf?utm_campaign=hugo
|
||||||
|
//https://www.jianshu.com/p/580b61ee7aee
|
||||||
|
|
||||||
|
private static final String TAG = XAPKUtils.class.getSimpleName();
|
||||||
|
private static XAPKUtils sInstance;
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
private XAPKUtils(Context context) {
|
||||||
|
this.mContext = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init(Context context) {
|
||||||
|
if (sInstance == null) {
|
||||||
|
sInstance = new XAPKUtils(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static XAPKUtils getInstance() {
|
||||||
|
if (sInstance == null) {
|
||||||
|
throw new IllegalStateException("You must be init XAPKUtils first");
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void installXAPK(String filePath) {
|
||||||
|
File file = new File(filePath);
|
||||||
|
if (file.exists() && file.isFile()) {
|
||||||
|
upzipXAPK(file);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "installXAPK: " + "File not exists");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String unpackPath;
|
||||||
|
private static long XAPKSize;
|
||||||
|
|
||||||
|
private void upzipXAPK(File XAPKFile) {
|
||||||
|
Observable.create(new ObservableOnSubscribe<String>() {
|
||||||
|
@Override
|
||||||
|
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||||
|
if (ZipUtil.containsEntry(XAPKFile, "manifest.json")) {
|
||||||
|
//判断json文件是否存在
|
||||||
|
String dirName = FileUtils.getFileNoExName(XAPKFile.getAbsolutePath());
|
||||||
|
unpackPath = XAPKFile.getParentFile().getAbsolutePath() + File.separator + dirName;
|
||||||
|
File unpackDir = new File(unpackPath);
|
||||||
|
ZipUtil.unpack(XAPKFile, unpackDir);
|
||||||
|
String jsonString = JsonUtils.readJsonFile(unpackDir.getAbsolutePath() + File.separator + "manifest.json");
|
||||||
|
emitter.onNext(jsonString);
|
||||||
|
} else {
|
||||||
|
ToastUtil.show("读取XAPK配置文件失败");
|
||||||
|
emitter.onComplete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<String>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(String s) {
|
||||||
|
JsonObject jsonObject = JsonParser.parseString(s).getAsJsonObject();
|
||||||
|
XAPKSize = jsonObject.get("total_size").getAsLong();
|
||||||
|
JsonElement split_configs_em = jsonObject.get("split_configs");
|
||||||
|
//获取分割的配置
|
||||||
|
JsonElement expansions_em = jsonObject.get("expansions");
|
||||||
|
//获取OBB文件配置
|
||||||
|
JsonElement split_apks_em = jsonObject.get("split_apks");
|
||||||
|
readConfig(split_configs_em, expansions_em, split_apks_em);
|
||||||
|
// Log.e(TAG, "installXAPK: " + jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
Log.e(TAG, "onError: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
Log.e(TAG, "onComplete: ");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readConfig(JsonElement split_configs, JsonElement expansions, JsonElement split_apks) {
|
||||||
|
//没有split_configs只有单个apk,读取split_apks 的base字段的file文件
|
||||||
|
//没有expansions 没有obb文件
|
||||||
|
//split_apks应该是都会有的,包含一个base的json对象
|
||||||
|
if (null != split_configs) {
|
||||||
|
getSplitConfigs(split_configs.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "readConfig: " + "not found split_configs json data");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != expansions) {
|
||||||
|
readOBBConfig(expansions.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "readConfig: " + "not found expansions json data");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != split_apks) {
|
||||||
|
getSplitApks(split_apks.getAsJsonArray());
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "readConfig: " + "not found split_apks json data");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> configList = new ArrayList<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分裂的配置文件
|
||||||
|
*
|
||||||
|
* @param jsonArray
|
||||||
|
*/
|
||||||
|
private void getSplitConfigs(JsonArray jsonArray) {
|
||||||
|
Type type = new TypeToken<List<String>>() {
|
||||||
|
}.getType();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
configList = gson.fromJson(gson.toJson(jsonArray), type);
|
||||||
|
// StringBuilder configStringBuilder = new StringBuilder();
|
||||||
|
// for (String config : configList) {
|
||||||
|
// if (configStringBuilder.length() > 0) {
|
||||||
|
// configStringBuilder.append(",");
|
||||||
|
// }
|
||||||
|
// configStringBuilder.append(config);
|
||||||
|
// }
|
||||||
|
// Log.e(TAG, "getSplitConfigs: " + configStringBuilder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取obb配置文件
|
||||||
|
*
|
||||||
|
* @param jsonArray
|
||||||
|
*/
|
||||||
|
private void readOBBConfig(JsonArray jsonArray) {
|
||||||
|
if (TextUtils.isEmpty(unpackPath)) {
|
||||||
|
Log.e(TAG, "readOBBConfig: " + "unpack directory is empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Type type = new TypeToken<List<Expansions>>() {
|
||||||
|
}.getType();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
List<Expansions> expansionsList = gson.fromJson(gson.toJson(jsonArray), type);
|
||||||
|
if (null != expansionsList && expansionsList.size() > 0) {
|
||||||
|
for (Expansions expansions : expansionsList) {
|
||||||
|
if (copyObbFile(expansions)) {
|
||||||
|
Log.e(TAG, "readOBBConfig: " + "success");
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "readOBBConfig: " + "copy oob File failure");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean copyObbFile(Expansions expansions) {
|
||||||
|
String install_location = expansions.getInstall_location();
|
||||||
|
//install_location 不清楚是否还有其他定义
|
||||||
|
|
||||||
|
String file = expansions.getFile();
|
||||||
|
String install_path = expansions.getInstall_path();
|
||||||
|
|
||||||
|
if (TextUtils.isEmpty(file)) {
|
||||||
|
Log.e(TAG, "copyObbFile: " + "file path is empty");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
File localFile = new File(unpackPath + File.separator + file);
|
||||||
|
if (localFile.exists() && localFile.isFile()) {
|
||||||
|
File installFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + install_path);
|
||||||
|
Log.e(TAG, "copyObbFile: " + "localFile: " + localFile.getAbsolutePath());
|
||||||
|
Log.e(TAG, "copyObbFile: " + "installFile: " + installFile.getAbsolutePath());
|
||||||
|
try {
|
||||||
|
Path path = Paths.get(localFile.getAbsolutePath());
|
||||||
|
Files.copy(path, new FileOutputStream(installFile));
|
||||||
|
return true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e(TAG, "copyObbFile: " + "IOException" + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "copyObbFile: " + "localFile: " + "File not exists");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分裂的apk文件
|
||||||
|
*
|
||||||
|
* @param jsonArray
|
||||||
|
*/
|
||||||
|
private void getSplitApks(JsonArray jsonArray) {
|
||||||
|
Type type = new TypeToken<List<SplitApks>>() {
|
||||||
|
}.getType();
|
||||||
|
Gson gson = new Gson();
|
||||||
|
List<SplitApks> splitApksList = gson.fromJson(gson.toJson(jsonArray), type);
|
||||||
|
getApkFilePath(configList, splitApksList);
|
||||||
|
// if (null != splitApksList && splitApksList.size() > 0) {
|
||||||
|
// for (SplitApks splitApks : splitApksList) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param configList
|
||||||
|
* @param apkList configList 可以为空,为空解析split_apks对象中的base
|
||||||
|
* apkList应该不会为空
|
||||||
|
*/
|
||||||
|
private void getApkFilePath(List<String> configList, List<SplitApks> apkList) {
|
||||||
|
List<String> filePath = new ArrayList<>();
|
||||||
|
//应该直接获取SplitApks里面的file
|
||||||
|
if (null != configList && configList.size() > 0) {
|
||||||
|
//split_configs不为空的情况
|
||||||
|
filePath.add(unpackPath + File.separator + apkList.get(getFileFromId(apkList, "base")).getFile());
|
||||||
|
for (String config : configList) {
|
||||||
|
int position = getFileFromId(apkList, config);
|
||||||
|
if (position != -1) {
|
||||||
|
String file = apkList.get(position).getFile();
|
||||||
|
filePath.add(unpackPath + File.separator + file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Log.e(TAG, "installxApk: " + filePath.toString());
|
||||||
|
} else {
|
||||||
|
//split_configs为空的情况
|
||||||
|
int position = getFileFromId(apkList, "base");
|
||||||
|
if (position != -1) {
|
||||||
|
String file = apkList.get(position).getFile();
|
||||||
|
filePath.add(file);
|
||||||
|
Log.e(TAG, "installxApk: " + "base file = " + file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (filePath.size() != 0) {
|
||||||
|
installApk(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id获取文件
|
||||||
|
*
|
||||||
|
* @param splitApks
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
private int getFileFromId(List<SplitApks> splitApks, String id) {
|
||||||
|
int position = -1;
|
||||||
|
for (int i = 0; i < splitApks.size(); i++) {
|
||||||
|
if (splitApks.get(i).getId().equals(id)) {
|
||||||
|
position = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void installApk(final List<String> paths) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
installAppatPie(mContext, paths);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
public static void installAppatPie(Context context, List<String> apkFilePath) {
|
||||||
|
// File file = new File(apkFilePath);
|
||||||
|
PackageInstaller packageInstaller = context.getPackageManager().getPackageInstaller();
|
||||||
|
PackageInstaller.SessionParams sessionParams = new PackageInstaller.SessionParams(PackageInstaller
|
||||||
|
.SessionParams.MODE_FULL_INSTALL);
|
||||||
|
sessionParams.setSize(XAPKSize);
|
||||||
|
int sessionId = createSession(packageInstaller, sessionParams);
|
||||||
|
if (sessionId != -1) {
|
||||||
|
for (String apkPath : apkFilePath) {
|
||||||
|
copyApkFile(packageInstaller, sessionId, apkPath);
|
||||||
|
}
|
||||||
|
// boolean copySuccess = ;
|
||||||
|
// if (copySuccess) {
|
||||||
|
ToastUtil.show("正在安装应用");
|
||||||
|
install(packageInstaller, sessionId, context);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
private static void install(PackageInstaller packageInstaller, int sessionId, Context context) {
|
||||||
|
try {
|
||||||
|
PackageInstaller.Session session = packageInstaller.openSession(sessionId);
|
||||||
|
Intent intent = new Intent(context, InstallResultReceiver.class);
|
||||||
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(
|
||||||
|
context,
|
||||||
|
1, intent,
|
||||||
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
|
);
|
||||||
|
session.commit(pendingIntent.getIntentSender());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e(TAG, "install: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
private static int createSession(PackageInstaller packageInstaller, PackageInstaller.SessionParams sessionParams) {
|
||||||
|
int sessionId = -1;
|
||||||
|
try {
|
||||||
|
sessionId = packageInstaller.createSession(sessionParams);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e(TAG, "createSession: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
private static boolean copyApkFile(PackageInstaller pi, int sessionId, String apkFilePath) {
|
||||||
|
boolean success = false;
|
||||||
|
File apkFile = new File(apkFilePath);
|
||||||
|
PackageInstaller.Session session = null;
|
||||||
|
try {
|
||||||
|
session = pi.openSession(sessionId);
|
||||||
|
OutputStream out = session.openWrite(FileUtils.getFileNoExName(apkFilePath), 0, apkFile.length());
|
||||||
|
FileInputStream input = new FileInputStream(apkFile);
|
||||||
|
int read = 0;
|
||||||
|
byte[] buffer = new byte[65536];
|
||||||
|
// while (read != -1) {
|
||||||
|
// read = input.read(buffer);
|
||||||
|
// out.write(buffer, 0, read);
|
||||||
|
// }
|
||||||
|
while (true) {
|
||||||
|
read = input.read(buffer);
|
||||||
|
if (read == -1) {
|
||||||
|
session.fsync(out);
|
||||||
|
success = true;
|
||||||
|
out.close();
|
||||||
|
input.close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
out.write(buffer, 0, read);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Log.e("fht", "copyApkFile" + e.getMessage());
|
||||||
|
}
|
||||||
|
Log.e("fht", "copyApkFile" + "success = " + success);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
app/src/main/libs/classes.jar
Normal file
BIN
app/src/main/libs/classes.jar
Normal file
Binary file not shown.
@@ -24,6 +24,11 @@ allprojects {
|
|||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://jitpack.io' }
|
||||||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
||||||
}
|
}
|
||||||
|
gradle.projectsEvaluated {
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.compilerArgs.add('-Xbootclasspath/p:app/src/main/libs/classes.jar')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//task clean(type: Delete) {
|
//task clean(type: Delete) {
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module external.linked.project.id="jiaoguanyiInfo" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="java-gradle" name="Java-Gradle">
|
|
||||||
<configuration>
|
|
||||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
|
|
||||||
<option name="BUILDABLE" value="false" />
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
Reference in New Issue
Block a user