San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _VOLUMEMANAGER_H |
| 18 | #define _VOLUMEMANAGER_H |
| 19 | |
| 20 | #include <pthread.h> |
| 21 | |
| 22 | #include <utils/List.h> |
| 23 | #include <sysutils/SocketListener.h> |
| 24 | |
| 25 | #include "BlockDevice.h" |
| 26 | #include "Volume.h" |
| 27 | |
| 28 | class VolumeManager { |
| 29 | private: |
| 30 | static VolumeManager *sInstance; |
| 31 | |
| 32 | private: |
| 33 | SocketListener *mBroadcaster; |
| 34 | BlockDeviceCollection *mBlockDevices; |
| 35 | |
| 36 | VolumeCollection *mVolumes; |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 37 | bool mUsbMassStorageConnected; |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 38 | |
| 39 | public: |
| 40 | virtual ~VolumeManager(); |
| 41 | |
| 42 | int start(); |
| 43 | int stop(); |
| 44 | |
San Mehat | fd7f587 | 2009-10-12 11:32:47 -0700 | [diff] [blame] | 45 | void handleBlockEvent(NetlinkEvent *evt); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 46 | void handleSwitchEvent(NetlinkEvent *evt); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 47 | |
| 48 | int addVolume(Volume *v); |
| 49 | |
| 50 | int listVolumes(SocketClient *cli); |
San Mehat | 49e2bce | 2009-10-12 16:29:01 -0700 | [diff] [blame] | 51 | int mountVolume(const char *label); |
| 52 | int unmountVolume(const char *label); |
San Mehat | a2677e4 | 2009-12-13 10:40:18 -0800 | [diff] [blame] | 53 | int shareVolume(const char *label, const char *method); |
| 54 | int unshareVolume(const char *label, const char *method); |
| 55 | int shareAvailable(const char *method, bool *avail); |
| 56 | int simulate(const char *cmd, const char *arg); |
| 57 | int formatVolume(const char *label); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 58 | |
San Mehat | 0cde53c | 2009-12-22 08:32:33 -0800 | [diff] [blame^] | 59 | // XXX: This should be moved private once switch uevents are working |
| 60 | void notifyUmsConnected(bool connected); |
| 61 | |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 62 | void setBroadcaster(SocketListener *sl) { mBroadcaster = sl; } |
| 63 | SocketListener *getBroadcaster() { return mBroadcaster; } |
| 64 | |
| 65 | static VolumeManager *Instance(); |
| 66 | |
| 67 | private: |
| 68 | VolumeManager(); |
San Mehat | 49e2bce | 2009-10-12 16:29:01 -0700 | [diff] [blame] | 69 | Volume *lookupVolume(const char *label); |
San Mehat | f1b736b | 2009-10-10 17:22:08 -0700 | [diff] [blame] | 70 | }; |
| 71 | #endif |