@@ -78,19 +78,57 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
78
78
import com.lody.virtual.helper.component.BaseService;
79
79
80
80
/**
81
- @@ -29,8 +32,10 @@
81
+ @@ -14,7 +17,7 @@
82
+ */
83
+ public class DaemonService extends BaseService {
84
+
85
+ - private static final int NOTIFY_ID = 1001;
86
+ + private static final int NOTIFY_ID = 1001;
87
+
88
+ public static void startup(Context context) {
89
+ context.startService(new Intent(context, DaemonService.class));
90
+ @@ -29,9 +32,15 @@
82
91
@Override
83
92
public void onCreate() {
84
93
super.onCreate();
85
- + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
94
+ + ForegroundNotificationDelegate foregroundNotificationDelegate = VirtualCore.get().foregroundNotificationDelegate;
95
+ + if (foregroundNotificationDelegate == null) {
86
96
- startService(new Intent(this, InnerService.class));
87
- + startService(new Intent(this, InnerService.class));
88
97
- startForeground(NOTIFY_ID, new Notification());
89
- + ForegroundNotificationDelegate foregroundNotificationDelegate = VirtualCore.get().foregroundNotificationDelegate;
90
- + startForeground(NOTIFY_ID, foregroundNotificationDelegate == null ? new Notification() : foregroundNotificationDelegate.getNotification());
91
-
98
+ + startService(new Intent(this, InnerService.class));
99
+ + startForeground(NOTIFY_ID, new Notification());
100
+ -
101
+ + } else if (foregroundNotificationDelegate.isEnable()) {
102
+ + startForeground(NOTIFY_ID, foregroundNotificationDelegate.getNotification());
103
+ + if (foregroundNotificationDelegate.isTryToHide())
104
+ + startService(new Intent(this, InnerService.class));
105
+ + }
92
106
}
93
107
108
+ @Override
109
+ @@ -41,14 +50,14 @@
110
+
111
+ public static final class InnerService extends BaseService {
112
+
113
+ - @Override
114
+ - public int onStartCommand(Intent intent, int flags, int startId) {
115
+ - startForeground(NOTIFY_ID, new Notification());
116
+ - stopForeground(true);
117
+ - stopSelf();
118
+ - return super.onStartCommand(intent, flags, startId);
119
+ - }
120
+ - }
121
+ + @Override
122
+ + public int onStartCommand(Intent intent, int flags, int startId) {
123
+ + startForeground(NOTIFY_ID, new Notification());
124
+ + stopForeground(true);
125
+ + stopSelf();
126
+ + return super.onStartCommand(intent, flags, startId);
127
+ + }
128
+ + }
129
+
130
+
131
+ }
94
132
Index: lib/src/main/java/com/lody/virtual/client/VClientImpl.java
95
133
IDEA additional info:
96
134
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
@@ -126,7 +164,7 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
126
164
===================================================================
127
165
--- lib/src/main/java/com/lody/virtual/client/hook/patchs/notification/compat/RemoteViewsUtils.java (revision 30d07f02ec29ccecfacbd2c627394a71565fb665)
128
166
+++ lib/src/main/java/com/lody/virtual/client/hook/patchs/notification/compat/RemoteViewsUtils.java (revision )
129
- @@ -115,14 +115,9 @@
167
+ @@ -115,16 +115,11 @@
130
168
}
131
169
int mode;
132
170
// TODO 各种适配
@@ -141,25 +179,34 @@ Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
141
179
- mCache.layout(0, 0, width, height);
142
180
+ mCache.layout(0, 0, mCache.getMeasuredWidth(), mCache.getMeasuredHeight());
143
181
VLog.i(TAG, "notification:systemId=" + systemId + ",max=%d/%d, szie=%d/%d", width, height,
144
- mCache.getMeasuredWidth(), mCache.getMeasuredHeight());
182
+ - mCache.getMeasuredWidth(), mCache.getMeasuredHeight());
183
+ + width, mCache.getMeasuredHeight());
145
184
// 打印action
185
+ // logActions(remoteViews, view1);
186
+ return mCache;
146
187
Index: lib/src/main/java/com/lody/virtual/client/hook/delegate/ForegroundNotificationDelegate.java
147
188
IDEA additional info:
148
189
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
149
190
<+>UTF-8
150
191
===================================================================
151
192
--- lib/src/main/java/com/lody/virtual/client/hook/delegate/ForegroundNotificationDelegate.java (revision )
152
193
+++ lib/src/main/java/com/lody/virtual/client/hook/delegate/ForegroundNotificationDelegate.java (revision )
153
- @@ -0,0 +1,9 @@
194
+ @@ -0,0 +1,14 @@
154
195
+ package com.lody.virtual.client.hook.delegate;
155
196
+
156
197
+ import android.app.Notification;
157
198
+
158
199
+ public interface ForegroundNotificationDelegate {
200
+ +
159
201
+ Notification getNotification();
160
202
+
203
+ + boolean isEnable();
204
+ +
205
+ + boolean isTryToHide();
206
+ +
161
207
+ String getGroup(String orig);
162
208
+ }
209
+ \ No newline at end of file
163
210
Index: lib/src/main/java/com/lody/virtual/client/core/VirtualCore.java
164
211
IDEA additional info:
165
212
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
0 commit comments