From db937c029a3f9dbaec86cbbc944ebbee3ece13be Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期四, 31 七月 2025 14:49:17 +0800 Subject: [PATCH] Merge branch '1.4.4' into dev --- app/src/main/java/com/hdl/photovoltaic/HDLApp.java | 96 +++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 91 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/HDLApp.java b/app/src/main/java/com/hdl/photovoltaic/HDLApp.java index ae50d6e..db24c47 100644 --- a/app/src/main/java/com/hdl/photovoltaic/HDLApp.java +++ b/app/src/main/java/com/hdl/photovoltaic/HDLApp.java @@ -2,7 +2,9 @@ import android.app.Activity; import android.app.ActivityManager; +import android.app.AlarmManager; import android.app.Application; +import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; @@ -27,9 +29,11 @@ import com.hdl.photovoltaic.config.AppConfigManage; import com.hdl.photovoltaic.config.ConstantManage; import com.hdl.photovoltaic.config.UserConfigManage; +import com.hdl.photovoltaic.enums.LogoutType; import com.hdl.photovoltaic.enums.LowerTagType; import com.hdl.photovoltaic.enums.NetworkType; import com.hdl.photovoltaic.listener.CloudCallBeak; +import com.hdl.photovoltaic.other.HdlAccountLogic; import com.hdl.photovoltaic.other.HdlDeviceLogic; import com.hdl.photovoltaic.other.HdlFileLogic; import com.hdl.photovoltaic.other.HdlLogLogic; @@ -94,9 +98,10 @@ @Override public void onCreate() { super.onCreate(); - Log.d("=======", "11111111"); + // // 鑾峰彇褰撳墠杩涚▼鐨凱ID -// String processMessage= "杩涚▼ID:"+Process.myPid()+" 杩涚▼鍚嶏細"+RuningAcitvityUtil.getAppName(getBaseContext()); +// String processMessage = "杩涚▼Uid:" + Process.myUid() + "杩涚▼ID:" + Process.myPid() + " 杩涚▼鍚嶏細" + RuningAcitvityUtil.getAppName(getBaseContext()); +// Log.d("=======", processMessage); // Log.d(TAG, processMessage); // if (RuningAcitvityUtil.getAppName(getBaseContext()).contains(":")) { // //闈炲師鐢熻繘绋嬶紝鐢ㄥ垵濮嬪寲鍚庨潰鐨� @@ -236,8 +241,7 @@ HDLLinkPMUser.getInstance().setOnReloginListener(new IOnReloginListener() { @Override public void onReLogin(int type) { - - if (100 == type) { + if (type == LogoutType.ServerSwitchingLogout.getValue()) { new Handler().postDelayed(new Runnable() { @Override public void run() { @@ -247,6 +251,47 @@ restartApp(mHDLApp); } }, 500); + } else if (type == LogoutType.AbnormalLogout.getValue()) { + //寮傚父鎯呭喌-寮哄埗閲嶅惎搴旂敤 + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + restartApp(mHDLApp); + } + }, 500); + } else if (type == LogoutType.UniLogout.getValue()) { + AppManagerUtils.getAppManager().finishAllActivity(); + //娓呯┖浣忓畢id + UserConfigManage.getInstance().setHomeId(""); + UserConfigManage.getInstance().setAutomaticSkipNoNetworkFlag(true); + //閲嶆柊璁惧畾涓�涓椂闂� + UserConfigManage.getInstance().setLoginDateTime(0); + UserConfigManage.getInstance().Save(); + //娓呯┖娑堟伅缂撳瓨鏁版嵁 + HdlMessageLogic.getInstance().clearListMessage(); + //娓呯┖鐢电珯缂撳瓨鏁版嵁 + HdlResidenceLogic.getInstance().clearHouseList(); + //娓呯┖璁惧缂撳瓨鏁版嵁 + HdlDeviceLogic.getInstance().clearDeviceList(); + //娓呯┖缂撳瓨鏁版嵁 + if (mInfoMap != null) { + mInfoMap.clear(); + } + //鏂紑mqtt杩炴帴 + if (MqttRecvClient.getInstance() != null) { + MqttRecvClient.getInstance().disConnect(); + } + //鏂紑鎵�鏈塼cp杩炴帴涓旀竻绌鸿繛鎺ョ紦瀛� + // TODO: 10/10/23 +// TcpSocketBoot.stopAllConnectLinkGateway(); + if (null != HDLUniMPSDKManager.getInstance().getUniMP()) { + HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP(); + } + SystemClock.sleep(200); + initDCUniMPSDK(); + Intent intent = new Intent(getInstance(), LoginActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); } else { HdlLogLogic.print("鐩戝惉鍒扮櫥褰曢��鍑�---" + type, true); //鍒犻櫎鎺ㄩ�乀oken @@ -298,6 +343,41 @@ }); } + + public void test(Context context) { +// new Handler().postDelayed(() -> { +// // 1. 璁剧疆寤惰繜閲嶅惎 +// Intent restartIntent = new Intent(context, StartActivity.class); +// restartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); +// +// PendingIntent pendingIntent = PendingIntent.getActivity( +// context, 0, restartIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_CANCEL_CURRENT +// ); +// +// AlarmManager am1 = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); +// am1.set(AlarmManager.RTC, System.currentTimeMillis() + 300, pendingIntent); +// +// int myUid = android.os.Process.myUid(); +// ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); +// String packageName = context.getPackageName(); +// +// for (ActivityManager.RunningAppProcessInfo proc : am.getRunningAppProcesses()) { +// if (proc.uid == myUid && proc.processName.startsWith(packageName)) { +// if (proc.pid != android.os.Process.myPid()) { +// try { +// android.os.Process.killProcess(proc.pid); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// } +// } +// +// // 3. 閫�鍑哄綋鍓嶈繘绋� +// android.os.Process.killProcess(android.os.Process.myPid()); +// }, 500); + } + /** * 鍒濆鍖朥niMPSDK 灏忕▼搴廠DK @@ -458,6 +538,7 @@ } } + /** * 閲嶅惎app */ @@ -473,6 +554,11 @@ } } + /** + * 鍏虫帀app鎵�鏈夎繘绋� + * + * @param context 涓婁笅鏂� + */ private void killAppProcess(Context context) { // AppManagerUtils.getAppManager().finishAllActivity(); try { @@ -480,7 +566,7 @@ List<android.app.ActivityManager.RunningAppProcessInfo> processInfos = manager.getRunningAppProcesses(); // 鍏堟潃鎺夌浉鍏宠繘绋嬶紝鏈�鍚庡啀鏉�鎺変富杩涚▼ for (android.app.ActivityManager.RunningAppProcessInfo runningAppProcessInfo : processInfos) { - if (runningAppProcessInfo.pid != android.os.Process.myPid()) { + if ((runningAppProcessInfo.uid == android.os.Process.myUid()) && (runningAppProcessInfo.pid != android.os.Process.myPid())) { try { android.os.Process.killProcess(runningAppProcessInfo.pid); } catch (Exception e) { -- Gitblit v1.8.0