diff --git a/app/build.gradle b/app/build.gradle index 2c1313a..23a4b0e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -15,10 +15,10 @@ android { minSdkVersion 20 targetSdkVersion 29 - versionCode 142 - versionName "2.9.9"//测试jiaoguanyi.cn -// versionCode 128 -// versionName "2.0.0.8"// 正式jiaoguanyi.com 双数正式 单数测试 + versionCode 145 + versionName "3.0.2"//测试jiaoguanyi.cn +// versionCode 129 +// versionName "2.0.0.9"// 正式jiaoguanyi.com 双数正式 单数测试 multiDexEnabled true testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -160,7 +160,7 @@ dependencies { implementation 'com.arialyy.aria:core:3.8.5' annotationProcessor 'com.arialyy.aria:compiler:3.8.5' - implementation 'com.github.tianma8023:NetDetector:v0.2.0' +// implementation 'com.github.tianma8023:NetDetector:v0.2.0' implementation "org.java-websocket:Java-WebSocket:1.4.1" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 77e31bf..e567d07 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,8 @@ + + = Build.VERSION_CODES.M) { + + PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); + + boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName()); + // 判断当前APP是否有加入电池优化的白名单,如果没有,弹出加入电池优化的白名单的设置对话框。 + if (!hasIgnored) { + Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); + intent.setData(Uri.parse("package:" + context.getPackageName())); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + } } private receiver receiver; @@ -181,6 +207,7 @@ public class MyApplication extends MultiDexApplication { //可能会多次触发,1分钟之内不执行 //application中启动服务,startcommand执行会两次 startService(new Intent(context, InitJpushServer.class)); + startService(new Intent(context, StepService.class)); startService(new Intent(context, GuardService.class)); time1 = time2; Log.e("fht", "onReceive"); @@ -192,6 +219,8 @@ public class MyApplication extends MultiDexApplication { } } + + public void onTagOperatorResult(JPushMessage jPushMessage) { if (jPushMessage == null) { return; @@ -570,7 +599,7 @@ public class MyApplication extends MultiDexApplication { result = result + "," + store; } Settings.System.putString(context.getContentResolver(), "qch_app_forbid", result); - Log.e("mjsheng", "qch_app_forbid :"+result); + Log.e("mjsheng", "qch_app_forbid :" + result); } else { Log.e("mjsheng", "writeAppPackageList is null:"); Settings.System.putString(context.getContentResolver(), "qch_app_forbid", appstore + "," + store); @@ -623,12 +652,6 @@ public class MyApplication extends MultiDexApplication { // // } - @Override - public void onTerminate() { - super.onTerminate(); - // 取消BroadcastReceiver注册 - NetStateChangeReceiver.unregisterReceiver(this); - } // static List fileList = new ArrayList<>(); // diff --git a/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java b/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java index c872e94..3667387 100644 --- a/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java +++ b/app/src/main/java/com/mjsheng/myappstore/activity/MainActivity.java @@ -1,5 +1,6 @@ package com.mjsheng.myappstore.activity; +import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.ContextWrapper; @@ -11,6 +12,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.Bitmap; +import android.net.Uri; import android.os.BatteryManager; import android.os.Build; import android.os.Bundle; @@ -18,12 +20,17 @@ import android.os.Environment; import android.os.Handler; import android.os.Message; import android.os.PersistableBundle; +import android.os.PowerManager; +import android.os.SystemClock; import android.provider.Settings; import android.support.v4.content.LocalBroadcastManager; import android.support.v7.app.AppCompatActivity; +import android.text.Layout; import android.text.TextUtils; import android.util.Log; +import android.view.View; import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.TextView; import com.alibaba.fastjson.JSON; @@ -54,6 +61,7 @@ import com.mjsheng.myappstore.bean.JsonCallback; import com.mjsheng.myappstore.bean.LzyResponse; import com.mjsheng.myappstore.bean.NetAndLaunchBean; import com.mjsheng.myappstore.bean.NetAndLaunchData; +import com.mjsheng.myappstore.bean.StudentsInfo; import com.mjsheng.myappstore.bean.UploadAppInfo; import com.mjsheng.myappstore.bean.UserInfo; import com.mjsheng.myappstore.comm.CommonDatas; @@ -83,8 +91,6 @@ import com.mjsheng.myappstore.utils.update.NotificationDownloadCreator; import com.mjsheng.myappstore.utils.update.OkhttpCheckWorker; import com.mjsheng.myappstore.utils.update.ToastCallback; import com.mjsheng.myappstore.utils.update.ToastTool; -import com.tianma.netdetector.lib.NetStateChangeObserver; -import com.tianma.netdetector.lib.NetworkType; import org.json.JSONObject; import org.lzh.framework.updatepluginlib.UpdateBuilder; @@ -122,7 +128,7 @@ import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.ACTION_SET; import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.TagAliasBean; import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence; -public class MainActivity extends AppCompatActivity implements NetStateChangeObserver { +public class MainActivity extends AppCompatActivity { private ToastCallback callback; private long mPreClickTime; @@ -132,8 +138,10 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs private DownloadManager downloadManager; private ImageView imageView; private TextView tv_devsn, tv_devmac, tv_version; + private TextView tv_class, tv_number, tv_name; private int DeviceInfo; - + private RelativeLayout checkupdate; + private ImageView back; //jiguang public static boolean isForeground = false; //for receive customer msg from jpush server @@ -287,6 +295,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs // setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // } requestPermission(); + acquireWakeLock(); registerMessageReceiver(); // used for receive msg // HTTPInterface.checkDevicesInfo(handler); startService(new Intent(MainActivity.this, MyDownloadService.class)); @@ -353,15 +362,49 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs } private void initView() { + checkupdate = findViewById(R.id.checkupdate); + checkupdate.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + continuousClick(COUNTS, DURATION); + } + }); imageView = findViewById(R.id.imageView); tv_devsn = findViewById(R.id.tv_devsn); - tv_devsn.setText("设备SN\t\t" + Utils.getSerial()); + tv_devsn.setText(Utils.getSerial()); tv_devmac = findViewById(R.id.tv_devmac); - tv_devmac.setText("MAC地址\t\t" + com.blankj.utilcode.util.DeviceUtils.getMacAddress()); + tv_devmac.setText(com.blankj.utilcode.util.DeviceUtils.getMacAddress()); tv_version = findViewById(R.id.version); - tv_version.setText("版本:" + BuildConfig.VERSION_NAME); + tv_version.setText(BuildConfig.VERSION_NAME); + tv_class = findViewById(R.id.tv_class); + tv_number = findViewById(R.id.tv_number); + tv_name = findViewById(R.id.tv_name); + back = findViewById(R.id.back); + back.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + lazyExit(); + } + }); } + final static int COUNTS = 5;// 点击次数 + final static long DURATION = 1000;// 规定有效时间 + long[] mHits = new long[COUNTS]; + + private void continuousClick(int count, long time) { + //每次点击时,数组向前移动一位 + System.arraycopy(mHits, 1, mHits, 0, mHits.length - 1); + //为数组最后一位赋值 + mHits[mHits.length - 1] = SystemClock.uptimeMillis(); + if (mHits[0] >= (SystemClock.uptimeMillis() - DURATION)) { + mHits = new long[COUNTS];//重新初始化数组 + ToastUtil.show("正在检查更新"); + HTTPInterface.checkUpdate(mHandler, BuildConfig.APPLICATION_ID); + } + } + + private void initData() { Log.e("mjhsneg", "gagagag--------------------------" + Utils.getSerial()); getLockedState(); @@ -389,8 +432,8 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs } private void setImageAndText(ImageView imageView, String text) { - Bitmap bitmap = Utils.createQRImage(Utils.getSn(), 250, 250); - imageView.setImageBitmap(bitmap); +// Bitmap bitmap = Utils.createQRImage(Utils.getSn(), 250, 250); +// imageView.setImageBitmap(bitmap); } @@ -465,6 +508,37 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs } + private PowerManager.WakeLock wakeLock = null; + private static final String mWakeLockName = "BackupService"; + + /** + * 获取电源锁,保持该服务在屏幕熄灭时仍然获取CPU时,保持运行 + */ + private synchronized void acquireWakeLock() { + if (null == wakeLock) { + PowerManager pm = (PowerManager) this.getSystemService(Context.POWER_SERVICE); + wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK + | PowerManager.ON_AFTER_RELEASE, mWakeLockName); + if (null != wakeLock) { + Log.e("fht", "acquireWakeLock!"); + wakeLock.acquire(); + } + } + } + + + /** + * 释放设备电源锁 + */ + private synchronized void releaseWakeLock() { + if (null != wakeLock) { + Log.e("fht", "releaseWakeLock!"); + wakeLock.release(); + wakeLock = null; + } + } + + private boolean locked = false; public void getLockedState() { @@ -562,6 +636,33 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs break; case -200: Log.e("fht", "no update"); + break; + case 2: + StudentsInfo info = com.alibaba.fastjson.JSONObject.parseObject(String.valueOf(msg.obj), StudentsInfo.class); + if (null != info) { + if (info.getBatch().equals("")) { + tv_class.setText("暂无信息"); + } else { + tv_class.setText(info.getBatch()); + } + if (info.getSno().equals("")) { + tv_number.setText("暂无信息"); + } else { + tv_number.setText(info.getSno()); + } + if (info.getRealname().equals("")) { + tv_name.setText("暂无信息"); + } else { + tv_name.setText(info.getRealname()); + } + } + break; + case -2: + tv_class.setText("暂无信息"); + tv_number.setText("暂无信息"); + tv_name.setText("暂无信息"); + break; + } } @@ -589,7 +690,8 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs .setExtendField(object.toJSONString()) .create(); //启动下载} } else { - Log.e("fht", "无需更新"); +// ToastUtil.show("已是最新版本"); + Log.e("fht", "已是最新版本"); } } @@ -628,7 +730,37 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs loadHeadImg(Configure.HTTP_TAG_HOME_PAGE_URL); getLockedState(); // MyApplication.getInstance().getWhitePackageList(); + getInfo(mHandler); + } + private void getInfo(final Handler handler) { + OkGo.post(Configure.GET_STUDENTS_INFO) + .params("sn", Utils.getSerial()) + .execute(new StringCallback() { + @Override + public void onSuccess(String s, Call call, Response response) { + try { + LzyResponse lzyResponse = (LzyResponse) JSON.parseObject(s, LzyResponse.class); + Message message = new Message(); + if (lzyResponse.code == 200) { + message.what = 2; + message.obj = lzyResponse.data; + handler.sendMessage(message); + } else { + handler.sendEmptyMessage(-2); + } + } catch (Exception e) { + Log.e("fht", "getInfo:" + e.getMessage()); + } + } + + @Override + public void onError(Call call, Response response, Exception e) { + super.onError(call, response, e); + Log.e("onError", "error"); + } + + });// 请求方式和请求url } private void loadHeadImg(String URL) { @@ -1579,18 +1711,4 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs } return num; } - - - @Override - public void onNetDisconnected() { - - } - - @Override - public void onNetConnected(NetworkType networkType) { - initJpush(); - Aria.download(this).resumeAllTask(); - } - - } diff --git a/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java b/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java index 95df396..62810d3 100644 --- a/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java +++ b/app/src/main/java/com/mjsheng/myappstore/network/HTTPInterface.java @@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.LogUtils; +import com.blankj.utilcode.util.ToastUtils; import com.lzy.okgo.OkGo; import com.lzy.okgo.callback.StringCallback; import com.mjsheng.myappstore.MyApplication; @@ -562,6 +563,7 @@ public class HTTPInterface { int code = jsonObject.getInteger("code"); String msg = jsonObject.getString("msg"); String data = jsonObject.getString("data"); + Log.e("setHideDesktopIcon", data); ApkUtils.showAllAPP(context); if (code == 200) { if (data != null && !"".equals(data)) { @@ -584,7 +586,7 @@ public class HTTPInterface { }); } - synchronized public static void getNetAndLaunchSetting(final Context context) { + synchronized public static void getNetAndLaunchSetting(final Context context) { OkGo.post(Configure.NET_AND_LAUNCH_API) .params("key", Configure.HTTP_KEY) .params("sn", Utils.getSerial()) @@ -593,7 +595,12 @@ public class HTTPInterface { public void onSuccess(String s, Call call, Response response) { NetAndLaunchBean netAndLaunchBeanList = JSON.parseObject(s, NetAndLaunchBean.class); LogUtils.e(s); - setNetAndlaunch(netAndLaunchBeanList, context); + switch (netAndLaunchBeanList.getCode()) { + case 200: + setNetAndlaunch(netAndLaunchBeanList, context); + break; + default: + } } @Override diff --git a/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java b/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java index 67b9d82..e45ef4c 100644 --- a/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java +++ b/app/src/main/java/com/mjsheng/myappstore/receiver/BootReceiver.java @@ -35,6 +35,8 @@ public class BootReceiver extends BroadcastReceiver { startService(context); } + + } private void startService(Context context) { diff --git a/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java b/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java index 0eb2896..2954f3a 100644 --- a/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java +++ b/app/src/main/java/com/mjsheng/myappstore/receiver/MyJPushReceiver.java @@ -444,13 +444,16 @@ public class MyJPushReceiver extends BroadcastReceiver { .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Observer() { + @Override public void onComplete() { } + @Override public void onError(Throwable param1Throwable) { Log.e("mjsheng", "DeselectIDApi=onError:"); } + @Override public void onNext(ResponseBody param1ResponseBody) { try { String str1; diff --git a/app/src/main/java/com/mjsheng/myappstore/server/GuardService.java b/app/src/main/java/com/mjsheng/myappstore/server/GuardService.java index e31f47d..6c7a71b 100644 --- a/app/src/main/java/com/mjsheng/myappstore/server/GuardService.java +++ b/app/src/main/java/com/mjsheng/myappstore/server/GuardService.java @@ -8,12 +8,18 @@ package com.mjsheng.myappstore.server; */ import android.app.Service; +import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.ServiceConnection; +import android.net.ConnectivityManager; +import android.net.Network; +import android.net.NetworkInfo; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; import android.os.IBinder; -import android.provider.Settings; import android.support.annotation.Nullable; import android.text.format.Formatter; import android.util.Log; @@ -25,16 +31,12 @@ import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.task.DownloadTask; import com.blankj.utilcode.util.LogUtils; -import com.blankj.utilcode.util.ToastUtils; import com.mjsheng.myappstore.KeepAliveConnection; import com.mjsheng.myappstore.MyApplication; import com.mjsheng.myappstore.utils.ApkUtils; import com.mjsheng.myappstore.utils.ServiceAliveUtils; import com.mjsheng.myappstore.utils.ToastUtil; -import com.tianma.netdetector.lib.NetStateChangeObserver; -import com.tianma.netdetector.lib.NetworkType; -import java.io.File; import java.util.List; @@ -44,7 +46,7 @@ import java.util.List; * @author LiGuangMin * @time Created by 2018/8/17 11:27 */ -public class GuardService extends Service implements NetStateChangeObserver { +public class GuardService extends Service { private final static String TAG = GuardService.class.getSimpleName(); private ServiceConnection mServiceConnection = new ServiceConnection() { @Override @@ -69,8 +71,10 @@ public class GuardService extends Service implements NetStateChangeObserver { @Nullable @Override public IBinder onBind(Intent intent) { + registerNetworkReceiver(); return new KeepAliveConnection.Stub() { }; + } @Override @@ -80,16 +84,115 @@ public class GuardService extends Service implements NetStateChangeObserver { Aria.init(this); Aria.get(this).getDownloadConfig().setMaxTaskNum(1); - Aria.download(this).register(); - // startForeground(1, new Notification()); // 绑定建立链接 bindService(new Intent(this, StepService.class), mServiceConnection, Context.BIND_IMPORTANT); return START_STICKY; } + @Override + public void onDestroy() { + super.onDestroy(); + if (null != mNetworkChangedRecceiver) { + unregisterReceiver(mNetworkChangedRecceiver); + } + } + + private NetworkChangedRecceiver mNetworkChangedRecceiver; + + public void registerNetworkReceiver() { + mNetworkChangedRecceiver = new NetworkChangedRecceiver(); + IntentFilter filter = new IntentFilter(); + filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); + filter.addAction("android.net.ethernet.ETHERNET_STATE_CHANGED"); + filter.addAction("android.net.ethernet.STATE_CHANGE"); + filter.addAction("android.net.conn.CONNECTIVITY_CHANGE"); + filter.addAction("android.net.wifi.WIFI_STATE_CHANGED"); + filter.addAction("android.net.wifi.STATE_CHANGE"); + filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); + registerReceiver(mNetworkChangedRecceiver, filter); + } + + Long time1 = 0L; + Long time2 = 0L; + + public class NetworkChangedRecceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) { + //获得ConnectivityManager对象 + ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + //获取ConnectivityManager对象对应的NetworkInfo对象 + //获取WIFI连接的信息 + NetworkInfo wifiNetworkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); + //获取移动数据连接的信息 + NetworkInfo dataNetworkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); + if (wifiNetworkInfo.isConnected() && dataNetworkInfo.isConnected()) { + Log.e("fht", "WIFI已连接,移动数据已连接"); + } else if (wifiNetworkInfo.isConnected() && !dataNetworkInfo.isConnected()) { + Log.e("fht", "WIFI已连接,移动数据已断开"); + } else if (!wifiNetworkInfo.isConnected() && dataNetworkInfo.isConnected()) { + Log.e("fht", "WIFI已连接,移动数据已连接"); + } else { + Log.e("fht", "WIFI已连接,移动数据已断开"); + } + //API大于23时使用下面的方式进行网络监听 + } else { + //获得ConnectivityManager对象 + ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + //获取所有网络连接的信息 + Network[] networks = connMgr.getAllNetworks(); + //用于存放网络连接信息 + StringBuilder sb = new StringBuilder(); + //通过循环将网络信息逐个取出来 + for (int i = 0; i < networks.length; i++) { + //获取ConnectivityManager对象对应的NetworkInfo对象 + NetworkInfo networkInfo = connMgr.getNetworkInfo(networks[i]); + if (null != networkInfo) { + sb.append(networkInfo.getTypeName() + " connect is " + networkInfo.isConnected()); + } + } + Log.e("fht", sb.toString()); + } + if (intent.getAction().equals(WifiManager.RSSI_CHANGED_ACTION)) { + Log.e("fht", "wifi信号强度变化"); + } + //wifi连接上与否 + if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { + + NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); + if (info.getState().equals(NetworkInfo.State.DISCONNECTED)) { + Log.e("fht", "wifi断开"); + } else if (info.getState().equals(NetworkInfo.State.CONNECTED)) { + WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); + WifiInfo wifiInfo = wifiManager.getConnectionInfo(); + //获取当前wifi名称 + Log.e("fht", "连接到网络 " + wifiInfo.getSSID()); + time2 = System.currentTimeMillis(); + if ((time2 - time1) > 60 * 1000) { + //可能会多次触发,1分钟之内不执行 + //application中启动服务,startcommand执行会两次 + startService(new Intent(context, InitJpushServer.class)); + Aria.download(this).resumeAllTask(); + time1 = time2; + Log.e("fht", "onReceive"); + } + } + } + //wifi打开与否 + if (intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) { + int wifistate = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED); + if (wifistate == WifiManager.WIFI_STATE_DISABLED) { + Log.e("fht", "系统关闭wifi"); + } else if (wifistate == WifiManager.WIFI_STATE_ENABLED) { + Log.e("fht", "系统开启wifi"); + } + } + } + } //在这里处理任务执行中的状态,如进度进度条的刷新 @Download.onTaskRunning @@ -147,15 +250,6 @@ public class GuardService extends Service implements NetStateChangeObserver { } - @Override - public void onNetDisconnected() { - } - - @Override - public void onNetConnected(NetworkType networkType) { - Aria.download(this).resumeAllTask(); - - } } diff --git a/app/src/main/java/com/mjsheng/myappstore/server/InitJpushServer.java b/app/src/main/java/com/mjsheng/myappstore/server/InitJpushServer.java index 0d0d286..fe7d747 100644 --- a/app/src/main/java/com/mjsheng/myappstore/server/InitJpushServer.java +++ b/app/src/main/java/com/mjsheng/myappstore/server/InitJpushServer.java @@ -573,6 +573,7 @@ public class InitJpushServer extends Service { } Utils.writeDisableUpdateList(this, upgrade_not.split(","), upgrade_ok.split(",")); + LogUtils.e("UpdateList:upgrade_not:" + upgrade_not + "-----------upgrade_ok:" + upgrade_ok); LogUtils.e("launch:" + launch + "-----------net_ok:" + net_ok + "-----------net_not:" + net_not); boolean qch_app_power_on = Settings.System.putString(getApplicationContext().getContentResolver(), "qch_app_power_on", launch); diff --git a/app/src/main/java/com/mjsheng/myappstore/utils/Configure.java b/app/src/main/java/com/mjsheng/myappstore/utils/Configure.java index 52984a3..49b2353 100644 --- a/app/src/main/java/com/mjsheng/myappstore/utils/Configure.java +++ b/app/src/main/java/com/mjsheng/myappstore/utils/Configure.java @@ -204,4 +204,6 @@ public class Configure { //获取隐藏桌面图标 public final static String NET_AND_LAUNCH_API = HTTP_TAG_HEAD_NEW + "automatic/get"; //获取应用升级自启 + public static final String GET_STUDENTS_INFO = HTTP_TAG_HEAD_NEW + "Sn/getStudent"; + } diff --git a/app/src/main/java/com/mjsheng/myappstore/utils/Utils.java b/app/src/main/java/com/mjsheng/myappstore/utils/Utils.java index 1e5d7f9..533f887 100644 --- a/app/src/main/java/com/mjsheng/myappstore/utils/Utils.java +++ b/app/src/main/java/com/mjsheng/myappstore/utils/Utils.java @@ -919,8 +919,14 @@ public class Utils { static synchronized public boolean writeDisableUpdateList(Context context, String[] banList, String[] notList) { String now = Settings.System.getString(context.getContentResolver(), "qch_app_forbid"); - String[] nowList = now.split(","); - List allList = new ArrayList<>(Arrays.asList(nowList));//已经写入的列表 + String[] nowList; + List allList; + if (now == null || now.equalsIgnoreCase("")) { + allList = new ArrayList<>(); + } else { + nowList = now.split(","); + allList = new ArrayList<>(Arrays.asList(nowList));//已经写入的列表 + } boolean writeSucceed = false; if (banList != null && banList.length > 0) { for (String s : banList) { @@ -944,7 +950,7 @@ public class Utils { list = list.substring(0, list.length() - 1); Log.e("fht", list); writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_app_forbid", list); - Log.e("fht","qch_app_forbid:"+list); + Log.e("fht", "qch_app_forbid:" + list); } else { writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_app_forbid", "Invalid"); } diff --git a/app/src/main/res/layout-land/activity_main.xml b/app/src/main/res/layout-land/activity_main.xml index c4eb313..7941f91 100644 --- a/app/src/main/res/layout-land/activity_main.xml +++ b/app/src/main/res/layout-land/activity_main.xml @@ -7,51 +7,77 @@ android:background="#ffffff" tools:context=".activity.MainActivity"> + + + + + + + app:layout_constraintTop_toBottomOf="@+id/bannerLayout" + app:layout_constraintVertical_bias="0.05"> - - + android:layout_height="@dimen/dp_20" + > + @@ -67,12 +106,11 @@ + android:layout_height="@dimen/dp_20" + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + app:layout_constraintHorizontal_bias="0.5" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/linearLayout" /> \ No newline at end of file diff --git a/app/src/main/res/layout-port/activity_main.xml b/app/src/main/res/layout-port/activity_main.xml index 05744ec..7f275ea 100644 --- a/app/src/main/res/layout-port/activity_main.xml +++ b/app/src/main/res/layout-port/activity_main.xml @@ -8,26 +8,63 @@ tools:context=".activity.MainActivity"> + + + + + + + + app:layout_constraintVertical_bias="0.15"> - - + android:layout_height="@dimen/dp_30"> + + @@ -71,8 +111,7 @@ android:layout_marginTop="@dimen/dp_10"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -89,15 +279,15 @@ + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 4e2f0ae..2e4185a 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 4e2f0ae..2e4185a 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 4e2f0ae..2e4185a 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 4e2f0ae..2e4185a 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 4e2f0ae..2e4185a 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ