From 0fd8faf8061369296b4a92b081d83c940dfc233e Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 06 一月 2026 18:24:36 +0800
Subject: [PATCH] 2026年01月06日18:24:23 暂隐藏前台服务

---
 /dev/null                                                           |   49 ------------------------
 app/src/main/res/values-zh/strings.xml                              |    2 +
 app/src/main/res/values/strings.xml                                 |    2 +
 app/src/main/AndroidManifest.xml                                    |   25 ++++--------
 app/src/main/java/com/hdl/photovoltaic/uni/CSplashView.java         |   27 +++++++------
 app/src/main/res/values-en/strings.xml                              |    2 +
 app/src/main/java/com/hdl/photovoltaic/uni/MyForegroundService.java |    5 +-
 app/src/main/res/values-ar/strings.xml                              |    2 +
 app/build.gradle                                                    |    2 
 9 files changed, 34 insertions(+), 82 deletions(-)

diff --git a/app/build.gradle b/app/build.gradle
index 8323815..3b4d0f1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -31,7 +31,7 @@
         applicationId "com.hdl.photovoltaic"
         minSdk 23
         targetSdk 35
-        versionCode 29
+        versionCode 30
         versionName "2.0.0"//鐗堟湰瑙勫垯1.3鏄骇鍝佸姛鑳借凯浠g敤鐨�,鏈�鍚庝竴浣�0鏄垜浠慨澶峛ug鐢ㄧ殑
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         multiDexEnabled true
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3ceb084..d132c0d 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -15,7 +15,7 @@
     <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />&lt;!&ndash;澶栭儴瀛樺偍鐩綍璁块棶鏉冮檺 璋锋瓕play涓婃灦涓嶄簡&ndash;&gt; -->
     <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> <!-- wifi鐘舵�佹潈闄� -->
-    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- 鍓嶅彴鏈嶅姟鏉冮檺 -->
+
     <!-- <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> -->
     <uses-permission android:name="android.permission.INTERNET" /> <!-- 寮�鍚綉缁滄潈闄� -->
     <!-- 浣嶇疆淇℃伅 -->
@@ -89,8 +89,9 @@
 
     <uses-permission android:name="com.hdl.photovoltaic.permission.JPUSH_MESSAGE" /> <!-- 閫傞厤Android13锛屽脊鍑洪�氱煡蹇呴』鏉冮檺 -->
     <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
-    <!-- 娣诲姞 dataSync 鍓嶅彴鏈嶅姟鏉冮檺 -->
-    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
+<!--    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> &lt;!&ndash; 鍓嶅彴鏈嶅姟鏉冮檺 &ndash;&gt;-->
+<!--    &lt;!&ndash; 娣诲姞 dataSync 鍓嶅彴鏈嶅姟鏉冮檺 &ndash;&gt;-->
+<!--    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />-->
 
     <queries>
         <package android:name="com.hdl.photovoltaic.services" />
@@ -246,14 +247,6 @@
         <service
             android:name="org.eclipse.paho.android.service.MqttService"
             android:exported="false" />
-        <service
-            android:name=".services.UniappService"
-            android:enabled="true"
-            android:exported="true">
-            <intent-filter>
-                <action android:name="UniappService.ACTION" />
-            </intent-filter>
-        </service> <!-- <service -->
         <!-- android:name=".services.ForeService" -->
         <!-- android:enabled="true" -->
         <!-- android:exported="true" /> -->
@@ -264,11 +257,11 @@
                 <action android:name="com.google.firebase.MESSAGING_EVENT" />
             </intent-filter>
         </service>
-        <service
-            android:name=".uni.MyForegroundService"
-            android:enabled="true"
-            android:exported="false"
-            android:foregroundServiceType="dataSync" /> <!-- Android 10+ 闇�瑕佹寚瀹氱被鍨� -->
+<!--        <service-->
+<!--            android:name=".uni.MyForegroundService"-->
+<!--            android:enabled="true"-->
+<!--            android:exported="false"-->
+<!--            android:foregroundServiceType="dataSync" /> &lt;!&ndash; Android 10+ 闇�瑕佹寚瀹氱被鍨� &ndash;&gt;-->
 
 
         <meta-data
diff --git a/app/src/main/java/com/hdl/photovoltaic/services/ForeService.java b/app/src/main/java/com/hdl/photovoltaic/services/ForeService.java
deleted file mode 100644
index fe681ef..0000000
--- a/app/src/main/java/com/hdl/photovoltaic/services/ForeService.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package com.hdl.photovoltaic.services;
-
-import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.ServiceInfo;
-import android.graphics.BitmapFactory;
-import android.graphics.Color;
-import android.os.Build;
-import android.os.IBinder;
-import android.text.TextUtils;
-import android.util.Log;
-
-import static android.app.Notification.VISIBILITY_SECRET;
-
-import androidx.core.app.NotificationCompat;
-
-import com.hdl.photovoltaic.R;
-
-/***
- * @Description: 鍓嶅彴鏈嶅姟
- * channelId蹇呴』瑕佷竴鑷达紝鍚﹀垯浼氭姤 android.app.RemoteServiceException: Bad notification for startForeground 閿欒
- * 8.0涔嬩笂涓�瀹氳浣跨敤 NotificationChannel 閫傞厤涓嬫墠琛�
- * 姝ラ
- * 1.閫氳繃 鈥滈�氱煡鏈嶅姟鈥� 鍒涘缓 NotificationChannel
- * 2.閫氳繃 Notification.Builder 鏋勯�犲櫒 鍒涘缓 Notification
- * 3.閫氳繃 startForeground 寮�鍚湇鍔�
- * 4.楂樹簬9.0鐨勭増鏈� manifest闇�瑕佸鍔�  <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
- *
- * 鍦╫nCreate涓垱寤轰竴涓箍鎾帴鏀跺櫒锛岃瘯璇曡兘涓嶈兘鎺ユ敹鍒� 寮�鍗曟垨鑰呴绾︾粨鏉熷悗鐨勯�氱煡
- */
-public class ForeService extends Service {
-
-    final String TAG = ForeService.class.getName();
-
-    @Override
-    public IBinder onBind(Intent intent) {
-        return null;
-    }
-
-
-    @SuppressLint("ForegroundServiceType")
-    @Override
-    public void onCreate() {
-        super.onCreate();
-//        Log.d(TAG, "ForeService onCreate() 杩涚▼Id:" + android.os.Process.myPid());
-//        try {
-//            // Kotlin 绀轰緥
-//            if (Build.VERSION.SDK_INT >= 34) {
-//                startForeground(1, getNotification(getString(R.string.app_name), "Running"), ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
-//            } else {
-//                startForeground(1, getNotification(getString(R.string.app_name), "Running"));
-//            }
-//        } catch (Exception e) {
-//        }
-    }
-
-    @Override
-    public int onStartCommand(Intent intent, int flags, int startId) {
-        return START_STICKY;
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        //鍋滄鐨勬椂鍊欓攢姣佸墠鍙版湇鍔�
-        stopForeground(true);
-    }
-
-
-    private Notification getNotification(String title, String message) {
-        createNotificationChannel();
-
-        //鍒涘缓涓�涓�氱煡娑堟伅鐨勬瀯閫犲櫒
-        Notification.Builder builder = new Notification.Builder(this);
-        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
-            //Android8.0寮�濮嬪繀椤荤粰姣忎釜閫氱煡鍒嗛厤瀵瑰簲鐨勬笭閬�
-            builder = new Notification.Builder(this, "f_channel_id");
-        }
-        builder.setAutoCancel(true)//璁剧疆鏄惁鍏佽鑷姩娓呴櫎
-                .setSmallIcon(R.drawable.notification_logo)//璁剧疆鐘舵�佹爮閲岀殑灏忓浘鏍�
-                .setContentTitle(title)//璁剧疆閫氱煡鏍忛噷闈㈢殑鏍囬鏂囨湰
-                .setContentText(message);//璁剧疆閫氱煡鏍忛噷闈㈢殑鍐呭鏂囨湰
-        //鏍规嵁娑堟伅鏋勯�犲櫒鍒涘缓涓�涓�氱煡瀵硅薄
-        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
-            return builder.build();
-        }
-        return null;
-    }
-
-    @TargetApi(Build.VERSION_CODES.O)
-    private void createNotificationChannel() {
-        NotificationChannel channel = new NotificationChannel("f_channel_id", "CHANNEL_NAME", NotificationManager.IMPORTANCE_HIGH);
-        //鏄惁缁曡繃璇峰嬁鎵撴壈妯″紡
-        channel.canBypassDnd();
-        //闂厜鐏�
-        channel.enableLights(true);
-        //閿佸睆鏄剧ず閫氱煡
-        channel.setLockscreenVisibility(VISIBILITY_SECRET);
-        //闂叧鐏殑鐏厜棰滆壊
-        channel.setLightColor(Color.RED);
-        //妗岄潰launcher鐨勬秷鎭鏍�
-        channel.canShowBadge();
-        //鏄惁鍏佽闇囧姩
-        channel.enableVibration(false);
-        //鑾峰彇绯荤粺閫氱煡鍝嶉搩澹伴煶鐨勯厤缃�
-        channel.getAudioAttributes();
-        //鑾峰彇閫氱煡鍙栧埌缁�
-        channel.getGroup();
-        //璁剧疆鍙粫杩�  璇峰嬁鎵撴壈妯″紡
-        channel.setBypassDnd(true);
-        //璁剧疆闇囧姩妯″紡
-        channel.setVibrationPattern(new long[]{100, 100, 200});
-        //鏄惁浼氭湁鐏厜
-        channel.shouldShowLights();
-        getManager().createNotificationChannel(channel);
-    }
-
-    private NotificationManager mManager;
-
-    private NotificationManager getManager() {
-        if (mManager == null) {
-            mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
-        }
-        return mManager;
-    }
-}
-
diff --git a/app/src/main/java/com/hdl/photovoltaic/services/UniappService.java b/app/src/main/java/com/hdl/photovoltaic/services/UniappService.java
deleted file mode 100644
index 2b1706d..0000000
--- a/app/src/main/java/com/hdl/photovoltaic/services/UniappService.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.hdl.photovoltaic.services;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-
-import com.hdl.photovoltaic.IUniappAidlInterface;
-import com.hdl.sdk.link.common.utils.LogUtils;
-
-
-/**
- * Created by hxb on 2024/12/27.
- */
-public class UniappService extends Service {
-
-    private static final String TAG = "UniappService";
-
-    public UniappService() {
-
-    }
-
-    IUniappAidlInterface.Stub mIBinder=new IUniappAidlInterface.Stub() {
-
-        @Override
-        public void sendMsg(String mes)  {
-            LogUtils.i(TAG,"鏀跺埌璇锋眰鏁版嵁锛�" + mes);
-        }
-    };
-
-    @Override
-
-    public IBinder onBind(Intent intent) {
-        LogUtils.i(TAG,"onBind: intent = "+intent.toString());
-        return mIBinder;
-    }
-
-    @Override
-
-    public boolean onUnbind(Intent intent) {
-        LogUtils.i(TAG,"onUnbind");
-        return super.onUnbind(intent);
-    }
-
-    @Override
-    public void onDestroy() {
-        LogUtils.i(TAG,"onDestroy");
-        super.onDestroy();
-    }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/hdl/photovoltaic/uni/CSplashView.java b/app/src/main/java/com/hdl/photovoltaic/uni/CSplashView.java
index 3e7b535..91b7f55 100755
--- a/app/src/main/java/com/hdl/photovoltaic/uni/CSplashView.java
+++ b/app/src/main/java/com/hdl/photovoltaic/uni/CSplashView.java
@@ -37,20 +37,21 @@
         //璁剧疆瀵艰埅鏉¤儗鏅鑹�
         Activity activity = (Activity) context;
         activity.getWindow().setNavigationBarColor(HDLApp.getInstance().getColor(R.color.text_FF1C1C1E));
-        try {
-//            if (!UserConfigManage.getInstance().isBAccount()) {
-            if (!ServiceUtils.isServiceRunning(context, MyForegroundService.class)) {
-                // 鍚姩鍓嶅彴鏈嶅姟
-                Intent serviceIntent = new Intent(context, MyForegroundService.class);
-                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-                    context.startForegroundService(serviceIntent);
-                } else {
-                    context.startService(serviceIntent);
-                }
-            }
+        // 2026骞�01鏈�06鏃�18:12:25 鍥犱笂鏋跺埌璋锋瓕琚嫆锛屽洜涓婃灦绱ф�ワ紝鏆傛椂鍏堝彇娑堝墠鍙版湇鍔★紝寰呬慨澶嶅悗鍐嶆仮澶嶏紱
+//        try {
+////            if (!UserConfigManage.getInstance().isBAccount()) {
+//            if (!ServiceUtils.isServiceRunning(context, MyForegroundService.class)) {
+//                // 鍚姩鍓嶅彴鏈嶅姟
+//                Intent serviceIntent = new Intent(context, MyForegroundService.class);
+//                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+//                    context.startForegroundService(serviceIntent);
+//                } else {
+//                    context.startService(serviceIntent);
+//                }
 //            }
-        } catch (Exception e) {
-        }
+////            }
+//        } catch (Exception e) {
+//        }
         return splashView;
     }
 
diff --git a/app/src/main/java/com/hdl/photovoltaic/uni/MyForegroundService.java b/app/src/main/java/com/hdl/photovoltaic/uni/MyForegroundService.java
index 523e730..8d6e06a 100644
--- a/app/src/main/java/com/hdl/photovoltaic/uni/MyForegroundService.java
+++ b/app/src/main/java/com/hdl/photovoltaic/uni/MyForegroundService.java
@@ -14,7 +14,6 @@
 import com.hdl.photovoltaic.R;
 
 
-
 public class MyForegroundService extends Service {
     private static final String CHANNEL_ID = "MyForegroundServiceChannel";
     private static final int NOTIFICATION_ID = 1;
@@ -48,8 +47,8 @@
     public int onStartCommand(Intent intent, int flags, int startId) {
         // 鍒涘缓閫氱煡
         Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
-                .setContentTitle("")//瀹夸富杩涚▼鏈嶅姟
-                .setContentText("")//姝e湪涓巙ni-app淇濇寔閫氫俊锛屼繚鎸佽繛鎺ヤ腑
+                .setContentTitle(getString(R.string.maintain_communication))//瀹夸富杩涚▼鏈嶅姟
+                .setContentText(getString(R.string.remain_connected))//姝e湪涓巙ni-app淇濇寔閫氫俊锛屼繚鎸佽繛鎺ヤ腑
                 .setSmallIcon(R.drawable.logo)  // 蹇呴』璁剧疆涓�涓浘鏍�
                 .setPriority(NotificationCompat.PRIORITY_LOW)
 //                .setOngoing(true)   // 璁剧疆閫氱煡涓烘寔缁�氱煡锛屼笉鍙竻闄�
diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml
index 0a61e39..d17d59f 100644
--- a/app/src/main/res/values-ar/strings.xml
+++ b/app/src/main/res/values-ar/strings.xml
@@ -374,4 +374,6 @@
     <string name="re_commissioning_power_station">鬲賲 廿毓丕丿丞 鬲卮睾賷賱 賲丨胤丞 丕賱胤丕賯丞 丕賱噩丿賷丿丞 賲賳 胤乇丕夭 APP</string>
     <string name="notification_settings">廿毓丿丕丿丕鬲 丕賱廿卮毓丕乇丕鬲</string>
     <string name="host_process_service_channel">賲賲乇 禺丿賲丞 毓賲賱賷丞 丕賱賲囟賷賮</string>
+    <string name="remain_connected">丕亘賯 毓賱賶 丕鬲氐丕賱</string>
+    <string name="maintain_communication">丕亘賯 毓賱賶 丕鬲氐丕賱</string>
 </resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml
index 4621557..614e788 100644
--- a/app/src/main/res/values-en/strings.xml
+++ b/app/src/main/res/values-en/strings.xml
@@ -377,4 +377,6 @@
     <string name="re_commissioning_power_station">The Xenterra app initiates the re-commissioning of the power station</string>
     <string name="notification_settings">Notification settings</string>
     <string name="host_process_service_channel">Host process service channel</string>
+    <string name="remain_connected">Remain connected</string>
+    <string name="maintain_communication">Maintain communication</string>
 </resources>
\ No newline at end of file
diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml
index ed1c1f0..66d57e4 100644
--- a/app/src/main/res/values-zh/strings.xml
+++ b/app/src/main/res/values-zh/strings.xml
@@ -373,4 +373,6 @@
     <string name="re_commissioning_power_station">鏂扮壒閿愯兘app鍙戣捣鐢电珯閲嶆柊璋冭瘯</string>
     <string name="notification_settings">閫氱煡璁剧疆</string>
     <string name="host_process_service_channel">瀹夸富杩涚▼鏈嶅姟閫氶亾</string>
+    <string name="remain_connected">淇濇寔杩炴帴涓�</string>
+    <string name="maintain_communication">淇濇寔閫氫俊</string>
 </resources>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 25aab6b..e2b7214 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -377,4 +377,6 @@
     <string name="re_commissioning_power_station">The Xenterra app initiates the re-commissioning of the power station</string>
     <string name="notification_settings">Notification settings</string>
     <string name="host_process_service_channel">Host process service channel</string>
+    <string name="remain_connected">Remain connected</string>
+    <string name="maintain_communication">Maintain communication</string>
 </resources>
\ No newline at end of file

--
Gitblit v1.8.0