@@ -56,47 +56,10 @@ VolumeManager::VolumeManager() {
56
56
mVolumes = new VolumeCollection ();
57
57
mActiveContainers = new AsecIdCollection ();
58
58
mBroadcaster = NULL ;
59
- mUsbMassStorageEnabled = false ;
60
- mUsbConnected = false ;
61
59
mUmsSharingCount = 0 ;
62
60
mSavedDirtyRatio = -1 ;
63
61
// set dirty ratio to 0 when UMS is active
64
62
mUmsDirtyRatio = 0 ;
65
-
66
- readInitialState ();
67
- }
68
-
69
- void VolumeManager::readInitialState () {
70
- FILE *fp;
71
- char state[255 ];
72
-
73
- /*
74
- * Read the initial mass storage enabled state
75
- */
76
- if ((fp = fopen (" /sys/devices/virtual/usb_composite/usb_mass_storage/enable" , " r" ))) {
77
- if (fgets (state, sizeof (state), fp)) {
78
- mUsbMassStorageEnabled = !strncmp (state, " 1" , 1 );
79
- } else {
80
- SLOGE (" Failed to read usb_mass_storage enabled state (%s)" , strerror (errno));
81
- }
82
- fclose (fp);
83
- } else {
84
- SLOGD (" USB mass storage support is not enabled in the kernel" );
85
- }
86
-
87
- /*
88
- * Read the initial USB connected state
89
- */
90
- if ((fp = fopen (" /sys/devices/virtual/switch/usb_configuration/state" , " r" ))) {
91
- if (fgets (state, sizeof (state), fp)) {
92
- mUsbConnected = !strncmp (state, " 1" , 1 );
93
- } else {
94
- SLOGE (" Failed to read usb_configuration switch (%s)" , strerror (errno));
95
- }
96
- fclose (fp);
97
- } else {
98
- SLOGD (" usb_configuration switch is not enabled in the kernel" );
99
- }
100
63
}
101
64
102
65
VolumeManager::~VolumeManager () {
@@ -157,56 +120,6 @@ int VolumeManager::addVolume(Volume *v) {
157
120
return 0 ;
158
121
}
159
122
160
- void VolumeManager::notifyUmsAvailable (bool available) {
161
- char msg[255 ];
162
-
163
- snprintf (msg, sizeof (msg), " Share method ums now %s" ,
164
- (available ? " available" : " unavailable" ));
165
- SLOGD (msg);
166
- getBroadcaster ()->sendBroadcast (ResponseCode::ShareAvailabilityChange,
167
- msg, false );
168
- }
169
-
170
- void VolumeManager::handleSwitchEvent (NetlinkEvent *evt) {
171
- const char *devpath = evt->findParam (" DEVPATH" );
172
- const char *name = evt->findParam (" SWITCH_NAME" );
173
- const char *state = evt->findParam (" SWITCH_STATE" );
174
-
175
- if (!name || !state) {
176
- SLOGW (" Switch %s event missing name/state info" , devpath);
177
- return ;
178
- }
179
-
180
- bool oldAvailable = massStorageAvailable ();
181
- if (!strcmp (name, " usb_configuration" )) {
182
- mUsbConnected = !strcmp (state, " 1" );
183
- SLOGD (" USB %s" , mUsbConnected ? " connected" : " disconnected" );
184
- bool newAvailable = massStorageAvailable ();
185
- if (newAvailable != oldAvailable) {
186
- notifyUmsAvailable (newAvailable);
187
- }
188
- }
189
- }
190
- void VolumeManager::handleUsbCompositeEvent (NetlinkEvent *evt) {
191
- const char *function = evt->findParam (" FUNCTION" );
192
- const char *enabled = evt->findParam (" ENABLED" );
193
-
194
- if (!function || !enabled) {
195
- SLOGW (" usb_composite event missing function/enabled info" );
196
- return ;
197
- }
198
-
199
- if (!strcmp (function, " usb_mass_storage" )) {
200
- bool oldAvailable = massStorageAvailable ();
201
- mUsbMassStorageEnabled = !strcmp (enabled, " 1" );
202
- SLOGD (" usb_mass_storage function %s" , mUsbMassStorageEnabled ? " enabled" : " disabled" );
203
- bool newAvailable = massStorageAvailable ();
204
- if (newAvailable != oldAvailable) {
205
- notifyUmsAvailable (newAvailable);
206
- }
207
- }
208
- }
209
-
210
123
void VolumeManager::handleBlockEvent (NetlinkEvent *evt) {
211
124
const char *devpath = evt->findParam (" DEVPATH" );
212
125
@@ -961,17 +874,6 @@ int VolumeManager::listMountedObbs(SocketClient* cli) {
961
874
return 0 ;
962
875
}
963
876
964
- int VolumeManager::shareAvailable (const char *method, bool *avail) {
965
-
966
- if (strcmp (method, " ums" )) {
967
- errno = ENOSYS;
968
- return -1 ;
969
- }
970
-
971
- *avail = massStorageAvailable ();
972
- return 0 ;
973
- }
974
-
975
877
int VolumeManager::shareEnabled (const char *label, const char *method, bool *enabled) {
976
878
Volume *v = lookupVolume (label);
977
879
@@ -993,24 +895,6 @@ int VolumeManager::shareEnabled(const char *label, const char *method, bool *ena
993
895
return 0 ;
994
896
}
995
897
996
- int VolumeManager::simulate (const char *cmd, const char *arg) {
997
-
998
- if (!strcmp (cmd, " ums" )) {
999
- if (!strcmp (arg, " connect" )) {
1000
- notifyUmsAvailable (true );
1001
- } else if (!strcmp (arg, " disconnect" )) {
1002
- notifyUmsAvailable (false );
1003
- } else {
1004
- errno = EINVAL;
1005
- return -1 ;
1006
- }
1007
- } else {
1008
- errno = EINVAL;
1009
- return -1 ;
1010
- }
1011
- return 0 ;
1012
- }
1013
-
1014
898
int VolumeManager::shareVolume (const char *label, const char *method) {
1015
899
Volume *v = lookupVolume (label);
1016
900
0 commit comments