version:2.1.4
update:第一次联网逻辑更新,可能会造成后面不能继续其他请求 fix:修复第一次使用联网不能自动下载apk add:增加应用内部白名单管控,增加通过系统自定义版本号添加桌面快捷方式
This commit is contained in:
@@ -63,7 +63,6 @@ import com.mjsheng.myappstore.utils.ExampleUtil;
|
||||
import com.mjsheng.myappstore.utils.JGYUtils;
|
||||
import com.mjsheng.myappstore.utils.SPUtils;
|
||||
import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.SysSettingUtils;
|
||||
import com.mjsheng.myappstore.utils.ToastUtil;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
|
||||
@@ -537,7 +536,7 @@ public class DiscardActivity extends AppCompatActivity {
|
||||
// getDeselectBrowerID();//浏览器网址管控
|
||||
HTTPInterface.setBrowserBlackList(DiscardActivity.this);//浏览器网址管控
|
||||
HTTPInterface.setHomepagtag(DiscardActivity.this);//设置主页和标签
|
||||
HTTPInterface.setAppinsideWeb(DiscardActivity.this);//app内部网页管控
|
||||
// HTTPInterface.getAppinsideWeb(DiscardActivity.this);//app内部网页管控
|
||||
HTTPInterface.setHideDesktopIcon(DiscardActivity.this);//设置桌面图标隐藏
|
||||
getDeselectID();//ID管控
|
||||
getAppLimitApi();//写入可被安装的包名
|
||||
@@ -1213,7 +1212,7 @@ public class DiscardActivity extends AppCompatActivity {
|
||||
.subscribe(new Observer<ForceDownloadBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getForceDownload", "forceDownloadApi---onSubscribe");
|
||||
// Log.e("getForceDownload", "forceDownloadApi---onSubscribe");
|
||||
|
||||
}
|
||||
|
||||
@@ -1221,7 +1220,7 @@ public class DiscardActivity extends AppCompatActivity {
|
||||
public void onNext(ForceDownloadBean forceDownloadBean) {
|
||||
switch (forceDownloadBean.getCode()) {
|
||||
case 200:
|
||||
Log.e("getForceDownload", "isDownloading=" + BaseApplication.getInstance().isDownloading());
|
||||
// Log.e("getForceDownload", "isDownloading=" + BaseApplication.getInstance().isDownloading());
|
||||
BaseApplication.getInstance().checkIsDownloading();
|
||||
if (!BaseApplication.getInstance().isDownloading()) {
|
||||
Aria.download(this).removeAllTask(true);
|
||||
@@ -1236,22 +1235,22 @@ public class DiscardActivity extends AppCompatActivity {
|
||||
break;
|
||||
case -200:
|
||||
boolean qch_force_app = Settings.System.putString(DiscardActivity.this.getContentResolver(), "qch_force_app", "invalid");
|
||||
Log.e("fht", "qch_force_app:" + qch_force_app);
|
||||
// Log.e("fht", "qch_force_app:" + qch_force_app);
|
||||
break;
|
||||
default:
|
||||
Log.e("getForceDownload", forceDownloadBean.getMsg());
|
||||
// Log.e("getForceDownload", forceDownloadBean.getMsg());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getForceDownload", "forceDownloadApi=onError:");
|
||||
// Log.e("getForceDownload", "forceDownloadApi=onError:");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getForceDownload", "forceDownloadApi---onComplete");
|
||||
// Log.e("getForceDownload", "forceDownloadApi---onComplete");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -364,6 +364,11 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
|
||||
@Override
|
||||
public void setSystemSettingFinished() {
|
||||
mPresenter.getROMApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getROMAppFinished() {
|
||||
mPresenter.getDeveloper();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ public class MainContact {
|
||||
void setAppinsideWebFinished();
|
||||
//获取系统其他管控设置结束
|
||||
void setSystemSettingFinished();
|
||||
//获取自定义版本内置app
|
||||
void getROMAppFinished();
|
||||
//获取开发者选项结束
|
||||
void getDeveloperFinished();
|
||||
//设置开机动画
|
||||
@@ -128,6 +130,8 @@ public class MainContact {
|
||||
void setAppinsideWeb();
|
||||
//获取系统其他管控设置
|
||||
void setSystemSetting();
|
||||
//获取自定义版本内置app
|
||||
void getROMApp();
|
||||
//获取开发者选项
|
||||
void getDeveloper();
|
||||
//设置开机动画
|
||||
|
||||
@@ -215,6 +215,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
int oldState = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 0);
|
||||
Log.e("getLockedState", "qch_unlock_ipad: " + oldState);
|
||||
//后台1是锁定,底层0是锁定
|
||||
SPUtils.put(mContext, "first_connect", 1);
|
||||
if (locked == 1) {
|
||||
if (oldState == 1) {
|
||||
Log.e("getLockedState", "onNext: " + "state changed , reset devices");
|
||||
@@ -222,7 +223,6 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
}
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_unlock_ipad", 0);
|
||||
} else {
|
||||
SPUtils.put(mContext, "first_connect", 1);
|
||||
// SysSettingUtils.setEnableSetting(mContext);
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_unlock_ipad", 1);
|
||||
}
|
||||
@@ -688,6 +688,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
boolean write = Settings.System.putString(mContext.getContentResolver(), "only_jgy_shortcut_list", "");
|
||||
Log.e(TAG, "onNext: only_jgy_shortcut_list: " + write);
|
||||
Log.e("getAppLimit", "onNext: " + bodyString);
|
||||
mView.getAppLimitFinished("");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -712,11 +713,12 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getDeviceBatch(String packageList) {
|
||||
if (JGYUtils.isOfficialVersion()) {
|
||||
if (JGYUtils.isOfficialVersion() || TextUtils.isEmpty(packageList)) {
|
||||
mView.getDeviceBatchFinished();
|
||||
return;
|
||||
}
|
||||
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 0);
|
||||
Log.e(TAG, "getDeviceBatch: " + locked);
|
||||
if (locked == 0) {
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getBatchObservable()
|
||||
@@ -1290,72 +1292,14 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void setAppinsideWeb() {
|
||||
// if (JGYUtils.isOfficialVersion()) {
|
||||
getAppinsideWeb();
|
||||
// } else {
|
||||
// getNewAppinsideWeb();
|
||||
// }
|
||||
HTTPInterface.getAppinsideWeb(mContext, new HTTPInterface.GetAppinsideWebCallback() {
|
||||
@Override
|
||||
public void ononComplete() {
|
||||
mView.setAppinsideWebFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getAppinsideWeb() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppinsideWebObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse<List<Appground>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("setAppinsideWeb", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<Appground>> listBaseResponse) {
|
||||
Log.e("setAppinsideWeb", "onNext: ");
|
||||
JGYUtils.getInstance().setAppinsideWeb(listBaseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("setAppinsideWeb", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("setAppinsideWeb", "onComplete: ");
|
||||
mView.setAppinsideWebFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getNewAppinsideWeb() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getNewAppinsideWebObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getNewAppinsideWeb", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse listBaseResponse) {
|
||||
Log.e("getNewAppinsideWeb", "onNext: ");
|
||||
JGYUtils.getInstance().setNewAppinsideWeb(listBaseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getNewAppinsideWeb", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getNewAppinsideWeb", "onComplete: ");
|
||||
mView.setAppinsideWebFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSystemSetting() {
|
||||
@@ -1414,6 +1358,48 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getROMApp() {
|
||||
String customVersion = Utils.getCustomVersion();
|
||||
Log.e(TAG, "getROMApp: " + customVersion);
|
||||
NetInterfaceManager.getInstance().getCustomROMAppApi()
|
||||
.getROMApp(NetInterfaceManager.HTTP_KEY, customVersion)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getROMApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("getROMApp", "onNext: " + baseResponse);
|
||||
if (baseResponse.code == OK) {
|
||||
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(baseResponse.data)).getAsJsonObject();
|
||||
String packageName = jsonObject.get("package_name").getAsString();
|
||||
Settings.System.putString(mContext.getContentResolver(), "jgy_customromapp", packageName);
|
||||
} else {
|
||||
Log.e("getROMApp", "onNext: " + baseResponse.msg);
|
||||
Settings.System.putString(mContext.getContentResolver(), "jgy_customromapp", "");
|
||||
onComplete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getROMApp", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getROMApp", "onComplete: ");
|
||||
mView.getROMAppFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDeveloper() {
|
||||
NetInterfaceManager.getInstance().getDeveloperControl()
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.mjsheng.myappstore.bean;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class NewAppground implements Serializable {
|
||||
public class TTAppground implements Serializable {
|
||||
private static final long serialVersionUID = -2071117846816082338L;
|
||||
private String packages;
|
||||
private String address;
|
||||
@@ -37,4 +39,20 @@ public class NewAppground implements Serializable {
|
||||
public String toString() {
|
||||
return packages + "," + address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof TTAppground) {
|
||||
TTAppground appground = (TTAppground) obj;
|
||||
return packages.equalsIgnoreCase(appground.getPackages())
|
||||
&& address.equalsIgnoreCase(appground.getAddress())
|
||||
&& type == appground.getType();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import com.mjsheng.myappstore.bean.ForceDownloadBean;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadData;
|
||||
import com.mjsheng.myappstore.bean.LogoImg;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchBean;
|
||||
import com.mjsheng.myappstore.bean.NewAppground;
|
||||
import com.mjsheng.myappstore.bean.StudentsInfo;
|
||||
import com.mjsheng.myappstore.network.api.AppLimitApi;
|
||||
import com.mjsheng.myappstore.network.api.BrankPicApi;
|
||||
@@ -30,6 +29,7 @@ import com.mjsheng.myappstore.network.api.newapi.BrowserBookmarksApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.BrowserListApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.CheckTestUpdateApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.CheckUpdateApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.CustomROMApp;
|
||||
import com.mjsheng.myappstore.network.api.newapi.DesktopIconApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.DevicesLockedStateApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.GetBatchApi;
|
||||
@@ -177,7 +177,6 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
||||
public Observable<BaseResponse<BrowserData>> getBrowserListSettingObservable() {
|
||||
return mRetrofit
|
||||
.create(BrowserListApi.class)
|
||||
@@ -313,6 +312,7 @@ public class NetInterfaceManager {
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getDeveloperControl() {
|
||||
return mRetrofit.create(GetDeveloper.class)
|
||||
.getDeveloperState(Utils.getSerial())
|
||||
@@ -320,8 +320,6 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* API
|
||||
@@ -399,4 +397,8 @@ public class NetInterfaceManager {
|
||||
.create(CheckUpdateApi.class);
|
||||
}
|
||||
|
||||
public CustomROMApp getCustomROMAppApi() {
|
||||
return mRetrofit.create(CustomROMApp.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -411,77 +411,81 @@ public class HTTPInterface {
|
||||
});
|
||||
}
|
||||
|
||||
public interface GetAppinsideWebCallback {
|
||||
void ononComplete();
|
||||
}
|
||||
|
||||
synchronized public static void setAppinsideWeb(final Context context) {
|
||||
OkGo.post(URLAddress.SET_APPINSIDEWEB)
|
||||
.params("key", NetInterfaceManager.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.execute(new StringCallback() {
|
||||
synchronized public static void getAppinsideWeb(Context context, GetAppinsideWebCallback callback) {
|
||||
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform) {
|
||||
setAppinsideWeb(callback);
|
||||
}else {
|
||||
setNewAppinsideWeb(callback);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setAppinsideWeb(GetAppinsideWebCallback callback) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppinsideWebObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse<List<Appground>>>() {
|
||||
@Override
|
||||
public void onSuccess(String s, Call call, Response response) {
|
||||
try {
|
||||
JSONObject jsonObject = JSON.parseObject(s);
|
||||
int code = jsonObject.getInteger("code");
|
||||
String msg = jsonObject.getString("msg");
|
||||
if (code == 200) {
|
||||
String data = jsonObject.getString("data");
|
||||
List<Appground> appgrounds = JSON.parseArray(data, Appground.class);
|
||||
if (appgrounds != null && appgrounds.size() > 0) {
|
||||
String strings = "";
|
||||
String packageList = "";//单条管控名单
|
||||
for (Appground appground : appgrounds) {
|
||||
if (appground.getAddress().equals("")) {
|
||||
packageList += appground.getPackages() + ",";
|
||||
} else {
|
||||
strings += appground.toString() + ";";
|
||||
}
|
||||
}
|
||||
if (packageList.length() > 0) {
|
||||
//app内所有的网页禁止
|
||||
// packageList = packageList.substring(0, packageList.length() - 1);
|
||||
//去掉多余的,
|
||||
Log.e("setAppinsideWeb ", "packageList:" + packageList);
|
||||
Intent qch_app_website = new Intent("qch_app_website")
|
||||
.setPackage("com.android.settings");
|
||||
qch_app_website.putExtra("package_name", packageList);
|
||||
context.sendBroadcast(qch_app_website);
|
||||
} else {
|
||||
sendAllweb(context);
|
||||
}
|
||||
if (strings.length() > 0) {
|
||||
//app内单个网页地址禁止打开
|
||||
// strings = strings.substring(0, strings.length() - 1);
|
||||
//去掉多余的;
|
||||
Log.e("setAppinsideWeb ", "strings:" + strings);
|
||||
Intent intent = new Intent("qch_app_inside_website")
|
||||
.setPackage("com.android.settings");
|
||||
intent.putExtra("websitelist", strings);
|
||||
context.sendBroadcast(intent);
|
||||
} else {
|
||||
sendwebUrl(context);
|
||||
}
|
||||
}
|
||||
} else if (code == 400) {
|
||||
//列表为空的情况
|
||||
sendAllweb(context);
|
||||
sendwebUrl(context);
|
||||
// ToastUtil.show(msg);
|
||||
Log.e("fht", "setAppinsideWeb" + msg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("setAppinsideWeb", e.getMessage());
|
||||
// ToastUtil.show("数据错误");
|
||||
}
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("setAppinsideWeb", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
// ToastUtil.show("网络连接失败");
|
||||
public void onNext(@NonNull BaseResponse<List<Appground>> listBaseResponse) {
|
||||
Log.e("setAppinsideWeb", "onNext: " + listBaseResponse);
|
||||
JGYUtils.getInstance().setAppinsideWeb(listBaseResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("setAppinsideWeb", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("setAppinsideWeb", "onComplete: ");
|
||||
callback.ononComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setNewAppinsideWeb(GetAppinsideWebCallback callback) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getNewAppinsideWebObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getNewAppinsideWeb", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse listBaseResponse) {
|
||||
Log.e("getNewAppinsideWeb", "onNext: " + listBaseResponse);
|
||||
long time1 = System.currentTimeMillis();
|
||||
JGYUtils.getInstance().setNewAppinsideWeb(listBaseResponse);
|
||||
Log.e(TAG, "setWhiteApp: time = " + (System.currentTimeMillis() - time1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getNewAppinsideWeb", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getNewAppinsideWeb", "onComplete: ");
|
||||
callback.ononComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static void sendAllweb(Context context) {
|
||||
Intent intent = new Intent("qch_app_website")
|
||||
.setPackage("com.android.settings");
|
||||
|
||||
@@ -60,5 +60,7 @@ public class URLAddress {
|
||||
public final static String GET_LOGO_IMG = HTTP_TAG_HEAD_NEW + "Sn/getLogoImg";
|
||||
//开发人员选项开关
|
||||
public final static String GET_DEVELOPER = HTTP_TAG_HEAD_NEW + "Sn/getDeveloper";
|
||||
//通过固件名获取内置应用
|
||||
public final static String GET_ROM_APP = HTTP_TAG_HEAD_NEW + "And/getFirmwareApp";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mjsheng.myappstore.network.api.newapi;
|
||||
|
||||
import com.mjsheng.myappstore.bean.BaseResponse;
|
||||
import com.mjsheng.myappstore.network.URLAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface CustomROMApp {
|
||||
@FormUrlEncoded
|
||||
@POST(URLAddress.GET_ROM_APP)
|
||||
Observable<BaseResponse> getROMApp(
|
||||
@Field("key") String key,
|
||||
@Field("version_number") String version_number
|
||||
);
|
||||
}
|
||||
@@ -2,11 +2,8 @@ package com.mjsheng.myappstore.network.api.newapi;
|
||||
|
||||
|
||||
import com.mjsheng.myappstore.bean.BaseResponse;
|
||||
import com.mjsheng.myappstore.bean.NewAppground;
|
||||
import com.mjsheng.myappstore.network.URLAddress;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.mjsheng.myappstore.server.GuardService;
|
||||
import com.mjsheng.myappstore.server.LogcatService;
|
||||
import com.mjsheng.myappstore.server.MainService;
|
||||
import com.mjsheng.myappstore.server.StepService;
|
||||
import com.mjsheng.myappstore.utils.JGYUtils;
|
||||
import com.mjsheng.myappstore.utils.SPUtils;
|
||||
|
||||
public class BootReceiver extends BroadcastReceiver {
|
||||
private String TAG = BootReceiver.class.getSimpleName() + ":myappstore";
|
||||
@@ -28,6 +30,7 @@ public class BootReceiver extends BroadcastReceiver {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", "");
|
||||
}
|
||||
startService(context);
|
||||
SPUtils.put(context, JGYUtils.JGY_APPINSIDE_FIRST_WRITE,0);
|
||||
break;
|
||||
case BOOT_COMPLETED:
|
||||
case Intent.ACTION_BATTERY_CHANGED:
|
||||
|
||||
@@ -1068,7 +1068,13 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private void setAPPinsideWebsite(String s) {
|
||||
//禁止app内部网页访问,包名用,隔开
|
||||
HTTPInterface.setAppinsideWeb(mContext);//app内部网页管控
|
||||
HTTPInterface.getAppinsideWeb(mContext, new HTTPInterface.GetAppinsideWebCallback() {
|
||||
@Override
|
||||
public void ononComplete() {
|
||||
Log.e(TAG, "ononComplete: setAPPinsideWebsite");
|
||||
}
|
||||
});//app内部网页管控
|
||||
|
||||
// if (TextUtils.isEmpty(s)) {
|
||||
// Log.e(TAG, "setAPPinsideWebsite extras is null");
|
||||
//
|
||||
|
||||
@@ -49,16 +49,16 @@ public class NewAppReceiver extends BroadcastReceiver {
|
||||
String packageName = intent.getDataString().replace("package:", "");
|
||||
switch (action) {
|
||||
case Intent.ACTION_PACKAGE_ADDED:
|
||||
state = "安装了";
|
||||
state = "安装了:";
|
||||
break;
|
||||
case Intent.ACTION_PACKAGE_REPLACED:
|
||||
state = "重装了";
|
||||
state = "重装了:";
|
||||
break;
|
||||
case Intent.ACTION_PACKAGE_REMOVED:
|
||||
state = "卸载了";
|
||||
state = "卸载了:";
|
||||
break;
|
||||
default:
|
||||
state = "未知";
|
||||
state = "未知:";
|
||||
break;
|
||||
}
|
||||
Log.e(TAG, "sendAppInfo: " + state + packageName);
|
||||
|
||||
@@ -61,7 +61,6 @@ import com.mjsheng.myappstore.utils.ForegroundAppUtil;
|
||||
import com.mjsheng.myappstore.utils.MySQLData;
|
||||
import com.mjsheng.myappstore.utils.SPUtils;
|
||||
import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.SysSettingUtils;
|
||||
import com.mjsheng.myappstore.utils.TimeUtils;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
|
||||
@@ -812,7 +811,7 @@ public class DiscardServer extends Service {
|
||||
.subscribe(new Observer<ForceDownloadBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getForceDownload", "forceDownloadApi---onSubscribe");
|
||||
// Log.e("getForceDownload", "forceDownloadApi---onSubscribe");
|
||||
|
||||
}
|
||||
|
||||
@@ -820,7 +819,7 @@ public class DiscardServer extends Service {
|
||||
public void onNext(ForceDownloadBean forceDownloadBean) {
|
||||
switch (forceDownloadBean.getCode()) {
|
||||
case 200:
|
||||
Log.e("getForceDownload", "isDownloading=" + BaseApplication.getInstance().isDownloading());
|
||||
// Log.e("getForceDownload", "isDownloading=" + BaseApplication.getInstance().isDownloading());
|
||||
BaseApplication.getInstance().checkIsDownloading();
|
||||
if (!BaseApplication.getInstance().isDownloading()) {
|
||||
Aria.download(this).removeAllTask(true);
|
||||
@@ -835,10 +834,10 @@ public class DiscardServer extends Service {
|
||||
break;
|
||||
case -200:
|
||||
boolean qch_force_app = Settings.System.putString(getContentResolver(), "qch_force_app", "invalid");
|
||||
Log.e("getForceDownload", "qch_force_app:" + qch_force_app);
|
||||
// Log.e("getForceDownload", "qch_force_app:" + qch_force_app);
|
||||
break;
|
||||
default:
|
||||
Log.e("getForceDownload", forceDownloadBean.getMsg());
|
||||
// Log.e("getForceDownload", forceDownloadBean.getMsg());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1185,7 +1184,7 @@ public class DiscardServer extends Service {
|
||||
HTTPInterface.setJpushTags(DiscardServer.this);
|
||||
sendMACaddress();
|
||||
HTTPInterface.setBrowserBlackList(DiscardServer.this);//浏览器网址管控
|
||||
HTTPInterface.setAppinsideWeb(DiscardServer.this);//app内部网页管控
|
||||
// HTTPInterface.getAppinsideWeb(DiscardServer.this);//app内部网页管控
|
||||
HTTPInterface.setHomepagtag(DiscardServer.this);//设置主页和标签
|
||||
HTTPInterface.setHideDesktopIcon(DiscardServer.this);//设置桌面图标隐藏
|
||||
// getAppLimitApi();//获取可以写入的app包名
|
||||
|
||||
@@ -139,7 +139,7 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
JPushInterface.init(this);
|
||||
if (MainActivity.isForeground) {
|
||||
Log.e(TAG, "onStartCommand: MainActivity: isForeground: " + MainActivity.isForeground);
|
||||
Log.e(TAG, "onStartCommand: MainService: isForeground: " + MainActivity.isForeground);
|
||||
} else {
|
||||
// if (((SystemClock.elapsedRealtime() - startCommandTime) < 60000) && startCommandTime != 0) {
|
||||
// Log.e(TAG, "onStartCommand: " + "启动时间过短");
|
||||
@@ -394,12 +394,15 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
installApkByPackage(filePath, packageName);
|
||||
} else if (!TextUtils.isEmpty(filePath)) {
|
||||
String pkg = ApkUtils.getPackageName(MainService.this, filePath);
|
||||
Log.e(TAG, "onReceive: " + "pkg: " + pkg + "\tfilePath: " + filePath);
|
||||
installApkByPackage(filePath, pkg);
|
||||
if (TextUtils.isEmpty(pkg)) {
|
||||
Log.e(TAG, "onReceive: " + "unknow packageName");
|
||||
} else {
|
||||
Log.e(TAG, "onReceive: " + "pkg: " + pkg + "\tfilePath: " + filePath);
|
||||
installApkByPackage(filePath, pkg);
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "onReceive: " + "no filePath and packageName");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,11 +414,11 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
synchronized private void installApkByPackage(String filePath, String pkg) {
|
||||
String oldListString = Settings.System.getString(getContentResolver(), "qch_app_forbid");
|
||||
HashSet<String> packageList = new HashSet<>(Arrays.asList(oldListString.split(",")));
|
||||
packageList.add(pkg);
|
||||
String join = String.join(",", packageList);
|
||||
Log.e(TAG, "installApkByPackage: " + join);
|
||||
Settings.System.putString(getContentResolver(), "qch_app_forbid", join);
|
||||
ApkUtils.installApp(MainService.this, filePath);
|
||||
if (!packageList.contains(pkg)) {
|
||||
Log.e(TAG, "installApkByPackage: " + "packageName: " + pkg + " not in whitelist");
|
||||
} else {
|
||||
ApkUtils.installApp(MainService.this, filePath);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -441,18 +444,19 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
@Override
|
||||
public void setLockedState(boolean loocked) {
|
||||
if (loocked) {
|
||||
Log.e(TAG, "setLockedState: " + netWorkIsRunning);
|
||||
//上传APP信息
|
||||
ApkUtils.getAppInfo(this);
|
||||
if (netWorkIsRunning) {
|
||||
//如果正在执行,不执行
|
||||
return;
|
||||
}
|
||||
//发送设备mac地址和信息
|
||||
mPresenter.sendMACAddress();
|
||||
//设置极光推送别名
|
||||
mPresenter.setJpushAlias();
|
||||
//设置极光推送标签
|
||||
SaveListUtils.getList();
|
||||
if (netWorkIsRunning) {
|
||||
//如果正在执行,不执行
|
||||
// return;
|
||||
}
|
||||
//获取系统管控
|
||||
mPresenter.getSystemSettingbegin();
|
||||
netWorkIsRunning = true;
|
||||
@@ -469,7 +473,7 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
*/
|
||||
@Override
|
||||
public void setFirstConnect(boolean state) {
|
||||
Log.e(TAG, "isFirstConnect: " + "end request");
|
||||
Log.e(TAG, "isFirstConnect: " + "end request: " + state);
|
||||
if (state) {
|
||||
mPresenter.setDisableSetting();
|
||||
} else {
|
||||
@@ -576,6 +580,11 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
|
||||
@Override
|
||||
public void setSystemSettingFinished() {
|
||||
mPresenter.getROMApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getROMAppFinished() {
|
||||
mPresenter.getDeveloper();
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,9 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -1088,14 +1090,23 @@ public class ApkUtils {
|
||||
}
|
||||
Log.e("addShortcut", "addShortcut: " + result);
|
||||
String[] stringList = result.split(",");
|
||||
List<String> packages = new ArrayList<>(Arrays.asList(stringList));
|
||||
HashSet<String> packages = new HashSet<>(Arrays.asList(stringList));
|
||||
String romapps = Settings.System.getString(context.getContentResolver(), "jgy_customromapp");
|
||||
Log.e(TAG, "addShortcut: romapps: " + romapps);
|
||||
HashSet<String> appSet = new HashSet<>();
|
||||
if (!TextUtils.isEmpty(romapps)) {
|
||||
appSet = new HashSet<>(Arrays.asList(romapps.split(",")));
|
||||
packages.addAll(appSet);
|
||||
}
|
||||
StringBuilder installedListBuilder = new StringBuilder();
|
||||
for (String s : packages) {
|
||||
if ("com.jiaoguanyi.store".equals(s) || "com.jiaoguanyi.appstore".equals(s)) {
|
||||
continue;
|
||||
}
|
||||
if (ApkUtils.isSystemApp(context, s)) {
|
||||
continue;
|
||||
if (!appSet.contains(s)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!ApkUtils.isAvailable(context, s)) {
|
||||
continue;
|
||||
|
||||
@@ -26,7 +26,9 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.FileUtils;
|
||||
import com.blankj.utilcode.util.PathUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mjsheng.myappstore.BuildConfig;
|
||||
import com.mjsheng.myappstore.base.BaseApplication;
|
||||
import com.mjsheng.myappstore.bean.Appground;
|
||||
@@ -34,7 +36,7 @@ import com.mjsheng.myappstore.bean.BaseResponse;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadData;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchBean;
|
||||
import com.mjsheng.myappstore.bean.NetAndLaunchData;
|
||||
import com.mjsheng.myappstore.bean.NewAppground;
|
||||
import com.mjsheng.myappstore.bean.TTAppground;
|
||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||
|
||||
import java.io.File;
|
||||
@@ -43,6 +45,7 @@ import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
@@ -52,6 +55,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE;
|
||||
|
||||
@@ -313,7 +317,7 @@ public class JGYUtils {
|
||||
}
|
||||
|
||||
|
||||
public void setAppinsideWeb(BaseResponse<List<Appground>> response) {
|
||||
synchronized public void setAppinsideWeb(BaseResponse<List<Appground>> response) {
|
||||
if (response.code == 200) {
|
||||
List<Appground> appgrounds = response.data;
|
||||
if (appgrounds != null && appgrounds.size() > 0) {
|
||||
@@ -364,73 +368,25 @@ public class JGYUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public void setNewAppinsideWeb(BaseResponse response) {
|
||||
/**
|
||||
* @param response 黑白名单都可以管控
|
||||
*/
|
||||
synchronized public void setNewAppinsideWeb(BaseResponse response) {
|
||||
if (response.code == 200) {
|
||||
String jsonString = JSONArray.toJSONString(response.data);
|
||||
List<NewAppground> appgrounds = JSONObject.parseArray(jsonString, NewAppground.class);
|
||||
StringBuilder whiteList = new StringBuilder();
|
||||
StringBuilder blackList = new StringBuilder();
|
||||
StringBuilder packageList = new StringBuilder();//单条管控名单
|
||||
List<TTAppground> appgrounds = JSONObject.parseArray(jsonString, TTAppground.class);
|
||||
List<TTAppground> whiteApp = new ArrayList<>();
|
||||
List<TTAppground> blackApp = new ArrayList<>();
|
||||
if (appgrounds != null && appgrounds.size() > 0) {
|
||||
for (NewAppground appground : appgrounds) {
|
||||
for (TTAppground appground : appgrounds) {
|
||||
if (appground.getType() == 1) {
|
||||
if (TextUtils.isEmpty(appground.getAddress())) {
|
||||
return;
|
||||
} else {
|
||||
if (whiteList.length() > 0) {
|
||||
whiteList.append(",");
|
||||
}
|
||||
whiteList.append(appground.getAddress());
|
||||
}
|
||||
whiteApp.add(appground);
|
||||
} 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());
|
||||
}
|
||||
blackApp.add(appground);
|
||||
}
|
||||
}
|
||||
// TODO: 2021/6/9
|
||||
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) {
|
||||
//app内所有的网页禁止
|
||||
Log.e("setAppinsideWeb ", "packageList:" + packageList.toString());
|
||||
Intent qch_app_website = new Intent("qch_app_website")
|
||||
.setPackage("com.android.settings");
|
||||
qch_app_website.putExtra("package_name", packageList.toString());
|
||||
mContext.sendBroadcast(qch_app_website);
|
||||
} else {
|
||||
sendAllweb(mContext);
|
||||
}
|
||||
if (blackList.length() > 0) {
|
||||
//app内单个网页地址禁止打开
|
||||
Log.e("setAppinsideWeb ", "blackList:" + blackList.toString());
|
||||
Intent intent = new Intent("qch_app_inside_website")
|
||||
.setPackage("com.android.settings");
|
||||
intent.putExtra("websitelist", blackList.toString());
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
sendwebUrl(mContext);
|
||||
}
|
||||
|
||||
|
||||
setWhiteApp(whiteApp);
|
||||
setBlackApp(blackApp);
|
||||
}
|
||||
} else if (response.code == 400) {
|
||||
//列表为空的情况
|
||||
@@ -439,24 +395,258 @@ public class JGYUtils {
|
||||
//ToastUtil.show(msg);
|
||||
Log.e("setAppinsideWeb", "setAppinsideWeb: " + response.msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String JGY_APPINSIDE_WHITELIST = "JGY_APPINSIDE_WHITELIST";
|
||||
public static final String JGY_APPINSIDE_FIRST_WRITE = "JGY_APPINSIDE_FIRST_WRITE";
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
synchronized private void setWhiteApp(List<TTAppground> appgrounds) {
|
||||
int first = (int) SPUtils.get(mContext, JGYUtils.JGY_APPINSIDE_FIRST_WRITE, 0);
|
||||
if (first == 0) {
|
||||
for (TTAppground appground : appgrounds) {
|
||||
if (TextUtils.isEmpty(appground.getAddress())) {
|
||||
Log.e(TAG, "setWhiteApp: " + "skip: " + appground.getAddress());
|
||||
} else {
|
||||
addPackage(appground.getPackages());
|
||||
addToWhitelist(appground.getPackages(), appground.getAddress());
|
||||
}
|
||||
}
|
||||
SPUtils.put(mContext, JGYUtils.JGY_APPINSIDE_FIRST_WRITE, 1);
|
||||
} else {
|
||||
List<TTAppground> old = getOldWhitelist();
|
||||
comparedAppground(old, appgrounds);
|
||||
setWhiteList(appgrounds);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void sendAllweb(Context context) {
|
||||
synchronized private void comparedAppground(List<TTAppground> oldAppgrounds, List<TTAppground> newAppgrounds) {
|
||||
List<TTAppground> addAppgrounds = new ArrayList<>();
|
||||
List<TTAppground> deleteAppgrounds = new ArrayList<>();
|
||||
List<TTAppground> changedAppgrounds = new ArrayList<>();
|
||||
|
||||
HashMap<String, TTAppground> oldAppgroundsMap = new HashMap<>();
|
||||
HashMap<String, TTAppground> newAppgroundsMap = new HashMap<>();
|
||||
for (TTAppground appground : oldAppgrounds) {
|
||||
oldAppgroundsMap.put(appground.getPackages(), appground);
|
||||
}
|
||||
for (TTAppground appground : newAppgrounds) {
|
||||
newAppgroundsMap.put(appground.getPackages(), appground);
|
||||
}
|
||||
|
||||
for (TTAppground appground : oldAppgrounds) {
|
||||
String packageName = appground.getPackages();
|
||||
TTAppground mapground = newAppgroundsMap.get(packageName);
|
||||
if (mapground == null) {
|
||||
deleteAppgrounds.add(appground);
|
||||
} else {
|
||||
if (!appground.equals(mapground)) {
|
||||
changedAppgrounds.add(mapground);
|
||||
}
|
||||
}
|
||||
newAppgroundsMap.remove(packageName);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, TTAppground> entry : newAppgroundsMap.entrySet()) {
|
||||
addAppgrounds.add(entry.getValue());
|
||||
}
|
||||
|
||||
Log.e(TAG, "comparedAppground: addAppgrounds.size():" + addAppgrounds.size());
|
||||
Log.e(TAG, "comparedAppground: deleteAppgrounds.size():" + deleteAppgrounds.size());
|
||||
Log.e(TAG, "comparedAppground: changedAppgrounds.size():" + changedAppgrounds.size());
|
||||
|
||||
addAppground(addAppgrounds);
|
||||
deleteAppground(deleteAppgrounds);
|
||||
changeAppground(oldAppgroundsMap, changedAppgrounds);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addAppground(List<TTAppground> appgroundList) {
|
||||
for (TTAppground appground : appgroundList) {
|
||||
addPackage(appground.getPackages());
|
||||
addToWhitelist(appground.getPackages(), appground.getAddress());
|
||||
Log.e("comparedAppground", "addAppground: " + appground.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteAppground(List<TTAppground> appgroundList) {
|
||||
for (TTAppground appground : appgroundList) {
|
||||
deleteWhitelistUrl(appground.getPackages(), appground.getAddress());
|
||||
Log.e("comparedAppground", "deleteAppground: " + appground.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
private void changeAppground(HashMap<String, TTAppground> oldAppgroundsMap, List<TTAppground> appgroundList) {
|
||||
for (TTAppground appground : appgroundList) {
|
||||
HashSet<String> newURL = new HashSet<>(Arrays.asList(appground.getAddress().split(",")));
|
||||
TTAppground oldAppground = oldAppgroundsMap.get(appground.getPackages());
|
||||
HashSet<String> oldURL = new HashSet<>(Arrays.asList(oldAppground.getAddress().split(",")));
|
||||
for (String url : newURL) {
|
||||
if (oldURL.contains(url)) {
|
||||
oldURL.remove(url);
|
||||
} else {
|
||||
addToWhitelist(appground.getPackages(), url);
|
||||
Log.e("comparedAppground", "addToWhitelist: " + url);
|
||||
}
|
||||
}
|
||||
for (String url : oldURL) {
|
||||
deleteWhitelistUrl(appground.getPackages(), url);
|
||||
Log.e("comparedAppground", "deleteWhitelistUrl: " + url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<TTAppground> getOldWhitelist() {
|
||||
String whiteListString = (String) SPUtils.get(mContext, JGY_APPINSIDE_WHITELIST, "");
|
||||
Log.e(TAG, "getOldWhitelist: " + whiteListString);
|
||||
Gson gson = new Gson();
|
||||
Type listType = new TypeToken<List<TTAppground>>() {
|
||||
}.getType();
|
||||
List<TTAppground> whiteList = gson.fromJson(whiteListString, listType);
|
||||
if (whiteList == null) {
|
||||
whiteList = new ArrayList<>();
|
||||
}
|
||||
return whiteList;
|
||||
}
|
||||
|
||||
private void setWhiteList(List<TTAppground> appgrounds) {
|
||||
String data = new Gson().toJson(appgrounds);
|
||||
SPUtils.put(mContext, JGY_APPINSIDE_WHITELIST, data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param pkg 开启app白名单
|
||||
*/
|
||||
synchronized private void addPackage(String pkg) {
|
||||
Log.e(TAG, "addPackage: " + pkg);
|
||||
Intent intent26 = new Intent();
|
||||
intent26.setAction("qch_app_inside_website");
|
||||
intent26.putExtra("WEBURLforbidapp", pkg);
|
||||
intent26.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent26);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pkg
|
||||
* @param urls 添加app白名单
|
||||
*/
|
||||
synchronized private void addToWhitelist(String pkg, String urls) {
|
||||
if (TextUtils.isEmpty(urls.trim())) {
|
||||
Log.e(TAG, "addToWhitelist: " + "urls is NULL");
|
||||
return;
|
||||
}
|
||||
HashSet<String> urlSet = new HashSet<>(Arrays.asList(urls.trim().split(",")));
|
||||
for (String url : urlSet) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
continue;
|
||||
}
|
||||
Intent intent25 = new Intent();
|
||||
intent25.setAction("qch_app_setAddAppWhitWebUid");
|
||||
intent25.putExtra("AddAppWhitWebUidPackage", pkg);
|
||||
intent25.putExtra("AddAppWhitWebUid", url);
|
||||
intent25.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent25);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pkg
|
||||
* @param urls 删除某个app 内某个白名单
|
||||
*/
|
||||
synchronized private void deleteWhitelistUrl(String pkg, String urls) {
|
||||
if (TextUtils.isEmpty(urls.trim())) {
|
||||
Log.e(TAG, "addToWhitelist: " + "urls is NULL");
|
||||
return;
|
||||
}
|
||||
HashSet<String> urlSet = new HashSet<>(Arrays.asList(urls.trim().split(",")));
|
||||
for (String url : urlSet) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
continue;
|
||||
}
|
||||
Intent intent25 = new Intent();
|
||||
intent25.setAction("qch_app_setAddAppWhitWebUid");
|
||||
intent25.putExtra("DelAppWhitWebUidPackage", pkg);
|
||||
intent25.putExtra("DelAppWhitWebUid", url);
|
||||
intent25.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent25);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pkg 取消某个白名单app
|
||||
*/
|
||||
// TODO: 2021/6/16 底层未实现功能
|
||||
synchronized private void disableAppWhitelist(String pkg) {
|
||||
Log.e(TAG, "disableAppWhitelist: " + pkg);
|
||||
Intent intent24 = new Intent();
|
||||
intent24.setAction("qch_app_setDelAppWhitUid");
|
||||
intent24.putExtra("DelAppWhitUidPackage", pkg);
|
||||
intent24.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent24);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param appgrounds 设置黑名单管控
|
||||
*/
|
||||
synchronized private void setBlackApp(List<TTAppground> appgrounds) {
|
||||
StringBuilder blackList = new StringBuilder();
|
||||
StringBuilder packageList = new StringBuilder();//单条管控名单
|
||||
for (TTAppground appground : appgrounds) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
//old
|
||||
if (packageList.length() > 0) {
|
||||
//app内所有的网页禁止
|
||||
Log.e("setAppinsideWeb ", "packageList:" + packageList.toString());
|
||||
Intent qch_app_website = new Intent("qch_app_website")
|
||||
.setPackage("com.android.settings");
|
||||
qch_app_website.putExtra("package_name", packageList.toString());
|
||||
mContext.sendBroadcast(qch_app_website);
|
||||
} else {
|
||||
sendAllweb(mContext);
|
||||
}
|
||||
if (blackList.length() > 0) {
|
||||
//app内单个网页地址禁止打开
|
||||
Log.e("setAppinsideWeb ", "blackList:" + blackList.toString());
|
||||
Intent intent = new Intent("qch_app_inside_website")
|
||||
.setPackage("com.android.settings");
|
||||
intent.putExtra("websitelist", blackList.toString());
|
||||
mContext.sendBroadcast(intent);
|
||||
} else {
|
||||
sendwebUrl(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
synchronized private static void sendAllweb(Context context) {
|
||||
Intent intent = new Intent("qch_app_website")
|
||||
.setPackage("com.android.settings");
|
||||
intent.putExtra("package_name", "Invalid");
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
private static void sendwebUrl(Context context) {
|
||||
synchronized private static void sendwebUrl(Context context) {
|
||||
Intent intent = new Intent("qch_app_inside_website")
|
||||
.setPackage("com.android.settings");
|
||||
intent.putExtra("websitelist", "Invalid");
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void SettingSysData(String data) {
|
||||
synchronized public void SettingSysData(String data) {
|
||||
if (TextUtils.isEmpty(data)) {
|
||||
Log.e(TAG, "SettingSysData: " + "data is empty");
|
||||
return;
|
||||
@@ -717,7 +907,7 @@ public class JGYUtils {
|
||||
public void deleteOtherApp() {
|
||||
Log.e(TAG, "deleteOtherApp: " + "start");
|
||||
//获取后台应用白名单
|
||||
String only_jgy_shortcut_list = Settings.System.getString(mContext.getContentResolver(), "only_jgy_shortcut_list");
|
||||
String only_jgy_shortcut_list = Settings.System.getString(mContext.getContentResolver(), "only_jgy_shortcut_list");
|
||||
//获取可以被安装的包名
|
||||
String qch_app_forbid = Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid");
|
||||
Log.e("deleteOtherApp", "only_jgy_shortcut_list:" + only_jgy_shortcut_list);
|
||||
|
||||
Reference in New Issue
Block a user