Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file |
| 5 | * except in compliance with the License. You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the |
| 10 | * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 11 | * KIND, either express or implied. See the License for the specific language governing |
| 12 | * permissions and limitations under the License. |
| 13 | */ |
| 14 | |
| 15 | package com.android.systemui.utils.leaks; |
| 16 | |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 17 | import android.testing.LeakCheck; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 18 | |
| 19 | import com.android.systemui.plugins.Plugin; |
| 20 | import com.android.systemui.plugins.PluginListener; |
| 21 | import com.android.systemui.plugins.PluginManager; |
| 22 | |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 23 | public class FakePluginManager implements PluginManager { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 24 | |
| 25 | private final BaseLeakChecker<PluginListener> mLeakChecker; |
| 26 | |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 27 | public FakePluginManager(LeakCheck test) { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 28 | mLeakChecker = new BaseLeakChecker<>(test, "Plugin"); |
| 29 | } |
| 30 | |
| 31 | @Override |
| 32 | public <T extends Plugin> void addPluginListener(String action, PluginListener<T> listener, |
Jason Monk | 5bec68f | 2017-02-08 20:45:10 -0800 | [diff] [blame] | 33 | Class cls, boolean allowMultiple) { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 34 | mLeakChecker.addCallback(listener); |
| 35 | } |
| 36 | |
| 37 | @Override |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 38 | public <T extends Plugin> void addPluginListener(PluginListener<T> listener, Class<?> cls) { |
| 39 | mLeakChecker.addCallback(listener); |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public <T extends Plugin> void addPluginListener(PluginListener<T> listener, Class<?> cls, |
| 44 | boolean allowMultiple) { |
| 45 | mLeakChecker.addCallback(listener); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public <T extends Plugin> void addPluginListener(String action, PluginListener<T> listener, |
| 50 | Class<?> cls) { |
| 51 | mLeakChecker.addCallback(listener); |
| 52 | } |
| 53 | |
| 54 | @Override |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 55 | public void removePluginListener(PluginListener<?> listener) { |
| 56 | mLeakChecker.removeCallback(listener); |
| 57 | } |
| 58 | |
| 59 | @Override |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 60 | public <T> boolean dependsOn(Plugin p, Class<T> cls) { |
| 61 | return false; |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public <T extends Plugin> T getOneShotPlugin(Class<T> cls) { |
| 66 | return null; |
| 67 | } |
| 68 | |
| 69 | @Override |
Jason Monk | 5bec68f | 2017-02-08 20:45:10 -0800 | [diff] [blame] | 70 | public <T extends Plugin> T getOneShotPlugin(String action, Class<?> cls) { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 71 | return null; |
| 72 | } |
| 73 | } |