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 #include <stdint.h> 18 #include <sys/types.h> 19 20 #include <binder/Parcel.h> 21 22 #include <hardware_legacy/IMountService.h> 23 24 namespace android { 25 26 enum { 27 GET_MASS_STORAGE_ENABLED_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION, 28 SET_MASS_STORAGE_ENABLED_TRANSACTION, 29 GET_MASS_STORAGE_CONNECTED_TRANSACTION, 30 MOUNT_MEDIA_TRANSACTION, 31 UNMOUNT_MEDIA_TRANSACTION, 32 FORMAT_MEDIA_TRANSACTION, 33 SET_PLAY_NOTIFICATION_SOUNDS_TRANSACTION, 34 GET_PLAY_NOTIFICATION_SOUNDS_TRANSACTION, 35 }; 36 37 class BpMountService : public BpInterface<IMountService> 38 { 39 public: BpMountService(const sp<IBinder> & impl)40 BpMountService(const sp<IBinder>& impl) 41 : BpInterface<IMountService>(impl) 42 { 43 } 44 getMassStorageEnabled()45 virtual bool getMassStorageEnabled() 46 { 47 uint32_t n; 48 Parcel data, reply; 49 data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); 50 remote()->transact(GET_MASS_STORAGE_ENABLED_TRANSACTION, data, &reply); 51 return reply.readInt32(); 52 } 53 setMassStorageEnabled(bool enabled)54 virtual void setMassStorageEnabled(bool enabled) 55 { 56 Parcel data, reply; 57 data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); 58 data.writeInt32(enabled ? 1 : 0); 59 remote()->transact(SET_MASS_STORAGE_ENABLED_TRANSACTION, data, &reply); 60 } 61 getMassStorageConnected()62 virtual bool getMassStorageConnected() 63 { 64 uint32_t n; 65 Parcel data, reply; 66 data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); 67 remote()->transact(GET_MASS_STORAGE_CONNECTED_TRANSACTION, data, &reply); 68 return reply.readInt32(); 69 } 70 mountMedia(String16 mountPoint)71 virtual void mountMedia(String16 mountPoint) 72 { 73 Parcel data, reply; 74 data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); 75 data.writeString16(mountPoint); 76 remote()->transact(MOUNT_MEDIA_TRANSACTION, data, &reply); 77 } 78 unmountMedia(String16 mountPoint)79 virtual void unmountMedia(String16 mountPoint) 80 { 81 Parcel data, reply; 82 data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); 83 data.writeString16(mountPoint); 84 remote()->transact(UNMOUNT_MEDIA_TRANSACTION, data, &reply); 85 } 86 formatMedia(String16 mountPoint)87 virtual void formatMedia(String16 mountPoint) 88 { 89 Parcel data, reply; 90 data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); 91 data.writeString16(mountPoint); 92 remote()->transact(FORMAT_MEDIA_TRANSACTION, data, &reply); 93 } 94 getPlayNotificationSounds()95 virtual bool getPlayNotificationSounds() 96 { 97 uint32_t n; 98 Parcel data, reply; 99 data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); 100 remote()->transact(GET_PLAY_NOTIFICATION_SOUNDS_TRANSACTION, data, &reply); 101 return reply.readInt32(); 102 } 103 setPlayNotificationSounds(bool enabled)104 virtual void setPlayNotificationSounds(bool enabled) 105 { 106 Parcel data, reply; 107 data.writeInterfaceToken(IMountService::getInterfaceDescriptor()); 108 data.writeInt32(enabled ? 1 : 0); 109 remote()->transact(SET_PLAY_NOTIFICATION_SOUNDS_TRANSACTION, data, &reply); 110 } 111 112 113 }; 114 115 IMPLEMENT_META_INTERFACE(MountService, "android.os.IMountService"); 116 117 118 }; 119