1*38e8c45fSAndroid Build Coastguard Worker /* 2*38e8c45fSAndroid Build Coastguard Worker * Copyright (C) 2011 The Android Open Source Project 3*38e8c45fSAndroid Build Coastguard Worker * 4*38e8c45fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*38e8c45fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*38e8c45fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*38e8c45fSAndroid Build Coastguard Worker * 8*38e8c45fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*38e8c45fSAndroid Build Coastguard Worker * 10*38e8c45fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*38e8c45fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*38e8c45fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*38e8c45fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*38e8c45fSAndroid Build Coastguard Worker * limitations under the License. 15*38e8c45fSAndroid Build Coastguard Worker */ 16*38e8c45fSAndroid Build Coastguard Worker 17*38e8c45fSAndroid Build Coastguard Worker #ifndef ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H 18*38e8c45fSAndroid Build Coastguard Worker #define ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H 19*38e8c45fSAndroid Build Coastguard Worker 20*38e8c45fSAndroid Build Coastguard Worker #include <stdint.h> 21*38e8c45fSAndroid Build Coastguard Worker #include <sys/types.h> 22*38e8c45fSAndroid Build Coastguard Worker 23*38e8c45fSAndroid Build Coastguard Worker #include <utils/Singleton.h> 24*38e8c45fSAndroid Build Coastguard Worker #include <utils/StrongPointer.h> 25*38e8c45fSAndroid Build Coastguard Worker 26*38e8c45fSAndroid Build Coastguard Worker 27*38e8c45fSAndroid Build Coastguard Worker namespace android { 28*38e8c45fSAndroid Build Coastguard Worker 29*38e8c45fSAndroid Build Coastguard Worker // --------------------------------------------------------------------------- 30*38e8c45fSAndroid Build Coastguard Worker 31*38e8c45fSAndroid Build Coastguard Worker class ISurfaceComposer; 32*38e8c45fSAndroid Build Coastguard Worker 33*38e8c45fSAndroid Build Coastguard Worker // --------------------------------------------------------------------------- 34*38e8c45fSAndroid Build Coastguard Worker 35*38e8c45fSAndroid Build Coastguard Worker // This holds our connection to the composer service (i.e. SurfaceFlinger). 36*38e8c45fSAndroid Build Coastguard Worker // If the remote side goes away, we will re-establish the connection. 37*38e8c45fSAndroid Build Coastguard Worker // Users of this class should not retain the value from 38*38e8c45fSAndroid Build Coastguard Worker // getComposerService() for an extended period. 39*38e8c45fSAndroid Build Coastguard Worker // 40*38e8c45fSAndroid Build Coastguard Worker // (TODO: b/219785927, It's not clear that using Singleton is useful here anymore.) 41*38e8c45fSAndroid Build Coastguard Worker class ComposerService : public Singleton<ComposerService> 42*38e8c45fSAndroid Build Coastguard Worker { 43*38e8c45fSAndroid Build Coastguard Worker sp<ISurfaceComposer> mComposerService; 44*38e8c45fSAndroid Build Coastguard Worker sp<IBinder::DeathRecipient> mDeathObserver; 45*38e8c45fSAndroid Build Coastguard Worker Mutex mLock; 46*38e8c45fSAndroid Build Coastguard Worker 47*38e8c45fSAndroid Build Coastguard Worker ComposerService(); 48*38e8c45fSAndroid Build Coastguard Worker bool connectLocked(); 49*38e8c45fSAndroid Build Coastguard Worker void composerServiceDied(); 50*38e8c45fSAndroid Build Coastguard Worker friend class Singleton<ComposerService>; 51*38e8c45fSAndroid Build Coastguard Worker public: 52*38e8c45fSAndroid Build Coastguard Worker // Get a connection to the Composer Service. This will block until 53*38e8c45fSAndroid Build Coastguard Worker // a connection is established. Returns null if permission is denied. 54*38e8c45fSAndroid Build Coastguard Worker static sp<ISurfaceComposer> getComposerService(); 55*38e8c45fSAndroid Build Coastguard Worker }; 56*38e8c45fSAndroid Build Coastguard Worker 57*38e8c45fSAndroid Build Coastguard Worker // --------------------------------------------------------------------------- 58*38e8c45fSAndroid Build Coastguard Worker }; // namespace android 59*38e8c45fSAndroid Build Coastguard Worker 60*38e8c45fSAndroid Build Coastguard Worker #endif // ANDROID_PRIVATE_GUI_COMPOSER_SERVICE_H 61