Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
system_vold
Commits
6b715592
Commit
6b715592
authored
13 years ago
by
Mike Lockwood
Committed by
Android (Google) Code Review
13 years ago
Browse files
Options
Download
Plain Diff
Merge "Remove obsolete code for monitoring USB status"
parents
86bccb14
a976656f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
172 deletions
+0
-172
CommandListener.cpp
CommandListener.cpp
+0
-34
CommandListener.h
CommandListener.h
+0
-7
NetlinkHandler.cpp
NetlinkHandler.cpp
+0
-6
VolumeManager.cpp
VolumeManager.cpp
+0
-116
VolumeManager.h
VolumeManager.h
+0
-9
No files found.
CommandListener.cpp
View file @
6b715592
...
...
@@ -44,7 +44,6 @@ CommandListener::CommandListener() :
registerCmd
(
new
VolumeCmd
());
registerCmd
(
new
AsecCmd
());
registerCmd
(
new
ObbCmd
());
registerCmd
(
new
ShareCmd
());
registerCmd
(
new
StorageCmd
());
registerCmd
(
new
XwarpCmd
());
registerCmd
(
new
CryptfsCmd
());
...
...
@@ -200,39 +199,6 @@ int CommandListener::VolumeCmd::runCommand(SocketClient *cli,
return
0
;
}
CommandListener
::
ShareCmd
::
ShareCmd
()
:
VoldCommand
(
"share"
)
{
}
int
CommandListener
::
ShareCmd
::
runCommand
(
SocketClient
*
cli
,
int
argc
,
char
**
argv
)
{
dumpArgs
(
argc
,
argv
,
-
1
);
if
(
argc
<
2
)
{
cli
->
sendMsg
(
ResponseCode
::
CommandSyntaxError
,
"Missing Argument"
,
false
);
return
0
;
}
VolumeManager
*
vm
=
VolumeManager
::
Instance
();
int
rc
=
0
;
if
(
!
strcmp
(
argv
[
1
],
"status"
))
{
bool
avail
=
false
;
if
(
vm
->
shareAvailable
(
argv
[
2
],
&
avail
))
{
cli
->
sendMsg
(
ResponseCode
::
OperationFailed
,
"Failed to determine share availability"
,
true
);
}
else
{
cli
->
sendMsg
(
ResponseCode
::
ShareStatusResult
,
(
avail
?
"Share available"
:
"Share unavailable"
),
false
);
}
}
else
{
cli
->
sendMsg
(
ResponseCode
::
CommandSyntaxError
,
"Unknown share cmd"
,
false
);
}
return
0
;
}
CommandListener
::
StorageCmd
::
StorageCmd
()
:
VoldCommand
(
"storage"
)
{
}
...
...
This diff is collapsed.
Click to expand it.
CommandListener.h
View file @
6b715592
...
...
@@ -42,13 +42,6 @@ private:
int
runCommand
(
SocketClient
*
c
,
int
argc
,
char
**
argv
);
};
class
ShareCmd
:
public
VoldCommand
{
public:
ShareCmd
();
virtual
~
ShareCmd
()
{}
int
runCommand
(
SocketClient
*
c
,
int
argc
,
char
**
argv
);
};
class
AsecCmd
:
public
VoldCommand
{
public:
AsecCmd
();
...
...
This diff is collapsed.
Click to expand it.
NetlinkHandler.cpp
View file @
6b715592
...
...
@@ -53,11 +53,5 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
if
(
!
strcmp
(
subsys
,
"block"
))
{
vm
->
handleBlockEvent
(
evt
);
}
else
if
(
!
strcmp
(
subsys
,
"switch"
))
{
vm
->
handleSwitchEvent
(
evt
);
}
else
if
(
!
strcmp
(
subsys
,
"usb_composite"
))
{
vm
->
handleUsbCompositeEvent
(
evt
);
}
else
if
(
!
strcmp
(
subsys
,
"battery"
))
{
}
else
if
(
!
strcmp
(
subsys
,
"power_supply"
))
{
}
}
This diff is collapsed.
Click to expand it.
VolumeManager.cpp
View file @
6b715592
...
...
@@ -56,47 +56,10 @@ VolumeManager::VolumeManager() {
mVolumes
=
new
VolumeCollection
();
mActiveContainers
=
new
AsecIdCollection
();
mBroadcaster
=
NULL
;
mUsbMassStorageEnabled
=
false
;
mUsbConnected
=
false
;
mUmsSharingCount
=
0
;
mSavedDirtyRatio
=
-
1
;
// set dirty ratio to 0 when UMS is active
mUmsDirtyRatio
=
0
;
readInitialState
();
}
void
VolumeManager
::
readInitialState
()
{
FILE
*
fp
;
char
state
[
255
];
/*
* Read the initial mass storage enabled state
*/
if
((
fp
=
fopen
(
"/sys/devices/virtual/usb_composite/usb_mass_storage/enable"
,
"r"
)))
{
if
(
fgets
(
state
,
sizeof
(
state
),
fp
))
{
mUsbMassStorageEnabled
=
!
strncmp
(
state
,
"1"
,
1
);
}
else
{
SLOGE
(
"Failed to read usb_mass_storage enabled state (%s)"
,
strerror
(
errno
));
}
fclose
(
fp
);
}
else
{
SLOGD
(
"USB mass storage support is not enabled in the kernel"
);
}
/*
* Read the initial USB connected state
*/
if
((
fp
=
fopen
(
"/sys/devices/virtual/switch/usb_configuration/state"
,
"r"
)))
{
if
(
fgets
(
state
,
sizeof
(
state
),
fp
))
{
mUsbConnected
=
!
strncmp
(
state
,
"1"
,
1
);
}
else
{
SLOGE
(
"Failed to read usb_configuration switch (%s)"
,
strerror
(
errno
));
}
fclose
(
fp
);
}
else
{
SLOGD
(
"usb_configuration switch is not enabled in the kernel"
);
}
}
VolumeManager
::~
VolumeManager
()
{
...
...
@@ -157,56 +120,6 @@ int VolumeManager::addVolume(Volume *v) {
return
0
;
}
void
VolumeManager
::
notifyUmsAvailable
(
bool
available
)
{
char
msg
[
255
];
snprintf
(
msg
,
sizeof
(
msg
),
"Share method ums now %s"
,
(
available
?
"available"
:
"unavailable"
));
SLOGD
(
msg
);
getBroadcaster
()
->
sendBroadcast
(
ResponseCode
::
ShareAvailabilityChange
,
msg
,
false
);
}
void
VolumeManager
::
handleSwitchEvent
(
NetlinkEvent
*
evt
)
{
const
char
*
devpath
=
evt
->
findParam
(
"DEVPATH"
);
const
char
*
name
=
evt
->
findParam
(
"SWITCH_NAME"
);
const
char
*
state
=
evt
->
findParam
(
"SWITCH_STATE"
);
if
(
!
name
||
!
state
)
{
SLOGW
(
"Switch %s event missing name/state info"
,
devpath
);
return
;
}
bool
oldAvailable
=
massStorageAvailable
();
if
(
!
strcmp
(
name
,
"usb_configuration"
))
{
mUsbConnected
=
!
strcmp
(
state
,
"1"
);
SLOGD
(
"USB %s"
,
mUsbConnected
?
"connected"
:
"disconnected"
);
bool
newAvailable
=
massStorageAvailable
();
if
(
newAvailable
!=
oldAvailable
)
{
notifyUmsAvailable
(
newAvailable
);
}
}
}
void
VolumeManager
::
handleUsbCompositeEvent
(
NetlinkEvent
*
evt
)
{
const
char
*
function
=
evt
->
findParam
(
"FUNCTION"
);
const
char
*
enabled
=
evt
->
findParam
(
"ENABLED"
);
if
(
!
function
||
!
enabled
)
{
SLOGW
(
"usb_composite event missing function/enabled info"
);
return
;
}
if
(
!
strcmp
(
function
,
"usb_mass_storage"
))
{
bool
oldAvailable
=
massStorageAvailable
();
mUsbMassStorageEnabled
=
!
strcmp
(
enabled
,
"1"
);
SLOGD
(
"usb_mass_storage function %s"
,
mUsbMassStorageEnabled
?
"enabled"
:
"disabled"
);
bool
newAvailable
=
massStorageAvailable
();
if
(
newAvailable
!=
oldAvailable
)
{
notifyUmsAvailable
(
newAvailable
);
}
}
}
void
VolumeManager
::
handleBlockEvent
(
NetlinkEvent
*
evt
)
{
const
char
*
devpath
=
evt
->
findParam
(
"DEVPATH"
);
...
...
@@ -961,17 +874,6 @@ int VolumeManager::listMountedObbs(SocketClient* cli) {
return
0
;
}
int
VolumeManager
::
shareAvailable
(
const
char
*
method
,
bool
*
avail
)
{
if
(
strcmp
(
method
,
"ums"
))
{
errno
=
ENOSYS
;
return
-
1
;
}
*
avail
=
massStorageAvailable
();
return
0
;
}
int
VolumeManager
::
shareEnabled
(
const
char
*
label
,
const
char
*
method
,
bool
*
enabled
)
{
Volume
*
v
=
lookupVolume
(
label
);
...
...
@@ -993,24 +895,6 @@ int VolumeManager::shareEnabled(const char *label, const char *method, bool *ena
return
0
;
}
int
VolumeManager
::
simulate
(
const
char
*
cmd
,
const
char
*
arg
)
{
if
(
!
strcmp
(
cmd
,
"ums"
))
{
if
(
!
strcmp
(
arg
,
"connect"
))
{
notifyUmsAvailable
(
true
);
}
else
if
(
!
strcmp
(
arg
,
"disconnect"
))
{
notifyUmsAvailable
(
false
);
}
else
{
errno
=
EINVAL
;
return
-
1
;
}
}
else
{
errno
=
EINVAL
;
return
-
1
;
}
return
0
;
}
int
VolumeManager
::
shareVolume
(
const
char
*
label
,
const
char
*
method
)
{
Volume
*
v
=
lookupVolume
(
label
);
...
...
This diff is collapsed.
Click to expand it.
VolumeManager.h
View file @
6b715592
...
...
@@ -59,8 +59,6 @@ private:
VolumeCollection
*
mVolumes
;
AsecIdCollection
*
mActiveContainers
;
bool
mUsbMassStorageEnabled
;
bool
mUsbConnected
;
bool
mDebug
;
// for adjusting /proc/sys/vm/dirty_ratio when UMS is active
...
...
@@ -75,8 +73,6 @@ public:
int
stop
();
void
handleBlockEvent
(
NetlinkEvent
*
evt
);
void
handleSwitchEvent
(
NetlinkEvent
*
evt
);
void
handleUsbCompositeEvent
(
NetlinkEvent
*
evt
);
int
addVolume
(
Volume
*
v
);
...
...
@@ -85,9 +81,7 @@ public:
int
unmountVolume
(
const
char
*
label
,
bool
force
);
int
shareVolume
(
const
char
*
label
,
const
char
*
method
);
int
unshareVolume
(
const
char
*
label
,
const
char
*
method
);
int
shareAvailable
(
const
char
*
method
,
bool
*
avail
);
int
shareEnabled
(
const
char
*
path
,
const
char
*
method
,
bool
*
enabled
);
int
simulate
(
const
char
*
cmd
,
const
char
*
arg
);
int
formatVolume
(
const
char
*
label
);
/* ASEC */
...
...
@@ -130,9 +124,6 @@ private:
VolumeManager
();
void
readInitialState
();
bool
isMountpointMounted
(
const
char
*
mp
);
inline
bool
massStorageAvailable
()
const
{
return
mUsbMassStorageEnabled
&&
mUsbConnected
;
}
void
notifyUmsAvailable
(
bool
available
);
};
extern
"C"
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment