version:4.3

fix:安装应用时不清除桌面缓存,锁定状态改变时不恢复出厂设置
update:在获取sn没有刷写的状态时,获取IMEI作为别名
This commit is contained in:
2022-04-19 09:24:45 +08:00
parent 2339e1484d
commit 69a8934bd4
24 changed files with 514 additions and 263 deletions

View File

@@ -51,6 +51,8 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import okhttp3.internal.Util;
public class SplashActivity extends AppCompatActivity {
private static String TAG = SplashActivity.class.getSimpleName();
@@ -86,6 +88,10 @@ public class SplashActivity extends AppCompatActivity {
private void initView() {
if (BuildConfig.DEBUG) {
Log.e(TAG, "initView: " + Utils.getIMEI(this));
Log.e(TAG, "initView: " + Utils.getIMEI(this, 0));
Log.e(TAG, "initView: " + Utils.getIMEI(this, 1));
// String jsonString = ApkUtils.getRunningAppInfo(this);
// Log.e(TAG, "initView: " + jsonString);
ApkUtils.showAllAPP(this);

View File

@@ -216,6 +216,9 @@ public class CheckNetActivity extends BaseActivity implements CheckNetContact.Ma
mCheckNetPresenter.setPushTags();
} else {
SysSettingUtils.setEnableSetting(this);
giv_2.setBackgroundResource(R.drawable.successful);
giv_3.setBackgroundResource(R.drawable.successful);
finish();
}
}

View File

@@ -105,7 +105,7 @@ public class CheckNetPresenter implements CheckNetContact.Presenter {
if (JGYUtils.isOfficialVersion()) {
mView.updateDeviceInfoFinish();
} else {
mNetInterfaceManager.updateDeviceInfo(new NetInterfaceManager.onCompleteCallback() {
mNetInterfaceManager.updateDeviceInfo(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override
public void onComplete() {
mView.updateDeviceInfoFinish();

View File

@@ -9,7 +9,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.os.IBinder;
import android.os.SystemClock;
import android.provider.Settings;
@@ -39,7 +38,6 @@ import com.aoleyun.sn.utils.Utils;
import com.blankj.utilcode.util.NetworkUtils;
import com.bumptech.glide.Glide;
import com.google.gson.JsonObject;
import com.tencent.mmkv.MMKV;
import java.util.concurrent.TimeUnit;
@@ -59,10 +57,12 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
public static final String UPDATE_LOCKED_STATUS = "UPDATE_LOCKED_STATUS";
@BindView(R.id.imageView)
@BindView(R.id.iv_head)
ImageView head;
@BindView(R.id.tv_devsn)
TextView tv_devsn;
@BindView(R.id.tv_imei2)
TextView tv_imei2;
@BindView(R.id.tv_devmac)
TextView tv_devmac;
@BindView(R.id.version)
@@ -83,9 +83,9 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
Button bt_checkupdate;
@BindView(R.id.checkupdate)
ConstraintLayout checkupdate;
@BindView(R.id.back)
@BindView(R.id.iv_back)
ImageView back;
@BindView(R.id.locked)
@BindView(R.id.iv_locked)
ImageView iv_locked;
@BindView(R.id.layout_class)
ConstraintLayout layout_class;
@@ -93,13 +93,15 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
ConstraintLayout layout_number;
@BindView(R.id.layout_name)
ConstraintLayout layout_name;
@BindView(R.id.cl_imei)
ConstraintLayout cl_imei;
@BindView(R.id.tv_customversion)
TextView tv_customversion;
@OnClick({R.id.back, R.id.tv_title, R.id.chkupd})
@OnClick({R.id.iv_back, R.id.tv_title, R.id.chkupd})
public void onClick(View view) {
switch (view.getId()) {
case R.id.back:
case R.id.iv_back:
lazyExit();
break;
case R.id.tv_title:
@@ -206,8 +208,9 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
}
private void getDevicesInfo() {
String sn = Utils.getSerial();
String sn = Utils.getSerial(this);
tv_devsn.setText(sn);
getIMEI();
checkSNError(sn);
String macaddr = Utils.getAndroid10MAC(this);
if (TextUtils.isEmpty(macaddr)) {
@@ -222,6 +225,16 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
tv_customversion.setText(Utils.getCustomVersion());
}
private void getIMEI() {
if (!Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) {
tv_imei2.setText(Utils.getIMEI(this, 1));
} else {
if (!TextUtils.isEmpty(Utils.getIMEI(this, 1))) {
tv_imei2.setText(Utils.getIMEI(this, 1));
}
}
}
private void checkSNError(String sn) {
//sn长度最长30位
if (sn.length() > 30) {
@@ -430,12 +443,14 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
@Override
protected void onDestroy() {
super.onDestroy();
if (mUpdateReceiver != null) {
unregisterReceiver(mUpdateReceiver);
}
JGYUtils.startServices(MainActivity.this);
NetworkUtils.unregisterNetworkStatusChangedListener(this);
mMainAPresenter.detachView();
mMainAPresenter = null;
if (mUpdateReceiver != null) {
unregisterReceiver(mUpdateReceiver);
mUpdateReceiver = null;
}
JGYUtils.startServices(MainActivity.this);
}
@Override

View File

@@ -27,13 +27,13 @@ public class RequestLogActivity extends BaseActivity implements RequestLogContac
ImageView iv_delete;
@BindView(R.id.iv_refresh)
ImageView iv_refresh;
@BindView(R.id.back)
@BindView(R.id.iv_back)
ImageView back;
@OnClick({R.id.back, R.id.iv_refresh, R.id.iv_delete})
@OnClick({R.id.iv_back, R.id.iv_refresh, R.id.iv_delete})
public void onClick(View view) {
switch (view.getId()) {
case R.id.back:
case R.id.iv_back:
finish();
break;
case R.id.iv_refresh:

View File

@@ -5,6 +5,7 @@ import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;
import androidx.multidex.MultiDexApplication;
@@ -60,21 +61,11 @@ public class BaseApplication extends MultiDexApplication {
@SuppressLint("StaticFieldLeak")
public static Context context;
@SuppressLint("StaticFieldLeak")
private static BaseApplication instance;
public static Context getAppContext() {
return context;
}
// 单例模式中获取唯一的ExitApplication实例
public static BaseApplication getInstance() {
if (null == instance) {
instance = new BaseApplication();
}
return instance;
}
@Override
public void onCreate() {
super.onCreate();
@@ -163,7 +154,11 @@ public class BaseApplication extends MultiDexApplication {
//token在设备卸载重装的时候有可能会变
Log.e("TPush", "注册成功设备token为" + data);
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial(getApplicationContext())));
if (Utils.NOSN.equalsIgnoreCase(Utils.getSerial())) {
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getAppContext(), 0)));
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getIMEI(getAppContext(), 1)));
}
XGPushManager.upsertAccounts(getAppContext(), accountInfoList, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
@@ -396,7 +391,7 @@ public class BaseApplication extends MultiDexApplication {
//https://docs.jiguang.cn/jpush/server/push/rest_api_v3_device/#_5
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(UrlAddress.DELETE_JPUSH_ALIAS + Utils.getSerial())
.url(UrlAddress.DELETE_JPUSH_ALIAS + Utils.getSerial(getAppContext()))
.header("Authorization", JGYUtils.getAuthorization())
.delete()
.build();
@@ -418,7 +413,7 @@ public class BaseApplication extends MultiDexApplication {
synchronized public static void cleanJpushTag() {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url(UrlAddress.DELETE_JPUSH_TAG + Utils.getSerial())
.url(UrlAddress.DELETE_JPUSH_TAG + Utils.getSerial(getAppContext()))
.header("Authorization", JGYUtils.getAuthorization())
.delete()
.build();
@@ -437,16 +432,6 @@ public class BaseApplication extends MultiDexApplication {
});
}
private boolean finished = false;
public boolean isFinished() {
return finished;
}
public void setFinished(boolean b) {
this.finished = b;
}
public static void sendAppUsedTime(String random, String type) {
StatisticsInfo statisticsInfo = null;
if (type.equals("0")) {
@@ -491,7 +476,7 @@ public class BaseApplication extends MultiDexApplication {
NetInterfaceManager.getInstance()
.getAppLogApi()
.getAppLog(Utils.getSerial(), random, data.toJSONString())
.getAppLog(Utils.getSerial(getAppContext()), random, data.toJSONString())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse>() {

View File

@@ -156,8 +156,6 @@ public class CacheHelper {
Log.e(TAG, "getAsString: " + sb.toString());
}
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
if (inputStream != null) {

View File

@@ -267,7 +267,7 @@ public class NetInterfaceManager {
*/
public Observable<BaseResponse<StudentsInfo>> getStudesInfoObservable() {
return mRetrofit.create(StudentsInfoApi.class)
.getStudentsInfo(Utils.getSerial())
.getStudentsInfo(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
@@ -279,7 +279,7 @@ public class NetInterfaceManager {
*/
public Observable<BaseResponse> getDevicesLockedStateObservable() {
return mRetrofit.create(DevicesLockedStateApi.class)
.getLockedState(Utils.getSerial())
.getLockedState(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
@@ -291,7 +291,7 @@ public class NetInterfaceManager {
*/
public Observable<BaseResponse> sendMACAddressObservable() {
return mRetrofit.create(MACAddressApi.class)
.sendMACaddress(Utils.getSerial(),
.sendMACaddress(Utils.getSerial(mContext),
Utils.getAndroid10MAC(mContext),
"0000",
// JPushInterface.getRegistrationID(mContext),
@@ -320,175 +320,175 @@ public class NetInterfaceManager {
*/
public Observable<BaseResponse<Batch>> getPushTagsObservable() {
return mRetrofit.create(GetJpushTagsApi.class)
.getJpushTags(Utils.getSerial())
.getJpushTags(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<BrowserData>> getBrowserListSettingObservable() {
return mRetrofit.create(BrowserListApi.class)
.getBrowserList(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getBrowserList(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<BrowserBookmarks>> getBrowserBookmarksObservable() {
return mRetrofit.create(BrowserBookmarksApi.class)
.getBrowserBookmarks(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getBrowserBookmarks(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse> getDesktopIconObservable() {
return mRetrofit.create(DesktopIconApi.class)
.getDesktopIcon(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getDesktopIcon(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<NetAndLaunchBean> getAppAutoStartUpdateAndNetObservable() {
return mRetrofit.create(NetAndLaunchApi.class)
.getNetAndLaunchApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getNetAndLaunchApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<AppID>> getAppIDControlObservable() {
return mRetrofit.create(DeselectIDApi.class)
.getDeselectIDApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getDeselectIDApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<List<Appground>>> getAppinsideWebObservable() {
return mRetrofit.create(AppinsideWebApi.class)
.getAppinsideWeb(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getAppinsideWeb(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse> getNewAppinsideWebObservable() {
return mRetrofit.create(NewAppinsideWebApi.class)
.getAppinsideWeb(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getAppinsideWeb(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse> getSystemSettingObservable() {
return mRetrofit.create(SystemSettingApi.class)
.getSystemSettingApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getSystemSettingApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<AppLimit>> getAppLimitObservable() {
return mRetrofit.create(AppLimitApi.class)
.getAppLimitApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getAppLimitApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<List<ForceDownloadData>>> getForceDownloadObservable() {
return mRetrofit.create(ForceDownloadApi.class)
.getForceDownloadApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getForceDownloadApi(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<List<ForceDownloadData>>> getTestUpdateObservable() {
return mRetrofit.create(CheckTestUpdateApi.class)
.getTestUpdate(Utils.getSerial())
.getTestUpdate(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<SnTimeControl>> getSnTimeObservable() {
return mRetrofit.create(SnTimeControlApi.class)
.getSnTimeControl(Utils.getSerial())
.getSnTimeControl(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<ScreenLockState>> getScreenLockObservable() {
return mRetrofit.create(ScreenLockStateApi.class)
.getScreenLockState(Utils.getSerial())
.getScreenLockState(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse> getDesktopObservable() {
return mRetrofit.create(GetDesktopApi.class)
.getDesktop(Utils.getSerial())
.getDesktop(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<ResponseBody> getBatchObservable() {
return mRetrofit.create(GetBatchApi.class)
.getBatch(Utils.getSerial())
.getBatch(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<LogoImg>> getLogoImgObservable() {
return mRetrofit.create(LogoImgApi.class)
.getLogoImg(Utils.getSerial())
.getLogoImg(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<TopApp>> getTopAppControl() {
return mRetrofit.create(TopAppControlApi.class)
.getSnAppControl(Utils.getSerial())
.getSnAppControl(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<DeveloperBean>> getDeveloperControl() {
return mRetrofit.create(GetDeveloperApi.class)
.getDeveloperState(Utils.getSerial())
.getDeveloperState(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<EBagCode>> getEBagCodeControl() {
return mRetrofit.create(GetEBagCodeApi.class)
.getEBagCode(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getEBagCode(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<DefaultApp>> getDefaultAppApi() {
return mRetrofit.create(DefaultAppApi.class)
.getDefaultApp(Utils.getSerial())
.getDefaultApp(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse> getRestoreTimesApi() {
return mRetrofit.create(SendRestoreTimesApi.class)
.sendRestoreTimes(Utils.getSerial())
.sendRestoreTimes(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<List<WiFiAlias>>> getWiFiControl() {
return mRetrofit.create(GetWiFiAliasApi.class)
.getWiFiAlias(Utils.getSerial())
.getWiFiAlias(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<List<PoweroffBean>>> getPoweroffTimeControl() {
return mRetrofit.create(GetPoweroffApi.class)
.getPoweroffTime(Utils.getSerial())
.getPoweroffTime(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
public Observable<BaseResponse<SnRunLog>> getSnRunLogControl() {
return mRetrofit.create(GetSnRunLogApi.class)
.GetSnRunLog(Utils.getSerial())
.GetSnRunLog(Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
@@ -502,7 +502,7 @@ public class NetInterfaceManager {
public Observable<BaseResponse<List<AppListInfo>>> GetAllAppApiControl() {
return mRetrofit.create(GetAllAppApi.class)
.getAllAppList(NetInterfaceManager.HTTP_KEY, Utils.getSerial())
.getAllAppList(NetInterfaceManager.HTTP_KEY, Utils.getSerial(mContext))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
@@ -1314,7 +1314,7 @@ public class NetInterfaceManager {
getAppIDControl(lifecycle, callback);
} else {
Gson gson = new Gson();
Type type = new TypeToken<String>() {
Type type = new TypeToken<AppID>() {
}.getType();
AppID appID = gson.fromJson(jsonString, type);
if (appID == null) {
@@ -1665,6 +1665,7 @@ public class NetInterfaceManager {
/**
* 获取设备锁定状态
* 不需要缓存
*
* @param lifecycle
* @param callback
*/
@@ -1684,15 +1685,15 @@ public class NetInterfaceManager {
JsonObject jsonObject = JsonParser.parseString(new Gson().toJson(response.data)).getAsJsonObject();
int locked = jsonObject.get("lock").getAsInt();
Log.e(TAG + ":" + "getLockedState", "locked: " + locked);
int oldState = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
Log.e(TAG + ":" + "getLockedState", "qch_unlock_ipad: " + oldState);
// int oldState = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
// Log.e(TAG + ":" + "getLockedState", "qch_unlock_ipad: " + oldState);
//后台1是锁定底层0是锁定
SPUtils.put(mContext, CommonConfig.JGY_FIRST_CONNECT, 1);
if (locked == JGYActions.NET_CODE_LOCKED) {
if (oldState == JGYActions.FRAME_CODE_UNLOCKED) {
Log.e(TAG + ":" + "getLockedState", "onNext: " + "state changed , reset devices");
Utils.doMasterClear(mContext);
}
// if (oldState == JGYActions.FRAME_CODE_UNLOCKED) {
// Log.e(TAG + ":" + "getLockedState", "onNext: " + "state changed , reset devices");
// Utils.doMasterClear(mContext);
// }
Settings.System.putInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
} else if (locked == JGYActions.NET_CODE_UNLOCKED) {
// SysSettingUtils.setEnableSetting(mContext);
@@ -1726,10 +1727,11 @@ public class NetInterfaceManager {
*/
public void sendMACAddress(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
String macJson = (String) SPUtils.get(mContext, "macJson", "");
String jsonString = JGYUtils.getInstance().getMacJson();
String jsonString = JGYUtils.getInstance().getMacJson(mContext);
// Log.e(TAG, "sendMACAddress: macJson = " + macJson);
// Log.e(TAG, "sendMACAddress: jsonString = " + jsonString);
if (macJson.equals(jsonString)) {
callback.onComplete();
return;
}
sendMACAddressObservable()
@@ -1745,7 +1747,7 @@ public class NetInterfaceManager {
public void onNext(@NonNull BaseResponse response) {
if (response.code == OK) {
Log.e("sendMACAddress", response.msg);
SPUtils.put(mContext, "macJson", JGYUtils.getInstance().getMacJson());
SPUtils.put(mContext, "macJson", JGYUtils.getInstance().getMacJson(mContext));
} else {
Log.e("sendMACAddress", response.toString());
}
@@ -1760,7 +1762,9 @@ public class NetInterfaceManager {
@Override
public void onComplete() {
Log.e("sendMACAddress", "onComplete: ");
callback.onComplete();
if (callback != null) {
callback.onComplete();
}
}
});
}
@@ -1860,59 +1864,86 @@ public class NetInterfaceManager {
});
}
@SuppressLint("NewApi")
public void updateDeviceInfo(onCompleteCallback callback) {
String address = String.valueOf(SPUtils.get(mContext, "AmapAddress", "-"));
if ("-".equals(address)) {
address = "定位失败";
// address = (String) SPUtils.get(mContext, "AmapError", "-");
public void updateDeviceInfo(boolean refresh, BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
ConnectMode connectMode = ConnectMode.SIX_HOUR;
if (refresh) {
connectMode = ConnectMode.DEFAULT;
}
String longitude = String.valueOf(SPUtils.get(mContext, "longitude", "0"));
String latitude = String.valueOf(SPUtils.get(mContext, "latitude", "0"));
JSONObject jsonObject = new JSONObject();
jsonObject.put("address", address);
jsonObject.put("longitude", longitude);
jsonObject.put("latitude", latitude);
String add = jsonObject.toJSONString();
getUpdateDeviceInfo().updateDeviceInfo(
Utils.getSerial(),
if (ConnectManager.getInstance().isNeedConnect(UrlAddress.UPDATE_DEVICEINFO, connectMode)) {
updateDeviceInfo(lifecycle, callback);
} else {
String jsonString = cacheHelper.getAsString(UrlAddress.UPDATE_DEVICEINFO);
//为 "" 是已经请求成功的
if (jsonString == null) {
updateDeviceInfo(lifecycle, callback);
} else {
callback.onComplete();
}
}
}
public void updateDeviceInfo(BehaviorSubject<ActivityEvent> lifecycle, onCompleteCallback callback) {
getUpdateDeviceInfoObservable()
.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getUpdateDeviceObserver(callback));
}
public void updateDeviceInfo(onCompleteCallback callback) {
getUpdateDeviceInfoObservable()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(getUpdateDeviceObserver(callback));
}
private Observable<BaseResponse> getUpdateDeviceInfoObservable() {
String add = Utils.getAddressJsonString(mContext);
cacheHelper.put(UrlAddress.UPDATE_DEVICEINFO, add);
return getUpdateDeviceInfo().updateDeviceInfo(
Utils.getSerial(mContext),
NetInterfaceManager.HTTP_KEY,
Utils.getMachine(mContext),
Utils.getHardware(mContext),
add
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("updateDeviceInfo", "onSubscribe: ");
}
);
}
@Override
public void onNext(BaseResponse baseResponse) {
Log.e("updateDeviceInfo", "onNext: " + baseResponse.toString());
}
private Observer getUpdateDeviceObserver(onCompleteCallback callback) {
return new Observer<BaseResponse>() {
@Override
public void onSubscribe(Disposable d) {
Log.e("updateDeviceInfo", "onSubscribe: ");
}
@Override
public void onError(Throwable e) {
Log.e("updateDeviceInfo", "onSubscribe: " + e.getMessage());
onComplete();
}
@Override
public void onNext(BaseResponse baseResponse) {
Log.e("updateDeviceInfo", "onNext: " + baseResponse.toString());
}
@Override
public void onComplete() {
Log.e("updateDeviceInfo", "onComplete: ");
callback.onComplete();
}
});
@Override
public void onError(Throwable e) {
Log.e("updateDeviceInfo", "onSubscribe: " + e.getMessage());
onComplete();
}
@Override
public void onComplete() {
Log.e("updateDeviceInfo", "onComplete: ");
if (callback != null) {
callback.onComplete();
}
}
};
}
public void sendInstalledAppInfo(onCompleteCallback callback) {
String jsonString = ApkUtils.getRunningAppInfo(mContext);
getUploadAppInfoApi()
.getUploadAppInfoApi(NetInterfaceManager.HTTP_KEY,
Utils.getSerial(),
Utils.getSerial(mContext),
jsonString)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
@@ -1949,7 +1980,7 @@ public class NetInterfaceManager {
return;
}
Map<String, String> params = new HashMap<>();
params.put("sn", Utils.getSerial());
params.put("sn", Utils.getSerial(mContext));
MediaType mediaType = MediaType.Companion.parse("text/plain");
RequestBody fileBody = RequestBody.Companion.create(logFile, mediaType);
//设置一个file文件
@@ -2317,7 +2348,9 @@ public class NetInterfaceManager {
Type Type = new TypeToken<ScreenLockState>() {
}.getType();
ScreenLockState screenLockState = gson.fromJson(jsonString, Type);
listener.setScreenLockState(screenLockState.getIs_screen_lock() == 1, screenLockState.getName());
if (screenLockState != null) {
listener.setScreenLockState(screenLockState.getIs_screen_lock() == 1, screenLockState.getName());
}
}
}
}
@@ -2377,7 +2410,9 @@ public class NetInterfaceManager {
Type type = new TypeToken<AppLimit>() {
}.getType();
AppLimit appLimit = gson.fromJson(jsonString, type);
Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST, appLimit.getResult());
if (appLimit != null) {
Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST, appLimit.getResult());
}
callback.onComplete();
}
}

View File

@@ -52,7 +52,7 @@ public class NewAppReceiver extends BroadcastReceiver {
state = "安装了:";
break;
case Intent.ACTION_PACKAGE_REPLACED:
JGYUtils.getInstance().cleanLauncher3Cache();
// JGYUtils.getInstance().cleanLauncher3Cache();
state = "重装了:";
break;
case Intent.ACTION_PACKAGE_REMOVED:
@@ -69,8 +69,7 @@ public class NewAppReceiver extends BroadcastReceiver {
ApkUtils.addShortcut(context);
ApkUtils.RemoveTask(context, packageName);
}
JGYUtils.getInstance().wakeUpAppstore();
JGYUtils.getInstance().wakeUpAoleyunAPP();
//启动教官壹
}
newAppListener.setNewAppListener(packageName);

View File

@@ -252,7 +252,7 @@ public class GuardService extends Service {
long time = System.currentTimeMillis();
getLockState("1", String.valueOf(time));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
JGYUtils.getInstance().wakeUpAppstore();
JGYUtils.getInstance().wakeUpAoleyunAPP();
JGYUtils.getInstance().deleteScreenshots();
}
sendScreenStatus(2);
@@ -310,7 +310,7 @@ public class GuardService extends Service {
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
.build();
SendScreenStatusApi sendScreenStatusApi = retrofit.create(SendScreenStatusApi.class);
sendScreenStatusApi.sendScreenStatus(NetInterfaceManager.HTTP_KEY, Utils.getSerial(), status)
sendScreenStatusApi.sendScreenStatus(NetInterfaceManager.HTTP_KEY, Utils.getSerial(this), status)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse>() {
@@ -347,7 +347,7 @@ public class GuardService extends Service {
}
NetInterfaceManager.getInstance()
.getLockState()
.getLockState(Utils.getSerial(), status, time)
.getLockState(Utils.getSerial(this), status, time)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<ResponseBody>() {
@@ -494,7 +494,7 @@ public class GuardService extends Service {
}
NetInterfaceManager.getInstance()
.getSendTimesApi()
.sendDownloadTimes(NetInterfaceManager.HTTP_KEY, Utils.getSerial(), app_package, app_id)
.sendDownloadTimes(NetInterfaceManager.HTTP_KEY, Utils.getSerial(this), app_package, app_id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<BaseResponse>() {

View File

@@ -219,9 +219,9 @@ public class LogcatService extends Service {
}
if (clear_file) {
logFileName = Utils.getSerial() + ".log";
logFileName = Utils.getSerial(this) + ".log";
} else {
logFileName = Utils.getSerial() + "-" + getTime() + ".log";
logFileName = Utils.getSerial(this) + "-" + getTime() + ".log";
}
try {
@@ -262,7 +262,7 @@ public class LogcatService extends Service {
return;
}
Map<String, String> params = new HashMap<>();
params.put("sn", Utils.getSerial());
params.put("sn", Utils.getSerial(this));
MediaType mediaType = MediaType.Companion.parse("text/html");
RequestBody fileBody = RequestBody.Companion.create(file, mediaType);
//设置一个file文件

View File

@@ -227,7 +227,7 @@ public class StepService extends Service implements NetworkUtils.OnNetworkStatus
*/
public void sendMsg() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("sn", Utils.getSerial());
jsonObject.put("sn", Utils.getSerial(this));
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
if (!pm.isScreenOn()) {
jsonObject.put("online", 2);
@@ -243,7 +243,7 @@ public class StepService extends Service implements NetworkUtils.OnNetworkStatus
public void sendMsg(int state) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("sn", Utils.getSerial());
jsonObject.put("sn", Utils.getSerial(this));
jsonObject.put("online", state);
try {
if (null != client) {

View File

@@ -72,7 +72,7 @@ public class MainSPresenter implements MainSContact.Presenter {
this.requesting = requesting;
}
public long responseTime;
public long responseTime;
/**
* 1
@@ -169,7 +169,7 @@ public class MainSPresenter implements MainSContact.Presenter {
if (JGYUtils.isOfficialVersion()) {
mView.updateDeviceInfoFinish();
}
NetInterfaceManager.getInstance().updateDeviceInfo(new NetInterfaceManager.onCompleteCallback() {
NetInterfaceManager.getInstance().updateDeviceInfo(true, getLifecycle(), new NetInterfaceManager.onCompleteCallback() {
@Override
public void onComplete() {
mView.updateDeviceInfoFinish();

View File

@@ -158,7 +158,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
//token在设备卸载重装的时候有可能会变
Log.e("TPush", "注册成功设备token为" + data);
List<XGPushManager.AccountInfo> accountInfoList = new ArrayList<>();
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial()));
accountInfoList.add(new XGPushManager.AccountInfo(XGPushManager.AccountType.CUSTOM.getValue(), Utils.getSerial(MainService.this)));
XGPushManager.upsertAccounts(MainService.this, accountInfoList, new XGIOperateCallback() {
@Override
public void onSuccess(Object data, int flag) {
@@ -402,7 +402,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e(TAG, "onStartCommand: ");
JGYUtils.getInstance().wakeUpAppstore();
JGYUtils.getInstance().wakeUpAoleyunAPP();
if (mMMKV.decodeInt(CommonConfig.DEVICES_FRIST_START, 1) == 0) {
if (!checkAoleyunApp()) {
Log.e(TAG, "onStartCommand: " + "checkAoleyunApp");

View File

@@ -82,12 +82,12 @@ import okhttp3.RequestBody;
import okhttp3.ResponseBody;
public class MessageReceiver extends XGPushBaseReceiver {
private static final String TAG = MessageReceiver.class.getSimpleName();
public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW";
public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION";
public static final String LogTag = "xg.test";
private static final String TAG = MessageReceiver.class.getSimpleName();
/*删除应用*/
private final String MSG_DELETE = "1";
/*系统设置管控*/
@@ -488,6 +488,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
ToastUtil.betaShow("收到管控:设备重置");
JGYUtils.getInstance().cleanAoleLauncher3Cache();
Utils.doMasterClear(mContext);
JGYUtils.getInstance().cleanAoleAppCache();
JGYUtils.getInstance().wakeUpAoleyunAPP();
MainService.mPresenter.getLockedState("MSG_PUSH_RESET");
break;
case MSG_INSTALL:
@@ -505,9 +507,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
break;
case MSG_ONEPACKAGES:
ToastUtil.betaShow("收到管控:");
if (BaseApplication.getInstance().isFinished()) {
settingOneNet(extras);
}
break;
case GET_APP_USEDTIME:
ToastUtil.betaShow("收到管控:获取应用使用时间");
@@ -689,6 +689,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
case UPDATE_BATCH:
ToastUtil.betaShow("收到管控:更换批次不恢复出厂设置");
Aria.download(this).removeAllTask(true);
JGYUtils.getInstance().cleanAoleAppCache();
try {
new CacheUtils().cleanApplicationUserData(mContext, "com.android.browser");
} catch (Exception e) {
@@ -772,7 +773,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
}
if (packageInfo == null) {
Log.e(TAG, "doDownloadAndInstall: " + app_package + "未安装");
Utils.ariaDownload(mContext, app_url, packageObj);
Utils.ariaDownload(mContext, app_url, packageObj);
} else {
long appVersionCode;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
@@ -781,7 +782,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
appVersionCode = packageInfo.versionCode;
}
if (app_version_code > appVersionCode) {
Utils.ariaDownload(mContext, app_url, packageObj);
Utils.ariaDownload(mContext, app_url, packageObj);
} else {
Log.e(TAG, "doDownloadAndInstall: " + app_package + "已安装最新版");
}
@@ -1005,7 +1006,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
//设置一个file文件
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), fileBody);
Map<String, String> params = new HashMap<>();
params.put("sn", Utils.getSerial());
params.put("sn", Utils.getSerial(mContext));
params.put("createtime", String.valueOf(time));
NetInterfaceManager.getInstance().getScreenshotApi()
.sendScreenshot(params, body)

View File

@@ -5,6 +5,7 @@ import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.ActivityTaskManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
@@ -102,6 +103,8 @@ public class JGYUtils {
@SuppressLint("StaticFieldLeak")
private static JGYUtils sInstance;
private Context mContext;
private ContentResolver crv;
public static int MTKPlatform = 1;
public static int ZhanruiPlatform = 2;
public static int UnknowPlatform = 0;
@@ -121,6 +124,7 @@ public class JGYUtils {
throw new RuntimeException("Context is NULL");
}
this.mContext = context;
this.crv = context.getContentResolver();
this.cacheHelper = new CacheHelper(context);
}
@@ -180,7 +184,7 @@ public class JGYUtils {
}
public boolean getDeviceIsLocked() {
int locked = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
int locked = Settings.System.getInt(crv, JGYActions.ACTION_QCH_UNLOCK_IPAD, JGYActions.FRAME_CODE_LOCKED);
return locked == JGYActions.FRAME_CODE_LOCKED;
}
@@ -265,11 +269,11 @@ public class JGYUtils {
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", slide_not);
boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", slide_not);
Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", "Invalid");
Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
@@ -283,19 +287,18 @@ public class JGYUtils {
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
if (TextUtils.isEmpty(qch_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
Settings.System.putString(crv, "qch_app_power_on", "Invalid");
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid");
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", qch_app_power_on);
Settings.System.putString(crv, "qch_app_power_on", qch_app_power_on);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "");
// boolean w = Settings.System.putString(crv, "qch_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp);
BaseApplication.getInstance().setFinished(true);
}
private void checkPackageAndVersion(HashSet<String> disallowUpgrade, List<AppListInfo> appListInfos) {
@@ -372,11 +375,11 @@ public class JGYUtils {
if (disallowSlide.size() != 0) {
String slide_not = String.join(",", disallowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", slide_not);
boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", slide_not);
Log.e("fht", "qch_disable_slide=" + writeSucceed + ":" + slide_not);
} else {
String slide_ok = String.join(",", allowSlide);
boolean writeSucceed = Settings.System.putString(mContext.getContentResolver(), "qch_disable_slide", "Invalid");
boolean writeSucceed = Settings.System.putString(crv, "qch_disable_slide", "Invalid");
Log.e("fht", "qch_disable_slide ok=" + writeSucceed + ":" + slide_ok);
}
@@ -389,19 +392,18 @@ public class JGYUtils {
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
if (TextUtils.isEmpty(qch_app_power_on)) {
//当 qch_app_power_on 的值为空时,会造成系统所有应用断网
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "Invalid");
Settings.System.putString(crv, "qch_app_power_on", "Invalid");
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + "Invalid");
} else {
Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", qch_app_power_on);
Settings.System.putString(crv, "qch_app_power_on", qch_app_power_on);
Log.e(TAG, "setNetAndlaunch: qch_app_power_on: " + qch_app_power_on);
}
// if (BuildConfig.DEBUG) {
// TODO: 2021/7/2 测试写入为空是否断网
// boolean w = Settings.System.putString(mContext.getContentResolver(), "qch_app_power_on", "");
// boolean w = Settings.System.putString(crv, "qch_app_power_on", "");
// Log.e(TAG, "setNetAndlaunch: 测试写入: " + w);
// }
setAppNetwork(mContext, disallowNetApp);
BaseApplication.getInstance().setFinished(true);
}
@SuppressLint("NewApi")
@@ -482,7 +484,7 @@ public class JGYUtils {
String net_not = String.join(",", blackList);
SPUtils.put(context, JGYActions.ACTION_HRRECEIVER_JGY_DIS, net_not);
//Settings.System.putString(mContext.getContentResolver(), JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
//Settings.System.putString(crv, JGYActions.ACTION_HrReceiver_JGY_DIS, net_not);
Log.e("fht", "not::" + net_not);
//Intent netControlIntent = new Intent(CommonDatas.ACTION_HrReceiver_JGY_DIS);
@@ -546,17 +548,17 @@ public class JGYUtils {
}
String olddeselectViewArray = Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid_id");
String olddeselectViewArray = Settings.System.getString(crv, "qch_app_forbid_id");
Log.e("writeDeselectIDtoSystem", "olddeselectViewArray: " + olddeselectViewArray);
Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid_id", packageStringBuilder.toString());
Settings.System.putString(mContext.getContentResolver(), "DeselectViewArray", idStringBuilder.toString());
Settings.System.putString(crv, "qch_app_forbid_id", packageStringBuilder.toString());
Settings.System.putString(crv, "DeselectViewArray", idStringBuilder.toString());
Log.e("writeDeselectIDtoSystem", "qch_app_forbid_id: " + packageStringBuilder.toString());
Log.e("writeDeselectIDtoSystem", "deselectViewArray: " + idStringBuilder.toString());
} else {
Log.e("writeDeselectIDtoSystem", "writeDeselectIDtoSystem is null:");
Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid_id", "");
Settings.System.putString(mContext.getContentResolver(), "DeselectViewArray", "");
Settings.System.putString(crv, "qch_app_forbid_id", "");
Settings.System.putString(crv, "DeselectViewArray", "");
}
}
@@ -963,8 +965,8 @@ public class JGYUtils {
pkgSet.removeIf(TextUtils::isEmpty);
String qch_app_forbid = String.join(",", pkgSet);
Log.e(TAG, "writeAppPackageList: " + qch_app_forbid);
boolean b = Settings.System.putString(mContext.getContentResolver(), "qch_app_forbid", qch_app_forbid);
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid"));
boolean b = Settings.System.putString(crv, "qch_app_forbid", qch_app_forbid);
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(crv, "qch_app_forbid"));
}
public void checkForceDownload() {
@@ -1151,10 +1153,10 @@ public class JGYUtils {
versionCode = info.versionCode;
}
if (app_version_code > versionCode) {
Utils.ariaDownload(mContext, app_url, jsonObject);
Utils.ariaDownload(mContext, app_url, jsonObject);
}
} else {
Utils.ariaDownload(mContext, app_url, jsonObject);
Utils.ariaDownload(mContext, app_url, jsonObject);
}
}
@@ -1162,7 +1164,7 @@ public class JGYUtils {
//删除用户除了在应用市场的其他应用
public void deleteOtherApp() {
int locked = Settings.System.getInt(mContext.getContentResolver(), JGYActions.ACTION_QCH_UNLOCK_IPAD, 0);
int locked = Settings.System.getInt(crv, JGYActions.ACTION_QCH_UNLOCK_IPAD, 0);
if (locked == 1) {
return;
}
@@ -1170,12 +1172,12 @@ public class JGYUtils {
String[] result_white = new String[]{};
String[] result_forbid = new String[]{};
//获取后台应用白名单
String only_jgy_shortcut_list = Settings.System.getString(mContext.getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST);
String only_jgy_shortcut_list = Settings.System.getString(crv, JGYActions.ACTION_JGY_SHORTCUTLIST);
if (!TextUtils.isEmpty(only_jgy_shortcut_list)) {
result_white = only_jgy_shortcut_list.split(",");
}
//获取可以被安装的包名
String qch_app_forbid = Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid");
String qch_app_forbid = Settings.System.getString(crv, "qch_app_forbid");
if (!TextUtils.isEmpty(qch_app_forbid)) {
result_forbid = qch_app_forbid.split(",");
}
@@ -1397,7 +1399,11 @@ public class JGYUtils {
public void setDeveloperOptions(int state) {
Log.e(TAG, "getDeveloper: " + state);
if (!BuildConfig.DEBUG) {
Settings.System.putInt(mContext.getContentResolver(), "qch_Developeroptions", state);
Settings.System.putInt(crv, "qch_Developeroptions", state);
if (JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZhanruiPlatform) {
Settings.Global.putInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, state == 1 ? 0 : 1);
Settings.Global.putInt(crv, Settings.Global.ADB_ENABLED, state == 1 ? 0 : 1);
}
if (state == 1) {
Intent intent = new Intent();
intent.setAction("qch_developeroptions_close");
@@ -1411,8 +1417,13 @@ public class JGYUtils {
}
}
private String chromium_pkg = "org.chromium.browser";
public void hookWebView() {
int sdkInt = Build.VERSION.SDK_INT;
if (!ApkUtils.isAvailable(mContext, chromium_pkg)) {
return;
}
try {
Class<?> factoryClass = Class.forName("android.webkit.WebViewFactory");
Field field = factoryClass.getDeclaredField("sProviderInstance");
@@ -1463,7 +1474,7 @@ public class JGYUtils {
Log.i(TAG, "Hook failed!");
}
} catch (Throwable e) {
Log.w(TAG, e.getMessage());
Log.w(TAG, "hookWebView: " + e.getMessage());
}
}
@@ -1908,9 +1919,9 @@ public class JGYUtils {
Log.e(TAG, "setDefaultDesktop: " + pkg + ":" + className);
}
public String getMacJson() {
public String getMacJson(Context context) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("sn", Utils.getSerial());
jsonObject.addProperty("sn", Utils.getSerial(context));
jsonObject.addProperty("mac", Utils.getAndroid10MAC(mContext));
// jsonObject.addProperty("jpush_id", JPushInterface.getRegistrationID(mContext));
jsonObject.addProperty("jpush_id", "0000");
@@ -1937,28 +1948,6 @@ public class JGYUtils {
}
}
public static final String PACKAGE_DEVICEINFO = "com.aoleyun.sn";
public static final String PACKAGE_APPSTORE = "com.aoleyun.appstore";
public static final String CLASS_DEVICEINFO = "com.aoleyun.sn.receiver.BootReceiver";
public static final String CLASS_APPSTORE = "com.aoleyun.appstore.receiver.BootReceiver";
public void wakeUpDeviceInfo() {
//启动设备信息
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_DEVICEINFO, CLASS_DEVICEINFO));
mContext.sendBroadcast(bootIntent);
}
public void wakeUpAppstore() {
//启动应用市场
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_APPSTORE, CLASS_APPSTORE));
mContext.sendBroadcast(bootIntent);
}
/**
* 判断网络连接状态
*
@@ -1990,8 +1979,59 @@ public class JGYUtils {
try {
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.os");
} catch (Exception e) {
Log.e(TAG, "onReceive: " + e.getMessage());
Log.e(TAG, "cleanAoleLauncher3Cache: " + e.getMessage());
e.printStackTrace();
}
}
public void cleanAoleAppCache() {
try {
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.os");
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.appstore");
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.info");
new CacheUtils().cleanApplicationUserData(mContext, "com.aoleyun.browser");
} catch (Exception e) {
Log.e(TAG, "cleanAoleAppCache: " + e.getMessage());
e.printStackTrace();
}
}
public static final String PACKAGE_DEVICEINFO = "com.aoleyun.sn";
public static final String CLASS_DEVICEINFO = "com.aoleyun.sn.receiver.BootReceiver";
public void wakeUpDeviceInfo() {
Log.e(TAG, "wakeUpDeviceInfo: ");
//启动设备信息
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_DEVICEINFO, CLASS_DEVICEINFO));
mContext.sendBroadcast(bootIntent);
}
public static final String PACKAGE_APPSTORE = "com.aoleyun.appstore";
public static final String CLASS_APPSTORE = "com.aoleyun.appstore.receiver.BootReceiver";
public void wakeUpAppstore() {
Log.e(TAG, "wakeUpAppstore: ");
//启动应用市场
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_APPSTORE, CLASS_APPSTORE));
mContext.sendBroadcast(bootIntent);
}
public static final String PACKAGE_NOTIFY = "com.aoleyun.info";
public static final String CLASS_NOTIFY = "com.aoleyun.info.receiver.BootReceiver";
public void wakeUpNotify() {
Log.e(TAG, "wakeUpNotify: ");
//启动通知
Intent bootIntent = new Intent(BootReceiver.BOOT_COMPLETED);
bootIntent.setComponent(new ComponentName(PACKAGE_NOTIFY, CLASS_NOTIFY));
mContext.sendBroadcast(bootIntent);
}
public void wakeUpAoleyunAPP() {
wakeUpAppstore();
wakeUpNotify();
}
}

View File

@@ -56,6 +56,7 @@ import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.network.NetInterfaceManager;
import com.arialyy.aria.core.Aria;
import com.blankj.utilcode.util.FileUtils;
import com.google.gson.JsonObject;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
@@ -73,6 +74,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.Inet4Address;
import java.net.InetAddress;
@@ -688,12 +690,41 @@ public class Utils {
return t1;
}
public static String NOSN = "012345679ABCDEF";
/**
* 获取设备序列号
*
* @return
*/
@SuppressLint("MissingPermission")
@SuppressLint({"MissingPermission", "HardwareIds"})
public static String getSerial(Context context) {
String serial = "unknow";
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
serial = Build.getSerial();
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
serial = Build.SERIAL;
} else {//8.0-
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial = (String) get.invoke(c, "ro.serialno");
}
} catch (Exception e) {
e.printStackTrace();
Log.e("getSerial", "读取设备序列号异常:" + e.toString());
}
if (BuildConfig.DEBUG) {
// return "QNG2DKB00463";
// serial = "012345679ABCDEF";
}
if (NOSN.equalsIgnoreCase(serial)) {
return getIMEI(context);
}
return serial;
}
@SuppressLint({"MissingPermission", "HardwareIds"})
public static String getSerial() {
String serial = "unknow";
try {
@@ -928,7 +959,7 @@ public class Utils {
}
}
/**
/**
* 更新应用白名单禁止升级
*
* @param context
@@ -1163,7 +1194,7 @@ public class Utils {
try {
interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
for (NetworkInterface networkInterface : interfaces) {
if (networkInterface != null && TextUtils.isEmpty(networkInterface.getName()) == false) {
if (networkInterface != null && !TextUtils.isEmpty(networkInterface.getName())) {
if ("wlan0".equalsIgnoreCase(networkInterface.getName())) {
byte[] macBytes = networkInterface.getHardwareAddress();
if (macBytes != null && macBytes.length > 0) {
@@ -1185,16 +1216,25 @@ public class Utils {
return "unknown";
}
@SuppressLint("HardwareIds")
public static String getIMEI(Context context, int slotIndex) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return tm.getImei(slotIndex);
} else {
return tm.getDeviceId(slotIndex);
}
}
@SuppressLint("HardwareIds")
public static String getIMEI(Context context) {
String IMEI = "unknow";
String IMEI1, IMEI2, IMEI3;
//获取手机设备号
TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
//8.0及以后版本获取
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
IMEI = TelephonyMgr.getDeviceId();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// try {
// Method method = TelephonyMgr.getClass().getMethod("getImei");
// IMEI = (String) method.invoke(TelephonyMgr);
@@ -1205,7 +1245,7 @@ public class Utils {
// IMEI = TelephonyMgr.getDeviceId();
// } else {//9.0到10.0获取
IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
// IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
Log.e("IMEI:", "IMEI: " + IMEI);
if (null == IMEI) {
@@ -1213,9 +1253,40 @@ public class Utils {
} else {
return IMEI.toUpperCase();
}
}
/**
* IMEI 1号
*
* @param context
* @return
*/
// public static String getIMEI_1(Context context) {
// TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// return tm != null ? tm.getDeviceId() : "";
// }
/**
* IMEI 2号
*
* @param context
* @return
*/
// public static String getIMEI_2(Context context) {
// TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
// Class clazz = tm.getClass();
// try {
// Method getImei = clazz.getDeclaredMethod("getImei", int.class);
// return getImei.invoke(tm, 1).toString();
// } catch (NoSuchMethodException e) {
// e.printStackTrace();
// } catch (InvocationTargetException e) {
// e.printStackTrace();
// } catch (IllegalAccessException e) {
// e.printStackTrace();
// }
// return "";
// }
public static String getMachine(Context context) {
String device = Build.MODEL;//机型
String imei = getIMEI(context);
@@ -1259,6 +1330,21 @@ public class Utils {
return jsonString;
}
public static String getAddressJsonString(Context context) {
String address = String.valueOf(SPUtils.get(context, "AmapAddress", "-"));
if ("-".equals(address)) {
address = "定位失败";
}
String longitude = String.valueOf(SPUtils.get(context, "longitude", "0"));
String latitude = String.valueOf(SPUtils.get(context, "latitude", "0"));
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("address", address);
jsonObject.addProperty("longitude", longitude);
jsonObject.addProperty("latitude", latitude);
String jsonString = jsonObject.toString();
return jsonString;
}
private static int getNumCores() {
// Private Class to display only CPU devices in the directory listing
class CpuFilter implements FileFilter {