Compare commits

..

6 Commits

Author SHA1 Message Date
2dust 3c9c9b5a4c Merge pull request #531 from yuhan6665/emui-notification
Fix notification for Emui 4.1
2020-08-06 20:40:45 +08:00
2dust e13024d6bb Merge pull request #526 from Vixb1122/master
exclude ScSwitchActivity from recent list
2020-08-06 20:39:08 +08:00
2dust 9d58edd31f Merge pull request #537 from yuhan6665/revert
Revert "Refresh prepared domain every 30 minutes"
2020-08-06 20:38:50 +08:00
yuhan6665 af7dfc3a43 Revert "Refresh prepared domain every 30 minutes"
This reverts commit 903352ec9c.
2020-08-05 20:22:01 -04:00
yuhan6665 ca554e6ac4 Fix notification for Emui 4.1 2020-08-02 08:42:04 -04:00
xuezhixin ec391d8689 exclude ScSwitchActivity from recent list 2020-07-29 16:47:40 +08:00
5 changed files with 17 additions and 15 deletions
+5 -10
View File
@@ -24,7 +24,6 @@ type resolved struct {
domain string domain string
IPs []net.IP IPs []net.IP
Port int Port int
lastResolved time.Time
ipIdx uint8 ipIdx uint8
ipLock sync.Mutex ipLock sync.Mutex
lastSwitched time.Time lastSwitched time.Time
@@ -98,7 +97,7 @@ func (d *ProtectedDialer) PrepareResolveChan() {
d.resolveChan = make(chan struct{}) d.resolveChan = make(chan struct{})
} }
func (d *ProtectedDialer) ResolveChan() chan struct{} { func (d *ProtectedDialer) ResolveChan() <-chan struct{} {
return d.resolveChan return d.resolveChan
} }
@@ -138,10 +137,9 @@ func (d *ProtectedDialer) lookupAddr(addr string) (*resolved, error) {
} }
rs := &resolved{ rs := &resolved{
domain: host, domain: host,
IPs: IPs, IPs: IPs,
Port: portnum, Port: portnum,
lastResolved: time.Now(),
} }
return rs, nil return rs, nil
@@ -152,6 +150,7 @@ func (d *ProtectedDialer) PrepareDomain(domainName string, closeCh <-chan struct
log.Printf("Preparing Domain: %s", domainName) log.Printf("Preparing Domain: %s", domainName)
d.currentServer = domainName d.currentServer = domainName
defer close(d.resolveChan)
maxRetry := 10 maxRetry := 10
for { for {
if maxRetry == 0 { if maxRetry == 0 {
@@ -213,10 +212,6 @@ func (d *ProtectedDialer) Dial(ctx context.Context,
} }
} }
if time.Now().Sub(d.vServer.lastResolved) > time.Minute * 30 {
d.PrepareDomain(Address, nil)
}
fd, err := d.getFd(dest.Network) fd, err := d.getFd(dest.Network)
if err != nil { if err != nil {
return nil, err return nil, err
+1 -4
View File
@@ -71,10 +71,7 @@ func (v *V2RayPoint) RunLoop() (err error) {
if !v.status.IsRunning { if !v.status.IsRunning {
v.closeChan = make(chan struct{}) v.closeChan = make(chan struct{})
v.dialer.PrepareResolveChan() v.dialer.PrepareResolveChan()
go func() { go v.dialer.PrepareDomain(v.DomainName, v.closeChan)
v.dialer.PrepareDomain(v.DomainName, v.closeChan)
close(v.dialer.ResolveChan())
}()
go func() { go func() {
select { select {
// wait until resolved // wait until resolved
+4 -1
View File
@@ -76,7 +76,10 @@
<activity android:name=".ui.SubEditActivity" /> <activity android:name=".ui.SubEditActivity" />
<activity android:name=".ui.ScScannerActivity" /> <activity android:name=".ui.ScScannerActivity" />
<activity android:name=".ui.ScSwitchActivity" /> <activity
android:name=".ui.ScSwitchActivity"
android:excludeFromRecents="true"
android:theme="@style/AppTheme.NoActionBar.Translucent" />
<service <service
android:name=".service.V2RayVpnService" android:name=".service.V2RayVpnService"
@@ -384,6 +384,7 @@ class V2RayVpnService : VpnService() {
mBuilder?.setSmallIcon(R.drawable.ic_stat_direct) mBuilder?.setSmallIcon(R.drawable.ic_stat_direct)
} }
mBuilder?.setStyle(NotificationCompat.BigTextStyle().bigText(contentText)) mBuilder?.setStyle(NotificationCompat.BigTextStyle().bigText(contentText))
mBuilder?.setContentText(contentText) // Emui4.1 need content text even if style is set as BigTextStyle
getNotificationManager().notify(NOTIFICATION_ID, mBuilder?.build()) getNotificationManager().notify(NOTIFICATION_ID, mBuilder?.build())
} }
} }
@@ -13,6 +13,12 @@
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
</style> </style>
<style name="AppTheme.NoActionBar.Translucent">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />