diff --git a/app/build.gradle b/app/build.gradle
index 19401cc..ee3f2d8 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -16,8 +16,8 @@ android {
minSdkVersion 24
targetSdkVersion 29
- versionCode 208
- versionName "2.0.7"
+ versionCode 212
+ versionName "2.1.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 563d615..b067b5c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -41,7 +41,9 @@
-
+
+
+
@@ -161,8 +163,8 @@
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme" />
+ android:screenOrientation="portrait"
+ android:theme="@style/AppBlackTheme" />
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme" />
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme" />
+ android:screenOrientation="portrait"
+ android:theme="@style/AppTheme" />
6 && hour < 22) {
+ mSoundPool.play(soundMap.get(hour), 1, 1, 0, 0, 1);
+ }
}
@Override
@@ -265,6 +273,34 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
});
}
+ private void setAlarmTime() {
+ /*Android 10 及以后息屏收不到time_tick广播*/
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
+ AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
+ Intent intent = new Intent(VSCOOL_ACTION_TIME_TICK);
+ PendingIntent pendingIntent = PendingIntent.getBroadcast(this, TIME_REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ long triggerAtTime = getIntervalMillis();
+ alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerAtTime, pendingIntent);
+ }
+ }
+
+ /**
+ * @return 获取下个整点的时间戳
+ */
+ private long getIntervalMillis() {
+ Calendar calendar = Calendar.getInstance();
+ int hour = calendar.get(Calendar.HOUR_OF_DAY);
+ Log.e(TAG, "getIntervalMillis: hour = " + hour);
+ int min = calendar.get(Calendar.MINUTE);
+ Log.e(TAG, "getIntervalMillis: min = " + min);
+ calendar.set(Calendar.HOUR_OF_DAY, hour + 1);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ long time = calendar.getTimeInMillis();
+ Log.e(TAG, "getIntervalMillis: time = " + TimeUtils.transferLongToDate(time));
+ return time;
+ }
+
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e(TAG, "onStartCommand: ");
@@ -299,6 +335,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
@Override
public void onDestroy() {
super.onDestroy();
+ Log.e(TAG, "onDestroy: ");
mPresenter.detachView();
NetworkUtils.unregisterNetworkStatusChangedListener(this);
if (alarmReceiver != null) {
@@ -403,7 +440,7 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
}
// 监听时间和日期变化
- public void registerTimeReceiver() {
+ public void registerTimeChangedReceiver() {
mTimeChangedReceiver = new TimeChangedReceiver();
IntentFilter filter = new IntentFilter();
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
@@ -411,6 +448,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
filter.addAction(Intent.ACTION_TIME_CHANGED);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(Intent.ACTION_TIME_TICK);
+ filter.addAction(VSCOOL_ACTION_TIME_TICK);
+ filter.addAction(VSCOOL_ACTION_TIME_CHANGED);
registerReceiver(mTimeChangedReceiver, filter);
}
@@ -420,20 +459,21 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
@Override
public void onReceive(Context context, Intent intent) {
- switch (intent.getAction()) {
+ String action = intent.getAction();
+ Log.e("TimeChangedReceiver", "onReceive: " + action);
+ switch (action) {
case Intent.ACTION_DATE_CHANGED:
- Log.e(TAG, "TimeChangedReceiver:" + "data changed");
- break;
case Intent.ACTION_TIME_CHANGED:
- Log.e(TAG, "TimeChangedReceiver:" + "time changed");
- break;
case Intent.ACTION_TIMEZONE_CHANGED:
- Log.e(TAG, "TimeChangedReceiver:" + "timezone changed");
+ case VSCOOL_ACTION_TIME_CHANGED:
+ setAlarmTime();
break;
case Intent.ACTION_TIME_TICK:
- Log.e(TAG, "TimeChangedReceiver:" + "time tick");
hourlyTimeSignal();
break;
+ case VSCOOL_ACTION_TIME_TICK:
+ alarmWakeup();
+ break;
default:
}
}
@@ -448,10 +488,10 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
private void hourlyTimeSignal() {
boolean hourly_time = mMMKV.decodeBool(CommonConfig.HOURLY_TIME_SIGNAL_KEY, false);
if (hourly_time) {
- Calendar cal = Calendar.getInstance();
- int hour = cal.get(Calendar.HOUR_OF_DAY);
+ Calendar calendar = Calendar.getInstance();
+ int hour = calendar.get(Calendar.HOUR_OF_DAY);
Log.e(TAG, "hourlyTimeSignal: hour = " + hour);
- int min = cal.get(Calendar.MINUTE);
+ int min = calendar.get(Calendar.MINUTE);
Log.e(TAG, "hourlyTimeSignal: min = " + min);
if (min == 0) {
mTimeSignalCallback.timeTick(hour);
@@ -461,6 +501,19 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
}
}
+ private void alarmWakeup() {
+ boolean hourly_time = mMMKV.decodeBool(CommonConfig.HOURLY_TIME_SIGNAL_KEY, false);
+ if (hourly_time) {
+ Calendar calendar = Calendar.getInstance();
+ int hour = calendar.get(Calendar.HOUR_OF_DAY);
+ Log.e(TAG, "hourlyTimeSignal: hour = " + hour);
+ mTimeSignalCallback.timeTick(hour);
+ setAlarmTime();
+ } else {
+ Log.e(TAG, "hourlyTimeSignal: not enable hourly time signal");
+ }
+ }
+
private void registFastCallReceive() {
if (null == mTimeSignalReceiver) {
mTimeSignalReceiver = new TimeSignalReceiver();
@@ -734,8 +787,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
if (mBallView.isAttachedToWindow()) {
mWindowManager.removeView(mBallView);
}
- mMMKV.encode(Float_Window_X, mBallParams.x);
- mMMKV.encode(Float_Window_Y, mBallParams.y);
+ mMMKV.encode(FLOAT_WINDOW_X, mBallParams.x);
+ mMMKV.encode(FLOAT_WINDOW_Y, mBallParams.y);
}
isBallShown = false;
break;
@@ -795,8 +848,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
mBallParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
mBallParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
// mBallParams.gravity = Gravity.TOP;
- int x = mMMKV.decodeInt(Float_Window_X, 360);
- int y = mMMKV.decodeInt(Float_Window_Y, -783);
+ int x = mMMKV.decodeInt(FLOAT_WINDOW_X, 360);
+ int y = mMMKV.decodeInt(FLOAT_WINDOW_Y, -783);
mBallParams.x = x;
mBallParams.y = y;
mWindowManager.addView(mBallView, mBallParams);
@@ -885,8 +938,8 @@ public class MainService extends BaseRxService implements MainSContact.MainSView
mBallParams.y += tranY;
// 更新悬浮窗位置
mWindowManager.updateViewLayout(mBallView, mBallParams);
- mMMKV.encode(Float_Window_X, mBallParams.x);
- mMMKV.encode(Float_Window_Y, mBallParams.y);
+ mMMKV.encode(FLOAT_WINDOW_X, mBallParams.x);
+ mMMKV.encode(FLOAT_WINDOW_Y, mBallParams.y);
// 记录当前坐标作为下一次计算的上一次移动的位置坐标
lastX = nowX;
lastY = nowY;
diff --git a/app/src/main/java/com/vscool/os/utils/ApkUtils.java b/app/src/main/java/com/vscool/os/utils/ApkUtils.java
index 83fe11d..23fe127 100644
--- a/app/src/main/java/com/vscool/os/utils/ApkUtils.java
+++ b/app/src/main/java/com/vscool/os/utils/ApkUtils.java
@@ -394,7 +394,7 @@ public class ApkUtils {
resolveInfos.add(resolveInfo);
}
} else {
- if ("com.android.mms".equals(pkg)) {
+ if ("com.android.mms".equals(pkg) || "com.lenovo.leos.appstore".equals(pkg)) {
resolveInfos.add(resolveInfo);
} else {
Log.e(TAG, "getAppstoreAppInfo: pkgSet ! contains " + pkg);
diff --git a/app/src/main/java/com/vscool/os/utils/JgyUtils.java b/app/src/main/java/com/vscool/os/utils/JgyUtils.java
new file mode 100644
index 0000000..ba32ba1
--- /dev/null
+++ b/app/src/main/java/com/vscool/os/utils/JgyUtils.java
@@ -0,0 +1,103 @@
+package com.vscool.os.utils;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiManager;
+import android.os.Build;
+import android.provider.Settings;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+
+public class JgyUtils {
+ private static String TAG = "JgyUtils";
+
+ private static JgyUtils sInstance;
+ private static WifiManager mWifiManager;
+ @SuppressLint("StaticFieldLeak")
+ private Context mContext;
+
+ public JgyUtils(Context context) {
+ this.mContext = context;
+ }
+
+ public static void init(Context context) {
+ mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+ if (sInstance == null) {
+ Log.e(TAG, "init: ");
+ sInstance = new JgyUtils(context);
+ }
+ }
+
+ public static JgyUtils getInstance() {
+ if (sInstance == null) {
+ throw new IllegalStateException("You must be init JgyUtils first");
+ }
+ return sInstance;
+ }
+
+ public String getIMEI() {
+ String IMEI = "unknown";
+ String IMEI1, IMEI2, IMEI3;
+ //获取手机设备号
+ TelephonyManager TelephonyMgr = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
+ //8.0及以后版本获取
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ IMEI = TelephonyMgr.getDeviceId();
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+// try {
+// Method method = TelephonyMgr.getClass().getMethod("getImei");
+// IMEI = (String) method.invoke(TelephonyMgr);
+// } catch (Exception e) {
+// e.printStackTrace();
+// Log.e("getIMEI", e.getMessage());
+// }
+// IMEI = TelephonyMgr.getDeviceId();
+
+// } else {//9.0到10.0获取
+ IMEI = Settings.System.getString(mContext.getContentResolver(), Settings.Secure.ANDROID_ID);
+ }
+// Log.e("IMEI:", "IMEI: " + IMEI);
+ if (null == IMEI) {
+ return "-";
+ } else {
+ return IMEI.toUpperCase();
+ }
+ }
+
+ /**
+ * wifi是否打开
+ *
+ * @return
+ */
+ public boolean isWifiEnable() {
+ boolean isEnable = false;
+ if (mWifiManager != null) {
+ if (mWifiManager.isWifiEnabled()) {
+ isEnable = true;
+ }
+ }
+ return isEnable;
+ }
+
+ /**
+ * 判断网络连接状态
+ *
+ * @return true:网络已链接, false:网络已断开连接
+ */
+ public boolean isNetworkConnected() {
+ if (mContext != null) {
+ ConnectivityManager mConnectivityManager = (ConnectivityManager) mContext
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo mNetworkInfo = mConnectivityManager
+ .getActiveNetworkInfo();
+ if (mNetworkInfo != null) {
+ return mNetworkInfo.isAvailable();
+ }
+ }
+ return false;
+ }
+
+
+}
diff --git a/app/src/main/java/com/vscool/os/utils/Utils.java b/app/src/main/java/com/vscool/os/utils/Utils.java
index 9e0973f..17449a7 100644
--- a/app/src/main/java/com/vscool/os/utils/Utils.java
+++ b/app/src/main/java/com/vscool/os/utils/Utils.java
@@ -43,13 +43,17 @@ import java.util.function.Consumer;
public class Utils {
private static final String TAG = "Utils";
+ public static String getSerial() {
+ return JgyUtils.getInstance().getIMEI();
+ }
+
/**
* 获取设备序列号
*
* @return
*/
@SuppressLint("MissingPermission")
- public static String getSerial() {
+ public static String getSn() {
String serial = "unknow";
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
diff --git a/app/src/main/java/com/vscool/os/utils/WiFiUtils.java b/app/src/main/java/com/vscool/os/utils/WiFiUtils.java
deleted file mode 100644
index 0114e03..0000000
--- a/app/src/main/java/com/vscool/os/utils/WiFiUtils.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package com.vscool.os.utils;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
-import android.net.wifi.ScanResult;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiInfo;
-import android.net.wifi.WifiManager;
-import android.text.TextUtils;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author : fanhuitong
- * e-mail :
- * @date : 2021/10/25 10:20
- * desc :
- * version: 1.0
- */
-public class WiFiUtils {
- private static WiFiUtils sInstance;
- private static WifiManager mWifiManager;
- @SuppressLint("StaticFieldLeak")
- private Context mContext;
- private static String TAG = "WiFiUtils";
-
- public WiFiUtils(Context context) {
- this.mContext = context;
- }
-
- public static void init(Context context) {
- mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- if (sInstance == null) {
- Log.e(TAG, "init: ");
- sInstance = new WiFiUtils(context);
- }
- }
-
- public static WiFiUtils getInstance() {
- if (sInstance == null) {
- throw new IllegalStateException("You must be init WiFiUtils first");
- }
- return sInstance;
- }
-
- /**
- * wifi是否打开
- *
- * @return
- */
- public boolean isWifiEnable() {
- boolean isEnable = false;
- if (mWifiManager != null) {
- if (mWifiManager.isWifiEnabled()) {
- isEnable = true;
- }
- }
- return isEnable;
- }
-
- /**
- * 打开WiFi
- */
- public void openWifi() {
- if (mWifiManager != null && !isWifiEnable()) {
- mWifiManager.setWifiEnabled(true);
- }
- }
-
- /**
- * 关闭WiFi
- */
- public void closeWifi() {
- if (mWifiManager != null && isWifiEnable()) {
- mWifiManager.setWifiEnabled(false);
- }
- }
-
- /**
- * 获取WiFi列表
- *
- * @return
- */
- public List getWifiList() {
- List resultList = new ArrayList<>();
- if (mWifiManager != null && isWifiEnable()) {
- resultList.addAll(mWifiManager.getScanResults());
- }
- return resultList;
- }
-
-
- /**
- * 有密码连接
- *
- * @param ssid
- * @param pws
- */
- public static void connectWifiPws(String ssid, String pws) {
-// mWifiManager.disableNetwork(mWifiManager.getConnectionInfo().getNetworkId());
- mWifiManager.disconnect();
- int netId = mWifiManager.addNetwork(getWifiConfig(ssid, pws, true));
- mWifiManager.enableNetwork(netId, true);
- mWifiManager.reconnect();
- }
-
- /**
- * 无密码连接
- *
- * @param ssid
- */
- public void connectWifiNoPws(String ssid) {
-// mWifiManager.disableNetwork(mWifiManager.getConnectionInfo().getNetworkId());
- int netId = mWifiManager.addNetwork(getWifiConfig(ssid, "", false));
- mWifiManager.enableNetwork(netId, true);
- }
-
- /**
- * wifi设置
- *
- * @param ssid
- * @param pws
- * @param isHasPws
- */
- private static WifiConfiguration getWifiConfig(String ssid, String pws, boolean isHasPws) {
- WifiConfiguration config = new WifiConfiguration();
- config.allowedAuthAlgorithms.clear();
- config.allowedGroupCiphers.clear();
- config.allowedKeyManagement.clear();
- config.allowedPairwiseCiphers.clear();
- config.allowedProtocols.clear();
- config.SSID = "\"" + ssid + "\"";
-
- WifiConfiguration tempConfig = isExist(ssid);
- if (tempConfig != null) {
- mWifiManager.removeNetwork(tempConfig.networkId);
- }
- if (isHasPws) {
- config.preSharedKey = "\"" + pws + "\"";
- config.hiddenSSID = true;
- config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
- config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
- config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
- config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
- config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
- config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
- config.status = WifiConfiguration.Status.ENABLED;
- } else {
- config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
- }
- return config;
- }
-
- /**
- * 得到配置好的网络连接
- *
- * @param ssid
- * @return
- */
- private static WifiConfiguration isExist(String ssid) {
- List configs = mWifiManager.getConfiguredNetworks();
- for (WifiConfiguration config : configs) {
- if (config.SSID.equals("\"" + ssid + "\"")) {
- return config;
- }
- }
- return null;
- }
-
- public static void addWiFiNetwork(String ssid, String passwd) {
- int netId;
- if (TextUtils.isEmpty(passwd)) {
- netId = mWifiManager.addNetwork(getWifiConfig(ssid, "", false));
- } else {
- netId = mWifiManager.addNetwork(getWifiConfig(ssid, passwd, true));
- }
- mWifiManager.enableNetwork(netId, true);
- }
-
- public static void removeWiFiNetwork(String ssid) {
- WifiConfiguration tempConfig = isExist(ssid);
- int networkId = tempConfig.networkId;
- mWifiManager.removeNetwork(networkId);
- mWifiManager.saveConfiguration();
- }
-
- synchronized private static boolean wifiSaved(String ssid) {
- // 获取已保存wifi配置链表
- List configs = mWifiManager.getConfiguredNetworks();
- boolean saved = false;
- for (WifiConfiguration configuration : configs) {
- if (ssid.equals(configuration.SSID)) {
- saved = true;
- }
- }
- return saved;
- }
-
- //断判某个wifi是否是连接成功的那个wifi
- public boolean isConnectedWifi(Context context, String myssid) {
- WifiManager mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
- if (isWifiConnect(context)) {
- WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
- String ssid = wifiInfo.getSSID();
- return ssid != null && ssid.contains(myssid);
- } else {
- return false;
- }
- }
-
- //判断wifi是否连接
- public static boolean isWifiConnect(Context context) {
- ConnectivityManager connManager = (ConnectivityManager) context
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- @SuppressLint("MissingPermission")
- NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
- return mWifi.getState() == NetworkInfo.State.CONNECTED;
- }
-
- /**
- * 判断网络连接状态
- *
- * @return true:网络已链接, false:网络已断开连接
- */
- public boolean isNetworkConnected() {
- if (mContext != null) {
- ConnectivityManager mConnectivityManager = (ConnectivityManager) mContext
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo mNetworkInfo = mConnectivityManager
- .getActiveNetworkInfo();
- if (mNetworkInfo != null) {
- return mNetworkInfo.isAvailable();
- }
- }
- return false;
- }
-}