Skip to content

Commit a976656

Browse files
committed
Remove obsolete code for monitoring USB status
Change-Id: I8ac8900b3135f03b7717540b825ff6df76f31c0b Signed-off-by: Mike Lockwood <[email protected]>
1 parent 29d8da8 commit a976656

5 files changed

+0
-172
lines changed

CommandListener.cpp

-34
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ CommandListener::CommandListener() :
4444
registerCmd(new VolumeCmd());
4545
registerCmd(new AsecCmd());
4646
registerCmd(new ObbCmd());
47-
registerCmd(new ShareCmd());
4847
registerCmd(new StorageCmd());
4948
registerCmd(new XwarpCmd());
5049
registerCmd(new CryptfsCmd());
@@ -200,39 +199,6 @@ int CommandListener::VolumeCmd::runCommand(SocketClient *cli,
200199
return 0;
201200
}
202201

203-
CommandListener::ShareCmd::ShareCmd() :
204-
VoldCommand("share") {
205-
}
206-
207-
int CommandListener::ShareCmd::runCommand(SocketClient *cli,
208-
int argc, char **argv) {
209-
dumpArgs(argc, argv, -1);
210-
211-
if (argc < 2) {
212-
cli->sendMsg(ResponseCode::CommandSyntaxError, "Missing Argument", false);
213-
return 0;
214-
}
215-
216-
VolumeManager *vm = VolumeManager::Instance();
217-
int rc = 0;
218-
219-
if (!strcmp(argv[1], "status")) {
220-
bool avail = false;
221-
222-
if (vm->shareAvailable(argv[2], &avail)) {
223-
cli->sendMsg(
224-
ResponseCode::OperationFailed, "Failed to determine share availability", true);
225-
} else {
226-
cli->sendMsg(ResponseCode::ShareStatusResult,
227-
(avail ? "Share available" : "Share unavailable"), false);
228-
}
229-
} else {
230-
cli->sendMsg(ResponseCode::CommandSyntaxError, "Unknown share cmd", false);
231-
}
232-
233-
return 0;
234-
}
235-
236202
CommandListener::StorageCmd::StorageCmd() :
237203
VoldCommand("storage") {
238204
}

CommandListener.h

-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ class CommandListener : public FrameworkListener {
4242
int runCommand(SocketClient *c, int argc, char ** argv);
4343
};
4444

45-
class ShareCmd : public VoldCommand {
46-
public:
47-
ShareCmd();
48-
virtual ~ShareCmd() {}
49-
int runCommand(SocketClient *c, int argc, char ** argv);
50-
};
51-
5245
class AsecCmd : public VoldCommand {
5346
public:
5447
AsecCmd();

NetlinkHandler.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,5 @@ void NetlinkHandler::onEvent(NetlinkEvent *evt) {
5353

5454
if (!strcmp(subsys, "block")) {
5555
vm->handleBlockEvent(evt);
56-
} else if (!strcmp(subsys, "switch")) {
57-
vm->handleSwitchEvent(evt);
58-
} else if (!strcmp(subsys, "usb_composite")) {
59-
vm->handleUsbCompositeEvent(evt);
60-
} else if (!strcmp(subsys, "battery")) {
61-
} else if (!strcmp(subsys, "power_supply")) {
6256
}
6357
}

VolumeManager.cpp

-116
Original file line numberDiff line numberDiff line change
@@ -56,47 +56,10 @@ VolumeManager::VolumeManager() {
5656
mVolumes = new VolumeCollection();
5757
mActiveContainers = new AsecIdCollection();
5858
mBroadcaster = NULL;
59-
mUsbMassStorageEnabled = false;
60-
mUsbConnected = false;
6159
mUmsSharingCount = 0;
6260
mSavedDirtyRatio = -1;
6361
// set dirty ratio to 0 when UMS is active
6462
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-
}
10063
}
10164

10265
VolumeManager::~VolumeManager() {
@@ -157,56 +120,6 @@ int VolumeManager::addVolume(Volume *v) {
157120
return 0;
158121
}
159122

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-
210123
void VolumeManager::handleBlockEvent(NetlinkEvent *evt) {
211124
const char *devpath = evt->findParam("DEVPATH");
212125

@@ -961,17 +874,6 @@ int VolumeManager::listMountedObbs(SocketClient* cli) {
961874
return 0;
962875
}
963876

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-
975877
int VolumeManager::shareEnabled(const char *label, const char *method, bool *enabled) {
976878
Volume *v = lookupVolume(label);
977879

@@ -993,24 +895,6 @@ int VolumeManager::shareEnabled(const char *label, const char *method, bool *ena
993895
return 0;
994896
}
995897

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-
1014898
int VolumeManager::shareVolume(const char *label, const char *method) {
1015899
Volume *v = lookupVolume(label);
1016900

VolumeManager.h

-9
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ class VolumeManager {
5959

6060
VolumeCollection *mVolumes;
6161
AsecIdCollection *mActiveContainers;
62-
bool mUsbMassStorageEnabled;
63-
bool mUsbConnected;
6462
bool mDebug;
6563

6664
// for adjusting /proc/sys/vm/dirty_ratio when UMS is active
@@ -75,8 +73,6 @@ class VolumeManager {
7573
int stop();
7674

7775
void handleBlockEvent(NetlinkEvent *evt);
78-
void handleSwitchEvent(NetlinkEvent *evt);
79-
void handleUsbCompositeEvent(NetlinkEvent *evt);
8076

8177
int addVolume(Volume *v);
8278

@@ -85,9 +81,7 @@ class VolumeManager {
8581
int unmountVolume(const char *label, bool force);
8682
int shareVolume(const char *label, const char *method);
8783
int unshareVolume(const char *label, const char *method);
88-
int shareAvailable(const char *method, bool *avail);
8984
int shareEnabled(const char *path, const char *method, bool *enabled);
90-
int simulate(const char *cmd, const char *arg);
9185
int formatVolume(const char *label);
9286

9387
/* ASEC */
@@ -130,9 +124,6 @@ class VolumeManager {
130124
VolumeManager();
131125
void readInitialState();
132126
bool isMountpointMounted(const char *mp);
133-
134-
inline bool massStorageAvailable() const { return mUsbMassStorageEnabled && mUsbConnected; }
135-
void notifyUmsAvailable(bool available);
136127
};
137128

138129
extern "C" {

0 commit comments

Comments
 (0)