1a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu/* 2a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * Copyright (C) 2012 The Android Open Source Project 3a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * 4a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * Licensed under the Apache License, Version 2.0 (the "License"); 5a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * you may not use this file except in compliance with the License. 6a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * You may obtain a copy of the License at 7a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * 8a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * http://www.apache.org/licenses/LICENSE-2.0 9a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * 10a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * Unless required by applicable law or agreed to in writing, software 11a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * distributed under the License is distributed on an "AS IS" BASIS, 12a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * See the License for the specific language governing permissions and 14a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu * limitations under the License. 15a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu */ 16a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu 17a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescupackage com.android.gallery3d.app; 18a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu 19a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescuimport android.app.Service; 20a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescuimport android.content.Intent; 21a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescuimport android.os.Binder; 22a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescuimport android.os.IBinder; 23a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu 24a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescuimport com.android.gallery3d.util.ThreadPool; 25a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu 26a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescupublic class BatchService extends Service { 27a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu 28a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu public class LocalBinder extends Binder { 29a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu BatchService getService() { 30a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu return BatchService.this; 31a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu } 32a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu } 33a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu 34a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu private final IBinder mBinder = new LocalBinder(); 35a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu private ThreadPool mThreadPool = new ThreadPool(1, 1); 36a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu 37a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu @Override 38a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu public IBinder onBind(Intent intent) { 39a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu return mBinder; 40a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu } 41a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu 42b380f17426f419e3663da80985dc62f544d47048Bobby Georgescu // The threadpool returned by getThreadPool must have only 1 thread 43b380f17426f419e3663da80985dc62f544d47048Bobby Georgescu // running at a time, as MenuExecutor (atrociously) depends on this 44b380f17426f419e3663da80985dc62f544d47048Bobby Georgescu // guarantee for synchronization. 45a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu public ThreadPool getThreadPool() { 46a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu return mThreadPool; 47a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu } 48a2d0d34a90543ee19ea295e72c112fde18fb3828Bobby Georgescu} 49