update:2021.04.02
fix:浏览器主页写进白名单,开机动画接口推送对接
add:
This commit is contained in:
FHT
2021-04-02 09:35:55 +08:00
parent 99f74e9f83
commit a43068a1a1
13 changed files with 449 additions and 112 deletions

View File

@@ -87,6 +87,7 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:networkSecurityConfig="@xml/network" android:networkSecurityConfig="@xml/network"
android:requestLegacyExternalStorage="true"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">

View File

@@ -293,8 +293,8 @@ public class MainActivity extends BaseActivity implements MainContact.MainView {
} }
@Override @Override
public void getBrowserListFinished() { public void getBrowserListFinished(String whitelist) {
mPresenter.getBrowserBookmarks(); mPresenter.getBrowserBookmarks(whitelist);
} }
@Override @Override

View File

@@ -45,7 +45,7 @@ public class MainContact {
//获取设备批次结束 //获取设备批次结束
void getForceDownloadFinished(); void getForceDownloadFinished();
//获取强制下载apk结束 //获取强制下载apk结束
void getBrowserListFinished(); void getBrowserListFinished(String whitelist);
//获取浏览器上网管控设置结束 //获取浏览器上网管控设置结束
void getBrowserBookmarksFinished(); void getBrowserBookmarksFinished();
//获取浏览器书签设置管控结束 //获取浏览器书签设置管控结束
@@ -106,7 +106,7 @@ public class MainContact {
//获取强制下载apk //获取强制下载apk
void getBrowserList(); void getBrowserList();
//获取浏览器上网管控设置 //获取浏览器上网管控设置
void getBrowserBookmarks(); void getBrowserBookmarks(String whitelist);
//获取浏览器书签设置管控 //获取浏览器书签设置管控
void getDesktopIcon(); void getDesktopIcon();
//获取应用图标桌面可见性管控 //获取应用图标桌面可见性管控

View File

@@ -29,6 +29,7 @@ import com.jiaoguanyi.appstore.bean.Desktop;
import com.jiaoguanyi.appstore.bean.ForceDownloadBean; import com.jiaoguanyi.appstore.bean.ForceDownloadBean;
import com.jiaoguanyi.appstore.bean.LogoImg; import com.jiaoguanyi.appstore.bean.LogoImg;
import com.jiaoguanyi.appstore.bean.NetAndLaunchBean; import com.jiaoguanyi.appstore.bean.NetAndLaunchBean;
import com.jiaoguanyi.appstore.bean.NewAppground;
import com.jiaoguanyi.appstore.bean.StudentsInfo; import com.jiaoguanyi.appstore.bean.StudentsInfo;
import com.jiaoguanyi.appstore.jpush.TagAliasOperatorHelper; import com.jiaoguanyi.appstore.jpush.TagAliasOperatorHelper;
import com.jiaoguanyi.appstore.manager.NetInterfaceManager; import com.jiaoguanyi.appstore.manager.NetInterfaceManager;
@@ -716,7 +717,7 @@ public class MainPresenter implements MainContact.Presenter {
Log.e("getForceDownload", "isDownloading=" + BaseApplication.getInstance().isDownloading()); Log.e("getForceDownload", "isDownloading=" + BaseApplication.getInstance().isDownloading());
BaseApplication.getInstance().checkIsDownloading(); BaseApplication.getInstance().checkIsDownloading();
if (!BaseApplication.getInstance().isDownloading()) { if (!BaseApplication.getInstance().isDownloading()) {
Aria.download(this).removeAllTask(true); // Aria.download(this).removeAllTask(true);
JGYUtils.getInstance().forceDownload(forceDownloadBean.getData()); JGYUtils.getInstance().forceDownload(forceDownloadBean.getData());
} else { } else {
Aria.download(this).resumeAllTask(); Aria.download(this).resumeAllTask();
@@ -762,7 +763,12 @@ public class MainPresenter implements MainContact.Presenter {
Log.e("getBrowserList", "onNext: "); Log.e("getBrowserList", "onNext: ");
if (browserDataBaseResponse.code == 200) { if (browserDataBaseResponse.code == 200) {
String white = browserDataBaseResponse.data.getWhite(); String white = browserDataBaseResponse.data.getWhite();
mView.getBrowserListFinished(white);
if (!TextUtils.isEmpty(white)) { if (!TextUtils.isEmpty(white)) {
String homePage = Settings.System.getString(mContext.getContentResolver(), "homepagURL");
if (!white.contains(homePage) && !TextUtils.isEmpty(homePage)) {
white += "," + homePage;
}
boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white); boolean whiteList = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", white);
Log.e("getBrowserList", "setBrowserList white: " + white + ":" + whiteList); Log.e("getBrowserList", "setBrowserList white: " + white + ":" + whiteList);
} else { } else {
@@ -775,6 +781,8 @@ public class MainPresenter implements MainContact.Presenter {
} else { } else {
Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " "); Settings.System.putString(mContext.getContentResolver(), "qch_webblack_url", " ");
} }
} else {
mView.getBrowserListFinished("");
} }
} }
@@ -787,13 +795,13 @@ public class MainPresenter implements MainContact.Presenter {
@Override @Override
public void onComplete() { public void onComplete() {
Log.e("getBrowserList", "onComplete: "); Log.e("getBrowserList", "onComplete: ");
mView.getBrowserListFinished();
} }
}); });
} }
@Override @Override
public void getBrowserBookmarks() { public void getBrowserBookmarks(String whitelist) {
List<String> whiteLists = Arrays.asList(whitelist.split(","));
NetInterfaceManager.getInstance() NetInterfaceManager.getInstance()
.getBrowserBookmarksObservable() .getBrowserBookmarksObservable()
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
@@ -806,15 +814,24 @@ public class MainPresenter implements MainContact.Presenter {
@Override @Override
public void onNext(@NonNull BaseResponse<BrowserBookmarks> browserBookmarksBaseResponse) { public void onNext(@NonNull BaseResponse<BrowserBookmarks> browserBookmarksBaseResponse) {
Log.e("getBrowserBookmarks", "onNext: "); Log.e("getBrowserBookmarks", "onNext: ");
String whiteString = whitelist;
if (browserBookmarksBaseResponse.code == 200) { if (browserBookmarksBaseResponse.code == 200) {
//主页 //主页
String homepagURL = browserBookmarksBaseResponse.data.getHomepage(); String homepagURL = browserBookmarksBaseResponse.data.getHomepage();
boolean home = Settings.System.putString(mContext.getContentResolver(), "homepagURL", homepagURL);
Log.e("getBrowserBookmarks", "onNext: homepagURL: save homepagURL = " + home);
if (whiteLists.size() <= 0 || !whiteLists.contains(homepagURL)) {
whiteString += "," + homepagURL;
boolean white = Settings.System.putString(mContext.getContentResolver(), "DeselectBrowserArray", whiteString);
Log.e("getBrowserBookmarks", "onNext: homepagURL: add to whiteList = " + whiteString + "write: " + white);
}
Intent homepag = new Intent("qch_app_brower_homepage"); Intent homepag = new Intent("qch_app_brower_homepage");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
homepag.setPackage("com.android.settings") homepag.setPackage("com.android.settings")
.setPackage("com.android.browser"); .setPackage("com.android.browser");
} }
if (homepagURL != null && !homepagURL.equals("")) { if (!TextUtils.isEmpty(homepagURL)) {
homepag.putExtra("homepage", homepagURL); homepag.putExtra("homepage", homepagURL);
} else { } else {
homepag.putExtra("homepage", "Invalid"); homepag.putExtra("homepage", "Invalid");
@@ -828,7 +845,7 @@ public class MainPresenter implements MainContact.Presenter {
websiteBookMark.setPackage("com.android.settings") websiteBookMark.setPackage("com.android.settings")
.setPackage("com.android.browser"); .setPackage("com.android.browser");
} }
if (labelpage != null && !labelpage.equals("")) { if (!TextUtils.isEmpty(labelpage)) {
websiteBookMark.putExtra("websiteBookMark", labelpage); websiteBookMark.putExtra("websiteBookMark", labelpage);
} else { } else {
websiteBookMark.putExtra("websiteBookMark", "Invalid"); websiteBookMark.putExtra("websiteBookMark", "Invalid");
@@ -842,6 +859,7 @@ public class MainPresenter implements MainContact.Presenter {
} }
intent1.putExtra("homepage", "Invalid"); intent1.putExtra("homepage", "Invalid");
mContext.sendBroadcast(intent1); mContext.sendBroadcast(intent1);
Settings.System.putString(mContext.getContentResolver(), "homepagURL", "");
Intent intent2 = new Intent("qch_app_brower_website"); Intent intent2 = new Intent("qch_app_brower_website");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
intent2.setPackage("com.android.settings") intent2.setPackage("com.android.settings")
@@ -1002,6 +1020,15 @@ public class MainPresenter implements MainContact.Presenter {
@Override @Override
public void setAppinsideWeb() { public void setAppinsideWeb() {
String channel_value = JGYUtils.getInstance().getStringMetaData();
if ("official".equals(channel_value)) {
getAppinsideWeb();
} else {
getNewAppinsideWeb();
}
}
private void getAppinsideWeb() {
NetInterfaceManager.getInstance() NetInterfaceManager.getInstance()
.getAppinsideWebObservable() .getAppinsideWebObservable()
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
@@ -1031,6 +1058,35 @@ public class MainPresenter implements MainContact.Presenter {
}); });
} }
private void getNewAppinsideWeb() {
NetInterfaceManager.getInstance()
.getNewAppinsideWebObservable()
.observeOn(Schedulers.io())
.subscribe(new Observer<BaseResponse<List<NewAppground>>>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
Log.e("getNewAppinsideWeb", "onSubscribe: ");
}
@Override
public void onNext(@NonNull BaseResponse<List<NewAppground>> listBaseResponse) {
Log.e("getNewAppinsideWeb", "onNext: ");
JGYUtils.getInstance().setNewAppinsideWeb(listBaseResponse);
}
@Override
public void onError(@NonNull Throwable e) {
Log.e("getNewAppinsideWeb", "onError: ");
onComplete();
}
@Override
public void onComplete() {
Log.e("getNewAppinsideWeb", "onComplete: ");
}
});
}
@Override @Override
public void setSystemSetting() { public void setSystemSetting() {
NetInterfaceManager.getInstance() NetInterfaceManager.getInstance()
@@ -1123,7 +1179,8 @@ public class MainPresenter implements MainContact.Presenter {
@Override @Override
public void getScreenLockState() { public void getScreenLockState() {
String channel_value = JGYUtils.getInstance().getStringMetaData(); String channel_value = JGYUtils.getInstance().getStringMetaData();
if ("official".equals(channel_value)) { int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 1);
if ("official".equals(channel_value) || locked == 1) {
mView.setScreenLockStateFinished(false, ""); mView.setScreenLockStateFinished(false, "");
return; return;
} }
@@ -1185,9 +1242,14 @@ public class MainPresenter implements MainContact.Presenter {
Log.e("getDefaultDesktop", "onNext: "); Log.e("getDefaultDesktop", "onNext: ");
try { try {
JSONObject jsonObject = JSONObject.parseObject(responseBody.string()); JSONObject jsonObject = JSONObject.parseObject(responseBody.string());
JSONObject data = jsonObject.getJSONObject("data"); int code = jsonObject.getInteger("code");
JGYUtils.getInstance().installDesktop(data); if (code == 200) {
Log.e("getDefaultDesktop", "onNext: " + data.toJSONString()); JSONObject data = jsonObject.getJSONObject("data");
JGYUtils.getInstance().installDesktop(data);
} else {
Log.e("getDefaultDesktop", "onNext: " + jsonObject.toJSONString());
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
Log.e("getDefaultDesktop", "onNext: IOException: " + e.getMessage()); Log.e("getDefaultDesktop", "onNext: IOException: " + e.getMessage());

View File

@@ -3,10 +3,14 @@ package com.jiaoguanyi.appstore.activity;
import android.app.StatusBarManager; import android.app.StatusBarManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@@ -17,12 +21,16 @@ import com.jiaoguanyi.appstore.utils.Utils;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
public class SplashActivity extends AppCompatActivity { public class SplashActivity extends AppCompatActivity {
private static String TAG = SplashActivity.class.getSimpleName();
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@@ -42,28 +50,112 @@ public class SplashActivity extends AppCompatActivity {
} }
private void DebugTest() { private void DebugTest() {
Utils.getHardware(this); // Utils.getHardware(this);
hookWebView();
setWebView();
}
File file = new File(Environment.getExternalStorageDirectory() + File.separator + "bootanimation.zip"); private void bootanimotion() {
String path0 = "/data/local/qchmedia/bootanimation.zip"; // File file = new File(Environment.getExternalStorageDirectory() + File.separator + "bootanimation.zip");
if (file.exists()) { // String path0 = "/data/local/qchmedia/bootanimation.zip";
File file1 = new File(path0); // if (file.exists()) {
if (!file1.exists()) { // File file1 = new File(path0);
file.mkdirs(); // if (!file1.exists()) {
try { // file.mkdirs();
file.createNewFile(); // try {
} catch (IOException e) { // file.createNewFile();
e.printStackTrace(); // } catch (IOException e) {
Log.e("bootanimation", e.getMessage()); // e.printStackTrace();
// Log.e("bootanimation", e.getMessage());
// }
// }
// Log.e("bootanimation", "SD卡路径存在");
// try {
// Path path = Paths.get(file.getAbsolutePath());
// Files.copy(path, new FileOutputStream(path0));
// } catch (Exception e) {
// Log.e("bootanimation", e.getMessage());
// }
// }
}
static final String url = "www.baidu.com";
private void setWebView() {
WebView webView = new WebView(this);
webView.loadUrl(url);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
//页面加载开始
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
//页面加载完成
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
String realUrl = url;
//这个realUrl即为重定向之后的地址
Log.e(TAG, "onPageFinished: " + realUrl);
}
});
}
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());
} }
} }
Log.e("bootanimation", "SD卡路径存在");
try { if (sProviderInstance != null){
Path path = Paths.get(file.getAbsolutePath()); field.set("sProviderInstance", sProviderInstance);
Files.copy(path, new FileOutputStream(path0)); Log.i(TAG,"Hook success!");
} catch (Exception e) { } else {
Log.e("bootanimation", e.getMessage()); Log.i(TAG,"Hook failed!");
} }
} catch (Throwable e) {
Log.w(TAG,e);
} }
} }
} }

View File

@@ -0,0 +1,34 @@
package com.jiaoguanyi.appstore.bean;
import java.io.Serializable;
public class NewAppground implements Serializable {
private static final long serialVersionUID = -2071117846816082338L;
private String packages;
private String address;
private String type;
public String getPackages() {
return packages;
}
public void setPackages(String packages) {
this.packages = packages;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@@ -12,6 +12,7 @@ import com.jiaoguanyi.appstore.bean.Desktop;
import com.jiaoguanyi.appstore.bean.ForceDownloadBean; import com.jiaoguanyi.appstore.bean.ForceDownloadBean;
import com.jiaoguanyi.appstore.bean.LogoImg; import com.jiaoguanyi.appstore.bean.LogoImg;
import com.jiaoguanyi.appstore.bean.NetAndLaunchBean; import com.jiaoguanyi.appstore.bean.NetAndLaunchBean;
import com.jiaoguanyi.appstore.bean.NewAppground;
import com.jiaoguanyi.appstore.bean.StudentsInfo; import com.jiaoguanyi.appstore.bean.StudentsInfo;
import com.jiaoguanyi.appstore.network.api.AppLimitApi; import com.jiaoguanyi.appstore.network.api.AppLimitApi;
import com.jiaoguanyi.appstore.network.api.BrankPicApi; import com.jiaoguanyi.appstore.network.api.BrankPicApi;
@@ -37,6 +38,7 @@ import com.jiaoguanyi.appstore.network.api.newapi.GetLockStateApi;
import com.jiaoguanyi.appstore.network.api.newapi.JpushTagsApi; import com.jiaoguanyi.appstore.network.api.newapi.JpushTagsApi;
import com.jiaoguanyi.appstore.network.api.newapi.LogoImgApi; import com.jiaoguanyi.appstore.network.api.newapi.LogoImgApi;
import com.jiaoguanyi.appstore.network.api.newapi.MACAddressApi; import com.jiaoguanyi.appstore.network.api.newapi.MACAddressApi;
import com.jiaoguanyi.appstore.network.api.newapi.NewAppinsideWebApi;
import com.jiaoguanyi.appstore.network.api.newapi.ScreenLockStateApi; import com.jiaoguanyi.appstore.network.api.newapi.ScreenLockStateApi;
import com.jiaoguanyi.appstore.network.api.newapi.SnTimeControl; import com.jiaoguanyi.appstore.network.api.newapi.SnTimeControl;
import com.jiaoguanyi.appstore.network.api.newapi.StudentsInfosApi; import com.jiaoguanyi.appstore.network.api.newapi.StudentsInfosApi;
@@ -224,6 +226,14 @@ public class NetInterfaceManager {
.observeOn(AndroidSchedulers.mainThread()); .observeOn(AndroidSchedulers.mainThread());
} }
public Observable<BaseResponse<List<NewAppground>>> getNewAppinsideWebObservable() {
return mRetrofit
.create(NewAppinsideWebApi.class)
.getAppinsideWeb(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<ResponseBody> getSystemSettingObservable() { public Observable<ResponseBody> getSystemSettingObservable() {
return mRetrofit return mRetrofit
.create(SystemSettingApi.class) .create(SystemSettingApi.class)

View File

@@ -400,77 +400,6 @@ public class HTTPInterface {
}); });
} }
synchronized public static void setHomepagtag(final Context context) {
//7.0setPackage不加没有问题,.setPackage("com.android.settings")10.0需要加上,待底层修改后
OkGo.post(URLAddress.SET_HOMEPAG_TAG)
.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) {
String data = jsonObject.getString("data");
JSONObject jsondata = JSON.parseObject(data);
//主页
String homepagURL = jsondata.getString("homepage");
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 (homepagURL != null && !homepagURL.equals("")) {
homepag.putExtra("homepage", homepagURL);
} else {
homepag.putExtra("homepage", "Invalid");
}
context.sendBroadcast(homepag);
//书签
String labelpage = jsondata.getString("labelpage");
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 (labelpage != null && !labelpage.equals("")) {
websiteBookMark.putExtra("websiteBookMark", labelpage);
} 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);
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);
}
// } catch (Exception e) {
// Log.e("fht", "setHomepagtag" + e.getMessage());
//// ToastUtil.show("数据错误");
// }
}
@Override
public void onError(Call call, Response response, Exception e) {
super.onError(call, response, e);
// ToastUtil.show("网络连接失败");
}
});
}
synchronized public static void setAppinsideWeb(final Context context) { synchronized public static void setAppinsideWeb(final Context context) {
OkGo.post(URLAddress.SET_APPINSIDEWEB) OkGo.post(URLAddress.SET_APPINSIDEWEB)
@@ -571,14 +500,18 @@ public class HTTPInterface {
if (code == 200) { if (code == 200) {
JSONObject data = JSON.parseObject(jsonObject.getString("data")); JSONObject data = JSON.parseObject(jsonObject.getString("data"));
String white = data.getString("white"); String white = data.getString("white");
if (white != null && !white.equals("")) { String homePage = Settings.System.getString(context.getContentResolver(), "homepagURL");
if (!TextUtils.isEmpty(white)) {
if (!white.contains(homePage) && !TextUtils.isEmpty(homePage)) {
white += "," + homePage;
}
boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white); boolean whiteList = Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", white);
Log.e("SystemSetting", "setBrowserList----white-----" + whiteList + ":" + white); Log.e("SystemSetting", "setBrowserList----white-----" + whiteList + ":" + white);
} else { } else {
Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " "); Settings.System.putString(context.getContentResolver(), "DeselectBrowserArray", " ");
} }
String black = data.getString("black"); String black = data.getString("black");
if (black != null && !black.equals("")) { if (!TextUtils.isEmpty(black)) {
boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black); boolean blackList = Settings.System.putString(context.getContentResolver(), "qch_webblack_url", black);
Log.e("SystemSetting", "setBrowserList----black-----" + blackList + ":" + black); Log.e("SystemSetting", "setBrowserList----black-----" + blackList + ":" + black);
} else { } else {
@@ -599,6 +532,88 @@ public class HTTPInterface {
}); });
} }
synchronized public static void setHomepagtag(final Context context) {
//7.0setPackage不加没有问题,.setPackage("com.android.settings")10.0需要加上,待底层修改后
OkGo.post(URLAddress.SET_HOMEPAG_TAG)
.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) {
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");
Log.e("setHomepagtag", "execute: DeselectBrowserArray: = " + DeselectBrowserArray);
if (!DeselectBrowserArray.contains(homepagURL)) {
DeselectBrowserArray += "," + homepagURL;
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")
.setPackage("com.android.browser");
}
if (!TextUtils.isEmpty(homepagURL)) {
homepag.putExtra("homepage", homepagURL);
} else {
homepag.putExtra("homepage", "Invalid");
}
context.sendBroadcast(homepag);
//书签
String labelpage = jsondata.getString("labelpage");
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");
}
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);
}
// } catch (Exception e) {
// Log.e("fht", "setHomepagtag" + e.getMessage());
//// ToastUtil.show("数据错误");
// }
}
@Override
public void onError(Call call, Response response, Exception e) {
super.onError(call, response, e);
// ToastUtil.show("网络连接失败");
}
});
}
public static void setHideDesktopIcon(final Context context) { public static void setHideDesktopIcon(final Context context) {
OkGo.post(URLAddress.GET_HIDE_DESKTOPICON) OkGo.post(URLAddress.GET_HIDE_DESKTOPICON)
.params("key", NetInterfaceManager.HTTP_KEY) .params("key", NetInterfaceManager.HTTP_KEY)

View File

@@ -0,0 +1,22 @@
package com.jiaoguanyi.appstore.network.api.newapi;
import com.jiaoguanyi.appstore.bean.BaseResponse;
import com.jiaoguanyi.appstore.bean.NewAppground;
import com.jiaoguanyi.appstore.network.URLAddress;
import java.util.List;
import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;
public interface NewAppinsideWebApi {
@FormUrlEncoded
@POST(URLAddress.SET_APPINSIDEWEB)
Observable<BaseResponse<List<NewAppground>>> getAppinsideWeb(
@Field("key") String key,
@Field("sn") String sn
);
}

View File

@@ -21,6 +21,7 @@ import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient; import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationListener; import com.amap.api.location.AMapLocationListener;
import com.blankj.utilcode.util.PathUtils; import com.blankj.utilcode.util.PathUtils;
import com.jiaoguanyi.appstore.utils.JGYUtils;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback; import com.lzy.okgo.callback.StringCallback;
import com.jiaoguanyi.appstore.base.BaseApplication; import com.jiaoguanyi.appstore.base.BaseApplication;
@@ -116,6 +117,8 @@ public class MyJPushReceiver extends BroadcastReceiver {
private final String TOP_APP = "28";//app霸屏 private final String TOP_APP = "28";//app霸屏
private final String LOGO_IMG = "29";//开机动画
private Context mContext; private Context mContext;
@@ -337,6 +340,10 @@ public class MyJPushReceiver extends BroadcastReceiver {
case TOP_APP: case TOP_APP:
getTopApp(context, extras); getTopApp(context, extras);
break; break;
case LOGO_IMG:
setBootanimation(context, extras);
Log.e(TAG, "processCustomMessage: " + extras);
break;
} }
} }
@@ -1325,7 +1332,24 @@ public class MyJPushReceiver extends BroadcastReceiver {
private void getTopApp(Context context, String extras) { private void getTopApp(Context context, String extras) {
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(extras); com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(extras);
String packageName = jsonObject.getString("app_package"); String packageName = jsonObject.getString("app_package");
if (TextUtils.isEmpty(packageName)) {
return;
}
SPUtils.put(context, ForegroundAppUtil.TOPAPP_KEY, packageName); SPUtils.put(context, ForegroundAppUtil.TOPAPP_KEY, packageName);
ForegroundAppUtil.openTopApp(context); ForegroundAppUtil.openTopApp(context);
} }
private void setBootanimation(Context context, String extras) {
com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(extras);
int type = jsonObject.getInteger("type");
if (type == 1) {
String file_url = jsonObject.getString("file_url");
String file_md5 = jsonObject.getString("file_md5");
JGYUtils.getInstance().checkBootFile(file_url, file_md5);
} else {
JGYUtils.getInstance().removeBootanimation();
}
}
} }

View File

@@ -277,7 +277,7 @@ public class GuardService extends Service {
JSONObject jsonObject = JSON.parseObject(task.getExtendField()); JSONObject jsonObject = JSON.parseObject(task.getExtendField());
String app_name = jsonObject.getString("app_name"); String app_name = jsonObject.getString("app_name");
String app_package = jsonObject.getString("app_package"); String app_package = jsonObject.getString("app_package");
Log.e("aria", "正在下载---:" + task.getPercent() + ":" + task.getExtendField()); Log.e("aria", "正在下载:" + task.getPercent() + ":" + task.getExtendField());
ToastUtil.show("正在下载:" + app_name + "-" + task.getPercent() + "%" + "\t" + Formatter.formatFileSize(GuardService.this, task.getSpeed()) + "/s"); ToastUtil.show("正在下载:" + app_name + "-" + task.getPercent() + "%" + "\t" + Formatter.formatFileSize(GuardService.this, task.getSpeed()) + "/s");
} }
@@ -343,6 +343,7 @@ public class GuardService extends Service {
Log.e("aria", "isDownloading=" + BaseApplication.getInstance().isDownloading()); Log.e("aria", "isDownloading=" + BaseApplication.getInstance().isDownloading());
} }
} else if (filepath.endsWith("zip")) { } else if (filepath.endsWith("zip")) {
Log.e("aria", "下载完成:" + task.getPercent() + ":" + task.getExtendField());
JGYUtils.getInstance().setBootanimation(task.getFilePath()); JGYUtils.getInstance().setBootanimation(task.getFilePath());
} }
} }

View File

@@ -70,13 +70,13 @@ public class MainService extends Service implements MainContact.MainView {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
if (MainActivity.isForeground){ if (MainActivity.isForeground) {
Log.e(TAG, "onStartCommand: MainActivity: " + MainActivity.isForeground); Log.e(TAG, "onStartCommand: MainActivity: " + MainActivity.isForeground);
}else { } else {
if (((SystemClock.elapsedRealtime() - startCommandTime) < 60000) ){ if (((SystemClock.elapsedRealtime() - startCommandTime) < 60000) && startCommandTime != 0) {
Log.e(TAG, "onStartCommand: " + "启动时间过短"); Log.e(TAG, "onStartCommand: " + "启动时间过短");
//一分钟内防止多次调用 //一分钟内防止多次调用
}else { } else {
mPresenter.getFirstConnect(); mPresenter.getFirstConnect();
mPresenter.getLockedState(); mPresenter.getLockedState();
startCommandTime = runningTime = SystemClock.elapsedRealtime(); startCommandTime = runningTime = SystemClock.elapsedRealtime();
@@ -391,8 +391,8 @@ public class MainService extends Service implements MainContact.MainView {
} }
@Override @Override
public void getBrowserListFinished() { public void getBrowserListFinished(String whitelist) {
mPresenter.getBrowserBookmarks(); mPresenter.getBrowserBookmarks(whitelist);
} }
@Override @Override

View File

@@ -27,6 +27,7 @@ import com.jiaoguanyi.appstore.bean.BaseResponse;
import com.jiaoguanyi.appstore.bean.ForceDownloadData; import com.jiaoguanyi.appstore.bean.ForceDownloadData;
import com.jiaoguanyi.appstore.bean.NetAndLaunchBean; import com.jiaoguanyi.appstore.bean.NetAndLaunchBean;
import com.jiaoguanyi.appstore.bean.NetAndLaunchData; import com.jiaoguanyi.appstore.bean.NetAndLaunchData;
import com.jiaoguanyi.appstore.bean.NewAppground;
import com.jiaoguanyi.appstore.comm.CommonDatas; import com.jiaoguanyi.appstore.comm.CommonDatas;
import org.w3c.dom.Text; import org.w3c.dom.Text;
@@ -270,7 +271,7 @@ public class JGYUtils {
String strings = ""; String strings = "";
String packageList = "";//单条管控名单 String packageList = "";//单条管控名单
for (Appground appground : appgrounds) { for (Appground appground : appgrounds) {
if (appground.getAddress().equals("")) { if (TextUtils.isEmpty(appground.getAddress())) {
packageList += appground.getPackages() + ","; packageList += appground.getPackages() + ",";
} else { } else {
strings += appground.toString() + ";"; strings += appground.toString() + ";";
@@ -310,6 +311,54 @@ public class JGYUtils {
} }
} }
public void setNewAppinsideWeb(BaseResponse<List<NewAppground>> response){
if (response.code == 200) {
List<NewAppground> appgrounds = response.data;
if (appgrounds != null && appgrounds.size() > 0) {
String strings = "";
String packageList = "";//单条管控名单
for (NewAppground appground : appgrounds) {
if (TextUtils.isEmpty(appground.getAddress())) {
packageList += appground.getPackages() + ",";
} else {
strings += appground.toString() + ";";
}
}
if (packageList.length() > 0) {
//app内所有的网页禁止
//packageList = packageList.substring(0, packageList.length() - 1);
//去掉多余的,
Log.e("setAppinsideWeb ", "packageList:" + packageList);
Intent qch_app_website = new Intent("qch_app_website")
.setPackage("com.android.settings");
qch_app_website.putExtra("package_name", packageList);
mContext.sendBroadcast(qch_app_website);
} else {
sendAllweb(mContext);
}
if (strings.length() > 0) {
//app内单个网页地址禁止打开
//strings = strings.substring(0, strings.length() - 1);
//去掉多余的;
Log.e("setAppinsideWeb ", "strings:" + strings);
Intent intent = new Intent("qch_app_inside_website")
.setPackage("com.android.settings");
intent.putExtra("websitelist", strings);
mContext.sendBroadcast(intent);
} else {
sendwebUrl(mContext);
}
}
} else if (response.code == 400) {
//列表为空的情况
sendAllweb(mContext);
sendwebUrl(mContext);
//ToastUtil.show(msg);
Log.e("setAppinsideWeb", "setAppinsideWeb: " + response.msg);
}
}
private static void sendAllweb(Context context) { private static void sendAllweb(Context context) {
Intent intent = new Intent("qch_app_website") Intent intent = new Intent("qch_app_website")
.setPackage("com.android.settings"); .setPackage("com.android.settings");
@@ -585,6 +634,8 @@ public class JGYUtils {
public void checkBootFile(String url, String MD5) { public void checkBootFile(String url, String MD5) {
String urlFileName = Utils.getFileNamefromURL(url); String urlFileName = Utils.getFileNamefromURL(url);
File bootFile = new File(PathUtils.getExternalDownloadsPath() + File.separator + "jgy" + File.separator + urlFileName); File bootFile = new File(PathUtils.getExternalDownloadsPath() + File.separator + "jgy" + File.separator + urlFileName);
Log.e(TAG, "checkBootFile: bootFile file path=" + bootFile.getAbsolutePath());
Log.e(TAG, "checkBootFile: bootFile exists=" + bootFile.exists() + " isFile=" + bootFile.isFile());
if (bootFile.exists() && bootFile.isFile()) { if (bootFile.exists() && bootFile.isFile()) {
String oldMd5 = FileUtils.getFileMD5ToString(bootFile); String oldMd5 = FileUtils.getFileMD5ToString(bootFile);
if (!TextUtils.isEmpty(oldMd5) && oldMd5.equalsIgnoreCase(MD5)) { if (!TextUtils.isEmpty(oldMd5) && oldMd5.equalsIgnoreCase(MD5)) {
@@ -598,14 +649,25 @@ public class JGYUtils {
} else { } else {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("MD5", MD5); jsonObject.put("MD5", MD5);
jsonObject.put("app_name", urlFileName);
Utils.ariaDownload(mContext, url, jsonObject); Utils.ariaDownload(mContext, url, jsonObject);
} }
} }
private static final String BOOTANIMATION_PATH = "/data/local/qchmedia/bootanimation.zip"; private static final String BOOTANIMATION_PATH = "/data/local/qchmedia/bootanimation.zip";
@SuppressLint("NewApi")
public void setBootanimation(String filePath) { public void setBootanimation(String filePath) {
File systemFile = new File(BOOTANIMATION_PATH); File systemFile = new File(BOOTANIMATION_PATH);
if (!systemFile.exists()) {
systemFile.mkdirs();
try {
systemFile.createNewFile();
} catch (IOException e) {
e.printStackTrace();
Log.e("setBootanimation: ", "createNewFile: " + e.getMessage());
}
}
File newFile = new File(filePath); File newFile = new File(filePath);
if (systemFile.exists() && systemFile.isFile()) { if (systemFile.exists() && systemFile.isFile()) {
String systemMD5 = FileUtils.getFileMD5ToString(systemFile); String systemMD5 = FileUtils.getFileMD5ToString(systemFile);
@@ -616,7 +678,9 @@ public class JGYUtils {
Path path = Paths.get(newFile.getAbsolutePath()); Path path = Paths.get(newFile.getAbsolutePath());
try { try {
Files.copy(path, new FileOutputStream(systemFile)); Files.copy(path, new FileOutputStream(systemFile));
Log.e(TAG, "setBootanimation: 设置新开机动画");
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "setBootanimation: IOException: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -626,8 +690,20 @@ public class JGYUtils {
Files.copy(path, new FileOutputStream(systemFile)); Files.copy(path, new FileOutputStream(systemFile));
Log.e(TAG, "setBootanimation: 设置新开机动画"); Log.e(TAG, "setBootanimation: 设置新开机动画");
} catch (IOException e) { } catch (IOException e) {
Log.e(TAG, "setBootanimation: IOException: " + e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
public void removeBootanimation() {
File systemFile = new File(BOOTANIMATION_PATH);
if (systemFile.exists()) {
if (systemFile.delete()) {
Log.e(TAG, "removeBootanimation: delete: " + "ture");
}else {
Log.e(TAG, "removeBootanimation: delete: " + "false");
}
}
}
} }