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 | |
Dan Sandler | f6e33b1 | 2017-08-15 16:39:33 -0400 | [diff] [blame] | 17 | import android.content.Context; |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 18 | import android.testing.LeakCheck; |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 19 | |
| 20 | import com.android.systemui.plugins.Plugin; |
| 21 | import com.android.systemui.plugins.PluginListener; |
| 22 | import com.android.systemui.plugins.PluginManager; |
| 23 | |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 24 | public class FakePluginManager implements PluginManager { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 25 | |
| 26 | private final BaseLeakChecker<PluginListener> mLeakChecker; |
| 27 | |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 28 | public FakePluginManager(LeakCheck test) { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 29 | mLeakChecker = new BaseLeakChecker<>(test, "Plugin"); |
| 30 | } |
| 31 | |
| 32 | @Override |
| 33 | public <T extends Plugin> void addPluginListener(String action, PluginListener<T> listener, |
Jason Monk | 5bec68f | 2017-02-08 20:45:10 -0800 | [diff] [blame] | 34 | Class cls, boolean allowMultiple) { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 35 | mLeakChecker.addCallback(listener); |
| 36 | } |
| 37 | |
| 38 | @Override |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 39 | public <T extends Plugin> void addPluginListener(PluginListener<T> listener, Class<?> cls) { |
| 40 | mLeakChecker.addCallback(listener); |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public <T extends Plugin> void addPluginListener(PluginListener<T> listener, Class<?> cls, |
| 45 | boolean allowMultiple) { |
| 46 | mLeakChecker.addCallback(listener); |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public <T extends Plugin> void addPluginListener(String action, PluginListener<T> listener, |
| 51 | Class<?> cls) { |
| 52 | mLeakChecker.addCallback(listener); |
| 53 | } |
| 54 | |
| 55 | @Override |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 56 | public void removePluginListener(PluginListener<?> listener) { |
| 57 | mLeakChecker.removeCallback(listener); |
| 58 | } |
| 59 | |
| 60 | @Override |
Jason Monk | 340b0e5 | 2017-03-08 14:57:56 -0500 | [diff] [blame] | 61 | public <T> boolean dependsOn(Plugin p, Class<T> cls) { |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public <T extends Plugin> T getOneShotPlugin(Class<T> cls) { |
| 67 | return null; |
| 68 | } |
| 69 | |
| 70 | @Override |
Jason Monk | 5bec68f | 2017-02-08 20:45:10 -0800 | [diff] [blame] | 71 | public <T extends Plugin> T getOneShotPlugin(String action, Class<?> cls) { |
Jason Monk | de850bb | 2017-02-01 19:26:30 -0500 | [diff] [blame] | 72 | return null; |
| 73 | } |
| 74 | } |