version:2.0.3

update:
fix:应用市场接口屏蔽,删除应用bug,设备加锁恢复出场设置
add:
This commit is contained in:
2021-05-13 18:43:00 +08:00
parent 161b0fa9d1
commit 5efa5b5370
14 changed files with 345 additions and 877 deletions

View File

@@ -140,7 +140,7 @@ public class DiscardActivity extends AppCompatActivity {
// downloadManager = DownloadService.getDownloadManager();
// downloadManager.startAllTask();
Intent allIntent = new Intent();
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
// allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
sendBroadcast(allIntent);
// CmdUtil.execute(" screencap -p /sdcard/" + "screen" + System.currentTimeMillis() + ".png");
@@ -743,7 +743,7 @@ public class DiscardActivity extends AppCompatActivity {
super.onResume();
isForeground = true;
Intent allIntent = new Intent();
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
// allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
sendBroadcast(allIntent);
// loadHeadImg(Configure.HTTP_TAG_HOME_PAGE_URL);
getLockedState(mHandler);

View File

@@ -41,7 +41,6 @@ import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Action1;
public class MainActivity extends BaseActivity implements MainContact.MainView {
private static final String TAG = MainActivity.class.getSimpleName();
@@ -172,23 +171,24 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
}
/**
* @param loocked
* @param loocked 后台1是锁定底层0是锁定
*/
@Override
public void setLockedState(boolean loocked) {
if (loocked) {
iv_locked.setVisibility(View.VISIBLE);
ApkUtils.getAppInfo(this);
//上传APP信息
ApkUtils.getAppInfo(this);
if (netWorkIsRunning|| MainService.netWorkIsRunning) {
//如果正在执行,不执行
return;
}
mPresenter.sendMACAddress();
//发送设备mac地址和信息
mPresenter.setJpushAlias();
mPresenter.sendMACAddress();
//设置极光推送别名
mPresenter.setJpushAlias();
SaveListUtils.getList();
//获取系统管控
mPresenter.getSystemSettingbegin();
netWorkIsRunning = true;
} else {
@@ -198,6 +198,10 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
}
}
/**
* 首次使用默认关闭所有功能
* @param state
*/
@Override
public void setFirstConnect(boolean state) {
Log.e(TAG, "isFirstConnect: " + "end request");
@@ -220,13 +224,18 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
@Override
public void getSnTimeControlFinished() {
mPresenter.getDeveloper();
}
@Override
public void getDeveloperFinished() {
}
@Override
public void setAliasFinished() {
mPresenter.setJpushTags();
//设置极光推送tag
mPresenter.setJpushTags();
}
@Override
@@ -345,11 +354,6 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
@Override
public void setTopAppFinished() {
mPresenter.getDeveloper();
}
@Override
public void getDeveloperFinished() {
netWorkIsRunning = false;
Log.e(TAG, "SettingFinished: " + (System.currentTimeMillis() - timeMillis) + " ms");
}

View File

@@ -8,134 +8,134 @@ import com.mjsheng.myappstore.base.BaseView;
public class MainContact {
public interface MainView extends BaseView {
void setBatchText(String text, int visibility);
//设置批次信息
void setClassText(String text, int visibility);
void setBatchText(String text, int visibility);
//设置班级信息
void setNumberText(String text, int visibility);
void setClassText(String text, int visibility);
//设置学号信息
void setNameText(String text, int visibility);
void setNumberText(String text, int visibility);
//设置姓名信息
void setLockedState(boolean loocked);
void setNameText(String text, int visibility);
//获取设备锁定状态
void setFirstConnect(boolean state);
void setLockedState(boolean loocked);
//是否第一次联网
void sendMACFinished();
void setFirstConnect(boolean state);
//发送mac地址
void updateDeviceInfoFinished();
void sendMACFinished();
//更新设备信息
void getSnTimeControlFinished();
void updateDeviceInfoFinished();
//获取时间管控
void setAliasFinished();
void getSnTimeControlFinished();
//获取开发者选项结束
void getDeveloperFinished();
//设置击关推送别名
void setTagsFinished();
void setAliasFinished();
//设置极光推送标签
void checkStoreUpdateFinished();
void setTagsFinished();
//获取应用市场更新
void checkTestUpdateFinished();
void checkStoreUpdateFinished();
//获取测试应用更新
void buttonCheckUpdateFinished(boolean update, JsonObject jsonObject);
void checkTestUpdateFinished();
//手动获取设备信息更新
void getSystemSettingbegin();
void buttonCheckUpdateFinished(boolean update, JsonObject jsonObject);
//开始
//设置设备后台设置
void getAppLimitFinished(String packageList);
void getSystemSettingbegin();
//获取可被写入的安装包名结束
void getDeviceBatchFinished();
void getAppLimitFinished(String packageList);
//获取设备批次结束
void getForceDownloadFinished();
void getDeviceBatchFinished();
//获取强制下载apk结束
void getBrowserListFinished(String whitelist);
void getForceDownloadFinished();
//获取浏览器上网管控设置结束
void getBrowserBookmarksFinished();
void getBrowserListFinished(String whitelist);
//获取浏览器书签设置管控结束
void getDesktopIconFinished();
void getBrowserBookmarksFinished();
//获取应用图标桌面可见性管控结束
void getAppAutoStartUpdateAndNetFinished();
void getDesktopIconFinished();
//获取应用自启升级和网络权限管理结束
void getAppIDControlFinished();
void getAppAutoStartUpdateAndNetFinished();
//获取第三方应用子页面ID连网限制结束
void setAppinsideWebFinished();
void getAppIDControlFinished();
//获取第三方应用内部网页跳转屏蔽结束
void setSystemSettingFinished();
void setAppinsideWebFinished();
//获取系统其他管控设置结束
void setLogoImgFinished ();
void setSystemSettingFinished();
//设置开机动画
void setTopAppFinished();
void setLogoImgFinished ();
//获取应用霸屏结束
void getDeveloperFinished();
//获取开发者选项结束
void setTopAppFinished();
/*
* MainService
* */
void setScreenLockStateFinished(boolean locked, String tips);
//设置屏幕锁状态结束
void getDefaultDesktopFinished();
void setScreenLockStateFinished(boolean locked, String tips);
//获取桌面结束
void getDefaultDesktopFinished();
}
public interface Presenter extends BasePresenter<MainView> {
void getStudesInfo();
//获取学生信息
void getLockedState();
void getStudesInfo();
//获取设备锁定状态
void getFirstConnect();
void getLockedState();
//是否第一次联网
void setDisableSetting();
void getFirstConnect();
//关闭所有功能
void sendMACAddress();
void setDisableSetting();
//发送mac地址
void updateDeviceInfo();
void sendMACAddress();
//更新设备信息
void getSnTimeControl();
void updateDeviceInfo();
//获取时间管控
void setJpushAlias();
void getSnTimeControl();
//获取开发者选项
void getDeveloper();
//设置击关推送别名
void setJpushTags();
void setJpushAlias();
//设置极光推送标签
void checkStoreUpdate();
void setJpushTags();
//获取应用更新
void buttonCheckUpdate(View view);
void checkStoreUpdate();
//手动获取设备信息更新
void checkTestUpdate();
void buttonCheckUpdate(View view);
//获取测试应用更新
void getSystemSettingbegin();
void checkTestUpdate();
//开始
//获取设备后台设置
void getAppLimit();
void getSystemSettingbegin();
//获取可被写入的安装包名
void getDeviceBatch(String packageList);
void getAppLimit();
//获取设备批次
void getForceDownload();
void getDeviceBatch(String packageList);
//获取强制下载apk
void getBrowserList();
void getForceDownload();
//获取浏览器上网管控设置
void getBrowserBookmarks(String whitelist);
void getBrowserList();
//获取浏览器书签设置管控
void getBrowserWhiteList();
void getBrowserBookmarks(String whitelist);
//设置白名单的url
void getDesktopIcon();
void getBrowserWhiteList();
//获取应用图标桌面可见性管控
void getAppAutoStartUpdateAndNet();
void getDesktopIcon();
//获取应用自启升级和网络权限管理
void getAppIDControl();
void getAppAutoStartUpdateAndNet();
//获取第三方应用子页面ID连网限制
void setAppinsideWeb();
void getAppIDControl();
//获取第三方应用内部网页跳转屏蔽
void setSystemSetting();
void setAppinsideWeb();
//获取系统其他管控设置
void setLogoImg();
void setSystemSetting();
//设置开机动画
void setTopApp();
void setLogoImg();
//应用霸屏
void getDeveloper();
//获取开发者选项
void setTopApp();
/*
* MainService
* */
void getScreenLockState();
//获取屏幕锁状态
void getDefaultDesktop();
void getScreenLockState();
//获取桌面
void getDefaultDesktop();
}
}

View File

@@ -22,7 +22,6 @@ import com.mjsheng.myappstore.BuildConfig;
import com.mjsheng.myappstore.base.BaseApplication;
import com.mjsheng.myappstore.bean.Appground;
import com.mjsheng.myappstore.bean.BaseResponse;
import com.mjsheng.myappstore.bean.Batch;
import com.mjsheng.myappstore.bean.BrowserBookmarks;
import com.mjsheng.myappstore.bean.BrowserData;
import com.mjsheng.myappstore.bean.ForceDownloadBean;
@@ -194,12 +193,18 @@ public class MainPresenter implements MainContact.Presenter {
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
int locked = jsonObject.get("lock").getAsInt();
Log.e("getLockedState", "locked: " + locked);
int oldState = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", -1);
Log.e("getLockedState", "qch_unlock_ipad: " + oldState);
//后台1是锁定底层0是锁定
if (locked == 1) {
if (oldState == 1) {
Log.e("getLockedState", "onNext: " + "state changed , reset devices");
Utils.doMasterClear(mContext);
}
Settings.System.putInt(mContext.getContentResolver(), "qch_unlock_ipad", 0);
} else {
SPUtils.put(mContext, "first_connect", 1);
SysSettingUtils.setEnableSetting(mContext);
// SysSettingUtils.setEnableSetting(mContext);
Settings.System.putInt(mContext.getContentResolver(), "qch_unlock_ipad", 1);
}
mView.setLockedState(locked == 1);
@@ -223,6 +228,9 @@ public class MainPresenter implements MainContact.Presenter {
});
}
/**
* 第一次连接
*/
@Override
public void getFirstConnect() {
int first = (int) SPUtils.get(mContext, "first_connect", 0);
@@ -603,8 +611,8 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void getSystemSettingbegin() {
JGYUtils.getInstance().resetDevice();
//重置设备
JGYUtils.getInstance().resetDevice();
mView.getSystemSettingbegin();
}
@@ -663,7 +671,7 @@ public class MainPresenter implements MainContact.Presenter {
mView.getDeviceBatchFinished();
return;
}
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 1);
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", -1);
if (locked == 0) {
// NetInterfaceManager.getInstance()
// .getBatchObservable()
@@ -708,9 +716,11 @@ public class MainPresenter implements MainContact.Presenter {
// @Override
// public void onComplete() {
// Log.e("getDeviceBatch", "onComplete: ");
// mView.getDeviceBatchFinished();
mView.getDeviceBatchFinished();
// }
// });
// mView.getDeviceBatchFinished();
}
}
@@ -765,26 +775,26 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void getBrowserList() {
// if (JGYUtils.isOfficialVersion()) {
oldSetBrowserList();
SetBrowserList();
// } else {
// setBrowserList();
// NewSetBrowserList();
// }
}
private void setBrowserList() {
private void NewSetBrowserList() {
NetInterfaceManager.getInstance()
.getBrowserListSettingObservable()
.observeOn(Schedulers.io())
.subscribe(new Observer<BaseResponse<BrowserData>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getBrowserList", "onSubscribe: ");
Log.e("NewSetBrowserList", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
Log.e("getBrowserList", "onNext: ");
Log.e("NewSetBrowserList", "onNext: ");
if (browserDataBaseResponse.code == 200) {
String white = browserDataBaseResponse.data.getWhite();
String black = browserDataBaseResponse.data.getBlack();
@@ -822,31 +832,31 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void onError(@NonNull Throwable e) {
Log.e("getBrowserList", "onError: " + e.getMessage());
Log.e("NewSetBrowserList", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getBrowserList", "onComplete: ");
Log.e("NewSetBrowserList", "onComplete: ");
}
});
}
private void oldSetBrowserList() {
private void SetBrowserList() {
NetInterfaceManager.getInstance()
.getBrowserListSettingObservable()
.observeOn(Schedulers.io())
.subscribe(new Observer<BaseResponse<BrowserData>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("oldSetBrowserList", "onSubscribe: ");
Log.e("SetBrowserList", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
Log.e("oldSetBrowserList", "onNext: ");
Log.e("SetBrowserList", "onNext: ");
if (browserDataBaseResponse.code == 200) {
//白名单
String white = browserDataBaseResponse.data.getWhite();
@@ -856,7 +866,9 @@ public class MainPresenter implements MainContact.Presenter {
white += "," + homePage;
}
boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white);
Log.e("oldSetBrowserList", "setBrowserList white: " + white + ":" + whiteList);
Log.e("SetBrowserList", "setBrowserList white: " + white + " :" + whiteList);
String black = Settings.System.getString(mContext.getContentResolver(), "qch_webblack_url");
Log.e("SetBrowserList", "getBrowserList black: " + black);
mView.getBrowserListFinished(white);
} else {
Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
@@ -866,7 +878,9 @@ public class MainPresenter implements MainContact.Presenter {
String black = browserDataBaseResponse.data.getBlack();
if (!TextUtils.isEmpty(black)) {
boolean blackList = Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", black);
Log.e("oldSetBrowserList", "setBrowserList black: " + black + ":" + blackList);
Log.e("SetBrowserList", "setBrowserList black: " + black + " :" + blackList);
String whiteList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
Log.e("SetBrowserList", "getBrowserList white: " + whiteList);
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
}
@@ -877,13 +891,13 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void onError(@NonNull Throwable e) {
Log.e("oldSetBrowserList", "onError: " + e.getMessage());
Log.e("SetBrowserList", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("oldSetBrowserList", "onComplete: ");
Log.e("SetBrowserList", "onComplete: ");
}
});
}
@@ -1348,9 +1362,9 @@ public class MainPresenter implements MainContact.Presenter {
JSONObject jsonObject = (JSONObject) JSON.toJSON(baseResponse.data);
int is_developer = jsonObject.getInteger("is_developer");
//后台1是0否 底层0是1否
JGYUtils.getInstance().setDeveloper(is_developer == 0 ? 1 : 0);
JGYUtils.getInstance().setDeveloperOptions(is_developer == 0 ? 1 : 0);
} else {
JGYUtils.getInstance().setDeveloper(1);
JGYUtils.getInstance().setDeveloperOptions(1);
}
}
@@ -1371,7 +1385,7 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void getScreenLockState() {
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 1);
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", -1);
if (JGYUtils.isOfficialVersion() || locked == 1) {
mView.setScreenLockStateFinished(false, "");
return;
@@ -1430,9 +1444,9 @@ public class MainPresenter implements MainContact.Presenter {
@Override
public void onNext(@NonNull ResponseBody responseBody) {
Log.e("getDefaultDesktop", "onNext: ");
try {
JSONObject jsonObject = JSONObject.parseObject(responseBody.string());
Log.e("getDefaultDesktop", "onNext: " + jsonObject.toString());
int code = jsonObject.getInteger("code");
if (code == 200) {
JSONObject data = jsonObject.getJSONObject("data");

View File

@@ -1,536 +0,0 @@
package com.mjsheng.myappstore.bean;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.util.Log;
import com.mjsheng.myappstore.database.DBHelper;
import com.mjsheng.myappstore.database.DBSqlBuilder;
import com.mjsheng.myappstore.utils.Utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class AppData {
private static final String TAG = "--AppData--";
private static final boolean DEBUG = false;
// 更新搜索历史
public static void upSearchData(Context context, String category, int search_time) {
DBHelper helper = new DBHelper(context);
Cursor cursor = null;
try {
cursor = helper.getCursor(DBSqlBuilder.APPLICATION_HISTORY,
" where category = '" + category + "'");
ContentValues values = new ContentValues();
if (cursor != null && cursor.moveToFirst()) {
helper.deleteRow(DBSqlBuilder.APPLICATION_HISTORY,"category = '" + category + "'" );
}
values.put("category", category);
values.put("search_time", search_time);
helper.insertValues(DBSqlBuilder.APPLICATION_HISTORY, values);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
helper.close();
}
}
// 删除搜索历史
public static void deleteSearchData(Context context, String category) {
DBHelper helper = new DBHelper(context);
helper.deleteRow(DBSqlBuilder.APPLICATION_HISTORY,"category = '" + category + "'" );
}
// 获取搜索历史
public static List<SearchBean> getSearchData(Context context) {
List<SearchBean> infoList = new ArrayList<>();
DBHelper helper = new DBHelper(context);
Cursor cursor = null;
SearchBean info;
try {
String sql = "select * from " + DBSqlBuilder.APPLICATION_HISTORY + " order by search_time desc";
cursor = helper.getCursorBySql(sql);
while (cursor.moveToNext()) {
info = new SearchBean();
info.setCategory(cursor.getString(cursor.getColumnIndex("category")));
info.setSearch_time(cursor.getInt(cursor.getColumnIndex("search_time")));
infoList.add(info);
}
helper.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
return infoList;
}
public static List<String> getConfigAppsPackageListWithoutMenuName(Context context, String sub_category) {
List<String> appPackageList = new ArrayList<String>();
DBHelper helper = new DBHelper(context);
Cursor cursor = null;
try {
String sql = "select * from " + DBSqlBuilder.CONFIG_APP_TABLE
+ " where sub_category <>'" + sub_category + "' order by order_id";
cursor = helper.getCursorBySql(sql);
String packageName = null;
while (cursor.moveToNext()) {
packageName = cursor.getString(cursor.getColumnIndex("pkg_name"));
appPackageList.add(packageName);
if (DEBUG)
Log.e(TAG, "getConfigAppsPackageListWithoutMenuName...menuName=" + sub_category + "; packageName=" + packageName);
}
if (cursor != null) {
cursor.close();
}
helper.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
appPackageList.add("com.mjsheng.myappstore");
return appPackageList;
}
public static List<String> getConfigAppsPackageList(Context context, String sub_category, boolean isFlag, boolean isThree) {
List<String> appPackageList = new ArrayList<String>();
DBHelper helper = new DBHelper(context);
Cursor cursor = null;
try {
String sql = "select * from " + DBSqlBuilder.CONFIG_APP_TABLE
+ " where sub_category='" + sub_category + "' order by order_id";
cursor = helper.getCursorBySql(sql);
String packageName = null;
while (cursor.moveToNext()) {
packageName = cursor.getString(cursor.getColumnIndex("pkg_name"));
if (sub_category.equals(Utils.MENU_TONGBUJIAOCAI) || sub_category.equals(Utils.MENU_LY)) {
if (isThree) {
if (appPackageList.size() <= 3) {
appPackageList.add(packageName);
}
} else {
appPackageList.add(packageName);
}
} else {
appPackageList.add(packageName);
}
}
if (cursor != null) {
cursor.close();
}
helper.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
if (isFlag) {
if (sub_category.equals(Utils.MENU_TONGBUJIAOCAI) || sub_category.equals(Utils.MENU_LY)) {
if (appPackageList.size() <= 3) {
appPackageList.add(Utils.STORE);
}
} else {
appPackageList.add(Utils.STORE);
}
}
return appPackageList;
}
public static List<String> getAllAppsPackageList(Context context) {
List<String> appPackageList = new ArrayList<String>();
DBHelper helper = new DBHelper(context);
Cursor cursor = null;
try {
String sql = "select * from " + DBSqlBuilder.CONFIG_APP_TABLE;
cursor = helper.getCursorBySql(sql);
String packageName = null;
while (cursor.moveToNext()) {
packageName = cursor.getString(cursor.getColumnIndex("pkg_name"));
appPackageList.add(packageName);
if (DEBUG)
Log.e(TAG, "databaseAppPackageList..." + " packageName=" + packageName);
}
if (cursor != null) {
cursor.close();
}
helper.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null) {
cursor.close();
}
}
return appPackageList;
}
public static List<AppInfo> getSystemAppDatas(Context context) {
List<AppInfo> systemAppList = new ArrayList<AppInfo>();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> mApps = context.getPackageManager().queryIntentActivities(mainIntent, 0);
AppInfo appInfo = null;
for (ResolveInfo app : mApps) {
if (context.getPackageName().equals(app.activityInfo.packageName)) {
continue;
}
appInfo = new AppInfo();
appInfo.setPackageName(app.activityInfo.packageName);
appInfo.setAppName(app.activityInfo.loadLabel(context.getPackageManager()).toString());
appInfo.setIcon(app.activityInfo.loadIcon(context.getPackageManager()));
systemAppList.add(appInfo);
}
return systemAppList;
}
public static List<AppInfo> getUserAppInfoList(Context context, String menuName) {
List<String> databaseAppPackageList;
if (menuName != null) {
databaseAppPackageList = getConfigAppsPackageList(context, menuName, false, false);
} else {
databaseAppPackageList = getAllAppsPackageList(context);
}
List<AppInfo> hotAppsList = new ArrayList<AppInfo>();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> mApps = context.getPackageManager().queryIntentActivities(mainIntent, 0);
HashMap<String, ResolveInfo> mHashmap = new HashMap<String, ResolveInfo>();
for (ResolveInfo resolveInfo : mApps) {
if (mHashmap.containsKey(resolveInfo.activityInfo.packageName)) {
continue;
}
mHashmap.put(resolveInfo.activityInfo.packageName, resolveInfo);
}
AppInfo appInfo = null;
ResolveInfo resolveInfo = null;
for (String app : databaseAppPackageList) {
if (mHashmap.containsKey(app)) {
resolveInfo = mHashmap.get(app);
appInfo = new AppInfo();
appInfo.setPackageName(resolveInfo.activityInfo.packageName);
appInfo.setAppName(resolveInfo.activityInfo.loadLabel(
context.getPackageManager()).toString());
appInfo.setIcon(resolveInfo.activityInfo
.loadIcon(context.getPackageManager()));
hotAppsList.add(appInfo);
}
}
return hotAppsList;
}
/**
* @param context
* @return
*/
public static List<AppInfo> getSystemAppInfoList(Context context) {
List<AppInfo> systemAppsList = new ArrayList<AppInfo>();
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> mApps = context.getPackageManager().queryIntentActivities(mainIntent, 0);
AppInfo appInfo = null;
for (ResolveInfo resolveInfo : mApps) {
appInfo = new AppInfo();
appInfo.setPackageName(resolveInfo.activityInfo.packageName);
appInfo.setAppName(resolveInfo.activityInfo.loadLabel(
context.getPackageManager()).toString());
appInfo.setIcon(resolveInfo.activityInfo
.loadIcon(context.getPackageManager()));
systemAppsList.add(appInfo);
}
return systemAppsList;
}
public static boolean isSystemApp(Context context, String pkg) {
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(pkg, 0);
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) <= 0) {
//第三方应用
return false;
} else {
//系统应用
return true;
}
} catch (NameNotFoundException e) {
e.printStackTrace();
return true;
}
}
public static boolean isExistInDB(Context context, AppInfo appInfo) {
DBHelper helper = new DBHelper(context);
try {
Cursor cursor = helper.getCursor(DBSqlBuilder.CONFIG_APP_TABLE,
"where pkg_name='" + appInfo.getPackageName() + "'");
if (cursor != null && cursor.moveToFirst()) {
return true;
}
} catch (Exception err) {
Log.e(TAG, "isExistInDB...err.getmessage=" + err.getMessage());
err.printStackTrace();
} finally {
helper.close();
}
return false;
}
public static boolean updateConfigApp(Context context, String category, String sub_category, String packageName) {
DBHelper helper = new DBHelper(context);
try {
Cursor cursor = helper.getCursor(DBSqlBuilder.CONFIG_APP_TABLE,
" where pkg_name='" + packageName + "' and sub_category='" + sub_category + "'");
Log.e(TAG, "updateConfigApp" + cursor.toString());
if (cursor != null && cursor.moveToFirst()) {
return true;
}
boolean result = false;
ContentValues values = new ContentValues();
values.put("pkg_name", packageName);
values.put("category", category);
values.put("sub_category", sub_category);
result = helper.insertValues(DBSqlBuilder.CONFIG_APP_TABLE, values);
return result;
} catch (Exception err) {
Log.e(TAG, "updateHotAppInfo...err.getmessage=" + err.getMessage());
err.printStackTrace();
} finally {
helper.close();
}
return false;
}
public static String getConfigApp(Context context, String packageName) {
String strings;
DBHelper helper = new DBHelper(context);
try {
Cursor cursor = helper.getCursor(DBSqlBuilder.CONFIG_APP_TABLE,
" where pkg_name='" + packageName + "'");
Log.e(TAG, "getDownloadApp" + cursor.toString());
if (cursor != null && cursor.moveToFirst()) {
strings = cursor.getString(cursor.getColumnIndex("category"));
return strings;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (helper != null) {
helper.close();
}
}
return null;
}
public static boolean AddDownloadApp(Context context, String category, String sub_category, String packageName) {
DBHelper helper = new DBHelper(context);
try {
Cursor cursor = helper.getCursor(DBSqlBuilder.DOWNLOADING_TABLE,
" where pkg_name='" + packageName + "' and sub_category='" + sub_category + "'");
Log.e(TAG, "AddDownloadApp" + cursor.toString());
if (cursor != null && cursor.moveToFirst()) {
return true;
}
boolean result = false;
ContentValues values = new ContentValues();
values.put("category", category);
values.put("sub_category", sub_category);
values.put("pkg_name", packageName);
result = helper.insertValues(DBSqlBuilder.DOWNLOADING_TABLE, values);
return result;
} catch (Exception err) {
Log.e(TAG, "updateHotAppInfo...err.getmessage=" + err.getMessage());
err.printStackTrace();
} finally {
helper.close();
}
return false;
}
public static String[] getDownloadApp(Context context, String packageName) {
String[] strings;
DBHelper helper = new DBHelper(context);
try {
Cursor cursor = helper.getCursor(DBSqlBuilder.DOWNLOADING_TABLE,
" where pkg_name='" + packageName + "'");
Log.e(TAG, "getDownloadApp" + cursor.toString());
if (cursor != null && cursor.moveToFirst()) {
strings = new String[]{cursor.getString(cursor.getColumnIndex("category")), cursor.getString(cursor.getColumnIndex("sub_category"))};
return strings;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (helper != null) {
helper.close();
}
}
return null;
}
public static void ChangedApp(Context context, String category, String sub_category, AppInfo appInfo) {
DBHelper helper = new DBHelper(context);
try {
Cursor cursor = helper.getCursor(DBSqlBuilder.CONFIG_APP_TABLE,
" where pkg_name='" + appInfo.getPackageName() + "'");
;
if (cursor != null && cursor.moveToFirst()) {
return;
}
ContentValues values = new ContentValues();
values.put("category", category);
values.put("sub_category", sub_category);
helper.updateValues(DBSqlBuilder.CONFIG_APP_TABLE, values, "pkg_name=?", new String[]{appInfo.getPackageName()});
} catch (Exception err) {
Log.e(TAG, "ChangedApp...err.getmessage=" + err.getMessage());
err.printStackTrace();
} finally {
helper.close();
}
}
public static void deleteDownloadApp(Context context, String packageName) {
try {
DBHelper helper = new DBHelper(context);
try {
String where = " pkg_name='" + packageName + "'";
helper.deleteRow(DBSqlBuilder.DOWNLOADING_TABLE, where);
helper.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (helper != null) {
helper.close();
}
}
} catch (Exception err) {
return;
}
}
public static void deleteAppsByAppKey(Context context, String packageName) {
try {
DBHelper helper = new DBHelper(context);
try {
String where = " pkg_name='" + packageName + "'";
helper.deleteRow(DBSqlBuilder.CONFIG_APP_TABLE, where);
helper.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (helper != null) {
helper.close();
}
}
} catch (Exception err) {
return;
}
}
public static void deleteAppsByTag(Context context, String sub_category) {
try {
DBHelper helper = new DBHelper(context);
try {
String where = " sub_category='" + sub_category + "'";
helper.deleteRow(DBSqlBuilder.CONFIG_APP_TABLE, where);
helper.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (helper != null) {
helper.close();
}
}
} catch (Exception err) {
return;
}
}
public static void clearHotAppList(Context context) {
try {
DBHelper helper = new DBHelper(context);
helper.deleteTable(DBSqlBuilder.CONFIG_APP_TABLE);
} catch (Exception err) {
return;
}
}
public static AppInfo getAppInfoByPackageName(Context context, String packageName) {
AppInfo appInfo = new AppInfo();
if (packageName.equals("") || packageName == null) {
AppData.clearHotAppList(context);
return null;
} else if (packageName.equals(Utils.STORE)) {
appInfo.STORE_APP = true;
appInfo.setAppName("添加");
appInfo.setPackageName("appstore");
} else {
PackageManager pm = context.getPackageManager();
try {
ApplicationInfo applicationInfo = pm.getApplicationInfo(packageName, 0);
appInfo.setAppName(applicationInfo.loadLabel(pm).toString());
appInfo.setPackageName(packageName);
appInfo.setIcon(applicationInfo.loadIcon(pm));
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
if (appInfo.getAppName() == null) {
AppData.clearHotAppList(context);
}
return appInfo;
}
}

View File

@@ -17,7 +17,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.mjsheng.myappstore.bean.BrowserData;
import com.mjsheng.myappstore.utils.JGYUtils;
import com.mjsheng.myappstore.utils.URLUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
@@ -492,25 +491,26 @@ public class HTTPInterface {
//设置浏览器黑白名单
synchronized public static void setBrowserBlackList(final Context context) {
// if (JGYUtils.isOfficialVersion()) {
oldSetBrowserList(context);
SetBrowserList(context);
// OldSetBrowserList(context);
// } else {
// setBrowserList(context);
// NewSetBrowserList(context);
// }
}
private static void setBrowserList(Context context) {
private static void NewSetBrowserList(Context context) {
NetInterfaceManager.getInstance()
.getBrowserListSettingObservable()
.observeOn(Schedulers.io())
.subscribe(new Observer<BaseResponse<BrowserData>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getBrowserList", "onSubscribe: ");
Log.e("NewSetBrowserList", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
Log.e("getBrowserList", "onNext: ");
Log.e("NewSetBrowserList", "onNext: ");
if (browserDataBaseResponse.code == 200) {
String white = browserDataBaseResponse.data.getWhite();
String black = browserDataBaseResponse.data.getBlack();
@@ -519,9 +519,9 @@ public class HTTPInterface {
Settings.System.putString(context.getContentResolver(), "BlackBrowserArray", " ");
//黑白名单同时存在时由以前的逻辑管控
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
Log.e("setBrowserList", "setBrowserList white: " + white + ":" + whiteList);
Log.e("NewSetBrowserList", "setBrowserList white: " + white + ":" + whiteList);
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black);
Log.e("setBrowserList", "setBrowserList black: " + black + ":" + blackList);
Log.e("NewSetBrowserList", "setBrowserList black: " + black + ":" + blackList);
} else if (TextUtils.isEmpty(white)) {
//设置黑名单
Settings.System.putInt(context.getContentResolver(), "qch_website_isBlackWebUrl", 1);
@@ -547,33 +547,33 @@ public class HTTPInterface {
@Override
public void onError(@NonNull Throwable e) {
Log.e("getBrowserList", "onError: " + e.getMessage());
Log.e("NewSetBrowserList", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("getBrowserList", "onComplete: ");
Log.e("NewSetBrowserList", "onComplete: ");
new URLUtils(context).setBrowserList();
}
});
}
private static void oldSetBrowserList(Context context) {
private static void SetBrowserList(Context context) {
NetInterfaceManager.getInstance()
.getBrowserListSettingObservable()
.observeOn(Schedulers.io())
.subscribe(new Observer<BaseResponse<BrowserData>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("oldSetBrowserList", "onSubscribe: ");
Log.e("SetBrowserList", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
Settings.System.putInt(context.getContentResolver(), "qch_website_isBlackWebUrl", 0);
Log.e("oldSetBrowserList", "onNext: ");
Log.e("SetBrowserList", "onNext: ");
if (browserDataBaseResponse.code == 200) {
//白名单
String white = browserDataBaseResponse.data.getWhite();
@@ -583,7 +583,10 @@ public class HTTPInterface {
white += "," + homePage;
}
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
Log.e("oldSetBrowserList", "setBrowserList white: " + white + ":" + whiteList);
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
Log.e("SetBrowserList", "setBrowserList white: " + white + " :" + whiteList);
String black = Settings.System.getString(context.getContentResolver(), "qch_webblack_url");
Log.e("SetBrowserList", "getBrowserList black: " + black);
} else {
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
}
@@ -591,7 +594,10 @@ public class HTTPInterface {
String black = browserDataBaseResponse.data.getBlack();
if (!TextUtils.isEmpty(black)) {
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black);
Log.e("oldSetBrowserList", "setBrowserList black: " + black + ":" + blackList);
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
Log.e("SetBrowserList", "setBrowserList black: " + black + " :" + blackList);
String whiteList = Settings.System.getString(context.getContentResolver(), "DeselectBrowserArray");
Log.e("SetBrowserList", "getBrowserList white: " + whiteList);
} else {
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
}
@@ -603,14 +609,57 @@ public class HTTPInterface {
@Override
public void onError(@NonNull Throwable e) {
Log.e("oldSetBrowserList", "onError: " + e.getMessage());
Log.e("SetBrowserList", "onError: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
new URLUtils(context).setBrowserList();
Log.e("oldSetBrowserList", "onComplete: ");
Log.e("SetBrowserList", "onComplete: ");
}
});
}
//设置浏览器黑白名单
synchronized public static void OldSetBrowserList(final Context context) {
OkGo.post(URLAddress.SET_BROWSER_LIST)
.params("key", NetInterfaceManager.HTTP_KEY)
.params("sn", Utils.getSerial())
.execute(new StringCallback() {
@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) {
JSONObject data = JSON.parseObject(jsonObject.getString("data"));
String white = data.getString("white");
if (white != null && !white.equals("")) {
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
Log.e("SystemSetting", "OldSetBrowserList----white-----" + whiteList + ":" + white);
} else {
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
}
String black = data.getString("black");
if (black != null && !black.equals("")) {
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black);
Log.e("SystemSetting", "OldSetBrowserList----black-----" + blackList + ":" + black);
} else {
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
}
} else {
Log.e("fht", "OldSetBrowserList" + msg);
}
} catch (JSONException e) {
Log.e("fht", "OldSetBrowserList" + e.getMessage());
}
}
@Override
public void onError(Call call, Response response, Exception e) {
super.onError(call, response, e);
}
});
}

View File

@@ -65,69 +65,70 @@ import okhttp3.ResponseBody;
public class MyJPushReceiver extends BroadcastReceiver {
private static final String TAG = MyJPushReceiver.class.getSimpleName();
private final String MSG_DELETE = "1";//删除应用
private final String MSG_SETTING = "2";//系统设置管控
private final String MSG_BROWSER = "4";//浏览器网址管控
//删除应用
private final String MSG_DELETE = "1";
//系统设置管控
private final String MSG_SETTING = "2";
//浏览器网址管控
private final String MSG_BROWSER = "4";
private final String MSG_APPID = "5";
private final String MSG_NET_CONTROL = "6";
private final String MSG_POWER_ON = "7";
private final String MSG_RESET = "8";//重置
//重置
private final String MSG_RESET = "8";
//强制安装
private final String MSG_INSTALL = "9";
private final String MSG_LOCK = "10";//解锁
//解锁
private final String MSG_LOCK = "10";
private final String MSG_CAMERA = "11";
private final String MSG_ONEPACKAGES = "12";
private final String GET_APP_USEDTIME = "13";
//强制下载
private final String GET_FORCEDOWNLOADURL = "14";
//主页和书签管控
private final String SET_HOMEPAG_TAG = "15";
//app内网页管控
private final String APP_WEBSITE = "16";
//禁止app升级
private final String DISABLE_APPUPDATE = "17";
//隐藏桌面图标
private final String HIDE_DESKTOP_ICON = "18";
//禁止滑动
private final String DISABLE_APP_SLIDE = "19";
private final String GET_FORCEDOWNLOADURL = "14";//强制下载
private final String SET_HOMEPAG_TAG = "15";//主页和书签管控
private final String APP_WEBSITE = "16";//app内网页管控
private final String DISABLE_APPUPDATE = "17";//禁止app升级
private final String HIDE_DESKTOP_ICON = "18";//隐藏桌面图标
private final String DISABLE_APP_SLIDE = "19";//禁止滑动
private final String UPDATE_INFO = "20";//
private final String SN_SCREENSHOT = "21";//截图
private final String DEVICES_REBOOT = "22";//重启
private final String GET_DEVICES_INFO = "23";//获取设备详细信息
private final String LOCK_SCREEN = "24";//霸屏
private final String UNLOCK_SCREEN = "25";//取消霸屏
private final String KILL_SERVER = "26";//结束进程
private final String TIME_CONTROL = "27";//时间管控
private final String TOP_APP = "28";//app霸屏
private final String LOGO_IMG = "29";//开机动画
private final String DEFAULTP_APP = "30";//默认应用
private final String PLAY_SOUND = "31";//发出声音
private final String CLEAN_APP_CACHE = "32";//清除app数据
private final String DEVELOPER_OPTIONS = "33";//开发人员选项
private final String UPDATE_INFO = "20";
//截图
private final String SN_SCREENSHOT = "21";
//重启
private final String DEVICES_REBOOT = "22";
//获取设备详细信息
private final String GET_DEVICES_INFO = "23";
//霸屏
private final String LOCK_SCREEN = "24";
//取消霸屏
private final String UNLOCK_SCREEN = "25";
//结束进程
private final String KILL_SERVER = "26";
//时间管控
private final String TIME_CONTROL = "27";
//app霸屏
private final String TOP_APP = "28";
//开机动画
private final String LOGO_IMG = "29";
//默认应用
private final String DEFAULTP_APP = "30";
//发出声音
private final String PLAY_SOUND = "31";
//清除app数据
private final String CLEAN_APP_CACHE = "32";
//开发人员选项
private final String DEVELOPER_OPTIONS = "33";
private Context mContext;
@@ -1130,6 +1131,10 @@ public class MyJPushReceiver extends BroadcastReceiver {
// }
/**
* 锁定设备
* @param s
*/
public void settingLock(String s) {
if (TextUtils.isEmpty(s)) {
Log.e("mjsheng", "settingLock extras is null");
@@ -1350,6 +1355,6 @@ public class MyJPushReceiver extends BroadcastReceiver {
JSONObject jsonObject = JSONObject.parseObject(extras);
int is_developer = jsonObject.getInteger("is_developer");
Log.e(TAG, "setDeveloperoptions: " + is_developer);
JGYUtils.getInstance().setDeveloper(is_developer == 0 ? 1 : 0);
JGYUtils.getInstance().setDeveloperOptions(is_developer == 0 ? 1 : 0);
}
}

View File

@@ -386,17 +386,18 @@ public class MainService extends Service implements MainContact.MainView {
@Override
public void setLockedState(boolean loocked) {
if (loocked) {
ApkUtils.getAppInfo(this);
//上传APP信息
ApkUtils.getAppInfo(this);
if (netWorkIsRunning) {
//如果正在执行,不执行
return;
}
mPresenter.sendMACAddress();
//发送设备mac地址和信息
mPresenter.setJpushAlias();
mPresenter.sendMACAddress();
//设置极光推送别名
mPresenter.setJpushAlias();
SaveListUtils.getList();
//获取系统管控
mPresenter.getSystemSettingbegin();
netWorkIsRunning = true;
} else {
@@ -405,6 +406,10 @@ public class MainService extends Service implements MainContact.MainView {
}
}
/**
* 首次使用默认关闭所有功能
* @param state
*/
@Override
public void setFirstConnect(boolean state) {
Log.e(TAG, "isFirstConnect: " + "end request");
@@ -427,6 +432,11 @@ public class MainService extends Service implements MainContact.MainView {
@Override
public void getSnTimeControlFinished() {
mPresenter.getDeveloper();
}
@Override
public void getDeveloperFinished() {
}
@@ -519,11 +529,6 @@ public class MainService extends Service implements MainContact.MainView {
@Override
public void setTopAppFinished() {
mPresenter.getDeveloper();
}
@Override
public void getDeveloperFinished() {
netWorkIsRunning = false;
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
}

View File

@@ -652,6 +652,8 @@ public class ApkUtils {
this.add("com.easyclient.activity");//移动课堂
this.add("com.jiandan.mobilelesson");//简单课堂
this.add("com.jiaoguanyi.store");//教官壹
this.add("com.uiuios.jgy1");
this.add("com.uiuios.jgy2");
}};
public static List<String> factoryapp = new ArrayList<String>() {{

View File

@@ -47,13 +47,11 @@ import java.util.LinkedHashSet;
import java.util.List;
public class JGYUtils {
private static final String TAG = JGYUtils.class.getSimpleName();
private static JGYUtils sInstance;
private Context mContext;
public static final String ROOT_URL = BuildConfig.ROOT_URL;
private JGYUtils(Context context) {
this.mContext = context;
@@ -435,41 +433,31 @@ public class JGYUtils {
}
public void SettingSysData(String data) {
SPUtils.put(mContext, "first_connect", 1);
SysSettingUtils.setSystemSetting(mContext, data);
}
public void writeAppPackageList(Context context, String packageList) {
StringBuilder stringBuilder = new StringBuilder(packageList);
ApkUtils.addShortcut(context);
String appstore = "com.jiaoguanyi.appstore";
String store = "com.jiaoguanyi.store";
String info = "com.info.sn";
// String iflytek = "com.estrongs.android.pop";
String jgy1 = "com.uiuios.jgy1";
String jgy2 = "com.uiuios.jgy2";
if (!TextUtils.isEmpty(packageList)) {
Log.e("writeAppPackageList", "result: is empty");
if (!packageList.contains(appstore)) {
stringBuilder.append(",").append(appstore);
}
if (!packageList.contains(store)) {
stringBuilder.append(",").append(store);
}
if (!packageList.contains(jgy1)) {
stringBuilder.append(",").append(jgy1);
}
if (!packageList.contains(jgy2)) {
stringBuilder.append(",").append(jgy2);
}
if (!packageList.contains(info)) {
stringBuilder.append(",").append(info);
List<String> packages = new ArrayList<String>() {{
this.add("com.jiaoguanyi.appstore");//设备信息
this.add("com.jiaoguanyi.store");//教管壹
this.add("com.info.sn");
this.add("com.uiuios.jgy1");
this.add("com.uiuios.jgy2");
}};
// if (!TextUtils.isEmpty(stringBuilder)) {
for (String pkg : packages) {
if (!packageList.contains(pkg)) {
stringBuilder.append(",");
stringBuilder.append(pkg);
}
}
boolean b = Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid", stringBuilder.toString());
Log.e("mjsheng", "qch_app_forbid is :" + b + Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid"));
} else {
Log.e("mjsheng", "writeAppPackageList is null:");
}
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid"));
// } else {
// Log.e("writeAppPackageList: ", "writeAppPackageList is null:");
// }
}
public void forceDownload(List<ForceDownloadData> data) {
@@ -660,6 +648,9 @@ public class JGYUtils {
Log.e("deleteOtherApp", "is systemApp:" + packageName);
continue;
}
if (ApkUtils.systemapp.contains(packageName)) {
continue;
}
if (ApkUtils.canremove_systemapp.contains(packageName)) {
continue;
}
@@ -779,7 +770,7 @@ public class JGYUtils {
}
}
public void setDeveloper(int state) {
public void setDeveloperOptions(int state) {
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);
if (state == 1) {
Intent intent = new Intent();
@@ -877,13 +868,13 @@ public class JGYUtils {
}
}
public void KillOTA() {
public void KillOTA() {
ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
manager.killBackgroundProcesses("com.adups.fota");
CmdUtil.execute("am force-stop " + "com.adups.fota");
}
public void openOTA() {
public void openOTA() {
Intent intent = new Intent(Intent.ACTION_MAIN);
/**知道要跳转应用的包命与目标Activity*/
ComponentName componentName = new ComponentName("com.adups.fota", "com.adups.fota.GoogleOtaClient");

View File

@@ -76,6 +76,7 @@ public class SysSettingUtils {
setIcon(context, 1);
setCanReset(context, 1);
setAutoTime(context, 1);
JGYUtils.getInstance().setDeveloperOptions(1);
}
public static void setEnableSetting(Context context) {
@@ -89,6 +90,7 @@ public class SysSettingUtils {
setIcon(context, 0);
setCanReset(context, 0);
setAutoTime(context, 0);
JGYUtils.getInstance().setDeveloperOptions(0);
}
private static void setPhoneList(Context context, int state) {
@@ -668,5 +670,4 @@ public class SysSettingUtils {
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);//显示隐藏的虚拟按键
}
}

View File

@@ -37,7 +37,16 @@ public class URLUtils {
}
public void setBrowserList() {
String whiteList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
boolean isOld = Settings.System.getInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0) == 0;
String whiteList = "";
if (isOld) {
whiteList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
Log.e(TAG, "setBrowserList: "+ "DeselectBrowserArray");
} else {
whiteList = Settings.System.getString(mContext.getContentResolver(), "BlackBrowserArray");
Log.e(TAG, "setBrowserList: "+ "BlackBrowserArray");
}
if (TextUtils.isEmpty(whiteList)) {
Log.e(TAG, "getBrowserWhiteList: " + "whiteList is empty");
} else {
@@ -116,13 +125,18 @@ public class URLUtils {
stringBuilder.append(s);
}
String DeselectBrowserArray = stringBuilder.toString();
boolean write = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", DeselectBrowserArray);
boolean write;
if (isOld){
write = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", DeselectBrowserArray);
}else {
write = Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", DeselectBrowserArray);
}
Log.e(TAG, "onComplete: " + "white list: " + DeselectBrowserArray);
Log.e(TAG, "onComplete: " + "write :" + write);
}
});
}
}
private String getOkHttpURL(String URL) {
@@ -228,7 +242,7 @@ public class URLUtils {
sb.append(c);
}
}
Log.e(TAG, "getUserAgent: " + sb.toString());
// Log.e(TAG, "getUserAgent: " + sb.toString());
return sb.toString();
}
}

View File

@@ -99,101 +99,6 @@ import io.reactivex.schedulers.Schedulers;
public class Utils {
public static final String PACKAGE = "appstore";
public static final String DOWNLOAD_STARTALL_ACTION = PACKAGE + "_startall"; // 开始所有任务
public static final String DOWNLOAD_DELETE_UPDATE_ACTION = PACKAGE + "_download_update_delete"; // 删除应用更新文件
public static final String DOWNLOAD_DELETEALL_ACTION = PACKAGE + "_deleteall_alltask"; // 删除所有任务
public static final String DOWNLOAD_ALLTASK_ACTION = PACKAGE + "_download_alltask"; // 获取所有任务
public static final String DOWNLOAD_START_ACTION = PACKAGE + "_download_start"; // 下载标识
public static final String DOWNLOAD_STOP_ACTION = PACKAGE + "_download_stop"; // 暂停标识
public static final String DOWNLOAD_DELETE_PACKAGENAME_ACTION = PACKAGE + "_download_packagename_delete"; // 删除标识 根据包名
public static final String DOWNLOAD_DELETE_URL_ACTION = PACKAGE + "_download_url_delete"; // 删除标识 根据下载地址
public static final String DOWNLOAD_INITIALIZE_ACTION = PACKAGE + "_download_initialize"; // item初始化状态
public static final String DOWNLOAD_PACKAGENAME_ACTION = PACKAGE + "_download_packagename"; // item初始化状态 包名
public static final String DOWNLOAD_SERVICE_ACTION = PACKAGE + "_download_service"; // 下载状态回调服务
public static final String DOWNLOAD_ALLSERVICE_ACTION = PACKAGE + "_download_allservice"; // 返回所有下载任务
public static final String DOWNLOAD_NEWSERVICE_ACTION = PACKAGE + "_download_newservice"; // 一个新的下载任务
// JPush 推送消息
public static final String MESSAGE_RECEIVED_ACTION = "com.appstore.jpushdemo.MESSAGE_RECEIVED_ACTION";
public static final String KEY_TITLE = "title"; // 消息标题
public static final String KEY_MESSAGE = "message"; // 消息内容
public static final String KEY_EXTRAS = "extras"; // 消息内容类型
public static final String KEY_TYPE = "type"; // 消息内容类型
public static final String ACTION_PACKAGE_REPLACED = PACKAGE + "PACKAGE_REPLACED"; // 替换应用
public static final String ACTION_PACKAGE_REMOVED = PACKAGE + "PACKAGE_REMOVED"; // 卸载应用
public static final String ACTION_PACKAGE_ADDED = PACKAGE + "PACKAGE_ADDED"; // 安装应用
// 学习日志上传标识
public static final String APP_LRARNLOG = "com.colorflykids.alarm";
// 学习日志下载标识
public static final String APP_DOWNLOADLEARNLOG = "com.colorflykids.downloadlearnlog";
// 账号注销标识
public static final String APP_USERLOGOUT = "com.colorflykids.userlogout";
public static final String UPDATE_SYSTEMUI = "cn.colorflykids.UPDATE_SYSTEMUI";
public static final int COUNT_ONE_PAGE = 8;
public static final int COUNT_ONE_PAGE2 = 10;
public static final String YOUNGSYSTEM_APP_TONGBU = "com.school.app.syn"; // 小学系统 同步教材app
/**
*
*/
public static final String number[] = {
"1", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "0", "11"};
public static final String STORE = "store";
public static final String CATEGORY_THREE = "3";
public static final String CATEGORY_SIX = "6";
public static final String CATEGORY_UPSIX = "10";
public static final String CLOSE_REST_WINDOW = "colse_rest_window";
public static final String STOP_LOOPING_TIMER = "stop_looping_timer";
public static final String START_LOOPING_TIMER = "start_looping_timer";
public static String DOWNLOADAPP_CALLBACK = "com.colorflykids.downloadapp"; // 子界面下载回调 提示更新UI
public static String MENU_YOUYOU = "youyou";
public static String MENU_LANGUAGE = "语言启蒙";
public static String MENU_HABIT = "行为习惯";
public static String MENU_KNOWLEDGE = "生活认知";
public static String MENU_SECURITY = "安全自理";
public static String MENU_PROMOTION = "入园-综合提升";
public static String MENU_LY = "优优乐园";
public static String MENU_YW = "语文知识";
public static String MENU_SX = "数理逻辑";
public static String MENU_YY = "英语启蒙";
public static String MENU_QS = "情商培养";
public static String MENU_YS = "艺术提升";
public static String MENU_ZH = "学前-综合提升";
public static String MENU_TONGBUJIAOCAI = "同步教材";
public static String MENU_YUWEN = "语文";
public static String MENU_SHUXUE = "数学";
public static String MENU_YINGYU = "英语";
public static String MENU_ZONGHETISHEGN = "小学-综合提升";
public static String[] babySystem = {MENU_LANGUAGE, MENU_HABIT, MENU_KNOWLEDGE, MENU_SECURITY, MENU_PROMOTION};
public static String[] childSystem = {MENU_LY, MENU_YW, MENU_SX, MENU_YY, MENU_QS, MENU_YS, MENU_ZH};
public static String[] youngSystem = {MENU_YUWEN, MENU_SHUXUE, MENU_YINGYU, MENU_ZONGHETISHEGN};
public static String[] sonSystem = {MENU_HABIT, MENU_SECURITY, MENU_LANGUAGE, MENU_KNOWLEDGE, MENU_PROMOTION,
MENU_LY, MENU_YW, MENU_SX, MENU_YY, MENU_QS, MENU_YS, MENU_ZH,
MENU_TONGBUJIAOCAI, MENU_YUWEN, MENU_SHUXUE, MENU_YINGYU, MENU_YINGYU, MENU_ZONGHETISHEGN};
public static String[][] tagList = {babySystem, childSystem, youngSystem};
public static String subcategories[][] = {babySystem, childSystem, youngSystem};
public static String system[] = {"入园系统", "学前系统", "小学系统"};
public static String systemandno[] = {"入园系统", "学前系统", "小学系统", "未分配"};
protected static Toast toast = null;
private static String oldMsg;
private static long oneTime = 0;
private static long twoTime = 0;
// 积分记录 达人标准次数记录
// MD5 设备地址标识
public static String getMAC(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // 如果当前设备系统大于等于6.0 使用下面的方法
@@ -577,25 +482,6 @@ public class Utils {
return new String(c);
}
public static void showToast(Context context, String s) {
if (toast == null) {
toast = Toast.makeText(context, s, Toast.LENGTH_SHORT);
toast.show();
oneTime = System.currentTimeMillis();
} else {
twoTime = System.currentTimeMillis();
if (s.equals(oldMsg)) {
if (twoTime - oneTime > Toast.LENGTH_SHORT) {
toast.show();
}
} else {
oldMsg = s;
toast.setText(s);
toast.show();
}
}
oneTime = twoTime;
}
public static boolean isShouldHideInput(View v, MotionEvent event) {
if (v != null && (v instanceof EditText)) {
@@ -724,14 +610,6 @@ public class Utils {
return t1;
}
private static void getAdmin(Context context, ComponentName componentName) {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "宏云萌书院OS");
context.startActivity(intent);
}
/**
* 获取设备序列号
*
@@ -791,10 +669,6 @@ public class Utils {
}
public static String getSn() {
return getSerial();
}
public static Bitmap createQRImage(String content, int widthPix, int heightPix) {
try {
// if (content == null || "".equals(content)) {
@@ -850,7 +724,13 @@ public class Utils {
}
//判断是否为系统应用
/**
* 判断是否为系统应用
*
* @param context 上下文
* @param pkgName 包名
* @return
*/
public static boolean isSystemApp(Context context, String pkgName) {
boolean isSystemApp = false;
PackageInfo pi = null;
@@ -922,6 +802,14 @@ public class Utils {
// return bgBitmap;
}
/**
* 获取系统保存的字段
*
* @param key
* @param defaultValue
* @return
*/
public static String getProperty(String key, String defaultValue) {
String value = defaultValue;
try {
@@ -935,6 +823,11 @@ public class Utils {
}
}
/**
* 重置系统
*
* @param context
*/
synchronized public static void doMasterClear(Context context) {
if (BuildConfig.DEBUG) {
ToastUtil.show("收到重置设备推送消息");
@@ -960,13 +853,29 @@ public class Utils {
}
}
/**
* 获取电量
*
* @param mContext
* @return
*/
synchronized private static int getBatteryLevel(Context mContext) {
if (Build.VERSION.SDK_INT >= 21)
if (Build.VERSION.SDK_INT >= 21) {
return ((BatteryManager) mContext.getSystemService(Context.BATTERY_SERVICE)).getIntProperty(4);
Intent intent = (new ContextWrapper(mContext)).registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
return intent.getIntExtra("level", -1) * 100 / intent.getIntExtra("scale", -1);
} else {
Intent intent = (new ContextWrapper(mContext)).registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
return intent.getIntExtra("level", -1) * 100 / intent.getIntExtra("scale", -1);
}
}
/**
* 更新应用白名单禁止升级
* @param context
* @param banList
* @param notList
* @return
*/
static synchronized public boolean writeDisableUpdateList(Context context, String[] banList, String[] notList) {
String now = Settings.System.getString(context.getContentResolver(), "qch_app_forbid");
String[] nowList;
@@ -1019,6 +928,10 @@ public class Utils {
*/
}
/**
* 重启设备
* @param context
*/
public static void rebootDevices(Context context) {
Intent iReboot = new Intent(Intent.ACTION_REBOOT);
iReboot.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -1035,6 +948,12 @@ public class Utils {
return fileName.substring(position + 9, fileName.length() - 4);
}
/**
* 主要的下载
* @param context
* @param url
* @param jsonObject
*/
public static void ariaDownload(Context context, String url, JSONObject jsonObject) {
String fileName = getFileNamefromURL(url);
String urlMD5 = jsonObject.getString("MD5");