version:2.1.2
update:增加其他apk静默安装应用,获取不到管控时关闭所有功能,主页书签手动加https:// fix:修复重启后图标丢失 add:
This commit is contained in:
@@ -41,9 +41,9 @@ android {
|
||||
//新平台正式
|
||||
newly {
|
||||
flavorDimensions "default"
|
||||
versionCode 511
|
||||
versionCode 512
|
||||
//versionCode 1037
|
||||
versionName "2.1.1"
|
||||
versionName "2.1.2"
|
||||
/*********************************极光推送************************************/
|
||||
manifestPlaceholders = [
|
||||
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
|
||||
|
||||
@@ -75,6 +75,10 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 如果设置了target >= 28 如果需要启动后台定位则必须声明这个权限 -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- 如果您的应用需要后台定位权限,且有可能运行在Android Q设备上,并且设置了target>28,必须增加这个权限声明 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
<uses-permission android:name="com.jiaoguanyi.appstore.permissions.INSTALL_APK" />
|
||||
|
||||
<permission android:name="com.jiaoguanyi.appstore.permissions.INSTALL_APK" />
|
||||
|
||||
|
||||
<application
|
||||
android:name=".base.BaseApplication"
|
||||
|
||||
@@ -5,7 +5,6 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -23,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.BrowserBookmarks;
|
||||
import com.mjsheng.myappstore.bean.BrowserData;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadBean;
|
||||
import com.mjsheng.myappstore.bean.ForceDownloadData;
|
||||
@@ -32,6 +30,7 @@ import com.mjsheng.myappstore.bean.NetAndLaunchBean;
|
||||
import com.mjsheng.myappstore.bean.StudentsInfo;
|
||||
import com.mjsheng.myappstore.jpush.TagAliasOperatorHelper;
|
||||
import com.mjsheng.myappstore.manager.NetInterfaceManager;
|
||||
import com.mjsheng.myappstore.network.HTTPInterface;
|
||||
import com.mjsheng.myappstore.server.MainService;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.ForegroundAppUtil;
|
||||
@@ -1014,90 +1013,112 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getBrowserBookmarks(String whitelist) {
|
||||
Log.e(TAG, "getBrowserBookmarks: " + "whitelist: " + whitelist);
|
||||
List<String> whiteLists = Arrays.asList(whitelist.split(","));
|
||||
NetInterfaceManager.getInstance()
|
||||
.getBrowserBookmarksObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse<BrowserBookmarks>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getBrowserBookmarks", "onSubscribe: ");
|
||||
}
|
||||
// Log.e(TAG, "getBrowserBookmarks: " + "whitelist: " + whitelist);
|
||||
// List<String> whiteLists = Arrays.asList(whitelist.split(","));
|
||||
// NetInterfaceManager.getInstance()
|
||||
// .getBrowserBookmarksObservable()
|
||||
// .observeOn(Schedulers.io())
|
||||
// .subscribe(new Observer<BaseResponse<BrowserBookmarks>>() {
|
||||
// @Override
|
||||
// public void onSubscribe(@NonNull Disposable d) {
|
||||
// Log.e("getBrowserBookmarks", "onSubscribe: ");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onNext(@NonNull BaseResponse<BrowserBookmarks> browserBookmarksBaseResponse) {
|
||||
// Log.e("getBrowserBookmarks", "onNext: ");
|
||||
// StringBuilder whiteString = new StringBuilder(whitelist);
|
||||
// if (browserBookmarksBaseResponse.code == OK) {
|
||||
// //主页不包含白名单添加进去
|
||||
// String homepagURL = browserBookmarksBaseResponse.data.getHomepage();
|
||||
//// boolean home = Settings.System.putString(mContext.getContentResolver(), "homepagURL", homepagURL);
|
||||
//// Log.e("getBrowserBookmarks", "onNext: homepagURL: save homepagURL = " + homepagURL);
|
||||
// if (whiteLists.size() <= 0 || !whiteLists.contains(homepagURL)) {
|
||||
// whiteString.append(",").append(homepagURL);
|
||||
// Log.e("getBrowserBookmarks ", "homepagURL: " + homepagURL);
|
||||
// boolean white = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", whiteString.toString());
|
||||
// Log.e("getBrowserBookmarks", "onNext: homepagURL: add to whiteList = " + whiteString + "write: " + white);
|
||||
// }
|
||||
// //主页
|
||||
// Intent homepag = new Intent("qch_app_brower_homepage");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// homepag.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(homepagURL)) {
|
||||
// homepag.putExtra("homepage", homepagURL);
|
||||
// } else {
|
||||
// homepag.putExtra("homepage", "Invalid");
|
||||
// }
|
||||
// mContext.sendBroadcast(homepag);
|
||||
//
|
||||
// //书签
|
||||
// String labelpage = browserBookmarksBaseResponse.data.getLabelpage();
|
||||
// Intent websiteBookMark = new Intent("qch_app_brower_website");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// websiteBookMark.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(labelpage)) {
|
||||
// websiteBookMark.putExtra("websiteBookMark", labelpage);
|
||||
// } else {
|
||||
// websiteBookMark.putExtra("websiteBookMark", "Invalid");
|
||||
// }
|
||||
// mContext.sendBroadcast(websiteBookMark);
|
||||
// } else {
|
||||
// Intent intent1 = new Intent("qch_app_brower_homepage");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// intent1.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// intent1.putExtra("homepage", "Invalid");
|
||||
// mContext.sendBroadcast(intent1);
|
||||
//
|
||||
// Settings.System.putString(mContext.getContentResolver(), "homepagURL", "");
|
||||
// Intent intent2 = new Intent("qch_app_brower_website");
|
||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
// intent2.setPackage("com.android.settings")
|
||||
// .setPackage("com.android.browser");
|
||||
// }
|
||||
// intent2.putExtra("websiteBookMark", "Invalid");
|
||||
// mContext.sendBroadcast(intent2);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(@NonNull Throwable e) {
|
||||
// Log.e("getBrowserBookmarks", "onError: " + e.getMessage());
|
||||
// onComplete();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onComplete() {
|
||||
// Log.e("getBrowserBookmarks", "onComplete: ");
|
||||
// mView.getBrowserBookmarksFinished();
|
||||
// }
|
||||
// });
|
||||
HTTPInterface.getHomePageBookmarks(mContext, new HTTPInterface.BookmarksCallback() {
|
||||
@Override
|
||||
public void onSubscribe() {
|
||||
Log.e("getBrowserBookmarks", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<BrowserBookmarks> browserBookmarksBaseResponse) {
|
||||
Log.e("getBrowserBookmarks", "onNext: ");
|
||||
StringBuilder whiteString = new StringBuilder(whitelist);
|
||||
if (browserBookmarksBaseResponse.code == OK) {
|
||||
//主页
|
||||
String homepagURL = browserBookmarksBaseResponse.data.getHomepage();
|
||||
boolean home = Settings.System.putString(mContext.getContentResolver(), "homepagURL", homepagURL);
|
||||
Log.e("getBrowserBookmarks", "onNext: homepagURL: save homepagURL = " + homepagURL);
|
||||
if (whiteLists.size() <= 0 || !whiteLists.contains(homepagURL)) {
|
||||
whiteString.append(",").append(homepagURL);
|
||||
Log.e("getBrowserBookmarks ", "homepagURL: " + homepagURL);
|
||||
boolean white = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", whiteString.toString());
|
||||
Log.e("getBrowserBookmarks", "onNext: homepagURL: add to whiteList = " + whiteString + "write: " + white);
|
||||
}
|
||||
@Override
|
||||
public void onNext() {
|
||||
Log.e("getBrowserBookmarks", "onNext: ");
|
||||
}
|
||||
|
||||
Intent homepag = new Intent("qch_app_brower_homepage");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
homepag.setPackage("com.android.settings")
|
||||
.setPackage("com.android.browser");
|
||||
}
|
||||
if (!TextUtils.isEmpty(homepagURL)) {
|
||||
homepag.putExtra("homepage", homepagURL);
|
||||
} else {
|
||||
homepag.putExtra("homepage", "Invalid");
|
||||
}
|
||||
mContext.sendBroadcast(homepag);
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getBrowserBookmarks", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
//书签
|
||||
String labelpage = browserBookmarksBaseResponse.data.getLabelpage();
|
||||
Intent websiteBookMark = new Intent("qch_app_brower_website");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
websiteBookMark.setPackage("com.android.settings")
|
||||
.setPackage("com.android.browser");
|
||||
}
|
||||
if (!TextUtils.isEmpty(labelpage)) {
|
||||
websiteBookMark.putExtra("websiteBookMark", labelpage);
|
||||
} else {
|
||||
websiteBookMark.putExtra("websiteBookMark", "Invalid");
|
||||
}
|
||||
mContext.sendBroadcast(websiteBookMark);
|
||||
} else {
|
||||
Intent intent1 = new Intent("qch_app_brower_homepage");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent1.setPackage("com.android.settings")
|
||||
.setPackage("com.android.browser");
|
||||
}
|
||||
intent1.putExtra("homepage", "Invalid");
|
||||
mContext.sendBroadcast(intent1);
|
||||
|
||||
Settings.System.putString(mContext.getContentResolver(), "homepagURL", "");
|
||||
Intent intent2 = new Intent("qch_app_brower_website");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent2.setPackage("com.android.settings")
|
||||
.setPackage("com.android.browser");
|
||||
}
|
||||
intent2.putExtra("websiteBookMark", "Invalid");
|
||||
mContext.sendBroadcast(intent2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getBrowserBookmarks", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getBrowserBookmarks", "onComplete: ");
|
||||
mView.getBrowserBookmarksFinished();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getBrowserBookmarks", "onComplete: ");
|
||||
mView.getBrowserBookmarksFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1150,7 +1171,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
if ("com.android.mms".equals(pack)) {
|
||||
pm.setApplicationEnabledSetting("com.android.messaging", PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
}
|
||||
}catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
Log.e("getDesktopIcon", "Exception: ex: " + ex.getMessage());
|
||||
}
|
||||
pm.setApplicationEnabledSetting(pack, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
@@ -1270,7 +1291,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
@Override
|
||||
public void setAppinsideWeb() {
|
||||
// if (JGYUtils.isOfficialVersion()) {
|
||||
getAppinsideWeb();
|
||||
getAppinsideWeb();
|
||||
// } else {
|
||||
// getNewAppinsideWeb();
|
||||
// }
|
||||
@@ -1361,8 +1382,9 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
SPUtils.put(mContext, "SystemSettingData", data);
|
||||
JGYUtils.getInstance().SettingSysData(data);
|
||||
} else {
|
||||
//没有就按照默认的管控
|
||||
//SysSettingUtils.setDisableSetting(mContext);
|
||||
//没有数据全部关闭
|
||||
SysSettingUtils.setDisableSetting(mContext);
|
||||
SPUtils.put(mContext, "SystemSettingData", "");
|
||||
//获取系统管控先不要关闭开发人员选项
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", 1);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mjsheng.myappstore.bean.BrowserBookmarks;
|
||||
import com.mjsheng.myappstore.bean.BrowserData;
|
||||
import com.mjsheng.myappstore.utils.JGYUtils;
|
||||
import com.mjsheng.myappstore.utils.URLUtils;
|
||||
@@ -42,6 +43,7 @@ import com.mjsheng.myappstore.utils.TimeUtils;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -738,7 +740,7 @@ public class HTTPInterface {
|
||||
if (code == 200) {
|
||||
String data = jsonObject.getString("data");
|
||||
JSONObject jsondata = JSON.parseObject(data);
|
||||
//主页
|
||||
//主页不包含白名单添加进去
|
||||
String homepagURL = jsondata.getString("homepage");
|
||||
boolean home = Settings.System.putString(context.getContentResolver(), "homepagURL", homepagURL);
|
||||
String DeselectBrowserArray = Settings.System.getString(context.getContentResolver(), "DeselectBrowserArray");
|
||||
@@ -748,6 +750,7 @@ public class HTTPInterface {
|
||||
boolean white = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", DeselectBrowserArray);
|
||||
Log.e("setHomepagtag", "execute: homepagURL: add to whiteList = " + DeselectBrowserArray + "write: " + white);
|
||||
}
|
||||
//主页
|
||||
Intent homepag = new Intent("qch_app_brower_homepage");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
homepag.setPackage("com.android.settings")
|
||||
@@ -804,6 +807,132 @@ public class HTTPInterface {
|
||||
});
|
||||
}
|
||||
|
||||
public interface BookmarksCallback {
|
||||
void onSubscribe();
|
||||
|
||||
void onNext();
|
||||
|
||||
void onError(Throwable e);
|
||||
|
||||
void onComplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param callback
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
synchronized public static void getHomePageBookmarks(Context context, BookmarksCallback callback) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getBrowserBookmarksObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse<BrowserBookmarks>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
if (callback != null)
|
||||
callback.onSubscribe();
|
||||
Log.e("getHomePageBookmarks", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<BrowserBookmarks> browserBookmarksBaseResponse) {
|
||||
if (callback != null)
|
||||
callback.onNext();
|
||||
Log.e("getHomePageBookmarks", "onNext: ");
|
||||
if (browserBookmarksBaseResponse.code == 200) {
|
||||
//主页不包含白名单添加进去
|
||||
String homepagURL = browserBookmarksBaseResponse.data.getHomepage();
|
||||
boolean home = Settings.System.putString(context.getContentResolver(), "homepagURL", homepagURL);
|
||||
Log.e("getHomePageBookmarks ", "homepagURL: " + homepagURL);
|
||||
Log.e("getHomePageBookmarks", "onNext: homepagURL: save homepagURL = " + home);
|
||||
|
||||
String whitelist = Settings.System.getString(context.getContentResolver(), "DeselectBrowserArray");
|
||||
Log.e("getHomePageBookmarks ", "whitelist: " + whitelist);
|
||||
|
||||
if (!TextUtils.isEmpty(whitelist.trim())) {
|
||||
HashSet<String> whiteLists = new HashSet<>(Arrays.asList(whitelist.trim().split(",")));
|
||||
whiteLists.add(homepagURL);
|
||||
String whiteString = String.join(",", whiteLists);
|
||||
boolean white = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", whiteString);
|
||||
Log.e("getHomePageBookmarks", "onNext: homepagURL: add to whiteList = " + whiteString + "write: " + white);
|
||||
} else {
|
||||
Log.e("getHomePageBookmarks", "onNext: whitelist is NULL");
|
||||
boolean white = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", homepagURL);
|
||||
Log.e("getHomePageBookmarks", "onNext: homepagURL: homepagURL = " + homepagURL + "write: " + white);
|
||||
}
|
||||
|
||||
//主页
|
||||
Intent homepag = new Intent("qch_app_brower_homepage");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
homepag.setPackage("com.android.settings")
|
||||
.setPackage("com.android.browser");
|
||||
}
|
||||
if (!TextUtils.isEmpty(homepagURL)) {
|
||||
String newHomePage = JGYUtils.getPrefixHttpsURL(homepagURL);
|
||||
Log.e("getHomePageBookmarks", "onNext: newHomePage: " + newHomePage);
|
||||
homepag.putExtra("homepage", newHomePage);
|
||||
} else {
|
||||
homepag.putExtra("homepage", "Invalid");
|
||||
}
|
||||
context.sendBroadcast(homepag);
|
||||
|
||||
//书签
|
||||
String labelpage = browserBookmarksBaseResponse.data.getLabelpage();
|
||||
Intent websiteBookMark = new Intent("qch_app_brower_website");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
websiteBookMark.setPackage("com.android.settings")
|
||||
.setPackage("com.android.browser");
|
||||
}
|
||||
if (!TextUtils.isEmpty(labelpage)) {
|
||||
HashSet<String> labels = new HashSet<>(Arrays.asList(labelpage.split(",")));
|
||||
List<String> urlList = new ArrayList<>();
|
||||
for (String urls : labels) {
|
||||
urlList.add(JGYUtils.getPrefixHttpsURL(urls));
|
||||
}
|
||||
String join = String.join(",", urlList);
|
||||
Log.e("getHomePageBookmarks", "onNext: getHomePageBookmarks: " + join);
|
||||
websiteBookMark.putExtra("websiteBookMark", join);
|
||||
} else {
|
||||
websiteBookMark.putExtra("websiteBookMark", "Invalid");
|
||||
}
|
||||
context.sendBroadcast(websiteBookMark);
|
||||
} else {
|
||||
Intent intent1 = new Intent("qch_app_brower_homepage");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent1.setPackage("com.android.settings")
|
||||
.setPackage("com.android.browser");
|
||||
}
|
||||
intent1.putExtra("homepage", "Invalid");
|
||||
context.sendBroadcast(intent1);
|
||||
|
||||
Settings.System.putString(context.getContentResolver(), "homepagURL", "");
|
||||
Intent intent2 = new Intent("qch_app_brower_website");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent2.setPackage("com.android.settings")
|
||||
.setPackage("com.android.browser");
|
||||
}
|
||||
intent2.putExtra("websiteBookMark", "Invalid");
|
||||
context.sendBroadcast(intent2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
if (callback != null)
|
||||
callback.onError(e);
|
||||
Log.e("getHomePageBookmarks", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
if (callback != null)
|
||||
callback.onComplete();
|
||||
Log.e("getHomePageBookmarks", "onComplete: ");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setHideDesktopIcon(final Context context) {
|
||||
OkGo.post(URLAddress.GET_HIDE_DESKTOPICON)
|
||||
@@ -1080,7 +1209,7 @@ public class HTTPInterface {
|
||||
String end_time = jsonObject.getString("end_time");
|
||||
TimeUtils.ContralTime c = TimeUtils.String2ContralTime(context, start_time + "-" + end_time);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", "200:" + c.toString());
|
||||
Log.e("getTimeControl", "200: " + c.toString());
|
||||
}
|
||||
} else {
|
||||
TimeUtils.setEmpty(context);
|
||||
|
||||
@@ -46,7 +46,6 @@ import com.mjsheng.myappstore.utils.ServiceAliveUtils;
|
||||
import com.mjsheng.myappstore.utils.Utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import io.reactivex.Observable;
|
||||
@@ -1047,8 +1046,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private void setHomepagtag(String s) {
|
||||
//设置主页和标签
|
||||
HTTPInterface.setHomepagtag(mContext);//设置主页和标签
|
||||
|
||||
// HTTPInterface.setHomepagtag(mContext);//设置主页和标签
|
||||
HTTPInterface.getHomePageBookmarks(mContext, null);
|
||||
// if (TextUtils.isEmpty(s)) {
|
||||
// Log.e(TAG, "setHomepagtag extras is null");
|
||||
//
|
||||
|
||||
@@ -35,6 +35,8 @@ import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.SysSettingUtils;
|
||||
import com.mjsheng.myappstore.utils.TimeUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
@@ -162,6 +164,7 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
private void registerReceivers() {
|
||||
registerLockScreenReceiver();
|
||||
registerTimeReceiver();
|
||||
registerInstallReceiver();
|
||||
}
|
||||
|
||||
private void unRegisterReceivers() {
|
||||
@@ -171,6 +174,9 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
if (null != mTimeChangedReceiver) {
|
||||
unregisterReceiver(mTimeChangedReceiver);
|
||||
}
|
||||
if (null != mInstallReceiver) {
|
||||
unregisterReceiver(mInstallReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private static WindowManager windowManager;
|
||||
@@ -355,6 +361,62 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerInstallReceiver() {
|
||||
if (mInstallReceiver == null) {
|
||||
mInstallReceiver = new InstallReceiver();
|
||||
}
|
||||
IntentFilter intentFilter = new IntentFilter(INSTALLAPK_ACTION);
|
||||
registerReceiver(mInstallReceiver, intentFilter, INSTALLAPK_PREMISSIONS, null);
|
||||
}
|
||||
|
||||
private String INSTALLAPK_ACTION = "JGY_INSTALLAPK_ACTION";
|
||||
private String INSTALLAPK_PREMISSIONS = "com.jiaoguanyi.appstore.permissions.INSTALL_APK";
|
||||
|
||||
private InstallReceiver mInstallReceiver;
|
||||
|
||||
/**
|
||||
* https://blog.csdn.net/jdsjlzx/article/details/82630113
|
||||
*/
|
||||
class InstallReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
Log.e(TAG, "onReceive: " + "Action is NULL!");
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "onReceive: " + "Sender is " + intent.getPackage());
|
||||
String packageName = intent.getStringExtra("packageName");
|
||||
String filePath = intent.getStringExtra("filePath");
|
||||
if (!TextUtils.isEmpty(packageName) && !TextUtils.isEmpty(filePath)) {
|
||||
Log.e(TAG, "onReceive: " + "packageName: " + packageName + "filePath: " + filePath);
|
||||
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);
|
||||
} else {
|
||||
Log.e(TAG, "onReceive: " + "no filePath and packageName");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param filePath 路径
|
||||
* @param pkg 包名
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBatchText(String text, int visibility) {
|
||||
|
||||
@@ -185,8 +185,9 @@ public class ApkUtils {
|
||||
if (info != null) {
|
||||
ApplicationInfo appInfo = info.applicationInfo;
|
||||
return appInfo.packageName; //得到安装包名称
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1093,7 +1094,7 @@ public class ApkUtils {
|
||||
if ("com.jiaoguanyi.store".equals(s) || "com.jiaoguanyi.appstore".equals(s)) {
|
||||
continue;
|
||||
}
|
||||
if (!ApkUtils.isSystemApp(context, s)) {
|
||||
if (ApkUtils.isSystemApp(context, s)) {
|
||||
continue;
|
||||
}
|
||||
if (!ApkUtils.isAvailable(context, s)) {
|
||||
|
||||
@@ -473,6 +473,7 @@ public class JGYUtils {
|
||||
this.add("com.info.sn");
|
||||
this.add("com.uiuios.jgy1");
|
||||
this.add("com.uiuios.jgy2");
|
||||
this.add("com.tt.ttutils");
|
||||
}};
|
||||
// if (!TextUtils.isEmpty(stringBuilder)) {
|
||||
for (String pkg : packages) {
|
||||
@@ -1128,4 +1129,23 @@ public class JGYUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPrefixHttpURL(String url) {
|
||||
if (url.startsWith("http://")) {
|
||||
return url;
|
||||
} else if (url.startsWith("https://")) {
|
||||
return url.replace("https://", "http://");
|
||||
} else {
|
||||
return "http://" + url;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPrefixHttpsURL(String url) {
|
||||
if (url.startsWith("https://")) {
|
||||
return url;
|
||||
} else if (url.startsWith("http://")) {
|
||||
return url.replace("http://", "https://");
|
||||
} else {
|
||||
return "https://" + url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class URLUtils {
|
||||
|
||||
public void setBrowserWhiteList() {
|
||||
String whiteList = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
|
||||
if (TextUtils.isEmpty(whiteList)) {
|
||||
if (TextUtils.isEmpty(whiteList.trim())) {
|
||||
Log.e(TAG, "getBrowserWhiteList: " + "whiteList is empty");
|
||||
} else {
|
||||
Log.e(TAG, "getBrowserWhiteList: " + "whiteList is : " + whiteList);
|
||||
|
||||
Reference in New Issue
Block a user