mirror of
https://github.com/ARM-software/devlib.git
synced 2025-02-12 07:58:07 +00:00
AndroidTarget: Port methods for refreshing target files
Adds a method to determine the appropriate method of triggering a media refresh of a given list of file based on the devices android version and root status. If a device is running android marshmallow and below or has root, trigger a refresh of the files containing folder otherwise trigger a refresh of each individual file.
This commit is contained in:
parent
405c155b96
commit
0390c9d26b
@ -15,8 +15,9 @@ from devlib.platform import Platform
|
|||||||
from devlib.exception import TargetError, TargetNotRespondingError, TimeoutError
|
from devlib.exception import TargetError, TargetNotRespondingError, TimeoutError
|
||||||
from devlib.utils.ssh import SshConnection
|
from devlib.utils.ssh import SshConnection
|
||||||
from devlib.utils.android import AdbConnection, AndroidProperties, LogcatMonitor, adb_command, adb_disconnect
|
from devlib.utils.android import AdbConnection, AndroidProperties, LogcatMonitor, adb_command, adb_disconnect
|
||||||
from devlib.utils.misc import memoized, isiterable, convert_new_lines, merge_lists
|
from devlib.utils.misc import memoized, isiterable, convert_new_lines
|
||||||
from devlib.utils.misc import ABI_MAP, get_cpu_name, ranges_to_list, escape_double_quotes
|
from devlib.utils.misc import commonprefix, escape_double_quotes, merge_lists
|
||||||
|
from devlib.utils.misc import ABI_MAP, get_cpu_name, ranges_to_list
|
||||||
from devlib.utils.types import integer, boolean, bitmask, identifier, caseless_string
|
from devlib.utils.types import integer, boolean, bitmask, identifier, caseless_string
|
||||||
|
|
||||||
|
|
||||||
@ -1213,6 +1214,33 @@ class AndroidTarget(Target):
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def refresh_files(self, file_list):
|
||||||
|
"""
|
||||||
|
Depending on the android version and root status, determine the
|
||||||
|
appropriate method of forcing a re-index of the mediaserver cache for a given
|
||||||
|
list of files.
|
||||||
|
"""
|
||||||
|
if self.is_rooted or self.get_sdk_version() < 24: # MM and below
|
||||||
|
common_path = commonprefix(file_list, sep=self.path.sep)
|
||||||
|
self.broadcast_media_mounted(common_path, self.is_rooted)
|
||||||
|
else:
|
||||||
|
for f in file_list:
|
||||||
|
self.broadcast_media_scan_file(f)
|
||||||
|
|
||||||
|
def broadcast_media_scan_file(self, filepath):
|
||||||
|
"""
|
||||||
|
Force a re-index of the mediaserver cache for the specified file.
|
||||||
|
"""
|
||||||
|
command = 'am broadcast -a android.intent.action.MEDIA_SCANNER_SCAN_FILE -d file://'
|
||||||
|
self.execute(command + filepath)
|
||||||
|
|
||||||
|
def broadcast_media_mounted(self, dirpath, as_root=False):
|
||||||
|
"""
|
||||||
|
Force a re-index of the mediaserver cache for the specified directory.
|
||||||
|
"""
|
||||||
|
command = 'am broadcast -a android.intent.action.MEDIA_MOUNTED -d file://'
|
||||||
|
self.execute(command + dirpath, as_root=as_root)
|
||||||
|
|
||||||
def install_executable(self, filepath, with_name=None):
|
def install_executable(self, filepath, with_name=None):
|
||||||
self._ensure_executables_directory_is_writable()
|
self._ensure_executables_directory_is_writable()
|
||||||
executable_name = with_name or os.path.basename(filepath)
|
executable_name = with_name or os.path.basename(filepath)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user