update:2021.01.27
fix:修复应用安装信息上传 add:时间管控,顶部app管控
This commit is contained in:
@@ -59,7 +59,15 @@
|
||||
<service
|
||||
android:name=".service.InitJpushServer"
|
||||
android:enabled="true"
|
||||
android:exported="true"></service>
|
||||
android:exported="true">
|
||||
<intent-filter android:priority="1000">
|
||||
<action android:name="android.intent.action.USER_PRESENT" />
|
||||
<action android:name="android.intent.action.SCREEN_ON" />
|
||||
<action android:name="android.intent.action.SCREEN_OFF" />
|
||||
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity android:name=".activity.MainActivity"
|
||||
android:launchMode="singleTask"
|
||||
@@ -198,7 +206,8 @@
|
||||
|
||||
<category android:name="com.info.sn" />
|
||||
</intent-filter>
|
||||
</activity> <!-- Since JCore2.0.0 Required SDK核心功能 -->
|
||||
</activity>
|
||||
<activity android:name=".activity.TopActivity" /> <!-- Since JCore2.0.0 Required SDK核心功能 -->
|
||||
<!-- 这个Service要继承JCommonService -->
|
||||
<service
|
||||
android:name=".jpush.PushService"
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.info.sn.service.StepService;
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
import com.info.sn.utils.LogUtils;
|
||||
import com.info.sn.utils.SPUtils;
|
||||
import com.info.sn.utils.TimeUtils;
|
||||
import com.info.sn.utils.ToastUtil;
|
||||
import com.info.sn.utils.Utils;
|
||||
|
||||
@@ -124,6 +125,8 @@ public class MainActivity extends CheckPermissionsActivity implements AMapLocati
|
||||
// HTTPInterface.setBrowser(MainActivity.this);
|
||||
delay(MainActivity.this);
|
||||
// HTTPInterface.get_settings(MainActivity.this);
|
||||
TimeUtils.ContralTime c2 = TimeUtils.getDefaltContralTime(MainActivity.this);
|
||||
Log.e("fht", "time:" + TimeUtils.getNowTime());
|
||||
}
|
||||
|
||||
private void initAmap() {
|
||||
@@ -165,10 +168,10 @@ public class MainActivity extends CheckPermissionsActivity implements AMapLocati
|
||||
HTTPInterface.getAllappPackage(MainActivity.this);
|
||||
HTTPInterface.setBrowser(context);
|
||||
HTTPInterface.getBrowserLabel(context);
|
||||
getSystemSettings(context);
|
||||
HTTPInterface.getSystemSettings(context);
|
||||
HTTPInterface.getForceInstall(context);
|
||||
HTTPInterface.getAppStart(context);
|
||||
HTTPInterface.getAppJump(context);
|
||||
// HTTPInterface.getAppJump(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,7 +182,6 @@ public class MainActivity extends CheckPermissionsActivity implements AMapLocati
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("delay", "onComplete: ");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -407,41 +409,6 @@ public class MainActivity extends CheckPermissionsActivity implements AMapLocati
|
||||
});
|
||||
}
|
||||
|
||||
private void getSystemSettings(final Context context) {
|
||||
Setting setting = NetWorkManager.getsettingControl();
|
||||
setting.getSetting(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<SystemSettings>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SystemSettings> systemSettingsBaseResponse) {
|
||||
int code = systemSettingsBaseResponse.code;
|
||||
if (code == 200) {
|
||||
SystemSettings settings = systemSettingsBaseResponse.data;
|
||||
Utils.setSystemSetting(context, settings.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e(TAG, "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
|
||||
33
app/src/main/java/com/info/sn/activity/TopActivity.java
Normal file
33
app/src/main/java/com/info/sn/activity/TopActivity.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.info.sn.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.info.sn.R;
|
||||
|
||||
|
||||
public class TopActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_top);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
startActivity(new Intent(this, this.getClass()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
return false;
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.info.sn.base;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
@@ -14,6 +17,8 @@ import com.arialyy.aria.core.Aria;
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.activity.MainActivity;
|
||||
import com.info.sn.network.HTTPInterface;
|
||||
import com.info.sn.receiver.APKinstallReceiver;
|
||||
import com.info.sn.receiver.BootReceiver;
|
||||
import com.info.sn.utils.LogUtils;
|
||||
import com.info.sn.utils.SPUtils;
|
||||
import com.info.sn.utils.ToastUtil;
|
||||
@@ -32,6 +37,9 @@ public class MyApplication extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
if (!getPackageName().equals(getCurrentProcessName())) {
|
||||
return;
|
||||
}
|
||||
app = this;
|
||||
if (!BuildConfig.DEBUG) {
|
||||
catchException();
|
||||
@@ -40,7 +48,25 @@ public class MyApplication extends Application {
|
||||
context = getApplicationContext();
|
||||
Aria.init(this);
|
||||
Aria.download(this).resumeAllTask();
|
||||
registAppReceive();
|
||||
registBootReceive();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前进程名
|
||||
*/
|
||||
private String getCurrentProcessName() {
|
||||
int pid = android.os.Process.myPid();
|
||||
String processName = "";
|
||||
ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService
|
||||
(Context.ACTIVITY_SERVICE);
|
||||
for (ActivityManager.RunningAppProcessInfo process : manager.getRunningAppProcesses()) {
|
||||
if (process.pid == pid) {
|
||||
processName = process.processName;
|
||||
}
|
||||
}
|
||||
return processName;
|
||||
}
|
||||
|
||||
private void catchException() {
|
||||
@@ -144,4 +170,30 @@ public class MyApplication extends Application {
|
||||
locationClient.startLocation();
|
||||
}
|
||||
|
||||
private APKinstallReceiver apKinstallReceiver;
|
||||
|
||||
private void registAppReceive() {
|
||||
if (null == apKinstallReceiver) {
|
||||
apKinstallReceiver = new APKinstallReceiver();
|
||||
}
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||
filter.addDataScheme("package");
|
||||
registerReceiver(apKinstallReceiver, filter);
|
||||
}
|
||||
private BootReceiver bootReceiver;
|
||||
|
||||
private void registBootReceive() {
|
||||
if (null == bootReceiver){
|
||||
bootReceiver = new BootReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_USER_PRESENT);
|
||||
registerReceiver(bootReceiver, filter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,10 @@ public class AppStart implements Serializable {
|
||||
private int is_network;
|
||||
private int is_upgrade;
|
||||
private int is_slide;
|
||||
private int is_lock;
|
||||
private String visit;
|
||||
private String address;
|
||||
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
@@ -49,4 +53,28 @@ public class AppStart implements Serializable {
|
||||
public void setIs_slide(int is_slide) {
|
||||
this.is_slide = is_slide;
|
||||
}
|
||||
|
||||
public int getIs_lock() {
|
||||
return is_lock;
|
||||
}
|
||||
|
||||
public void setIs_lock(int is_lock) {
|
||||
this.is_lock = is_lock;
|
||||
}
|
||||
|
||||
public String getVisit() {
|
||||
return visit;
|
||||
}
|
||||
|
||||
public void setVisit(String visit) {
|
||||
this.visit = visit;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
|
||||
24
app/src/main/java/com/info/sn/bean/AppUploadInfo.java
Normal file
24
app/src/main/java/com/info/sn/bean/AppUploadInfo.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.info.sn.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AppUploadInfo implements Serializable {
|
||||
String app_package;
|
||||
long app_version_code;
|
||||
|
||||
public String getApp_package() {
|
||||
return app_package;
|
||||
}
|
||||
|
||||
public void setApp_package(String app_package) {
|
||||
this.app_package = app_package;
|
||||
}
|
||||
|
||||
public long getApp_version_code() {
|
||||
return app_version_code;
|
||||
}
|
||||
|
||||
public void setApp_version_code(long app_version_code) {
|
||||
this.app_version_code = app_version_code;
|
||||
}
|
||||
}
|
||||
@@ -21,15 +21,17 @@ import android.view.WindowManager;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.activity.MainActivity;
|
||||
import com.info.sn.bean.BaseResponse;
|
||||
import com.info.sn.network.HTTPInterface;
|
||||
import com.info.sn.network.NetWorkManager;
|
||||
import com.info.sn.network.api.BindDevices;
|
||||
import com.info.sn.network.api.UploadScreenshot;
|
||||
import com.info.sn.service.InitJpushServer;
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
import com.info.sn.utils.CmdUtil;
|
||||
import com.info.sn.utils.LogUtils;
|
||||
import com.info.sn.utils.SPUtils;
|
||||
import com.info.sn.utils.ServiceAliveUtils;
|
||||
import com.info.sn.utils.ToastUtil;
|
||||
import com.info.sn.utils.Utils;
|
||||
import com.info.sn.view.CustomDialog;
|
||||
@@ -46,11 +48,17 @@ import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
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.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.annotations.NonNull;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
|
||||
/**
|
||||
* 自定义接收器
|
||||
@@ -60,7 +68,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||
* 2) 接收不到自定义消息
|
||||
*/
|
||||
public class MyReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "JIGUANG-Example";
|
||||
private static final String TAG = "MyReceiver";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -182,6 +190,16 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
//系统管控
|
||||
private static final String JIGUANG_REBOOT_DEVICES = "22";
|
||||
//重启
|
||||
private static final String JIGUANG_APP_SETTING = "23";
|
||||
//获取app管控设置
|
||||
private static final String JIGUANG_FORCE_KILL = "24";
|
||||
//强制停止应用
|
||||
private static final String JIGUANG_LOCK_SCREEN = "25";
|
||||
//锁屏
|
||||
private static final String JIGUANG_SNAPSHOT = "26";
|
||||
//截图
|
||||
private static final String JIGUANG_TIME_CONTROL = "27";
|
||||
//时间管控
|
||||
|
||||
//send msg to MainActivity
|
||||
private void processCustomMessage(Context context, Bundle bundle) {
|
||||
@@ -259,7 +277,7 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
setAppUpdate(context, extras);
|
||||
break;
|
||||
case JIGUANG_APP_WEBSITE:
|
||||
HTTPInterface.getAppJump(context);
|
||||
// HTTPInterface.getAppJump(context);
|
||||
break;
|
||||
case JIGUANG_REBOOT_DEVICES:
|
||||
Utils.rebootDevices(context);
|
||||
@@ -276,32 +294,42 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
case JIGUANG_RESET_DEVICES:
|
||||
Utils.doMasterClear(context);
|
||||
break;
|
||||
case JIGUANG_APP_SETTING:
|
||||
HTTPInterface.getAppStart(context);
|
||||
break;
|
||||
case JIGUANG_FORCE_KILL:
|
||||
Log.e(TAG, extras);
|
||||
break;
|
||||
case JIGUANG_LOCK_SCREEN:
|
||||
setLock_screen(context, extras);
|
||||
Log.e(TAG, extras);
|
||||
break;
|
||||
case JIGUANG_SNAPSHOT:
|
||||
doscreenshot(context);
|
||||
Log.e(TAG, extras);
|
||||
break;
|
||||
case JIGUANG_TIME_CONTROL:
|
||||
timeControl(context, extras);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private int changeNum(int paramInt) {
|
||||
switch (paramInt) {
|
||||
default:
|
||||
return 1;
|
||||
case 0:
|
||||
return 1;
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
return paramInt == 1 ? 0 : 1;
|
||||
}
|
||||
|
||||
private void setPhone(Context context, String json) {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
|
||||
int setting_phone = jsonObject.getInteger("setting_phone");
|
||||
Log.e("setting_phone", String.valueOf(setting_phone));
|
||||
boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", setting_phone);
|
||||
boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", setting_phone);
|
||||
boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", "981964879");
|
||||
Log.e("SystemSetting", "qch_call_forbid---------" + setting_phone);
|
||||
Log.e("SystemSetting", "qch_call_forbid---------" + qch_call_forbid);
|
||||
Log.e("SystemSetting", "qch_call_forbid---------" + qch_white_list_on);
|
||||
Log.e("SystemSetting", "qch_call_forbid---------" + qch_white_list_Array);
|
||||
// com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
|
||||
// int setting_phone = jsonObject.getInteger("setting_phone");
|
||||
// Log.e("setting_phone", String.valueOf(setting_phone));
|
||||
// boolean qch_call_forbid = Settings.System.putInt(context.getContentResolver(), "qch_call_forbid", setting_phone);
|
||||
// boolean qch_white_list_on = Settings.System.putInt(context.getContentResolver(), "qch_white_list_on", setting_phone);
|
||||
// boolean qch_white_list_Array = Settings.System.putString(context.getContentResolver(), "qch_white_list_Array", "123456");
|
||||
// Log.e("SystemSetting", "qch_call_forbid---------" + setting_phone);
|
||||
// Log.e("SystemSetting", "qch_call_forbid---------" + qch_call_forbid);
|
||||
// Log.e("SystemSetting", "qch_call_forbid---------" + qch_white_list_on);
|
||||
// Log.e("SystemSetting", "qch_call_forbid---------" + qch_white_list_Array);
|
||||
HTTPInterface.getSystemSettings(context);
|
||||
}
|
||||
|
||||
private void setCameta(Context context, String json) {
|
||||
@@ -313,10 +341,13 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
|
||||
String cameraStatus = "";
|
||||
switch (setting_camera) {
|
||||
case 0:
|
||||
case 1:
|
||||
cameraStatus = "qch_camera_open";
|
||||
break;
|
||||
case 1:
|
||||
case 0:
|
||||
cameraStatus = "qch_camera_forbid";
|
||||
break;
|
||||
default:
|
||||
cameraStatus = "qch_camera_forbid";
|
||||
break;
|
||||
}
|
||||
@@ -330,16 +361,16 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(json);
|
||||
//影音管控开关
|
||||
int setting_tfmedia = jsonObject.getInteger("setting_tfmedia");
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", setting_tfmedia);
|
||||
Log.e("SystemSetting", "qch_tfmedia_forbid---------" + setting_tfmedia);
|
||||
|
||||
if (setting_tfmedia == 1) {
|
||||
if (setting_tfmedia == 0) {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 1);
|
||||
} else {
|
||||
String s = Settings.System.getString(context.getContentResolver(), "qch_tfmedia_filetypes");//影音管控
|
||||
Log.e("SystemSetting", "qch_tfmedia_filetypes old" + s);
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||
boolean b = Settings.System.putString(context.getContentResolver(), "qch_tfmedia_filetypes", tftype);//影音管控
|
||||
Log.e("SystemSetting", "qch_tfmedia_filetypes---------" + b + ":" + tftype);
|
||||
} else {
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_tfmedia_forbid", 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,16 +406,17 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
synchronized private void sendStartTime(Context context, String jsonArray) {
|
||||
if (jsonArray.length() > 0) {
|
||||
try {
|
||||
JSONObject extra = new JSONObject(jsonArray);
|
||||
String random = extra.getString("random");
|
||||
int battery = getSystemBattery(context);
|
||||
// HTTPInterface.sendStartTime(context, 0, getTaskPackname(context), battery, random);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
HTTPInterface.updateAdminInfo(context);
|
||||
// if (jsonArray.length() > 0) {
|
||||
// try {
|
||||
// JSONObject extra = new JSONObject(jsonArray);
|
||||
// String random = extra.getString("random");
|
||||
// int battery = getSystemBattery(context);
|
||||
//// HTTPInterface.sendStartTime(context, 0, getTaskPackname(context), battery, random);
|
||||
// } catch (JSONException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,25 +463,23 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
if (jsonArray.length() > 0) {
|
||||
try {
|
||||
JSONObject extra = new JSONObject(jsonArray);
|
||||
int is_dataline = extra.getInt("is_dataline");
|
||||
if (is_dataline == 1) {
|
||||
boolean qch_usb_choose = Settings.System.putString(context.getContentResolver(), "qch_usb_choose", "usb_charge");
|
||||
LogUtils.e("setUsbState:", Settings.System.getString(context.getContentResolver(), "qch_usb_choose"));
|
||||
} else {
|
||||
boolean qch_usb_choose = Settings.System.putString(context.getContentResolver(), "qch_usb_choose", "usb_mtp");
|
||||
LogUtils.e("setUsbState:", Settings.System.getString(context.getContentResolver(), "qch_usb_choose"));
|
||||
}
|
||||
String setting_usb = extra.getString("setting_usb");
|
||||
boolean qch_usb_choose = Settings.System.putString(context.getContentResolver(), "qch_usb_choose", setting_usb);
|
||||
LogUtils.e("setUsbState:", Settings.System.getString(context.getContentResolver(), "qch_usb_choose"));
|
||||
String usbStatus = "";
|
||||
switch (is_dataline) {
|
||||
case 1:
|
||||
switch (setting_usb) {
|
||||
case "usb_charge":
|
||||
usbStatus = "qch_action_usb_usb_charge";
|
||||
break;
|
||||
case 0:
|
||||
case "usb_mtp":
|
||||
usbStatus = "qch_action_usb_usb_mtp";
|
||||
break;
|
||||
// case "usb_midi":
|
||||
// usbStatus = "qch_action_usb_usb_midi";
|
||||
// break;
|
||||
default:
|
||||
usbStatus = "qch_action_usb_usb_charge";
|
||||
break;
|
||||
}
|
||||
Intent usbIntent = new Intent(usbStatus).setPackage("com.android.settings");
|
||||
context.sendBroadcast(usbIntent);
|
||||
@@ -466,8 +496,8 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
if (jsonArray.length() > 0) {
|
||||
try {
|
||||
JSONObject extra = new JSONObject(jsonArray);
|
||||
int is_tf = extra.getInt("is_tf");
|
||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", is_tf);
|
||||
int is_tf = extra.getInt("setting_memory");
|
||||
boolean qch_sdcard_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_sdcard_forbid_on", changeNum(is_tf));
|
||||
if (qch_sdcard_forbid_on) {
|
||||
LogUtils.e("setTfcardState:", Settings.System.getString(context.getContentResolver(), "qch_sdcard_forbid_on"));
|
||||
} else {
|
||||
@@ -491,11 +521,11 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
}
|
||||
try {
|
||||
JSONObject extra = new JSONObject(jsonArray);
|
||||
int is_bluetooth = extra.getInt("is_bluetooth");
|
||||
if (is_bluetooth == 1) {
|
||||
int is_bluetooth = extra.getInt("setting_bluetooth");
|
||||
if (is_bluetooth == 0) {
|
||||
mBluetoothAdapter.disable();//设置关闭时关闭蓝牙
|
||||
}
|
||||
boolean qch_bt_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", is_bluetooth);
|
||||
boolean qch_bt_forbid_on = Settings.System.putInt(context.getContentResolver(), "qch_bht_forbid_on", changeNum(is_bluetooth));
|
||||
if (qch_bt_forbid_on) {
|
||||
LogUtils.e("setBluetoothState:", Settings.System.getString(context.getContentResolver(), "qch_bht_forbid_on"));
|
||||
} else {
|
||||
@@ -653,7 +683,7 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
|
||||
try {
|
||||
JSONObject object = new JSONObject(json);
|
||||
String packageName = object.getString("package");
|
||||
String packageName = object.getString("app_package");
|
||||
ToastUtil.debugShow("收到应用卸载消息:包名" + packageName);
|
||||
if (!packageName.equals("") && !packageName.equals(context.getApplicationContext().getPackageName())) {
|
||||
if (!ApkUtils.isAvailable(context.getApplicationContext(), packageName)) {
|
||||
@@ -816,4 +846,112 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
}
|
||||
|
||||
|
||||
private void setLock_screen(Context context, String extras) {
|
||||
String type = "0";
|
||||
try {
|
||||
JSONObject jSONObject = new JSONObject(extras);
|
||||
type = jSONObject.getString("type");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!ServiceAliveUtils.isServiceAlice(InitJpushServer.class.getName())) {
|
||||
context.startService(new Intent(context, InitJpushServer.class));
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
// intent.putExtra("name", name);
|
||||
if (type.equals("1")) {
|
||||
intent.setAction(InitJpushServer.LockScreenReceiver.ACTION_LOCK);
|
||||
} else if (type.equals("0")) {
|
||||
intent.setAction(InitJpushServer.LockScreenReceiver.ACTION_UNLOCK);
|
||||
}
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
||||
public void doscreenshot(final Context context) {
|
||||
final long time = System.currentTimeMillis();
|
||||
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
|
||||
String filepath = context.getExternalFilesDir("db").getAbsolutePath();
|
||||
int n = CmdUtil.execute("screencap -p " + filepath + File.separator + time + ".png").code;
|
||||
e.onNext(n);
|
||||
}
|
||||
}).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<Integer>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Integer integer) {
|
||||
if (integer == 0) {
|
||||
uplaodImage(context, time);
|
||||
} else {
|
||||
Log.e("doss", "失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("doss", "Throwable=" + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void uplaodImage(final Context context, long time) {
|
||||
String filepath = context.getExternalFilesDir("db").getAbsolutePath();
|
||||
// String filepath = mContext.getFileStreamPath("screenshot").getAbsolutePath();
|
||||
//放在app内部data下面
|
||||
File file = new File(filepath + File.separator + time + ".png");
|
||||
//不要直接使用常用图片格式
|
||||
if (!file.exists()) {
|
||||
Log.e("uplaodImage", "File does not exists");
|
||||
return;
|
||||
}
|
||||
UploadScreenshot uploadScreenshot = NetWorkManager.getUploadScreenshotControl();
|
||||
RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file);
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), requestFile);
|
||||
uploadScreenshot.uploadScreenshot(Utils.getSerial(), body)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
Log.e(TAG, "onNext: " + baseResponse.msg);
|
||||
} else {
|
||||
Log.e(TAG, code + ": " + baseResponse.msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("uplaod", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void timeControl(Context context, String extras) {
|
||||
HTTPInterface.getTimeControl(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,10 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.bean.AppInfo;
|
||||
import com.info.sn.bean.AppJump;
|
||||
import com.info.sn.bean.AppStart;
|
||||
import com.info.sn.bean.BaseResponse;
|
||||
import com.info.sn.bean.BrowserBean;
|
||||
import com.info.sn.network.api.APPJump;
|
||||
import com.info.sn.bean.SystemSettings;
|
||||
import com.info.sn.network.api.AddAppInstall;
|
||||
import com.info.sn.network.api.Browser;
|
||||
import com.info.sn.network.api.ForceInstall;
|
||||
@@ -27,13 +26,16 @@ import com.info.sn.network.api.Label;
|
||||
import com.info.sn.network.api.NewestAppUpdate;
|
||||
import com.info.sn.network.api.QueryAllApp;
|
||||
import com.info.sn.network.api.QuerySnAppStart;
|
||||
import com.info.sn.network.api.Setting;
|
||||
import com.info.sn.network.api.TimeControl;
|
||||
import com.info.sn.network.api.UpdateAdminSn;
|
||||
import com.info.sn.service.InitJpushServer;
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
import com.info.sn.utils.FileUtils;
|
||||
import com.info.sn.utils.SPUtils;
|
||||
import com.info.sn.utils.TimeUtils;
|
||||
import com.info.sn.utils.Utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
@@ -43,14 +45,16 @@ import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class HTTPInterface {
|
||||
public static void SendAppInstall(String jsonString) {
|
||||
// if (packageName.equals(packages)) {
|
||||
// Log.e("SendAppInstall", installOrRemove + "return: " + packages);
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
public static void SendAppInstall(String packageName, int versionCode, int installOrRemove) {
|
||||
AddAppInstall addAppInstall = NetWorkManager.getAddAppInstallControl();
|
||||
addAppInstall.installorRemove(
|
||||
Utils.getSerial(),
|
||||
packageName,
|
||||
versionCode,
|
||||
installOrRemove
|
||||
Utils.getSerial(), jsonString
|
||||
).subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@@ -73,6 +77,7 @@ public class HTTPInterface {
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.e("SendAppInstall", "onComplete: ");
|
||||
|
||||
}
|
||||
});
|
||||
@@ -229,7 +234,7 @@ public class HTTPInterface {
|
||||
int code = listBaseResponse.code;
|
||||
if (code == 200) {
|
||||
List<AppStart> list = listBaseResponse.data;
|
||||
setAotuandNet(context, list);
|
||||
setAppState(context, list);
|
||||
} else {
|
||||
setInvalid(context);
|
||||
}
|
||||
@@ -247,42 +252,33 @@ public class HTTPInterface {
|
||||
});
|
||||
}
|
||||
|
||||
private static void setAppState(Context context, List<AppStart> list) {
|
||||
setAppAutoStart(context, list);
|
||||
setAppNetwork(context, list);
|
||||
setAppNUpdate(context, list);
|
||||
setAppSlide(context, list);
|
||||
setAppHide(context, list);
|
||||
setAPPinsideBrowser(context, list);
|
||||
setAPPIDJump(context, list);
|
||||
}
|
||||
|
||||
private static void setAotuandNet(Context context, List<AppStart> list) {
|
||||
|
||||
//应用自启动
|
||||
private static void setAppAutoStart(Context context, List<AppStart> list) {
|
||||
String auto_allow = "";
|
||||
String auto_not = "";
|
||||
String network_allow = "";
|
||||
String network_not = "";
|
||||
String upgrade_allow = "";
|
||||
String upgrade_not = "";
|
||||
String slide_allow = "";
|
||||
String slide_not = "";
|
||||
if (null != list && list.size() != 0) {
|
||||
for (AppStart app : list) {
|
||||
int is_auto = app.getIs_auto();
|
||||
int is_network = app.getIs_network();
|
||||
int is_upgrade = app.getIs_upgrade();
|
||||
int is_slide = app.getIs_slide();
|
||||
String app_package = app.getApp_package();
|
||||
if (is_auto == 1) {
|
||||
auto_allow += app_package + ",";
|
||||
if (!auto_allow.contains(app_package)) {
|
||||
auto_allow += app_package + ",";
|
||||
}
|
||||
} else {
|
||||
auto_not += app_package + ",";
|
||||
}
|
||||
if (is_network == 1) {
|
||||
network_allow += app_package + ",";
|
||||
} else {
|
||||
network_not += app_package + ",";
|
||||
}
|
||||
if (is_upgrade == 1) {
|
||||
upgrade_allow += app.getApp_package() + ",";
|
||||
} else {
|
||||
upgrade_not += app.getApp_package() + ",";
|
||||
}
|
||||
if (is_slide == 1) {
|
||||
slide_allow += app.getApp_package() + ",";
|
||||
} else {
|
||||
slide_not += app.getApp_package() + ",";
|
||||
if (!auto_not.contains(app_package)) {
|
||||
auto_not += app_package + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(auto_allow) && auto_allow.endsWith(",")) {
|
||||
@@ -292,6 +288,27 @@ public class HTTPInterface {
|
||||
if (!TextUtils.isEmpty(auto_not) && auto_not.endsWith(",")) {
|
||||
auto_not = auto_not.substring(0, auto_not.length() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//应用联网管控
|
||||
private static void setAppNetwork(Context context, List<AppStart> list) {
|
||||
String network_allow = "";
|
||||
String network_not = "";
|
||||
if (null != list && list.size() != 0) {
|
||||
for (AppStart app : list) {
|
||||
int is_network = app.getIs_network();
|
||||
String app_package = app.getApp_package();
|
||||
if (is_network == 1) {
|
||||
if (!network_allow.contains(app_package)) {
|
||||
network_allow += app_package + ",";
|
||||
}
|
||||
} else {
|
||||
if (!network_not.contains(app_package)) {
|
||||
network_not += app_package + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(network_allow) && network_allow.endsWith(",")) {
|
||||
network_allow = network_allow.substring(0, network_allow.length() - 1);
|
||||
Settings.System.putString(context.getContentResolver(), "qch_jgy_network_allow", network_allow);
|
||||
@@ -302,15 +319,54 @@ public class HTTPInterface {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", network_not);
|
||||
Log.e("fht", "ban::" + network_not);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//app更新
|
||||
private static void setAppNUpdate(Context context, List<AppStart> list) {
|
||||
if (null != list && list.size() != 0) {
|
||||
String upgrade_allow = "";
|
||||
String upgrade_not = "";
|
||||
for (AppStart app : list) {
|
||||
int is_upgrade = app.getIs_upgrade();
|
||||
String app_package = app.getApp_package();
|
||||
if (is_upgrade == 0) {
|
||||
upgrade_allow += app_package + ",";
|
||||
} else {
|
||||
upgrade_not += app_package + ",";
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(upgrade_allow) && upgrade_allow.endsWith(",")) {
|
||||
upgrade_allow = upgrade_allow.substring(0, upgrade_allow.length() - 1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(upgrade_not) && upgrade_not.endsWith(",")) {
|
||||
upgrade_not = upgrade_not.substring(0, upgrade_not.length() - 1);
|
||||
}
|
||||
|
||||
Log.e("setAppNUpdate", "upgrade_allow: " + upgrade_allow);
|
||||
Log.e("setAppNUpdate", "upgrade_allow: " + upgrade_not);
|
||||
Utils.writeDisableUpdateList(context, upgrade_not.split(","), upgrade_allow.split(","));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//app滑动管控
|
||||
private static void setAppSlide(Context context, List<AppStart> list) {
|
||||
String slide_allow = "";
|
||||
String slide_not = "";
|
||||
if (null != list && list.size() != 0) {
|
||||
for (AppStart app : list) {
|
||||
int is_slide = app.getIs_slide();
|
||||
String app_package = app.getApp_package();
|
||||
if (is_slide == 1) {
|
||||
if (!slide_allow.contains(app_package)) {
|
||||
slide_allow += app_package + ",";
|
||||
}
|
||||
} else {
|
||||
if (!slide_not.contains(app_package)) {
|
||||
slide_not += app_package + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(slide_allow) && slide_allow.endsWith(",")) {
|
||||
slide_allow = slide_allow.substring(0, slide_allow.length() - 1);
|
||||
}
|
||||
@@ -328,69 +384,48 @@ public class HTTPInterface {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setInvalid(Context context) {
|
||||
boolean qch_app_power_on = Settings.System.putString(context.getContentResolver(), "qch_app_power_on", "Invalid");
|
||||
boolean qch_jgy_network_allow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_allow", "Invalid");
|
||||
boolean qch_jgy_network_disallow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", "Invalid");
|
||||
boolean writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_disable_slide", "Invalid");
|
||||
//隐藏显示app
|
||||
private static void setAppHide(Context context, List<AppStart> list) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (null != list && list.size() != 0) {
|
||||
for (AppStart app : list) {
|
||||
String app_package = app.getApp_package();
|
||||
int is_lock = app.getIs_lock();
|
||||
try {
|
||||
if (is_lock == 1) {
|
||||
pm.setApplicationEnabledSetting(app_package, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
} else {
|
||||
pm.setApplicationEnabledSetting(app_package, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e("setAppHide", "setAppHide: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void getAppJump(final Context context) {
|
||||
APPJump appJump = NetWorkManager.getAppJumpControl();
|
||||
appJump.getSNJump(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<List<AppJump>>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<List<AppJump>> listBaseResponse) {
|
||||
int code = listBaseResponse.code;
|
||||
if (code == 200) {
|
||||
List<AppJump> list = listBaseResponse.data;
|
||||
setAPPinsideBrowser(context, list);
|
||||
} else {
|
||||
sendAllweb(context);
|
||||
sendwebUrl(context);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getAppJump", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setAPPinsideBrowser(Context context, List<AppJump> list) {
|
||||
//应用内网页管控
|
||||
public static void setAPPinsideBrowser(Context context, List<AppStart> list) {
|
||||
String packageList = "";
|
||||
String urlList = "";
|
||||
for (AppJump appJump : list) {
|
||||
if (TextUtils.isEmpty(appJump.getAddress())) {
|
||||
packageList += appJump.getApp_package() + ",";
|
||||
for (AppStart app : list) {
|
||||
if (TextUtils.isEmpty(app.getAddress())) {
|
||||
packageList += app.getApp_package() + ",";
|
||||
} else {
|
||||
urlList += appJump.toString() + ";";
|
||||
urlList += app.getApp_package() + "," + app.getAddress() + ";";
|
||||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(packageList)) {
|
||||
//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);
|
||||
context.sendBroadcast(qch_app_website);
|
||||
// //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);
|
||||
// context.sendBroadcast(qch_app_website);
|
||||
sendAllweb(context);
|
||||
} else {
|
||||
sendAllweb(context);
|
||||
}
|
||||
@@ -408,6 +443,44 @@ public class HTTPInterface {
|
||||
}
|
||||
}
|
||||
|
||||
//应用ID管控
|
||||
public static void setAPPIDJump(Context context, List<AppStart> list) {
|
||||
String ids = "";
|
||||
String packages = "";
|
||||
if (null != list && list.size() != 0) {
|
||||
for (AppStart app : list) {
|
||||
String app_package = app.getApp_package();
|
||||
String id = app.getVisit();
|
||||
if (!ids.contains(id)) {
|
||||
ids += id + ",";
|
||||
}
|
||||
if (!packages.contains(app_package)) {
|
||||
packages += app_package + ",";
|
||||
}
|
||||
}
|
||||
if (TextUtils.isEmpty(ids)) {
|
||||
Settings.System.putString(context.getContentResolver(), "qch_app_forbid_id", "Invalid");
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectViewArray", "Invalid");
|
||||
} else {
|
||||
if (ids.endsWith(",")) {
|
||||
ids = ids.substring(0, ids.length() - 1);
|
||||
}
|
||||
if (packages.endsWith(",")) {
|
||||
packages = packages.substring(0, packages.length() - 1);
|
||||
}
|
||||
Settings.System.putString(context.getContentResolver(), "qch_app_forbid_id", packages);
|
||||
Settings.System.putString(context.getContentResolver(), "DeselectViewArray", ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setInvalid(Context context) {
|
||||
boolean qch_app_power_on = Settings.System.putString(context.getContentResolver(), "qch_app_power_on", "Invalid");
|
||||
boolean qch_jgy_network_allow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_allow", "Invalid");
|
||||
boolean qch_jgy_network_disallow = Settings.System.putString(context.getContentResolver(), "qch_jgy_network_disallow", "Invalid");
|
||||
boolean writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_disable_slide", "Invalid");
|
||||
}
|
||||
|
||||
private static void sendAllweb(Context context) {
|
||||
Intent intent = new Intent("qch_app_website")
|
||||
.setPackage("com.android.settings");
|
||||
@@ -422,7 +495,7 @@ public class HTTPInterface {
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public static void updateAdminInfo(Context context) {
|
||||
synchronized public static void updateAdminInfo(Context context) {
|
||||
String address = String.valueOf(SPUtils.get(context, "AmapAddress", "-"));
|
||||
String longitude = String.valueOf(SPUtils.get(context, "longitude", "0"));
|
||||
String latitude = String.valueOf(SPUtils.get(context, "latitude", "0"));
|
||||
@@ -449,6 +522,8 @@ public class HTTPInterface {
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse baseResponse) {
|
||||
// Log.e("updateAdminInfo", "onNext: " + baseResponse.toString());
|
||||
Log.e("updateAdminInfo", "onNext: " + baseResponse.msg);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -552,7 +627,9 @@ public class HTTPInterface {
|
||||
String packageList = "";
|
||||
PackageManager pm = context.getPackageManager();
|
||||
for (AppInfo appInfo : list) {
|
||||
packageList += appInfo.getApp_package() + ",";
|
||||
if (!packageList.contains(appInfo.getApp_package())) {
|
||||
packageList += appInfo.getApp_package() + ",";
|
||||
}
|
||||
PackageInfo info = null;
|
||||
try {
|
||||
info = pm.getPackageInfo(appInfo.getApp_package(), 0);
|
||||
@@ -652,6 +729,85 @@ public class HTTPInterface {
|
||||
}
|
||||
}
|
||||
|
||||
public static void getSystemSettings(final Context context) {
|
||||
Setting setting = NetWorkManager.getsettingControl();
|
||||
setting.getSetting(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse<SystemSettings>>() {
|
||||
@Override
|
||||
public void onSubscribe(@NonNull Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(@NonNull BaseResponse<SystemSettings> systemSettingsBaseResponse) {
|
||||
int code = systemSettingsBaseResponse.code;
|
||||
if (code == 200) {
|
||||
SystemSettings settings = systemSettingsBaseResponse.data;
|
||||
Utils.setSystemSetting(context, settings.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(@NonNull Throwable e) {
|
||||
Log.e("getSystemSettings", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
synchronized public static void getTimeControl(final Context context) {
|
||||
TimeControl timeControl = NetWorkManager.getTimeControl();
|
||||
timeControl.getTimeControl(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(baseResponse.data);
|
||||
String start_time = jsonObject.getString("start_time");
|
||||
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());
|
||||
}
|
||||
} else {
|
||||
TimeUtils.setEmpty(context);
|
||||
TimeUtils.ContralTime c = TimeUtils.getDefaltContralTime(context);
|
||||
if (null != c) {
|
||||
Log.e("getTimeControl", c.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.e("getTimeControl", "onError: " + e.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(InitJpushServer.TimeChangedReceiver.ACTION_UPDATE);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//获取设备信息接口
|
||||
// public static synchronized void checkDevicesInfo(final Handler handler) {
|
||||
// OkGo.<String>get(UrlAddress.SNINFO)
|
||||
|
||||
@@ -13,8 +13,11 @@ import com.info.sn.network.api.NewestAppUpdate;
|
||||
import com.info.sn.network.api.QueryAllApp;
|
||||
import com.info.sn.network.api.QuerySnAppStart;
|
||||
import com.info.sn.network.api.SNInfo;
|
||||
import com.info.sn.network.api.ScreenLock;
|
||||
import com.info.sn.network.api.Setting;
|
||||
import com.info.sn.network.api.TimeControl;
|
||||
import com.info.sn.network.api.UpdateAdminSn;
|
||||
import com.info.sn.network.api.UploadScreenshot;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -63,6 +66,10 @@ public class NetWorkManager {
|
||||
private static UpdateAdminSn updateAdminSnControl;
|
||||
private static QueryAllApp queryAllAppControl;
|
||||
private static NewestAppUpdate newestAppUpdateControl;
|
||||
private static UploadScreenshot uploadScreenshotControl;
|
||||
private static ScreenLock getScreenLockControl;
|
||||
private static TimeControl getTimeControl;
|
||||
|
||||
|
||||
public static SNInfo getsnInfoControl() {
|
||||
if (null == snInfoControl) {
|
||||
@@ -220,5 +227,42 @@ public class NetWorkManager {
|
||||
return newestAppUpdateControl;
|
||||
}
|
||||
|
||||
public static UploadScreenshot getUploadScreenshotControl() {
|
||||
if (null == uploadScreenshotControl) {
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.client(client)
|
||||
.baseUrl(ROOT_URL)
|
||||
.addConverterFactory(gsonConverterFactory)
|
||||
.addCallAdapterFactory(rxJavaCallAdapterFactory)
|
||||
.build();
|
||||
uploadScreenshotControl = retrofit.create(UploadScreenshot.class);
|
||||
}
|
||||
return uploadScreenshotControl;
|
||||
}
|
||||
|
||||
public static ScreenLock getScreenLockControl() {
|
||||
if (null == getScreenLockControl) {
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.client(client)
|
||||
.baseUrl(ROOT_URL)
|
||||
.addConverterFactory(gsonConverterFactory)
|
||||
.addCallAdapterFactory(rxJavaCallAdapterFactory)
|
||||
.build();
|
||||
getScreenLockControl = retrofit.create(ScreenLock.class);
|
||||
}
|
||||
return getScreenLockControl;
|
||||
}
|
||||
public static TimeControl getTimeControl() {
|
||||
if (null == getTimeControl) {
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.client(client)
|
||||
.baseUrl(ROOT_URL)
|
||||
.addConverterFactory(gsonConverterFactory)
|
||||
.addCallAdapterFactory(rxJavaCallAdapterFactory)
|
||||
.build();
|
||||
getTimeControl = retrofit.create(TimeControl.class);
|
||||
}
|
||||
return getTimeControl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,10 @@ public class UrlAddress {
|
||||
//发送卸载或者安装信息
|
||||
public final static String GET_NEWESTAPPUPDATE = ROOT_URL + "app/newestAppUpdate";
|
||||
//根据包名获取更新
|
||||
public final static String UPLOAD_SCREEN_SNAPSHOT = ROOT_URL + "sn/uploadScreenshot";
|
||||
//上传屏幕截图
|
||||
public final static String GET_SCREEN_LOCK = ROOT_URL + "sn/getScreenshot";
|
||||
//上传屏幕截图
|
||||
public final static String GET_TIME_CONTROL = ROOT_URL + "sn/getTimeControl";
|
||||
//上传屏幕截图
|
||||
}
|
||||
|
||||
@@ -13,9 +13,7 @@ public interface AddAppInstall {
|
||||
@POST(UrlAddress.SEND_INSTALLEDORREMOVED)
|
||||
Observable<BaseResponse> installorRemove(
|
||||
@Field("sn") String sn,
|
||||
@Field("packageName") String packageName,
|
||||
@Field("versionCode") int versionCode,
|
||||
@Field("type") int type
|
||||
@Field("app") String jsonString
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
15
app/src/main/java/com/info/sn/network/api/ScreenLock.java
Normal file
15
app/src/main/java/com/info/sn/network/api/ScreenLock.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.info.sn.network.api;
|
||||
|
||||
import com.info.sn.bean.BaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface ScreenLock {
|
||||
@GET(UrlAddress.GET_SCREEN_LOCK)
|
||||
Observable<BaseResponse> getScreenshot(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
15
app/src/main/java/com/info/sn/network/api/TimeControl.java
Normal file
15
app/src/main/java/com/info/sn/network/api/TimeControl.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.info.sn.network.api;
|
||||
|
||||
import com.info.sn.bean.BaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface TimeControl {
|
||||
@GET(UrlAddress.GET_TIME_CONTROL)
|
||||
Observable<BaseResponse> getTimeControl(
|
||||
@Query("sn") String sn
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.info.sn.network.api;
|
||||
|
||||
import com.info.sn.bean.BaseResponse;
|
||||
import com.info.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import okhttp3.MultipartBody;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface UploadScreenshot {
|
||||
@Multipart
|
||||
@POST(UrlAddress.UPLOAD_SCREEN_SNAPSHOT)
|
||||
Observable<BaseResponse> uploadScreenshot(
|
||||
@Query("sn") String sn,
|
||||
@Part MultipartBody.Part file
|
||||
);
|
||||
}
|
||||
@@ -3,24 +3,85 @@ package com.info.sn.receiver;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.info.sn.bean.AppUploadInfo;
|
||||
import com.info.sn.network.HTTPInterface;
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class APKinstallReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
public void onReceive(final Context context, Intent intent) {
|
||||
// TODO: This method is called when the BroadcastReceiver is receiving
|
||||
// an Intent broadcast.
|
||||
String action = intent.getAction();
|
||||
if (action.equals(Intent.ACTION_PACKAGE_ADDED) || action.equals(Intent.ACTION_PACKAGE_REPLACED)) {
|
||||
if (action.equals(Intent.ACTION_PACKAGE_ADDED)
|
||||
|| action.equals(Intent.ACTION_PACKAGE_REPLACED)
|
||||
|| action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
|
||||
String packageName = intent.getDataString().replace("package:", "");
|
||||
int code = ApkUtils.getAppVersionCode(context,packageName);
|
||||
HTTPInterface.SendAppInstall(packageName,code ,1);
|
||||
} else if (action.equals(Intent.ACTION_PACKAGE_REMOVED)) {
|
||||
String packageName = intent.getDataString().replace("package:", "");
|
||||
HTTPInterface.SendAppInstall(packageName,0 ,2);
|
||||
Observable.create(new ObservableOnSubscribe<List<AppUploadInfo>>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<List<AppUploadInfo>> emitter) throws Exception {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
List<PackageInfo> list = pm.getInstalledPackages(0);
|
||||
List<AppUploadInfo> uploadInfos = new ArrayList<>();
|
||||
for (PackageInfo info : list) {
|
||||
if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1){
|
||||
continue;
|
||||
}
|
||||
AppUploadInfo uploadInfo = new AppUploadInfo();
|
||||
uploadInfo.setApp_package(info.packageName);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
uploadInfo.setApp_version_code(info.getLongVersionCode());
|
||||
} else {
|
||||
uploadInfo.setApp_version_code(info.versionCode);
|
||||
}
|
||||
uploadInfos.add(uploadInfo);
|
||||
}
|
||||
emitter.onNext(uploadInfos);
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<List<AppUploadInfo>>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(List<AppUploadInfo> appUploadInfos) {
|
||||
String json = JSONArray.toJSONString(appUploadInfos);
|
||||
HTTPInterface.SendAppInstall(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class GuardService extends Service {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
LogUtils.e(TAG, "GuardService:建立链接");
|
||||
boolean isServiceRunning = ServiceAliveUtils.isServiceAlice();
|
||||
boolean isServiceRunning = ServiceAliveUtils.isServiceAlice(getClass().getName());
|
||||
if (!isServiceRunning) {
|
||||
Intent i = new Intent(GuardService.this, MyDownloadService.class);
|
||||
startService(i);
|
||||
|
||||
@@ -1,25 +1,39 @@
|
||||
package com.info.sn.service;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.info.sn.KeepAliveConnection;
|
||||
import com.info.sn.activity.MainActivity;
|
||||
import com.info.sn.bean.AppInfo;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.bean.BaseResponse;
|
||||
import com.info.sn.network.HTTPInterface;
|
||||
import com.info.sn.network.NetWorkManager;
|
||||
import com.info.sn.network.api.ForceInstall;
|
||||
import com.info.sn.network.api.ScreenLock;
|
||||
import com.info.sn.utils.ApkUtils;
|
||||
import com.info.sn.utils.ForegroundAppUtil;
|
||||
import com.info.sn.utils.TimeUtils;
|
||||
import com.info.sn.utils.Utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
|
||||
@@ -40,6 +54,19 @@ public class InitJpushServer extends Service {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
registReceiver();
|
||||
registerTimeReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (null != mTimeChangedReceiver) {
|
||||
unregisterReceiver(mTimeChangedReceiver);
|
||||
}
|
||||
if (null != lockScreenReceiver) {
|
||||
unregisterReceiver(lockScreenReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,9 +75,234 @@ public class InitJpushServer extends Service {
|
||||
HTTPInterface.getAllappPackage(InitJpushServer.this);
|
||||
HTTPInterface.getForceInstall(InitJpushServer.this);
|
||||
HTTPInterface.checkUpdate(InitJpushServer.this);
|
||||
HTTPInterface.checkUpdate(InitJpushServer.this,"com.appstore.uiui");
|
||||
HTTPInterface.checkUpdate(InitJpushServer.this, "com.appstore.uiui");
|
||||
getScreenLockState();
|
||||
HTTPInterface.getTimeControl(InitJpushServer.this);
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
private void getScreenLockState() {
|
||||
ScreenLock getScreenLock = NetWorkManager.getScreenLockControl();
|
||||
getScreenLock.getScreenshot(Utils.getSerial())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<BaseResponse>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(BaseResponse baseResponse) {
|
||||
int code = baseResponse.code;
|
||||
if (code == 200) {
|
||||
JSONObject jsonObject = (JSONObject) JSON.toJSON(baseResponse.data);
|
||||
int is_screen_lock = jsonObject.getInteger("is_screen_lock");
|
||||
if (is_screen_lock == 1) {
|
||||
if (!timelocked) {
|
||||
showFloatingWindow("屏幕已锁定");
|
||||
}
|
||||
screenlocked = true;
|
||||
} else {
|
||||
if (!timelocked) {
|
||||
hideFloatingWindow();
|
||||
}
|
||||
screenlocked = false;
|
||||
}
|
||||
} else {
|
||||
if (!timelocked) {
|
||||
hideFloatingWindow();
|
||||
}
|
||||
screenlocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static WindowManager windowManager;
|
||||
private View topView;
|
||||
boolean screenlocked = false;
|
||||
boolean timelocked = false;
|
||||
|
||||
private void showFloatingWindow(String name) {
|
||||
if (Settings.canDrawOverlays(this)) {
|
||||
// 获取WindowManager服务
|
||||
if (null == windowManager) {
|
||||
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
}
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
windowManager.getDefaultDisplay().getRealMetrics(dm);
|
||||
int width = dm.widthPixels; // 屏幕宽度(像素)
|
||||
int height = dm.heightPixels; // 屏幕高度(像素)
|
||||
// 新建悬浮窗控件
|
||||
final Button button = new Button(getApplicationContext());
|
||||
button.setText("霸屏测试");
|
||||
button.setAlpha(0.9f);
|
||||
button.setBackgroundColor(Color.WHITE);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// windowManager.removeView(button);
|
||||
}
|
||||
});
|
||||
if (null == topView) {
|
||||
topView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.activity_top, null);
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
} else {
|
||||
if (topView.getTag().equals("added")) {
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText(name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// topView.setAlpha(0.8f);
|
||||
// 设置LayoutParam
|
||||
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
} else {
|
||||
layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE;
|
||||
}
|
||||
layoutParams.flags = WindowManager.LayoutParams.FLAG_BLUR_BEHIND;
|
||||
layoutParams.format = PixelFormat.RGBA_8888;
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.x = 0;
|
||||
layoutParams.y = 0;
|
||||
|
||||
// 将悬浮窗控件添加到WindowManager
|
||||
windowManager.addView(topView, layoutParams);
|
||||
topView.setTag("added");
|
||||
}
|
||||
}
|
||||
|
||||
private void hideFloatingWindow() {
|
||||
if (null == windowManager) {
|
||||
return;
|
||||
}
|
||||
if (null != topView) {
|
||||
windowManager.removeView(topView);
|
||||
topView = null;
|
||||
}
|
||||
}
|
||||
|
||||
private LockScreenReceiver lockScreenReceiver;
|
||||
|
||||
private void registReceiver() {
|
||||
if (null == lockScreenReceiver) {
|
||||
lockScreenReceiver = new LockScreenReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(LockScreenReceiver.ACTION_LOCK);
|
||||
filter.addAction(LockScreenReceiver.ACTION_UNLOCK);
|
||||
registerReceiver(lockScreenReceiver, filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class LockScreenReceiver extends BroadcastReceiver {
|
||||
public static final String ACTION_LOCK = "LockScreenReceiver_lockscreen";
|
||||
public static final String ACTION_UNLOCK = "LockScreenReceiver_unlockscreen";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
getScreenLockState();
|
||||
return;
|
||||
}
|
||||
if (ACTION_LOCK.equals(action)) {
|
||||
// String name = intent.getStringExtra("name");
|
||||
String name = "屏幕已锁定";
|
||||
if (!timelocked) {
|
||||
showFloatingWindow(name);
|
||||
}
|
||||
screenlocked = true;
|
||||
} else if (ACTION_UNLOCK.equals(action)) {
|
||||
if (!timelocked) {
|
||||
hideFloatingWindow();
|
||||
}
|
||||
screenlocked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private TimeChangedReceiver mTimeChangedReceiver;
|
||||
|
||||
//监听时间和日期变化
|
||||
public void registerTimeReceiver() {
|
||||
mTimeChangedReceiver = new TimeChangedReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(Intent.ACTION_DATE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_TIME_TICK);
|
||||
filter.addAction(TimeChangedReceiver.ACTION_UPDATE);
|
||||
registerReceiver(mTimeChangedReceiver, filter);
|
||||
}
|
||||
|
||||
public class TimeChangedReceiver extends BroadcastReceiver {
|
||||
public static final String ACTION_UPDATE = "TimeChangedReceiver_update";
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_DATE_CHANGED.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "data changed");
|
||||
} else if (Intent.ACTION_TIME_CHANGED.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "time changed");
|
||||
} else if (Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "timezone changed");
|
||||
} else if (Intent.ACTION_TIME_TICK.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "time tick");
|
||||
} else if (ACTION_UPDATE.equals(intent.getAction())) {
|
||||
Log.e("fht", "TimeChangedReceiver:" + "date update");
|
||||
}
|
||||
long nowTime = System.currentTimeMillis();
|
||||
TimeUtils.ContralTime contralTime = TimeUtils.getDefaltContralTime(InitJpushServer.this);
|
||||
if (null != contralTime) {
|
||||
if (contralTime.inControlTime(nowTime)) {
|
||||
if (!screenlocked) {
|
||||
showFloatingWindow("管控时间:" + contralTime.toString());
|
||||
} else {
|
||||
TextView textView = topView.findViewById(R.id.textView);
|
||||
textView.setText("管控时间:" + contralTime.toString());
|
||||
}
|
||||
timelocked = true;
|
||||
} else {
|
||||
getScreenLockState();
|
||||
if (!screenlocked) {
|
||||
hideFloatingWindow();
|
||||
}
|
||||
timelocked = false;
|
||||
}
|
||||
} else {
|
||||
if (!screenlocked) {
|
||||
hideFloatingWindow();
|
||||
}
|
||||
getScreenLockState();
|
||||
timelocked = false;
|
||||
}
|
||||
// String packages = ForegroundAppUtil.getForegroundPackageName(context);
|
||||
// if (!packages.equals("com.estrongs.android.pop")) {
|
||||
// ApkUtils.openApp(context, "com.estrongs.android.pop");
|
||||
// }
|
||||
// Log.e("TimeChangedReceiver", "packages:" + packages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class StepService extends Service {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
LogUtils.e(TAG, "StepService:建立链接");
|
||||
boolean isServiceRunning = ServiceAliveUtils.isServiceAlice();
|
||||
boolean isServiceRunning = ServiceAliveUtils.isServiceAlice(getClass().getName());
|
||||
if (!isServiceRunning) {
|
||||
Intent i = new Intent(StepService.this, MyDownloadService.class);
|
||||
startService(i);
|
||||
|
||||
@@ -87,7 +87,7 @@ public class ApkUtils {
|
||||
public static void openApp(Context context, String packageName) {
|
||||
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
if (intent != null) {
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
@@ -631,12 +631,12 @@ public class ApkUtils {
|
||||
} catch (Settings.SettingNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PackageManager pm = context.getPackageManager();
|
||||
if (hide == 0) {
|
||||
pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||
} else {
|
||||
pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
}
|
||||
// PackageManager pm = context.getPackageManager();
|
||||
// if (hide == 0) {
|
||||
// pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||
// } else {
|
||||
// pm.setApplicationEnabledSetting(pkage, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -676,8 +676,10 @@ public class ApkUtils {
|
||||
continue;
|
||||
}
|
||||
// ApkUtils.getStartActivityName(context, s);
|
||||
installedList += s + ",";
|
||||
Log.e("addShortcut", s);
|
||||
if (!installedList.contains(s)) {
|
||||
installedList += s + ",";
|
||||
Log.e("addShortcut", s);
|
||||
}
|
||||
}
|
||||
if (installedList.length() != 0) {
|
||||
installedList = installedList.substring(0, installedList.length() - 1);
|
||||
@@ -697,6 +699,7 @@ public class ApkUtils {
|
||||
String store = "com.jiaoguanyi.store";
|
||||
String infosn = "com.info.sn";
|
||||
String appstoreuiui = "com.appstore.uiui";
|
||||
String desktop = "com.android.uiuios";
|
||||
String jgy1 = "com.uiuios.jgy1";
|
||||
String jgy2 = "com.uiuios.jgy2";
|
||||
if (!TextUtils.isEmpty(result)) {
|
||||
@@ -718,6 +721,9 @@ public class ApkUtils {
|
||||
if (!result.contains(appstoreuiui)) {
|
||||
result = result + "," + appstoreuiui;
|
||||
}
|
||||
if (!result.contains(desktop)) {
|
||||
result = result + "," + desktop;
|
||||
}
|
||||
boolean qch_app_forbid = Settings.System.putString(context.getContentResolver(), "qch_app_forbid", result);
|
||||
Log.e("fht", "qch_app_forbid :" + result + ":" + qch_app_forbid);
|
||||
} else {
|
||||
|
||||
103
app/src/main/java/com/info/sn/utils/CmdUtil.java
Normal file
103
app/src/main/java/com/info/sn/utils/CmdUtil.java
Normal file
@@ -0,0 +1,103 @@
|
||||
package com.info.sn.utils;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class CmdUtil {
|
||||
private static final String TAG = "CmdUtil";
|
||||
|
||||
private static final String COMMAND_SH = "sh";
|
||||
private static final String COMMAND_EXIT = "exit\n";
|
||||
private static final String COMMAND_LINE_END = "\n";
|
||||
|
||||
|
||||
/**
|
||||
* 运行命令
|
||||
*
|
||||
* @param command 命令
|
||||
* @return 结果
|
||||
*/
|
||||
public static Result execute(String command) {
|
||||
Log.i(TAG, "execute() command = " + command);
|
||||
Result result = new Result();
|
||||
|
||||
if (TextUtils.isEmpty(command)) {
|
||||
Log.w(TAG, "WARNING: command should not be null or empty");
|
||||
return result;
|
||||
}
|
||||
|
||||
Process process = null;
|
||||
DataOutputStream dos = null;
|
||||
|
||||
try {
|
||||
process = Runtime.getRuntime().exec(COMMAND_SH);
|
||||
dos = new DataOutputStream(process.getOutputStream());
|
||||
dos.write(command.trim().getBytes());
|
||||
dos.writeBytes(COMMAND_LINE_END);
|
||||
dos.flush();
|
||||
dos.writeBytes(COMMAND_EXIT);
|
||||
dos.flush();
|
||||
result.code = process.waitFor();
|
||||
result.success = readBuffer(new BufferedReader(new InputStreamReader(process.getInputStream())));
|
||||
result.error = readBuffer(new BufferedReader(new InputStreamReader(process.getErrorStream())));
|
||||
Log.i(TAG, "result = " + result);
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
Log.e(TAG, ioe.getMessage());
|
||||
} catch (InterruptedException ie) {
|
||||
ie.printStackTrace();
|
||||
Log.e(TAG, ie.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
if (null != dos) {
|
||||
dos.close();
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
Log.e(TAG, ioe.getMessage());
|
||||
}
|
||||
if (null != process) {
|
||||
process.destroy();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String readBuffer(BufferedReader bufferedReader) throws IOException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String s;
|
||||
while ((s = bufferedReader.readLine()) != null) {
|
||||
sb.append(s);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Command执行结果
|
||||
*/
|
||||
public static final class Result {
|
||||
|
||||
public static final int SUCCESS = 0;
|
||||
public static final int ERROR = -1;
|
||||
|
||||
public int code = ERROR;
|
||||
String error;
|
||||
String success;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Result{" +
|
||||
"code=" + code +
|
||||
", error='" + error + '\'' +
|
||||
", success='" + success + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
114
app/src/main/java/com/info/sn/utils/ForegroundAppUtil.java
Normal file
114
app/src/main/java/com/info/sn/utils/ForegroundAppUtil.java
Normal file
@@ -0,0 +1,114 @@
|
||||
package com.info.sn.utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.usage.UsageStats;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ForegroundAppUtil {
|
||||
|
||||
private static final long END_TIME = System.currentTimeMillis();
|
||||
private static final long TIME_INTERVAL = 7 * 24 * 60 * 60 * 1000L;
|
||||
private static final long START_TIME = END_TIME - TIME_INTERVAL;
|
||||
|
||||
|
||||
public static String getForegroundPackageName(Context context) {
|
||||
//系统应用可以直接获取
|
||||
ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningTaskInfo> runningTaskInfos = mActivityManager.getRunningTasks(1);
|
||||
return runningTaskInfos.get(0).topActivity.getPackageName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取栈顶的应用包名
|
||||
*/
|
||||
public static String getForegroundActivityName(Context context) {
|
||||
String currentClassName = "";
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
ActivityManager manager = (ActivityManager) context.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
currentClassName = manager.getRunningTasks(1).get(0).topActivity.getPackageName();
|
||||
} else {
|
||||
UsageStats initStat = getForegroundUsageStats(context, START_TIME, END_TIME);
|
||||
if (initStat != null) {
|
||||
currentClassName = initStat.getPackageName();
|
||||
}
|
||||
}
|
||||
return currentClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前应用是否在前台
|
||||
*/
|
||||
public static boolean isForegroundApp(Context context) {
|
||||
return TextUtils.equals(getForegroundActivityName(context), context.getPackageName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间段内,
|
||||
*/
|
||||
public static long getTotleForegroundTime(Context context) {
|
||||
UsageStats usageStats = getCurrentUsageStats(context, START_TIME, END_TIME);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
return usageStats != null ? usageStats.getTotalTimeInForeground() : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取记录前台应用的UsageStats对象
|
||||
*/
|
||||
private static UsageStats getForegroundUsageStats(Context context, long startTime, long endTime) {
|
||||
UsageStats usageStatsResult = null;
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
List<UsageStats> usageStatses = getUsageStatsList(context, startTime, endTime);
|
||||
if (usageStatses == null || usageStatses.isEmpty()) return null;
|
||||
for (UsageStats usageStats : usageStatses) {
|
||||
if (usageStatsResult == null || usageStatsResult.getLastTimeUsed() < usageStats.getLastTimeUsed()) {
|
||||
usageStatsResult = usageStats;
|
||||
}
|
||||
}
|
||||
}
|
||||
return usageStatsResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取记录当前应用的UsageStats对象
|
||||
*/
|
||||
public static UsageStats getCurrentUsageStats(Context context, long startTime, long endTime) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
List<UsageStats> usageStatses = getUsageStatsList(context, startTime, endTime);
|
||||
if (usageStatses == null || usageStatses.isEmpty()) return null;
|
||||
for (UsageStats usageStats : usageStatses) {
|
||||
if (TextUtils.equals(usageStats.getPackageName(), context.getPackageName())) {
|
||||
return usageStats;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过UsageStatsManager获取List<UsageStats>集合
|
||||
*/
|
||||
public static List<UsageStats> getUsageStatsList(Context context, long startTime, long endTime) {
|
||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
UsageStatsManager manager = (UsageStatsManager) context.getApplicationContext().getSystemService(Context.USAGE_STATS_SERVICE);
|
||||
//UsageStatsManager.INTERVAL_WEEKLY,UsageStatsManager的参数定义了5个,具体查阅源码
|
||||
List<UsageStats> usageStatses = manager.queryUsageStats(UsageStatsManager.INTERVAL_BEST, startTime, endTime);
|
||||
if (usageStatses == null || usageStatses.size() == 0) {// 没有权限,获取不到数据
|
||||
Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.getApplicationContext().startActivity(intent);
|
||||
return null;
|
||||
}
|
||||
return usageStatses;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,23 +2,24 @@ package com.info.sn.utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.info.sn.base.MyApplication;
|
||||
|
||||
public class ServiceAliveUtils {
|
||||
|
||||
public static boolean isServiceAlice() {
|
||||
public static boolean isServiceAlice(String className) {
|
||||
boolean isServiceRunning = false;
|
||||
ActivityManager manager =
|
||||
(ActivityManager) MyApplication.getAppContext().getSystemService(Context.ACTIVITY_SERVICE);
|
||||
if (manager == null) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||
if ("demo.lgm.com.keepalivedemo.service.DownloadService".equals(service.service.getClassName())) {
|
||||
if (className.equals(service.service.getClassName())) {
|
||||
isServiceRunning = true;
|
||||
}
|
||||
}
|
||||
Log.e("ServiceAliveUtils", "className isServiceAlice: " + isServiceRunning);
|
||||
return isServiceRunning;
|
||||
}
|
||||
}
|
||||
|
||||
172
app/src/main/java/com/info/sn/utils/TimeUtils.java
Normal file
172
app/src/main/java/com/info/sn/utils/TimeUtils.java
Normal file
@@ -0,0 +1,172 @@
|
||||
package com.info.sn.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.info.sn.service.InitJpushServer;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class TimeUtils {
|
||||
private static DateFormat df = new SimpleDateFormat("HH:mm");
|
||||
public static final String START_TIME_KEY = "START_TIME";
|
||||
public static final String END_TIME_KEY = "END_TIME";
|
||||
public static long dayTime = 60 * 60 * 24 * 1000;
|
||||
|
||||
public static String getNowTime() {
|
||||
long nowTime = System.currentTimeMillis();
|
||||
DateFormat df = ContralTime.getDf();
|
||||
return df.format(nowTime);
|
||||
}
|
||||
|
||||
// public static boolean CurrentInTimeScope(ContralTime contralTime) {
|
||||
// boolean result = true;
|
||||
// final long aDayInMillis = 1000 * 60 * 60 * 24;
|
||||
// long currentTimeMillis = System.currentTimeMillis();
|
||||
//
|
||||
// }
|
||||
|
||||
public static ContralTime String2ContralTime(Context context, @NonNull String timeText) {
|
||||
DateFormat df = ContralTime.getDf();
|
||||
String[] time = timeText.trim().split("-");
|
||||
if (time.length != 2) {
|
||||
throw new RuntimeException("Time format error!");
|
||||
}
|
||||
try {
|
||||
SPUtils.put(context, START_TIME_KEY, time[0].trim());
|
||||
SPUtils.put(context, END_TIME_KEY, time[1].trim());
|
||||
Date startDate = df.parse(time[0].trim());
|
||||
Date endDate = df.parse(time[1].trim());
|
||||
ContralTime contralTime = new ContralTime();
|
||||
// if (date1.getTime() < date2.getTime()) {
|
||||
contralTime.setStartTime(df.format(startDate));
|
||||
contralTime.setEndTime(df.format(endDate));
|
||||
// } else {
|
||||
// contralTime.setStartTime(df.format(date2));
|
||||
// contralTime.setEndTime(df.format(date1));
|
||||
// }
|
||||
return contralTime;
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ContralTime getDefaltContralTime(Context context) {
|
||||
String startTime = (String) SPUtils.get(context, START_TIME_KEY, "00:00");
|
||||
String endTime = (String) SPUtils.get(context, END_TIME_KEY, "00:00");
|
||||
if (null == startTime || null == endTime || (startTime.equals("00:00") && endTime.equals("00:00"))) {
|
||||
return null;
|
||||
} else {
|
||||
try {
|
||||
Date startDate = df.parse(startTime.trim());
|
||||
Date endDate = df.parse(endTime.trim());
|
||||
ContralTime contralTime = new ContralTime();
|
||||
contralTime.setStartTime(df.format(startDate));
|
||||
contralTime.setEndTime(df.format(endDate));
|
||||
return contralTime;
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setEmpty(Context context) {
|
||||
SPUtils.put(context, START_TIME_KEY, "00:00");
|
||||
SPUtils.put(context, END_TIME_KEY, "00:00");
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(InitJpushServer.TimeChangedReceiver.ACTION_UPDATE);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
|
||||
public static class ContralTime {
|
||||
|
||||
//format HH:mm
|
||||
static String startTime;
|
||||
static String endTime;
|
||||
|
||||
public ContralTime() {
|
||||
|
||||
}
|
||||
|
||||
public ContralTime(String startT, String endT) {
|
||||
startTime = startT;
|
||||
endTime = endT;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
|
||||
public void setStartTime(String startT) {
|
||||
startTime = startT;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endT) {
|
||||
endTime = endT;
|
||||
}
|
||||
|
||||
public static DateFormat getDf() {
|
||||
return df;
|
||||
}
|
||||
|
||||
public static void setDf(DateFormat d) {
|
||||
df = d;
|
||||
}
|
||||
|
||||
public String getNowTimeString(long time) {
|
||||
return df.format(new Date(time));
|
||||
}
|
||||
|
||||
public boolean inControlTime(long time) {
|
||||
return inControlTime(df.format(new Date(time)));
|
||||
}
|
||||
|
||||
public boolean inControlTime(String time) {
|
||||
if (TextUtils.isEmpty(time)) {
|
||||
throw new RuntimeException("Time is empty");
|
||||
} else {
|
||||
if (!time.contains(":")) {
|
||||
throw new RuntimeException("Time format error");
|
||||
}
|
||||
}
|
||||
try {
|
||||
Date startDate = df.parse(startTime);
|
||||
Date endDate = df.parse(endTime);
|
||||
Date nowDate = df.parse(time);
|
||||
if (startDate.getTime() > endDate.getTime()) {
|
||||
//开始时间大于结束时间 列 16:00-01:00
|
||||
endDate.setTime(endDate.getTime() + dayTime);
|
||||
}
|
||||
if (nowDate.getTime() >= startDate.getTime() && nowDate.getTime() <= endDate.getTime()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return startTime + "\t-\t" + endTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,86 +1,86 @@
|
||||
package com.info.sn.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.StatFs;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.StatFs;
|
||||
import android.provider.Settings;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.bean.SystemSettings;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.R;
|
||||
import com.info.sn.bean.SystemSettings;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static java.lang.System.getProperty;
|
||||
import static java.lang.System.getProperty;
|
||||
|
||||
|
||||
public class Utils {
|
||||
@@ -853,6 +853,7 @@ public class Utils {
|
||||
//MTP模式:usb_mtp
|
||||
//Midi模式:usb_midi
|
||||
String setting_usb = settings.getSetting_usb();
|
||||
Log.e("SystemSetting", "setting_usb:" + setting_usb);
|
||||
if (!BuildConfig.DEBUG) {
|
||||
try {
|
||||
boolean qch_usb_choose = Settings.System.putString(mContext.getContentResolver(), "qch_usb_choose", setting_usb);
|
||||
@@ -1085,6 +1086,14 @@ public class Utils {
|
||||
Log.e(TAG, "setIcon: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param notList 禁止列表
|
||||
* @param allowList 允许列表
|
||||
* @return
|
||||
*/
|
||||
static synchronized public boolean writeDisableUpdateList(Context context, String[] notList, String[] allowList) {
|
||||
String now = Settings.System.getString(context.getContentResolver(), "qch_app_forbid");
|
||||
String[] nowList;
|
||||
@@ -1110,7 +1119,7 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String s : notList) {
|
||||
for (String s : allowList) {
|
||||
if (allList.indexOf(s) == -1) {
|
||||
allList.add(s);
|
||||
//没找到元素添加到白名单
|
||||
@@ -1396,9 +1405,9 @@ public class Utils {
|
||||
} else {
|
||||
//10.0的不需要最小电量
|
||||
// if (getBatteryLevel(context) >= CommonDatas.MIN_POWER) {
|
||||
Intent intent = new Intent("android.intent.action.MASTER_CLEAR");
|
||||
Intent intent = new Intent("android.intent.action.MASTER_CLEAR");
|
||||
// intent.setPackage("com.android.settings");
|
||||
context.sendBroadcast(intent);
|
||||
context.sendBroadcast(intent);
|
||||
// } else {
|
||||
// MySQLData.SetBooleanData(context, CommonDatas.IS_RESET, true);
|
||||
// }
|
||||
|
||||
@@ -253,6 +253,7 @@ public class CustomDialog extends Dialog {
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
Intent intent = new Intent(mContext, MainActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
21
app/src/main/res/layout-land/activity_top.xml
Normal file
21
app/src/main/res/layout-land/activity_top.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/gray"
|
||||
tools:context=".activity.TopActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TextView"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
21
app/src/main/res/layout-port/activity_top.xml
Normal file
21
app/src/main/res/layout-port/activity_top.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/gray"
|
||||
tools:context=".activity.TopActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TextView"
|
||||
android:textSize="20sp"
|
||||
android:textColor="@color/white"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -3,4 +3,9 @@
|
||||
<color name="colorPrimary">#008577</color>
|
||||
<color name="colorPrimaryDark">#00574B</color>
|
||||
<color name="colorAccent">#D81B60</color>
|
||||
|
||||
<color name="white">#ffffff</color>
|
||||
<color name="black">#000000</color>
|
||||
<color name="gray">#80808080</color>
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user