version:1.3.4
update: fix: add:增加丢失模式,增加开发人员选项管控
This commit is contained in:
@@ -47,7 +47,6 @@ public class HomeActivity extends AppCompatActivity {
|
||||
|
||||
private void DebugTest() {
|
||||
// Utils.getHardware(this);
|
||||
hookWebView();
|
||||
// setWebView();
|
||||
// hideStatusBar();
|
||||
Log.e(TAG, "DebugTest: " + HttpHeaders.getUserAgent());
|
||||
@@ -121,60 +120,5 @@ public class HomeActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
public static void hookWebView() {
|
||||
int sdkInt = Build.VERSION.SDK_INT;
|
||||
try {
|
||||
Class<?> factoryClass = Class.forName("android.webkit.WebViewFactory");
|
||||
Field field = factoryClass.getDeclaredField("sProviderInstance");
|
||||
field.setAccessible(true);
|
||||
Object sProviderInstance = field.get(null);
|
||||
if (sProviderInstance != null) {
|
||||
Log.i(TAG, "sProviderInstance isn't null");
|
||||
return;
|
||||
}
|
||||
|
||||
Method getProviderClassMethod;
|
||||
if (sdkInt > 22) {
|
||||
getProviderClassMethod = factoryClass.getDeclaredMethod("getProviderClass");
|
||||
} else if (sdkInt == 22) {
|
||||
getProviderClassMethod = factoryClass.getDeclaredMethod("getFactoryClass");
|
||||
} else {
|
||||
Log.i(TAG, "Don't need to Hook WebView");
|
||||
return;
|
||||
}
|
||||
getProviderClassMethod.setAccessible(true);
|
||||
Class<?> factoryProviderClass = (Class<?>) getProviderClassMethod.invoke(factoryClass);
|
||||
Class<?> delegateClass = Class.forName("android.webkit.WebViewDelegate");
|
||||
Constructor<?> delegateConstructor = delegateClass.getDeclaredConstructor();
|
||||
delegateConstructor.setAccessible(true);
|
||||
if (sdkInt < 26) {//低于Android O版本
|
||||
Constructor<?> providerConstructor = factoryProviderClass.getConstructor(delegateClass);
|
||||
if (providerConstructor != null) {
|
||||
providerConstructor.setAccessible(true);
|
||||
sProviderInstance = providerConstructor.newInstance(delegateConstructor.newInstance());
|
||||
}
|
||||
} else {
|
||||
Field chromiumMethodName = factoryClass.getDeclaredField("CHROMIUM_WEBVIEW_FACTORY_METHOD");
|
||||
chromiumMethodName.setAccessible(true);
|
||||
String chromiumMethodNameStr = (String) chromiumMethodName.get(null);
|
||||
if (chromiumMethodNameStr == null) {
|
||||
chromiumMethodNameStr = "create";
|
||||
}
|
||||
Method staticFactory = factoryProviderClass.getMethod(chromiumMethodNameStr, delegateClass);
|
||||
if (staticFactory != null) {
|
||||
sProviderInstance = staticFactory.invoke(null, delegateConstructor.newInstance());
|
||||
}
|
||||
}
|
||||
|
||||
if (sProviderInstance != null) {
|
||||
field.set("sProviderInstance", sProviderInstance);
|
||||
Log.i(TAG, "Hook success!");
|
||||
} else {
|
||||
Log.i(TAG, "Hook failed!");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.gson.JsonObject;
|
||||
import com.mjsheng.myappstore.BuildConfig;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.base.BaseActivity;
|
||||
import com.mjsheng.myappstore.server.MainService;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.ExampleUtil;
|
||||
import com.mjsheng.myappstore.utils.JGYUtils;
|
||||
@@ -175,7 +176,7 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
iv_locked.setVisibility(View.VISIBLE);
|
||||
ApkUtils.getAppInfo(this);
|
||||
//上传APP信息
|
||||
if (netWorkIsRunning) {
|
||||
if (netWorkIsRunning|| MainService.netWorkIsRunning) {
|
||||
//如果正在执行,不执行
|
||||
return;
|
||||
}
|
||||
@@ -335,6 +336,16 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
|
||||
|
||||
@Override
|
||||
public void setLogoImgFinished() {
|
||||
mPresenter.setTopApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopAppFinished() {
|
||||
mPresenter.getDeveloper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDeveloperFinished() {
|
||||
netWorkIsRunning = false;
|
||||
Log.e(TAG, "SettingFinished: " + (System.currentTimeMillis() - timeMillis) + " ms");
|
||||
}
|
||||
|
||||
@@ -61,6 +61,10 @@ public class MainContact {
|
||||
//获取系统其他管控设置结束
|
||||
void setLogoImgFinished ();
|
||||
//设置开机动画
|
||||
void setTopAppFinished();
|
||||
//获取应用霸屏结束
|
||||
void getDeveloperFinished();
|
||||
//获取开发者选项结束
|
||||
/*
|
||||
* MainService
|
||||
* */
|
||||
@@ -122,6 +126,10 @@ public class MainContact {
|
||||
//获取系统其他管控设置
|
||||
void setLogoImg();
|
||||
//设置开机动画
|
||||
void setTopApp();
|
||||
//应用霸屏
|
||||
void getDeveloper();
|
||||
//获取开发者选项
|
||||
/*
|
||||
* MainService
|
||||
* */
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.mjsheng.myappstore.manager.NetInterfaceManager;
|
||||
import com.mjsheng.myappstore.network.api.newapi.UpdateDeviceInfoApi;
|
||||
import com.mjsheng.myappstore.server.MainService;
|
||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||
import com.mjsheng.myappstore.utils.ForegroundAppUtil;
|
||||
import com.mjsheng.myappstore.utils.JGYUtils;
|
||||
import com.mjsheng.myappstore.utils.SPUtils;
|
||||
import com.mjsheng.myappstore.utils.SysSettingUtils;
|
||||
@@ -80,7 +81,6 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
this.mView = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 通过sn获取用户信息
|
||||
@@ -675,6 +675,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
String data = jsonObject.getString("data");
|
||||
List<Batch> batchList = JSON.parseArray(data, Batch.class);
|
||||
if (null != batchList && batchList.size() > 1) {
|
||||
Log.e("getDeviceBatch", "onNext: " + "deleteOtherApp");
|
||||
if (!BuildConfig.DEBUG) {
|
||||
JGYUtils.getInstance().deleteOtherApp(packageList);
|
||||
}
|
||||
@@ -753,6 +754,15 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
|
||||
@Override
|
||||
public void getBrowserList() {
|
||||
// if (JGYUtils.isOfficialVersion()) {
|
||||
oldSetBrowserList();
|
||||
// } else {
|
||||
// setBrowserList();
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
private void setBrowserList() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getBrowserListSettingObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
@@ -767,28 +777,36 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
Log.e("getBrowserList", "onNext: ");
|
||||
if (browserDataBaseResponse.code == 200) {
|
||||
String white = browserDataBaseResponse.data.getWhite();
|
||||
|
||||
if (!TextUtils.isEmpty(white)) {
|
||||
String homePage = Settings.System.getString(mContext.getContentResolver(), "homepagURL");
|
||||
if (!TextUtils.isEmpty(homePage) && !white.contains(homePage)) {
|
||||
white += "," + homePage;
|
||||
}
|
||||
boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white);
|
||||
Log.e("getBrowserList", "setBrowserList white: " + white + ":" + whiteList);
|
||||
mView.getBrowserListFinished(white);
|
||||
} else {
|
||||
Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
mView.getBrowserListFinished("");
|
||||
}
|
||||
String black = browserDataBaseResponse.data.getBlack();
|
||||
if (!TextUtils.isEmpty(black)) {
|
||||
if (!TextUtils.isEmpty(white) && !TextUtils.isEmpty(black)) {
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", " ");
|
||||
//黑白名单同时存在时由以前的逻辑管控
|
||||
boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white);
|
||||
Log.e("setBrowserList", "setBrowserList white: " + white + ":" + whiteList);
|
||||
boolean blackList = Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", black);
|
||||
Log.e("getBrowserList", "setBrowserList black: " + black + ":" + blackList);
|
||||
} else {
|
||||
Log.e("setBrowserList", "setBrowserList black: " + black + ":" + blackList);
|
||||
mView.getBrowserListFinished(white);
|
||||
} else if (TextUtils.isEmpty(white)) {
|
||||
//设置黑名单
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 1);
|
||||
Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", black);
|
||||
//白名单为空由新的管控执行
|
||||
mView.getBrowserListFinished("");
|
||||
Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
} else if (TextUtils.isEmpty(black)) {
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", " ");
|
||||
//黑名单为空由旧的管控执行
|
||||
mView.getBrowserListFinished(white);
|
||||
Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
} else {
|
||||
//所有置空
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
Settings.System.putString(mContext.getContentResolver(), "BlackBrowserArray", " ");
|
||||
mView.getBrowserListFinished("");
|
||||
Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,8 +823,64 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
private void oldSetBrowserList() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getBrowserListSettingObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse<BrowserData>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("oldSetBrowserList", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
Log.e("oldSetBrowserList", "onNext: ");
|
||||
if (browserDataBaseResponse.code == 200) {
|
||||
//白名单
|
||||
String white = browserDataBaseResponse.data.getWhite();
|
||||
if (!TextUtils.isEmpty(white)) {
|
||||
String homePage = Settings.System.getString(mContext.getContentResolver(), "homepagURL");
|
||||
if (!TextUtils.isEmpty(homePage) && !white.contains(homePage)) {
|
||||
white += "," + homePage;
|
||||
}
|
||||
boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white);
|
||||
Log.e("oldSetBrowserList", "setBrowserList white: " + white + ":" + whiteList);
|
||||
mView.getBrowserListFinished(white);
|
||||
} else {
|
||||
Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
mView.getBrowserListFinished("");
|
||||
}
|
||||
//黑名单
|
||||
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);
|
||||
} else {
|
||||
Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
} else {
|
||||
mView.getBrowserListFinished("");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("oldSetBrowserList", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("oldSetBrowserList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBrowserBookmarks(String whitelist) {
|
||||
Log.e(TAG, "getBrowserBookmarks: " + "whitelist: " + whitelist);
|
||||
List<String> whiteLists = Arrays.asList(whitelist.split(","));
|
||||
NetInterfaceManager.getInstance()
|
||||
.getBrowserBookmarksObservable()
|
||||
@@ -828,6 +902,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
Log.e("getBrowserBookmarks", "onNext: homepagURL: save homepagURL = " + home);
|
||||
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);
|
||||
}
|
||||
@@ -865,6 +940,7 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
}
|
||||
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) {
|
||||
@@ -893,6 +969,18 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
@Override
|
||||
public void getBrowserWhiteList() {
|
||||
new URLUtils(mContext).setBrowserList();
|
||||
try {
|
||||
int qch_website_isBlackWebUrl = Settings.System.getInt(mContext.getContentResolver(), "qch_website_isBlackWebUrl");
|
||||
String BlackBrowserArray = Settings.System.getString(mContext.getContentResolver(), "BlackBrowserArray");
|
||||
String DeselectBrowserArray = Settings.System.getString(mContext.getContentResolver(), "DeselectBrowserArray");
|
||||
String qch_webblack_url = Settings.System.getString(mContext.getContentResolver(), "qch_webblack_url");
|
||||
Log.e("getBrowserWhiteList", "qch_website_isBlackWebUrl: " + qch_website_isBlackWebUrl);
|
||||
Log.e("getBrowserWhiteList", "BlackBrowserArray: " + BlackBrowserArray);
|
||||
Log.e("getBrowserWhiteList", "DeselectBrowserArray: " + DeselectBrowserArray);
|
||||
Log.e("getBrowserWhiteList", "qch_webblack_url: " + qch_webblack_url);
|
||||
} catch (Settings.SettingNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -948,7 +1036,8 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
public void getAppAutoStartUpdateAndNet() {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getAppAutoStartUpdateAndNetObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<NetAndLaunchBean>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
@@ -1192,6 +1281,89 @@ public class MainPresenter implements MainContact.Presenter {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopApp() {
|
||||
NetInterfaceManager.getInstance().getTopAppControl()
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("setTopApp", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse response) {
|
||||
Log.e("setTopApp", "onNext: " + response.data);
|
||||
if (response.code == 200) {
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(response.data);
|
||||
String app_package = jsonObject.getString("app_package");
|
||||
SPUtils.put(mContext, ForegroundAppUtil.TOPAPP_KEY, app_package);
|
||||
ForegroundAppUtil.openTopApp(mContext);
|
||||
} else {
|
||||
SPUtils.put(mContext, ForegroundAppUtil.TOPAPP_KEY, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("setTopApp", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("setTopApp", "onComplete: ");
|
||||
mView.setTopAppFinished();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDeveloper() {
|
||||
NetInterfaceManager.getInstance().getDeveloperControl()
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
Log.e("getDeveloper", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
Log.e("getDeveloper", "onNext: ");
|
||||
if (baseResponse.code == 200) {
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(baseResponse.data);
|
||||
int is_developer = jsonObject.getInteger("is_developer");
|
||||
//后台1是0否 底层0是1否
|
||||
setDeveloper(is_developer == 0 ? 1 : 0);
|
||||
} else {
|
||||
setDeveloper(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getDeveloper", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
mView.getDeveloperFinished();
|
||||
Log.e("getDeveloper", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void setDeveloper(int state) {
|
||||
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);
|
||||
if (state == 1) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("qch_developeroptions_close");
|
||||
intent.setPackage("com.android.settings");
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getScreenLockState() {
|
||||
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 1);
|
||||
|
||||
@@ -533,7 +533,7 @@ public class OldActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void call(Long aLong) {
|
||||
// getDeselectBrowerID();//浏览器网址管控
|
||||
HTTPInterface.setBrowserList(OldActivity.this);//浏览器网址管控
|
||||
HTTPInterface.setBrowserBlackList(OldActivity.this);//浏览器网址管控
|
||||
HTTPInterface.setHomepagtag(OldActivity.this);//设置主页和标签
|
||||
HTTPInterface.setAppinsideWeb(OldActivity.this);//app内部网页管控
|
||||
HTTPInterface.setHideDesktopIcon(OldActivity.this);//设置桌面图标隐藏
|
||||
|
||||
@@ -55,6 +55,9 @@ import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -112,6 +115,7 @@ public class BaseApplication extends MultiDexApplication {
|
||||
JGYUtils.init(this);
|
||||
XAPKUtils.init(this);
|
||||
FileManager.init(this);
|
||||
hookWebView();
|
||||
Configuration config = getResources().getConfiguration();
|
||||
int smallestScreenWidthDp = config.smallestScreenWidthDp;
|
||||
Log.e("mjsheng", "smallestScreenWidthDp=" + smallestScreenWidthDp);
|
||||
@@ -158,6 +162,63 @@ public class BaseApplication extends MultiDexApplication {
|
||||
AmapManager.init(this);
|
||||
}
|
||||
|
||||
public void hookWebView() {
|
||||
int sdkInt = Build.VERSION.SDK_INT;
|
||||
try {
|
||||
Class<?> factoryClass = Class.forName("android.webkit.WebViewFactory");
|
||||
Field field = factoryClass.getDeclaredField("sProviderInstance");
|
||||
field.setAccessible(true);
|
||||
Object sProviderInstance = field.get(null);
|
||||
if (sProviderInstance != null) {
|
||||
Log.i(TAG, "sProviderInstance isn't null");
|
||||
return;
|
||||
}
|
||||
|
||||
Method getProviderClassMethod;
|
||||
if (sdkInt > 22) {
|
||||
getProviderClassMethod = factoryClass.getDeclaredMethod("getProviderClass");
|
||||
} else if (sdkInt == 22) {
|
||||
getProviderClassMethod = factoryClass.getDeclaredMethod("getFactoryClass");
|
||||
} else {
|
||||
Log.i(TAG, "Don't need to Hook WebView");
|
||||
return;
|
||||
}
|
||||
getProviderClassMethod.setAccessible(true);
|
||||
Class<?> factoryProviderClass = (Class<?>) getProviderClassMethod.invoke(factoryClass);
|
||||
Class<?> delegateClass = Class.forName("android.webkit.WebViewDelegate");
|
||||
Constructor<?> delegateConstructor = delegateClass.getDeclaredConstructor();
|
||||
delegateConstructor.setAccessible(true);
|
||||
if (sdkInt < 26) {//低于Android O版本
|
||||
Constructor<?> providerConstructor = factoryProviderClass.getConstructor(delegateClass);
|
||||
if (providerConstructor != null) {
|
||||
providerConstructor.setAccessible(true);
|
||||
sProviderInstance = providerConstructor.newInstance(delegateConstructor.newInstance());
|
||||
}
|
||||
} else {
|
||||
Field chromiumMethodName = factoryClass.getDeclaredField("CHROMIUM_WEBVIEW_FACTORY_METHOD");
|
||||
chromiumMethodName.setAccessible(true);
|
||||
String chromiumMethodNameStr = (String) chromiumMethodName.get(null);
|
||||
if (chromiumMethodNameStr == null) {
|
||||
chromiumMethodNameStr = "create";
|
||||
}
|
||||
Method staticFactory = factoryProviderClass.getMethod(chromiumMethodNameStr, delegateClass);
|
||||
if (staticFactory != null) {
|
||||
sProviderInstance = staticFactory.invoke(null, delegateConstructor.newInstance());
|
||||
}
|
||||
}
|
||||
|
||||
if (sProviderInstance != null) {
|
||||
field.set("sProviderInstance", sProviderInstance);
|
||||
Log.i(TAG, "Hook success!");
|
||||
} else {
|
||||
Log.i(TAG, "Hook failed!");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 忽略电池优化
|
||||
@@ -722,7 +783,7 @@ public class BaseApplication extends MultiDexApplication {
|
||||
new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
Log.d("捕获异常子线程:", Thread.currentThread().getName() +
|
||||
Log.e("捕获异常子线程:", Thread.currentThread().getName() +
|
||||
"在:" + e.getStackTrace()[0].getClassName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.mjsheng.myappstore.network.api.newapi.DesktopIconApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.DevicesLockedStateApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.GetBatchApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.GetDesktopApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.GetDeveloper;
|
||||
import com.mjsheng.myappstore.network.api.newapi.GetLockStateApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.JpushTagsApi;
|
||||
import com.mjsheng.myappstore.network.api.newapi.LogoImgApi;
|
||||
@@ -305,6 +306,20 @@ public class NetInterfaceManager {
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
public Observable<BaseResponse> getTopAppControl() {
|
||||
return mRetrofit.create(TopAppControlApi.class)
|
||||
.getSnAppControl(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
public Observable<BaseResponse> getDeveloperControl() {
|
||||
return mRetrofit.create(GetDeveloper.class)
|
||||
.getDeveloperState(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
||||
@@ -16,6 +16,8 @@ import android.util.Log;
|
||||
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;
|
||||
@@ -45,6 +47,7 @@ import java.util.Set;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Call;
|
||||
@@ -487,50 +490,126 @@ public class HTTPInterface {
|
||||
}
|
||||
|
||||
//设置浏览器黑白名单
|
||||
synchronized public static void setBrowserList(final Context context) {
|
||||
OkGo.post(URLAddress.SET_BROWSER_LIST)
|
||||
.params("key", NetInterfaceManager.HTTP_KEY)
|
||||
.params("sn", Utils.getSerial())
|
||||
.execute(new StringCallback() {
|
||||
synchronized public static void setBrowserBlackList(final Context context) {
|
||||
// if (JGYUtils.isOfficialVersion()) {
|
||||
oldSetBrowserList(context);
|
||||
// } else {
|
||||
// setBrowserList(context);
|
||||
// }
|
||||
}
|
||||
private static void setBrowserList(Context context) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getBrowserListSettingObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse<BrowserData>>() {
|
||||
@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");
|
||||
String homePage = Settings.System.getString(context.getContentResolver(), "homepagURL");
|
||||
if (!TextUtils.isEmpty(white)) {
|
||||
if (!TextUtils.isEmpty(homePage) && !white.contains(homePage)) {
|
||||
white += "," + homePage;
|
||||
}
|
||||
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
|
||||
new URLUtils(context).setBrowserList();
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("getBrowserList", "onSubscribe: ");
|
||||
}
|
||||
|
||||
Log.e("SystemSetting", "setBrowserList----white-----" + whiteList + ":" + white);
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
}
|
||||
String black = data.getString("black");
|
||||
if (!TextUtils.isEmpty(black)) {
|
||||
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black);
|
||||
Log.e("SystemSetting", "setBrowserList----black-----" + blackList + ":" + black);
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
} else {
|
||||
Log.e("fht", "setBrowserList" + msg);
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
|
||||
Log.e("getBrowserList", "onNext: ");
|
||||
if (browserDataBaseResponse.code == 200) {
|
||||
String white = browserDataBaseResponse.data.getWhite();
|
||||
String black = browserDataBaseResponse.data.getBlack();
|
||||
if (!TextUtils.isEmpty(white) && !TextUtils.isEmpty(black)) {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
Settings.System.putString(context.getContentResolver(), "BlackBrowserArray", " ");
|
||||
//黑白名单同时存在时由以前的逻辑管控
|
||||
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
|
||||
Log.e("setBrowserList", "setBrowserList white: " + white + ":" + whiteList);
|
||||
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black);
|
||||
Log.e("setBrowserList", "setBrowserList black: " + black + ":" + blackList);
|
||||
} else if (TextUtils.isEmpty(white)) {
|
||||
//设置黑名单
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_website_isBlackWebUrl", 1);
|
||||
Settings.System.putString(context.getContentResolver(), "BlackBrowserArray", black);
|
||||
//白名单为空由新的管控执行
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
|
||||
} else if (TextUtils.isEmpty(black)) {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
Settings.System.putString(context.getContentResolver(), "BlackBrowserArray", " ");
|
||||
//黑名单为空由旧的管控执行
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
|
||||
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
Log.e("fht", "setBrowserList" + e.getMessage());
|
||||
} else {
|
||||
//所有置空
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
Settings.System.putString(context.getContentResolver(), "BlackBrowserArray", " ");
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Call call, Response response, Exception e) {
|
||||
super.onError(call, response, e);
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getBrowserList", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("getBrowserList", "onComplete: ");
|
||||
new URLUtils(context).setBrowserList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static void oldSetBrowserList(Context context) {
|
||||
NetInterfaceManager.getInstance()
|
||||
.getBrowserListSettingObservable()
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(new Observer<BaseResponse<BrowserData>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
Log.e("oldSetBrowserList", "onSubscribe: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<BrowserData> browserDataBaseResponse) {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_website_isBlackWebUrl", 0);
|
||||
Log.e("oldSetBrowserList", "onNext: ");
|
||||
if (browserDataBaseResponse.code == 200) {
|
||||
//白名单
|
||||
String white = browserDataBaseResponse.data.getWhite();
|
||||
if (!TextUtils.isEmpty(white)) {
|
||||
String homePage = Settings.System.getString(context.getContentResolver(), "homepagURL");
|
||||
if (!TextUtils.isEmpty(homePage) && !white.contains(homePage)) {
|
||||
white += "," + homePage;
|
||||
}
|
||||
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
|
||||
Log.e("oldSetBrowserList", "setBrowserList white: " + white + ":" + whiteList);
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
}
|
||||
//黑名单
|
||||
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);
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
} else {
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
|
||||
Settings.System.putString(context.getContentResolver(), "qch_webblack_url", " ");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("oldSetBrowserList", "onError: " + e.getMessage());
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
new URLUtils(context).setBrowserList();
|
||||
Log.e("oldSetBrowserList", "onComplete: ");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,5 +53,7 @@ public class URLAddress {
|
||||
public final static String GET_SN_APP_TEST = HTTP_TAG_HEAD_NEW + "Sn/getSnAppTest";
|
||||
//获取测试app
|
||||
public final static String GET_LOGO_IMG = HTTP_TAG_HEAD_NEW + "Sn/getLogoImg";
|
||||
//开机动画
|
||||
public final static String GET_DEVELOPER = HTTP_TAG_HEAD_NEW + "Sn/getDeveloper";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mjsheng.myappstore.network.api.newapi;
|
||||
|
||||
import com.mjsheng.myappstore.bean.BaseResponse;
|
||||
import com.mjsheng.myappstore.network.URLAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GetDeveloper {
|
||||
@GET(URLAddress.GET_DEVELOPER)
|
||||
Observable<BaseResponse> getDeveloperState(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -9,6 +9,10 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -21,6 +25,7 @@ import com.amap.api.location.AMapLocation;
|
||||
import com.amap.api.location.AMapLocationClient;
|
||||
import com.amap.api.location.AMapLocationListener;
|
||||
import com.blankj.utilcode.util.PathUtils;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.utils.CacheUtils;
|
||||
import com.mjsheng.myappstore.utils.JGYUtils;
|
||||
import com.lzy.okgo.OkGo;
|
||||
@@ -120,6 +125,10 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
|
||||
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数据
|
||||
|
||||
|
||||
@@ -347,6 +356,12 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
setBootanimation(context, extras);
|
||||
Log.e(TAG, "processCustomMessage: " + extras);
|
||||
break;
|
||||
|
||||
case DEFAULTP_APP:
|
||||
break;
|
||||
case PLAY_SOUND:
|
||||
playSound(context, extras);
|
||||
break;
|
||||
case CLEAN_APP_CACHE:
|
||||
cleanCache(context, extras);
|
||||
break;
|
||||
@@ -850,7 +865,7 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
private void getDeselectBrowerID() {
|
||||
HTTPInterface.setBrowserList(mContext);//浏览器网址管控
|
||||
HTTPInterface.setBrowserBlackList(mContext);//浏览器网址管控
|
||||
|
||||
// Network.getDeselectBrowserIDApi().getDeselectBrowserIDApi("YTM3YTAxNTJmMmZmNzkyM2E2YzIwZjlhZTc0NzNmMGI=", Utils.getSerial()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<ResponseBody>() {
|
||||
// public void onComplete() {
|
||||
@@ -1310,9 +1325,9 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
private void getTopApp(Context context, String extras) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(extras);
|
||||
String packageName = jsonObject.getString("app_package");
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
return;
|
||||
}
|
||||
// if (TextUtils.isEmpty(packageName)) {
|
||||
// return;
|
||||
// }
|
||||
SPUtils.put(context, ForegroundAppUtil.TOPAPP_KEY, packageName);
|
||||
ForegroundAppUtil.openTopApp(context);
|
||||
}
|
||||
@@ -1329,6 +1344,76 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void playSound(Context context, String extras) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(extras);
|
||||
defaultCallMediaPlayer(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放系统默认来电铃声
|
||||
*
|
||||
* @return MediaPlayer对象
|
||||
* @throws Exception
|
||||
*/
|
||||
public void defaultCallMediaPlayer(Context context) {
|
||||
// Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
|
||||
// Ringtone r = RingtoneManager.getRingtone(mContext, notification);
|
||||
// r.play();
|
||||
MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.test);
|
||||
try {
|
||||
// mediaPlayer.prepare();
|
||||
mediaPlayer.setLooping(false);
|
||||
int duration = mediaPlayer.getDuration() / 1000;
|
||||
Log.e(TAG, "defaultCallMediaPlayer: " + "duration: " + duration);
|
||||
int loop = 0;
|
||||
if (duration <= 1) {
|
||||
loop = 30;
|
||||
} else {
|
||||
loop = (30 / duration);
|
||||
}
|
||||
final int[] soundCount = {0};
|
||||
int finalLoop = loop;
|
||||
mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||
if (soundCount[0] <= finalLoop) {
|
||||
setMaxVolume(context);
|
||||
mediaPlayer.start();
|
||||
soundCount[0] += 1;
|
||||
Log.e(TAG, "onCompletion: " + "loop: " + finalLoop);
|
||||
Log.e(TAG, "onCompletion: " + "soundCount: " + soundCount[0]);
|
||||
} else {
|
||||
mediaPlayer.stop();
|
||||
mediaPlayer.release();
|
||||
Log.e(TAG, "onCompletion: " + "loop: " + finalLoop);
|
||||
Log.e(TAG, "onCompletion: " + "soundCount: " + soundCount[0]);
|
||||
}
|
||||
}
|
||||
});
|
||||
mediaPlayer.setLooping(false);
|
||||
setMaxVolume(context);
|
||||
mediaPlayer.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "defaultCallMediaPlayer: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setMaxVolume(Context context) {
|
||||
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
int ringMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
|
||||
int musicMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||
int voiceMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0);
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 0); //音乐音量
|
||||
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
|
||||
audioManager.setSpeakerphoneOn(true);
|
||||
}
|
||||
|
||||
|
||||
private void cleanCache(Context context, String extras) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(extras);
|
||||
String packageName = jsonObject.getString("app_package");
|
||||
|
||||
@@ -761,7 +761,7 @@ public class InitJpushServer extends Service {
|
||||
List<Batch> batchList = JSON.parseArray(data, Batch.class);
|
||||
if (null != batchList && batchList.size() > 1) {
|
||||
if (!BuildConfig.DEBUG) {
|
||||
deleteOtherApp(result);
|
||||
JGYUtils.getInstance().deleteOtherApp(result);
|
||||
}
|
||||
} else {
|
||||
Log.e("getDeviceBatch", "批次为空");
|
||||
@@ -783,39 +783,6 @@ public class InitJpushServer extends Service {
|
||||
|
||||
}
|
||||
|
||||
//删除用户除了在应用市场的其他应用
|
||||
private void deleteOtherApp(String packageList) {
|
||||
Log.e("deleteOtherApp", "packageList:" + packageList);
|
||||
String[] result = packageList.split(",");
|
||||
List<String> resultList = new ArrayList<>(Arrays.asList(result));
|
||||
List<String> packageLists = ApkUtils.queryFilterAppInfo(this);
|
||||
|
||||
Log.e("deleteOtherApp", "packageLists:" + packageLists.toString());
|
||||
if (resultList.size() > 0) {
|
||||
for (final String packageName : packageLists) {
|
||||
if (Utils.isSystemApp(this, packageName)) {
|
||||
Log.e("deleteOtherApp", "is systemApp:" + packageName);
|
||||
continue;
|
||||
}
|
||||
if (ApkUtils.canremove_systemapp.contains(packageName)) {
|
||||
continue;
|
||||
}
|
||||
if (!resultList.contains(packageName)) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
ApkUtils.uninstall(InitJpushServer.this, packageName);
|
||||
} else {
|
||||
ApkUtils.deleteApkInSilence(packageName);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
Log.e("deleteOtherApp", "uninstall apkName:" + packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getNetAndLaunchSetting() {
|
||||
NetAndLaunchApi netAndLaunchApi = NetInterfaceManager.getNetAndLaunchApi();
|
||||
@@ -1260,7 +1227,7 @@ public class InitJpushServer extends Service {
|
||||
initJpush();
|
||||
HTTPInterface.setJpushTags(InitJpushServer.this);
|
||||
sendMACaddress();
|
||||
HTTPInterface.setBrowserList(InitJpushServer.this);//浏览器网址管控
|
||||
HTTPInterface.setBrowserBlackList(InitJpushServer.this);//浏览器网址管控
|
||||
HTTPInterface.setAppinsideWeb(InitJpushServer.this);//app内部网页管控
|
||||
HTTPInterface.setHomepagtag(InitJpushServer.this);//设置主页和标签
|
||||
HTTPInterface.setHideDesktopIcon(InitJpushServer.this);//设置桌面图标隐藏
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.widget.TextView;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mjsheng.myappstore.R;
|
||||
import com.mjsheng.myappstore.activity.HomeActivity;
|
||||
import com.mjsheng.myappstore.activity.MainActivity;
|
||||
import com.mjsheng.myappstore.activity.MainContact;
|
||||
import com.mjsheng.myappstore.activity.MainPresenter;
|
||||
@@ -35,12 +34,64 @@ import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||
import com.mjsheng.myappstore.utils.SysSettingUtils;
|
||||
import com.mjsheng.myappstore.utils.TimeUtils;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public class MainService extends Service implements MainContact.MainView {
|
||||
private MainPresenter mPresenter;
|
||||
private static final String TAG = MainService.class.getSimpleName();
|
||||
private boolean netWorkIsRunning = false;
|
||||
public static boolean netWorkIsRunning = false;
|
||||
|
||||
private interface Start {
|
||||
void onstar(long time);
|
||||
}
|
||||
|
||||
private Start start;
|
||||
|
||||
|
||||
private ObservableOnSubscribe<Long> subscribe = new ObservableOnSubscribe<Long>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Long> 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);
|
||||
startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
||||
mPresenter.getFirstConnect();
|
||||
mPresenter.getLockedState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public MainService() {
|
||||
|
||||
@@ -58,6 +109,9 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
mPresenter.attachView(this);
|
||||
registerReceivers();
|
||||
addShortcut();
|
||||
Observable.create(subscribe)
|
||||
.throttleLast(60, TimeUnit.SECONDS)
|
||||
.subscribe(TimeObserver);
|
||||
// cleanLauncherCache();
|
||||
super.onCreate();
|
||||
}
|
||||
@@ -81,16 +135,18 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
if (MainActivity.isForeground) {
|
||||
Log.e(TAG, "onStartCommand: MainActivity: isForeground: " + MainActivity.isForeground);
|
||||
} else {
|
||||
if (((SystemClock.elapsedRealtime() - startCommandTime) < 60000) && startCommandTime != 0) {
|
||||
Log.e(TAG, "onStartCommand: " + "启动时间过短");
|
||||
//一分钟内防止多次调用
|
||||
} else {
|
||||
mPresenter.getFirstConnect();
|
||||
mPresenter.getLockedState();
|
||||
startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
||||
Log.e(TAG, "onStartCommand: isForeground: " + MainActivity.isForeground);
|
||||
Log.e(TAG, "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime));
|
||||
}
|
||||
// if (((SystemClock.elapsedRealtime() - startCommandTime) < 60000) && startCommandTime != 0) {
|
||||
// Log.e(TAG, "onStartCommand: " + "启动时间过短");
|
||||
// //一分钟内防止多次调用
|
||||
// } else {
|
||||
// mPresenter.getFirstConnect();
|
||||
// mPresenter.getLockedState();
|
||||
// startCommandTime = runningTime = SystemClock.elapsedRealtime();
|
||||
// Log.e(TAG, "onStartCommand: isForeground: " + MainActivity.isForeground);
|
||||
// Log.e(TAG, "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime));
|
||||
// }
|
||||
start.onstar(SystemClock.elapsedRealtime());
|
||||
Log.e("TimeObserver", "onStartCommand: " + (SystemClock.elapsedRealtime() - startCommandTime) + "ms");
|
||||
}
|
||||
return START_STICKY;
|
||||
}
|
||||
@@ -170,17 +226,23 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
// 设置LayoutParam
|
||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
|
||||
} else {
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
layoutParams.flags = WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
|
||||
layoutParams.flags |= WindowManager.LayoutParams.FLAG_BLUR_BEHIND
|
||||
| WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
|
||||
layoutParams.format = PixelFormat.RGBA_8888;
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
//systemUiVisibility 关闭通知栏和导航栏
|
||||
layoutParams.systemUiVisibility =
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
||||
layoutParams.x = 0;
|
||||
layoutParams.y = 0;
|
||||
|
||||
// 将悬浮窗控件添加到WindowManager
|
||||
windowManager.addView(topView, layoutParams);
|
||||
topView.setTag("added");
|
||||
@@ -422,6 +484,7 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
|
||||
@Override
|
||||
public void getBrowserBookmarksFinished() {
|
||||
mPresenter.getBrowserWhiteList();
|
||||
mPresenter.getDesktopIcon();
|
||||
}
|
||||
|
||||
@@ -452,6 +515,16 @@ public class MainService extends Service implements MainContact.MainView {
|
||||
|
||||
@Override
|
||||
public void setLogoImgFinished() {
|
||||
mPresenter.setTopApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTopAppFinished() {
|
||||
mPresenter.getDeveloper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDeveloperFinished() {
|
||||
netWorkIsRunning = false;
|
||||
Log.e(TAG, "SettingFinished: " + (SystemClock.elapsedRealtime() - runningTime) + " ms");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class URLUtils {
|
||||
if (TextUtils.isEmpty(whiteList)) {
|
||||
Log.e(TAG, "getBrowserWhiteList: " + "whiteList is empty");
|
||||
} else {
|
||||
List<String> URLList = Arrays.asList(whiteList.split(","));
|
||||
List<String> URLList = new ArrayList<>(Arrays.asList(whiteList.split(",")));
|
||||
Observable.create(new ObservableOnSubscribe<String>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
||||
@@ -53,14 +53,19 @@ public class URLUtils {
|
||||
if (!baseURLList.contains(noHttp)) {
|
||||
baseURLList.add(noHttp);
|
||||
}
|
||||
}
|
||||
if (url.startsWith("https://")) {
|
||||
emitter.onNext(getOkHttpURL(url));
|
||||
} else if (url.startsWith("https://")) {
|
||||
String noHttps = url.substring(8);
|
||||
if (!baseURLList.contains(noHttps)) {
|
||||
baseURLList.add(noHttps);
|
||||
}
|
||||
emitter.onNext(getOkHttpURL(url));
|
||||
} else {
|
||||
baseURLList.add("http://" + url);
|
||||
emitter.onNext(getOkHttpURL("http://" + url));
|
||||
baseURLList.add("https://" + url);
|
||||
emitter.onNext(getOkHttpURL("https://" + url));
|
||||
}
|
||||
emitter.onNext(getOkHttpURL(url));
|
||||
Log.e(TAG, "subscribe: " + url);
|
||||
}
|
||||
emitter.onComplete();
|
||||
@@ -97,7 +102,7 @@ public class URLUtils {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
Log.e(TAG, "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -223,6 +228,7 @@ public class URLUtils {
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "getUserAgent: " + sb.toString());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1501,5 +1501,7 @@ public class Utils {
|
||||
long availableSize = sf.getAvailableBytes();
|
||||
return Formatter.formatFileSize(context, availableSize);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user