1 /* 2 * Copyright (C) 2015 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 package com.android.systemui.qs.external; 17 18 import android.os.IBinder; 19 import android.service.quicksettings.IQSService; 20 import android.service.quicksettings.IQSTileService; 21 import android.service.quicksettings.Tile; 22 import android.util.Log; 23 24 25 public class QSTileServiceWrapper { 26 private static final String TAG = "IQSTileServiceWrapper"; 27 28 private final IQSTileService mService; 29 30 public QSTileServiceWrapper(IQSTileService service) { 31 mService = service; 32 } 33 34 public IBinder asBinder() { 35 return mService.asBinder(); 36 } 37 38 public boolean onTileAdded() { 39 try { 40 mService.onTileAdded(); 41 return true; 42 } catch (Exception e) { 43 Log.d(TAG, "Caught exception from TileService", e); 44 return false; 45 } 46 } 47 48 public boolean onTileRemoved() { 49 try { 50 mService.onTileRemoved(); 51 return true; 52 } catch (Exception e) { 53 Log.d(TAG, "Caught exception from TileService", e); 54 return false; 55 } 56 } 57 58 public boolean onStartListening() { 59 try { 60 mService.onStartListening(); 61 return true; 62 } catch (Exception e) { 63 Log.d(TAG, "Caught exception from TileService", e); 64 return false; 65 } 66 } 67 68 public boolean onStopListening() { 69 try { 70 mService.onStopListening(); 71 return true; 72 } catch (Exception e) { 73 Log.d(TAG, "Caught exception from TileService", e); 74 return false; 75 } 76 } 77 78 public boolean onClick(IBinder token) { 79 try { 80 mService.onClick(token); 81 return true; 82 } catch (Exception e) { 83 Log.d(TAG, "Caught exception from TileService", e); 84 return false; 85 } 86 } 87 88 public boolean onUnlockComplete() { 89 try { 90 mService.onUnlockComplete(); 91 return true; 92 } catch (Exception e) { 93 Log.d(TAG, "Caught exception from TileService", e); 94 return false; 95 } 96 } 97 98 public IQSTileService getService() { 99 return mService; 100 } 101 } 102