version:1.8.1

date:2021-11-03 11:12:56
fix:修复恢复出厂设置后搜题开关不显示
add:
This commit is contained in:
2021-11-03 11:20:15 +08:00
parent c04d66726b
commit 32e1d3726f
18 changed files with 370 additions and 217 deletions

View File

@@ -68,10 +68,10 @@ public class BaseApplication extends Application {
// }
context = this;
instance = this;
if (SystemUtils.isMainProcessName(this, Process.myPid())) {
// if (SystemUtils.isMainProcessName(this, Process.myPid())) {
//非主进程不初始化
utilsInint();
}
// }
}
private void utilsInint() {

View File

@@ -37,12 +37,10 @@ import io.reactivex.subjects.BehaviorSubject;
* create an instance of this fragment.
*/
public class AppletQRCodeFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
@@ -61,7 +59,6 @@ public class AppletQRCodeFragment extends Fragment {
* @param param2 Parameter 2.
* @return A new instance of fragment WechatFragment.
*/
// TODO: Rename and change types and number of parameters
public static AppletQRCodeFragment newInstance(String param1, String param2) {
AppletQRCodeFragment fragment = new AppletQRCodeFragment();
Bundle args = new Bundle();

View File

@@ -24,14 +24,12 @@ import butterknife.BindView;
* create an instance of this fragment.
*/
public class QRCodeFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
ImageView qr_code;
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private String TAG = QRCodeFragment.class.getSimpleName();
@@ -48,7 +46,6 @@ public class QRCodeFragment extends Fragment {
* @param param2 Parameter 2.
* @return A new instance of fragment QRCodeFragment.
*/
// TODO: Rename and change types and number of parameters
public static QRCodeFragment newInstance(String param1, String param2) {
QRCodeFragment fragment = new QRCodeFragment();
Bundle args = new Bundle();

View File

@@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSONObject;
import com.info.sn.bean.zuoye.SystemSettings;
import com.info.sn.utils.ApkUtils;
import com.info.sn.utils.JGYUtils;
import com.info.sn.utils.SPUtils;
import com.info.sn.utils.ToastUtil;
import java.util.Arrays;
@@ -71,7 +72,8 @@ public class ControlManager {
setIcon(context, settings);
setCanReset(context, jsonString);
setDeveloperOptions(context, jsonString);
JGYUtils.updateForbidList(context);
setSearchTopic(context, jsonString);
JGYUtils.getInstance().updateForbidList();
}
}
@@ -93,10 +95,12 @@ public class ControlManager {
if (!DeviceManager.isDebugMode()) {
setDeveloperOptions(1);
}
setSearchTopic(0);
}
/**
* usb连接模式管控
*
* @param mContext
* @param settings
*/
@@ -136,6 +140,7 @@ public class ControlManager {
/**
* usb连接模式管控
*
* @param state
*/
public void setUSBstate(int state) {
@@ -218,7 +223,7 @@ public class ControlManager {
//蓝牙总开关开启
String setting_context = settings.getSetting_context();
if (setting_bhtvideo == 0) {
if (null != setting_context && !setting_context.equals("") && !setting_context.equals(" ") && !setting_context.equals("null")) {
if (null != setting_context && !"".equals(setting_context) && !" ".equals(setting_context) && !"null".equals(setting_context)) {
Log.e("SystemSetting", "setting_context:" + setting_context);
JGYUtils.putString(mContext.getContentResolver(), "qch_bhtvideo_forbid_on", setting_context);
} else {
@@ -597,6 +602,18 @@ public class ControlManager {
}
}
public void setSearchTopic(Context context, String jsonString) {
JSONObject jsonObject = JSON.parseObject(jsonString);
int mode = jsonObject.getIntValue("search_topic");
SPUtils.put(context, "search_topic", mode);
Log.e(TAG, "search_topic:" + mode);
}
public void setSearchTopic(int state) {
SPUtils.put(mContext, "search_topic", state);
Log.e(TAG, "search_topic:" + state);
}
/**
* 开机管控usb
*/

View File

@@ -2,7 +2,7 @@ package com.info.sn.manager;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Environment;
import android.util.Log;
import com.info.sn.bean.zuoye.AppInfo;
import com.info.sn.bean.zuoye.AppStart;
@@ -42,19 +42,26 @@ import com.info.sn.network.api.gankao.QueryPowerUserListApi;
import com.info.sn.network.api.gankao.QueryProductApi;
import com.info.sn.network.api.gankao.UpgradeUserPowerApi;
import com.info.sn.network.api.gankao.UserProductsApi;
import com.info.sn.utils.MD5Util;
import com.info.sn.utils.Utils;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.Cache;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import retrofit2.CallAdapter;
import retrofit2.Converter;
import okhttp3.Protocol;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
@@ -63,26 +70,91 @@ public class NetInterfaceManager {
@SuppressLint("StaticFieldLeak")
private static NetInterfaceManager INSTANCE;
private Context mContext;
private static Retrofit mRetrofit;
private static Retrofit mGankaoRetrofit;
private static final String ROOT_URL = UrlAddress.ROOT_URL;
private Retrofit mRetrofit;
private OkHttpClient okHttpClient;
private Retrofit mGankaoRetrofit;
private final ConcurrentHashMap<String, Long> requestIdsMap = new ConcurrentHashMap<>();
//超时时间
private static int timeOut = 5;
// 缓存文件最大限制大小20M
private static long cacheSize = 1024 * 1024 * 64;
public static final String CUSTOM_REPEAT_REQ_PROTOCOL = "MY_CUSTOM_REPEAT_REQ_PROTOCOL";
private NetInterfaceManager(Context context) {
mContext = context;
if (null == mRetrofit) {
if (okHttpClient == null) {
Interceptor myHttpInterceptor = new Interceptor() {
@NotNull
@Override
public Response intercept(@NotNull Chain chain) throws IOException {
Request request = chain.request();
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString());
Response response = chain.proceed(request); //准备返回Response
synchronized (requestIdsMap) {
requestIdsMap.remove(requestKey); //在这里移除正常的请求登记
Log.e("REPEAT-REQUEST", "移除请求2:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
}
return response;
}
};
Interceptor mRequestInterceptor = new Interceptor() {
@NotNull
@Override
public Response intercept(@NotNull Chain chain) throws IOException {
Request request = chain.request();
//拦截处理重复的HTTP 请求,类似 防止快速点击按钮去重 可以不去处理了,全局统一处理
String requestKey = MD5Util.getUpperMD5Str(request.method() + request.url().toString());
synchronized (requestIdsMap) {
if (requestIdsMap.get(requestKey) == null) {
// Log.e("REPEAT-REQUEST", "intercept: " + requestIdsMap);
requestIdsMap.put(requestKey, System.currentTimeMillis());
Log.e("REPEAT-REQUEST", "注册请求:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
} else {
//如果是重复的请求,抛出一个自定义的错误,这个错误大家根据自己的业务定义吧
Log.e("REPEAT-REQUEST", "重复请求:" + requestKey + " --- " + Thread.currentThread().getName() + " URL = " + request.url());
return new Response.Builder()
.protocol(Protocol.get(CUSTOM_REPEAT_REQ_PROTOCOL))
.request(request) //multi thread
.build();
}
}
Response originalResponse = chain.proceed(request);
return originalResponse.newBuilder().build();
}
};
//如果无法生存缓存文件目录,检测权限使用已经加上,检测手机是否把文件读写权限禁止了
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.connectTimeout(timeOut, TimeUnit.SECONDS); // 设置连接超时时间
builder.writeTimeout(timeOut, TimeUnit.SECONDS);// 设置写入超时时间
builder.readTimeout(timeOut, TimeUnit.SECONDS);// 设置读取数据超时时间
builder.retryOnConnectionFailure(true);// 设置进行连接失败重试
builder.addInterceptor(myHttpInterceptor);
builder.addNetworkInterceptor(mRequestInterceptor);
// 设置缓存文件路径
String cacheDirectory = mContext.getExternalCacheDir().getAbsolutePath() + "/OkHttpCache";
Cache cache = new Cache(new File(cacheDirectory), cacheSize);
builder.cache(cache);// 设置缓存
okHttpClient = builder.build();
}
mRetrofit = new Retrofit.Builder()
.client(okHttpClient)
.baseUrl(ROOT_URL)
.addConverterFactory(gsonConverterFactory)
.addCallAdapterFactory(rxJavaCallAdapterFactory)
.baseUrl(UrlAddress.ROOT_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
}
if (null == mGankaoRetrofit) {
mGankaoRetrofit = new Retrofit.Builder()
.client(okHttpClient)
.baseUrl(UrlAddress.GANKAN_ROOT_URL)
.addConverterFactory(gsonConverterFactory)
.addCallAdapterFactory(rxJavaCallAdapterFactory)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
}
}
@@ -100,26 +172,10 @@ public class NetInterfaceManager {
return INSTANCE;
}
private static final long cacheSize = 1024 * 1024 * 32;// 缓存文件最大限制大小20M
private static String cacheDirectory = Environment.getExternalStorageDirectory() + "/okttpcaches"; // 设置缓存文件路径
private static Cache cache = new Cache(new File(cacheDirectory), cacheSize); //
private static final OkHttpClient okHttpClient;
private static final int timeOut = 5;
static {
//如果无法生存缓存文件目录,检测权限使用已经加上,检测手机是否把文件读写权限禁止了
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.connectTimeout(timeOut, TimeUnit.SECONDS); // 设置连接超时时间
builder.writeTimeout(timeOut, TimeUnit.SECONDS);// 设置写入超时时间
builder.readTimeout(timeOut, TimeUnit.SECONDS);// 设置读取数据超时时间
builder.retryOnConnectionFailure(true);// 设置进行连接失败重试
builder.cache(cache);// 设置缓存
okHttpClient = builder.build();
public OkHttpClient getOkHttpClient() {
return okHttpClient;
}
private static CallAdapter.Factory rxJavaCallAdapterFactory = RxJava2CallAdapterFactory.create();
private static Converter.Factory gsonConverterFactory = GsonConverterFactory.create();
public Observable<BaseResponse<UserInfo>> getsnInfoControl() {
return mRetrofit.create(SNInfoApi.class)
.getsninfo(Utils.getSerial())
@@ -141,14 +197,6 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread());
}
public BindDevices getbindDevicesControl() {
return mRetrofit.create(BindDevices.class);
}
public AddAppInstall getAddAppInstallControl() {
return mRetrofit.create(AddAppInstall.class);
}
public Observable<BaseResponse> getBrowserControl() {
return mRetrofit.create(Browser.class)
.getBrowser(Utils.getSerial())
@@ -170,14 +218,6 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread());
}
public APPJump getAppJumpControl() {
return mRetrofit.create(APPJump.class);
}
public UpdateAdminSn getUpdateAdminSnControl() {
return mRetrofit.create(UpdateAdminSn.class);
}
public Observable<BaseResponse<List<AppInfo>>> getQueryAllAppControl() {
return mRetrofit.create(QueryAllApp.class)
.getAllApp(Utils.getSerial())
@@ -185,18 +225,6 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread());
}
public NewestAppUpdate getNewestAppUpdateControl() {
return mRetrofit.create(NewestAppUpdate.class);
}
public UploadScreenshot getUploadScreenshotControl() {
return mRetrofit.create(UploadScreenshot.class);
}
public ScreenLock getScreenLockControl() {
return mRetrofit.create(ScreenLock.class);
}
public Observable<BaseResponse> getTimeControl() {
return mRetrofit.create(TimeControl.class)
.getTimeControl(Utils.getSerial())
@@ -204,10 +232,6 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread());
}
public ScreenState setScreen() {
return mRetrofit.create(ScreenState.class);
}
public Observable<BaseResponse<UserAvatarInfo>> getUserAvatarInfoControl() {
return mRetrofit.create(UserInfoControl.class)
.getUserAvatarInfo(Utils.getSerial())
@@ -215,15 +239,6 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread());
}
public SaveSnUidApi getSaveSnUidApiControl() {
return mRetrofit.create(SaveSnUidApi.class);
}
public AppUsedApi getAppUsedControl() {
return mRetrofit.create(AppUsedApi.class);
}
public Observable<BaseResponse> getRunningAppObservable(String json) {
return mRetrofit.create(RunningApp.class)
.sendAppInfo(Utils.getSerial(), json)
@@ -266,6 +281,46 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread());
}
public BindDevices getbindDevicesControl() {
return mRetrofit.create(BindDevices.class);
}
public AddAppInstall getAddAppInstallControl() {
return mRetrofit.create(AddAppInstall.class);
}
public APPJump getAppJumpControl() {
return mRetrofit.create(APPJump.class);
}
public UpdateAdminSn getUpdateAdminSnControl() {
return mRetrofit.create(UpdateAdminSn.class);
}
public NewestAppUpdate getNewestAppUpdateControl() {
return mRetrofit.create(NewestAppUpdate.class);
}
public UploadScreenshot getUploadScreenshotControl() {
return mRetrofit.create(UploadScreenshot.class);
}
public ScreenLock getScreenLockControl() {
return mRetrofit.create(ScreenLock.class);
}
public ScreenState setScreen() {
return mRetrofit.create(ScreenState.class);
}
public SaveSnUidApi getSaveSnUidApiControl() {
return mRetrofit.create(SaveSnUidApi.class);
}
public AppUsedApi getAppUsedControl() {
return mRetrofit.create(AppUsedApi.class);
}
//赶考
public CreateUserApi getCreateUserControl() {

View File

@@ -183,7 +183,7 @@ public class HTTPInterface {
homepag.setPackage("com.android.settings")
.setPackage("com.android.browser");
}
if (home_page != null && !home_page.equals("")) {
if (home_page != null && !"".equals(home_page)) {
homepag.putExtra("homepage", home_page);
} else {
homepag.putExtra("homepage", "Invalid");
@@ -196,7 +196,7 @@ public class HTTPInterface {
websiteBookMark.setPackage("com.android.settings")
.setPackage("com.android.browser");
}
if (label_page != null && !label_page.equals("")) {
if (label_page != null && !"".equals(label_page)) {
websiteBookMark.putExtra("websiteBookMark", label_page);
} else {
websiteBookMark.putExtra("websiteBookMark", "Invalid");
@@ -463,7 +463,7 @@ public class HTTPInterface {
}
String jsonString = JSONObject.toJSONString(hideAPPList);
SPUtils.put(context, "Hide_APP_List", String.join(",", jsonString));
JGYUtils.updateHideList(context);
JGYUtils.getInstance().updateHideList();
Log.e(TAG, "Hide_APP_List: " + jsonString);
}
}
@@ -732,11 +732,12 @@ public class HTTPInterface {
.subscribe(new Observer<BaseResponse<AppInfo>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e(TAG, "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<AppInfo> appInfoBaseResponse) {
Log.e(TAG, "onNext: " + appInfoBaseResponse);
int code = appInfoBaseResponse.code;
if (code == 200) {
AppInfo appInfo = appInfoBaseResponse.data;
@@ -746,7 +747,7 @@ public class HTTPInterface {
}
Log.e("checkUpdate", "update now");
} else {
Log.e("checkUpdate", "not find update");
Log.e("checkUpdate", "not found update");
}
}
@@ -757,7 +758,7 @@ public class HTTPInterface {
@Override
public void onComplete() {
Log.e(TAG, "onComplete: ");
}
});
@@ -770,6 +771,7 @@ public class HTTPInterface {
}
public static void checkUpdate(Context context, String packageName) {
Log.e(TAG, "checkUpdate: " + packageName);
PackageManager pm = context.getPackageManager();
PackageInfo info = null;
try {

View File

@@ -45,7 +45,6 @@ public class APKinstallReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, Intent intent) {
mContext = context;
// TODO: This method is called when the BroadcastReceiver is receiving
// an Intent broadcast.
String action = intent.getAction();
ApkUtils.addShortcut(context);
@@ -100,7 +99,6 @@ public class APKinstallReceiver extends BroadcastReceiver {
}
}
public interface NewAppListener {
void setNewAppListener(String packageName);
}

View File

@@ -17,7 +17,6 @@ public class InstallResultReceiver extends BroadcastReceiver {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onReceive(Context context, Intent intent) {
// TODO: This method is called when the BroadcastReceiver is receiving
// an Intent broadcast.
//throw new UnsupportedOperationException("Not yet implemented");
@@ -52,7 +51,7 @@ public class InstallResultReceiver extends BroadcastReceiver {
// Log.e("fht", SESSION_ID);
// Log.e("fht", LEGACY_STATUS);
// Log.e("fht", STATUS_MESSAGE);
if (STATUS_MESSAGE != null && STATUS_MESSAGE.equals("INSTALL_SUCCEEDED")) {
if (STATUS_MESSAGE != null && "INSTALL_SUCCEEDED".equals(STATUS_MESSAGE)) {
// ToastUtil.show(PACKAGE_NAME + "安装成功");
}
}

View File

@@ -293,6 +293,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
case JIGUANG_CAMRERA:
ToastUtil.debugShow("收到推送消息: 摄像头管控");
setCameta(context, extras);
JGYUtils.getInstance().updateForbidList();
break;
case JIGUANG_PHONE:
ToastUtil.debugShow("收到推送消息: 电话管控");
@@ -598,7 +599,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
JSONObject object = JSON.parseObject(jsonString);
String packageName = object.getString("app_package");
ToastUtil.debugShow("收到应用卸载消息:包名" + packageName);
if (!packageName.equals("") && !packageName.equals(context.getApplicationContext().getPackageName())) {
if (!"".equals(packageName) && !packageName.equals(context.getApplicationContext().getPackageName())) {
if (!ApkUtils.isAvailable(context.getApplicationContext(), packageName)) {
// HTTPInterface.setAppuninstallInfo(sn_id, packageName);
} else {
@@ -747,13 +748,13 @@ public class MyJPushReceiver extends BroadcastReceiver {
String packageName = jsonObject.getString("package");
String nowApplist = JGYUtils.getString(context.getContentResolver(), "qch_app_forbid");
List<String> applist = new ArrayList<>(Arrays.asList(nowApplist.split(",")));
if (is_upgrade.equals("0")) {
if ("0".equals(is_upgrade)) {
if (applist.contains(packageName)) {
applist.remove(packageName);
} else {
Log.e("setAppUpdate", "app已经存在");
}
} else if (is_upgrade.equals("1")) {
} else if ("1".equals(is_upgrade)) {
if (!applist.contains(packageName)) {
applist.add(packageName);
}
@@ -838,7 +839,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
if (!TextUtils.isEmpty(jsonString)) {
JSONObject extra = JSON.parseObject(jsonString);
String white = extra.getString("white");
if (white != null && !white.equals("")) {
if (white != null && !"".equals(white)) {
boolean whiteList = JGYUtils.putString(context.getContentResolver(), "DeselectBrowserArray", white);
Log.e("SystemSetting", "setBrowserList-whiteList" + whiteList + ":" + white);
} else {
@@ -846,7 +847,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
}
Log.e("whiteList", JGYUtils.getString(context.getContentResolver(), "DeselectBrowserArray"));
String black = extra.getString("black");
if (black != null && !black.equals("")) {
if (black != null && !"".equals(black)) {
boolean blackList = JGYUtils.putString(context.getContentResolver(), "qch_webblack_url", black);
Log.e("SystemSetting", "setBrowserList-blackList" + blackList + ":" + black);
} else {
@@ -988,7 +989,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
JSONObject jsonObject = JSON.parseObject(jsonString);
int search_topic = jsonObject.getIntValue("search_topic");
Log.e(TAG, "searchTopic: put = " + SPUtils.put(context, "search_topic", search_topic));
JGYUtils.updateForbidList(context);
JGYUtils.getInstance().updateForbidList();
}

View File

@@ -41,17 +41,9 @@ public class DownloadService extends Service {
startService(new Intent(this, GuardService.class));
startService(new Intent(this, MainService.class));
startService(new Intent(this, ManagerService.class));
CheckUpdate();
CheckUpdateByPackageName("com.jgyapp.market", handler);
//静默升级应用市场
// CheckUpdateByPackageName("com.android.uiuios", handler);
//静默升级桌面
CheckUpdateByPackageName("com.uiuios.updatetools", handler);
//静默升级更新工具
// HTTPInterface.getAllAppPackageName(handler);
Aria.download(this).register();
Aria.download(this).resumeAllTask();
//恢复所有未完成的下载任务
Aria.download(this).resumeAllTask();
return START_STICKY;
}
@@ -61,25 +53,6 @@ public class DownloadService extends Service {
super.onCreate();
}
synchronized private void CheckUpdate() {
// HTTPInterface.checkUpdateByself(handler, this.getPackageName(), String.valueOf(BuildConfig.VERSION_CODE));
}
synchronized private void CheckUpdateByPackageName(String packageName, Handler handlers) {
PackageManager pm = getPackageManager();
PackageInfo packageInfo = null;
try {
packageInfo = pm.getPackageInfo(packageName, 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if (null != packageInfo) {
// HTTPInterface.checkUpdateByPackage(handlers, packageName, String.valueOf(packageInfo.versionCode));
} else {
// HTTPInterface.checkUpdateByPackage(handlers, packageName, "0");
}
}
@Override
public void onDestroy() {
super.onDestroy();
@@ -92,37 +65,6 @@ public class DownloadService extends Service {
};
}
private Handler handler = new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 0:
break;
case 200:
Bundle bundle = (Bundle) msg.obj;
getFile(bundle);
break;
case 201:
String apppackage = (String) msg.obj;
Log.e("handler", JGYUtils.getString(getContentResolver(), "qch_app_forbid") + "?");
try {
JGYUtils.putString(getContentResolver(), "qch_app_forbid", apppackage + "com.info.sn,com.android.uiuios,com.appstore.uiui,com.jgyapp.market,com.uiuios.updatetools");
} catch (Exception e) {
Log.e("fht", e.getMessage());
}
break;
case 202:
break;
case 300:
Bundle b = (Bundle) msg.obj;
update(b);
break;
}
}
};
private void getFile(final Bundle bundle) {
String url = bundle.getString("url");

View File

@@ -8,7 +8,9 @@ import android.content.IntentFilter;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.SystemClock;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.DisplayMetrics;
@@ -32,6 +34,11 @@ import com.info.sn.utils.SPUtils;
import com.info.sn.utils.TimeUtils;
import com.info.sn.utils.Utils;
import java.util.concurrent.TimeUnit;
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;
@@ -52,6 +59,50 @@ public class ManagerService extends Service {
private boolean screenlocked = false;
private boolean timelocked = false;
private interface Start {
void onstar(long time);
}
private Start start;
private final ObservableOnSubscribe<Long> subscribe = new ObservableOnSubscribe<Long>() {
@Override
public void subscribe(ObservableEmitter emitter) throws Exception {
start = new Start() {
@Override
public void onstar(long time) {
emitter.onNext(time);
}
};
}
};
private Observer<Long> timeObserver = new Observer<Long>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Long aLong) {
Log.e("TimeObserver", "onNext: " + aLong);
Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this), 1234);
Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, "com.jgyapp.market"), 3456);
Handler.getMain().postDelayed(() -> HTTPInterface.checkUpdate(ManagerService.this, "com.uiuios.updatetools"), 5678);
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
};
@Override
public IBinder onBind(Intent intent) {
return null;
@@ -67,13 +118,14 @@ public class ManagerService extends Service {
registBootReceive();
registerBatteryReceiver();
setFloatingWindow();
Observable.create(subscribe)
.throttleFirst(3, TimeUnit.HOURS)
.subscribe(timeObserver);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
HTTPInterface.checkUpdate(this);
HTTPInterface.checkUpdate(this, "com.jgyapp.market");
HTTPInterface.checkUpdate(this, "com.uiuios.updatetools");
start.onstar(System.currentTimeMillis());
return START_STICKY;
}

View File

@@ -72,12 +72,12 @@ public class RemoteService extends Service {
@Override
public List<String> getHideAPP() throws RemoteException {
return JGYUtils.getHideList(RemoteService.this);
return JGYUtils.getInstance().getHideList();
}
@Override
public List<String> getForbidAPP() throws RemoteException {
return JGYUtils.getForbidList(RemoteService.this);
return JGYUtils.getInstance().getForbidList();
}
};
}

View File

@@ -232,7 +232,6 @@ public class CXAESUtil {
e.printStackTrace(); // To change body of catch statement use File |
// Settings | File Templates.
} catch (InvalidAlgorithmParameterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return cipher;
@@ -242,7 +241,6 @@ public class CXAESUtil {
* 对文件进行AES加密
*
* @param sourceFile
* @param fileType
* @param sKey
* @return
*/

View File

@@ -74,7 +74,6 @@ public class JGYUtils {
}
public static String getAuthorization() {
// TODO: 2021/10/19 ndk代码待实现
return "Basic ZWRmOWNlYzIyNzMxYjhiMmZlZDU2ZWU2OmIzYWRlZDRmODk5N2E0ODM5ZTI5MjRjYg==";
}
@@ -98,7 +97,7 @@ public class JGYUtils {
* 从Manifest中获取meta-data值
* https://blog.csdn.net/yue_233/article/details/91453451
*
* @return
* @return MetaData
*/
public String getStringMetaData() {
ApplicationInfo appInfo = null;
@@ -577,43 +576,43 @@ public class JGYUtils {
return processName;
}
public void setDefaultDesktop(Context context, String pkg, String className) {
public void setDefaultDesktop( String pkg, String className) {
Intent intent = new Intent("setDefaultLauncher");
intent.putExtra("package", pkg);
intent.putExtra("className", className);
intent.setPackage("com.android.settings");
context.sendBroadcast(intent);
mContext.sendBroadcast(intent);
}
public static ArrayList<String> getForbidList(Context context) {
public ArrayList<String> getForbidList() {
ArrayList<String> disableApp = new ArrayList<>();
int search_topic = (int) SPUtils.get(context, "search_topic", 0);
int search_topic = (int) SPUtils.get(mContext, "search_topic", 0);
Log.e(TAG, "getForbidList: search_topic = " + search_topic);
Log.e(TAG, "getForbidList: " + JSONObject.toJSONString(SPUtils.getAll(context)));
Log.e(TAG, "getForbidList: " + JSONObject.toJSONString(SPUtils.getAll(mContext)));
if (search_topic == 0) {
disableApp.add("拍照搜题");
}
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_camera", 0) == 1) {
if (JGYUtils.getInt(mContext.getContentResolver(), "qch_app_camera", 0) == 1) {
disableApp.add("com.mediatek.camera");
}
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_filemanager", 0) == 1) {
if (JGYUtils.getInt(mContext.getContentResolver(), "qch_app_filemanager", 0) == 1) {
disableApp.add("com.android.documentsui");
disableApp.add("com.mediatek.filemanager");
}
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_deskclock", 0) == 1) {
if (JGYUtils.getInt(mContext.getContentResolver(), "qch_app_deskclock", 0) == 1) {
disableApp.add("com.android.deskclock");
}
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_soundrecorder", 0) == 1) {
if (JGYUtils.getInt(mContext.getContentResolver(), "qch_app_soundrecorder", 0) == 1) {
disableApp.add("com.android.soundrecorder");
}
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_gallery", 0) == 1) {
if (JGYUtils.getInt(mContext.getContentResolver(), "qch_app_gallery", 0) == 1) {
disableApp.add("com.android.gallery3d");
}
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_music", 0) == 1) {
if (JGYUtils.getInt(mContext.getContentResolver(), "qch_app_music", 0) == 1) {
disableApp.add("com.android.music");
}
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_browser", 0) == 1) {
if (JGYUtils.getInt(mContext.getContentResolver(), "qch_app_browser", 0) == 1) {
disableApp.add("com.android.browser");
}
Log.e(TAG, "getForbidAPP: " + disableApp);
@@ -622,18 +621,18 @@ public class JGYUtils {
private static final String UPDATE_FORBID_APP = "UPDATE_FORBID_APP";
public static void updateForbidList(Context context) {
public void updateForbidList() {
Intent intent = new Intent(UPDATE_FORBID_APP);
intent.putStringArrayListExtra("forbid_app_list", getForbidList(context));
Log.e(TAG, "updateForbidList: " + getForbidList(context));
intent.putStringArrayListExtra("forbid_app_list", getForbidList());
Log.e(TAG, "updateForbidList: " + getForbidList());
// intent.setComponent(new ComponentName("com.jiaoguanyi.os","com.jiaoguanyi.os.view.MainActivity"));
intent.setPackage("com.jiaoguanyi.os");
// intent.setPackage("com.tt.ttutils");
context.sendBroadcast(intent);
mContext.sendBroadcast(intent);
}
public static ArrayList<String> getHideList(Context context) {
String appString = (String) SPUtils.get(context, "Hide_APP_List", "");
public ArrayList<String> getHideList() {
String appString = (String) SPUtils.get(mContext, "Hide_APP_List", "");
Log.e(TAG, "Hide_APP_List: " + appString);
if (TextUtils.isEmpty(appString)) {
return new ArrayList<>();
@@ -644,13 +643,13 @@ public class JGYUtils {
private static final String UPDATE_HIDE_APP = "UPDATE_HIDE_APP";
public static void updateHideList(Context context) {
public void updateHideList() {
Intent intent = new Intent(UPDATE_HIDE_APP);
intent.putStringArrayListExtra("hide_app_list", getHideList(context));
intent.putStringArrayListExtra("hide_app_list", getHideList());
// intent.setComponent(new ComponentName("com.jiaoguanyi.os","com.jiaoguanyi.os.view.MainActivity"));
intent.setPackage("com.jiaoguanyi.os");
// intent.setPackage("com.tt.ttutils");
context.sendBroadcast(intent);
mContext.sendBroadcast(intent);
}
//应用管理-允许联网
@@ -675,13 +674,8 @@ public class JGYUtils {
String oldBlackList = (String) SPUtils.get(context, ACTION_HrReceiver_JGY_DIS, "");
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackList.split(",")));
oldBlackListSet.removeIf(new Predicate<String>() {
@Override
public boolean test(String s) {
//去空
return TextUtils.isEmpty(s.trim());
}
});
//去空
oldBlackListSet.removeIf(s -> TextUtils.isEmpty(s.trim()));
//之前禁止上网得列表
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
if (oldBlackListSet.size() == 0) {
@@ -757,12 +751,7 @@ public class JGYUtils {
String oldBlackListString = (String) SPUtils.get(mContext, ACTION_HrReceiver_JGY_DIS, "");
HashSet<String> oldBlackListSet = new HashSet<>(Arrays.asList(oldBlackListString.split(",")));
Log.e(TAG, "setAppNetwork: oldBlackListSet: " + oldBlackListSet);
oldBlackListSet.removeIf(new Predicate<String>() {
@Override
public boolean test(String s) {
return TextUtils.isEmpty(s.trim());
}
});
oldBlackListSet.removeIf(s -> TextUtils.isEmpty(s.trim()));
for (String pkg : oldBlackListSet) {
if (TextUtils.isEmpty(pkg)) continue;
if (!ApkUtils.isAvailable(mContext, pkg)) {

View File

@@ -0,0 +1,112 @@
package com.info.sn.utils;
import android.annotation.SuppressLint;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Util {
public static String packetMD5(String str) {
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(str.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException caught!");
System.exit(-1);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] byteArray = messageDigest.digest();
StringBuffer md5StrBuff = new StringBuffer();
for (int i = 0; i < byteArray.length; i++) {
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)
md5StrBuff.append("0").append(
Integer.toHexString(0xFF & byteArray[i]));
else
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
}
return md5StrBuff.toString();
}
@SuppressLint("DefaultLocale")
public static String getUpperMD5Str(String str) {
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(str.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException caught!");
System.exit(-1);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] byteArray = messageDigest.digest();
StringBuffer md5StrBuff = new StringBuffer();
for (int i = 0; i < byteArray.length; i++) {
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)
md5StrBuff.append("0").append(
Integer.toHexString(0xFF & byteArray[i]));
else
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
}
return md5StrBuff.toString().toUpperCase();
}
/**
* 获取16位的MD5 值得
*
* @param str
* @return
*/
@SuppressLint("DefaultLocale")
public static String getUpperMD5Str16(String str) {
MessageDigest messageDigest = null;
try {
messageDigest = MessageDigest.getInstance("MD5");
messageDigest.reset();
messageDigest.update(str.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
System.out.println("NoSuchAlgorithmException caught!");
System.exit(-1);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
byte[] byteArray = messageDigest.digest();
StringBuffer md5StrBuff = new StringBuffer();
for (int i = 0; i < byteArray.length; i++) {
if (Integer.toHexString(0xFF & byteArray[i]).length() == 1)
md5StrBuff.append("0").append(
Integer.toHexString(0xFF & byteArray[i]));
else
md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
}
return md5StrBuff.toString().toUpperCase().substring(8, 24);
}
}

View File

@@ -160,7 +160,7 @@ public class Utils {
try {
List<NetworkInterface> all = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface nif : all) {
if (!nif.getName().equalsIgnoreCase("wlan0"))
if (!"wlan0".equalsIgnoreCase(nif.getName()))
continue;
byte[] macBytes = nif.getHardwareAddress();
if (macBytes == null) {
@@ -208,15 +208,15 @@ public class Utils {
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
if (WLANMAC != null && !WLANMAC.equals("")) {
if (WLANMAC != null && !"".equals(WLANMAC)) {
m.update(WLANMAC.getBytes(), 0, WLANMAC.length());
} else if (getSimSerialNumber(context) != null && !getSimSerialNumber(context).equals("")) {
} else if (getSimSerialNumber(context) != null && !"".equals(getSimSerialNumber(context))) {
m.update(getSimSerialNumber(context).getBytes(), 0, getSimSerialNumber(context).length());
} else {
m.update(getPesudoUniqueID().getBytes(), 0, getPesudoUniqueID().length());
}
// get md5 bytes
byte p_md5Data[] = m.digest();
byte[] p_md5Data = m.digest();
// create a hex string
String m_szUniqueID = new String();
for (int i = 0; i < p_md5Data.length; i++) {
@@ -559,7 +559,6 @@ public class Utils {
;
return version;
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "";
@@ -1227,12 +1226,7 @@ public class Utils {
used.setApp_name(information.getLabel());
appUsedList.add(used);
}
appUsedList.removeIf(new Predicate<AppUsed>() {
@Override
public boolean test(AppUsed appUsed) {
return appUsed.getUseTime() == 0;
}
});
appUsedList.removeIf(appUsed -> appUsed.getUseTime() == 0);
String jsonString = JSON.toJSONString(appUsedList);
Log.e(TAG, "getAppUsedStatistics: " + jsonString);
return jsonString;

View File

@@ -9,7 +9,6 @@
<string name="setting">设置</string>
<string name="cancel">取消</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="hello"><u>查看操作指引</u></string>
<string name="caption">尊敬的用户:\n非常感谢选用教管壹品牌云管控·AI学习机您可按以下步骤激活家长管控账号并绑定AI学习机以便获得相关管控功能如应用安装黑白名单设置、浏览器上网网址黑白