Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
42107a85
Commit
42107a85
authored
7 years ago
by
Geoffrey Métais
Browse files
Options
Downloads
Patches
Plain Diff
Scanning service stop triggered by ML idling
parent
f751ea68
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+5
-0
5 additions, 0 deletions
medialibrary/src/org/videolan/medialibrary/Medialibrary.java
vlc-android/src/org/videolan/vlc/MediaParsingService.java
+16
-16
16 additions, 16 deletions
vlc-android/src/org/videolan/vlc/MediaParsingService.java
with
21 additions
and
16 deletions
medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+
5
−
0
View file @
42107a85
...
...
@@ -2,11 +2,13 @@ package org.videolan.medialibrary;
import
android.Manifest
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.pm.PackageManager
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.content.LocalBroadcastManager
;
import
android.text.TextUtils
;
import
android.util.Log
;
...
...
@@ -41,6 +43,8 @@ public class Medialibrary {
public
static
final
int
FLAG_MEDIA_ADDED_VIDEO
=
1
<<
5
;
private
static
final
String
extDirPath
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
();
public
static
final
String
ACTION_IDLE
=
"action_idle"
;
public
static
final
String
STATE_IDLE
=
"state_idle"
;
private
static
final
MediaWrapper
[]
EMPTY_COLLECTION
=
{};
public
static
final
String
VLC_MEDIA_DB_NAME
=
"/vlc_media.db"
;
...
...
@@ -365,6 +369,7 @@ public class Medialibrary {
}
public
void
onBackgroundTasksIdleChanged
(
boolean
isIdle
)
{
LocalBroadcastManager
.
getInstance
(
mContext
).
sendBroadcast
(
new
Intent
(
ACTION_IDLE
).
putExtra
(
STATE_IDLE
,
isIdle
));
mIsWorking
=
!
isIdle
;
}
...
...
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/MediaParsingService.java
+
16
−
16
View file @
42107a85
...
...
@@ -53,7 +53,6 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
public
static
final
long
NOTIFICATION_DELAY
=
1000L
;
private
PowerManager
.
WakeLock
mWakeLock
;
private
volatile
boolean
initOngoing
=
false
;
private
final
IBinder
mBinder
=
new
LocalBinder
();
private
Medialibrary
mMedialibrary
;
private
int
mParsing
=
0
,
mReload
=
0
;
...
...
@@ -64,26 +63,33 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
new
LinkedBlockingQueue
<
Runnable
>(),
VLCApplication
.
THREAD_FACTORY
);
private
BroadcastReceiver
mReceiver
=
new
BroadcastReceiver
()
{
boolean
paused
=
false
;
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
switch
(
intent
.
getAction
())
{
case
ACTION_PAUSE_SCAN:
if
(
mWakeLock
.
isHeld
())
mWakeLock
.
release
();
paused
=
true
;
mMedialibrary
.
pauseBackgroundOperations
();
break
;
case
ACTION_RESUME_SCAN:
if
(!
mWakeLock
.
isHeld
())
mWakeLock
.
acquire
();
mMedialibrary
.
resumeBackgroundOperations
();
paused
=
false
;
break
;
case
Medialibrary
.
ACTION_IDLE
:
if
(
intent
.
getBooleanExtra
(
Medialibrary
.
STATE_IDLE
,
true
)
&&
!
paused
)
{
stopSelf
();
}
else
{
synchronized
(
this
)
{
mLastNotificationTime
=
0L
;
}
showNotification
();
}
break
;
default
:
return
;
}
synchronized
(
this
)
{
mLastNotificationTime
=
0L
;
}
showNotification
();
}
};
...
...
@@ -96,6 +102,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
filter
.
addAction
(
ACTION_PAUSE_SCAN
);
filter
.
addAction
(
ACTION_RESUME_SCAN
);
registerReceiver
(
mReceiver
,
filter
);
LocalBroadcastManager
.
getInstance
(
this
).
registerReceiver
(
mReceiver
,
new
IntentFilter
(
Medialibrary
.
ACTION_IDLE
));
PowerManager
pm
=
(
PowerManager
)
VLCApplication
.
getAppContext
().
getSystemService
(
Context
.
POWER_SERVICE
);
mWakeLock
=
pm
.
newWakeLock
(
PowerManager
.
PARTIAL_WAKE_LOCK
,
TAG
);
mWakeLock
.
acquire
();
...
...
@@ -186,7 +193,6 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
mThreadPool
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
initOngoing
=
true
;
boolean
shouldInit
=
!(
new
File
(
MediaParsingService
.
this
.
getCacheDir
()+
Medialibrary
.
VLC_MEDIA_DB_NAME
).
exists
());
mMedialibrary
.
setup
();
if
(
mMedialibrary
.
init
(
MediaParsingService
.
this
))
{
...
...
@@ -216,7 +222,6 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
}
else
if
(
upgrade
)
mMedialibrary
.
forceParserRetry
();
}
initOngoing
=
false
;
}
});
}
...
...
@@ -295,17 +300,13 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
@Override
public
void
onDiscoveryCompleted
(
String
entryPoint
)
{
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
"onDiscoveryCompleted: "
+
entryPoint
);
if
(!
initOngoing
&&
!
mMedialibrary
.
isWorking
())
stopSelf
();
}
@Override
public
void
onParsingStatsUpdated
(
int
percent
)
{
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
"onParsingStatsUpdated: "
+
percent
);
mParsing
=
percent
;
if
(
mParsing
==
100
)
stopSelf
();
else
if
(
mParsing
!=
100
)
showNotification
();
}
...
...
@@ -321,8 +322,6 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
if
(
BuildConfig
.
DEBUG
)
Log
.
d
(
TAG
,
"onReloadCompleted "
+
entryPoint
);
if
(
TextUtils
.
isEmpty
(
entryPoint
))
--
mReload
;
if
(!
initOngoing
&&
!
mMedialibrary
.
isWorking
())
stopSelf
();
}
@Override
...
...
@@ -331,6 +330,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
hideNotification
();
mMedialibrary
.
removeDeviceDiscoveryCb
(
this
);
unregisterReceiver
(
mReceiver
);
LocalBroadcastManager
.
getInstance
(
this
).
unregisterReceiver
(
mReceiver
);
if
(
mWakeLock
.
isHeld
())
mWakeLock
.
release
();
super
.
onDestroy
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment