Loading packages/SystemUI/src/com/android/systemui/ActivityStarter.java→packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -12,17 +12,21 @@ * permissions and limitations under the License. * permissions and limitations under the License. */ */ package com.android.systemui; package com.android.systemui.plugins; import android.app.PendingIntent; import android.app.PendingIntent; import android.content.Intent; import android.content.Intent; import com.android.systemui.plugins.annotations.ProvidesInterface; /** /** * An interface to start activities. This is used as a callback from the views to * An interface to start activities. This is used as a callback from the views to * {@link PhoneStatusBar} to allow custom handling for starting the activity, i.e. dismissing the * {@link PhoneStatusBar} to allow custom handling for starting the activity, i.e. dismissing the * Keyguard. * Keyguard. */ */ @ProvidesInterface(version = ActivityStarter.VERSION) public interface ActivityStarter { public interface ActivityStarter { int VERSION = 1; void startPendingIntentDismissingKeyguard(PendingIntent intent); void startPendingIntentDismissingKeyguard(PendingIntent intent); void startActivity(Intent intent, boolean dismissShade); void startActivity(Intent intent, boolean dismissShade); Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginDependency.java 0 → 100644 +31 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.systemui.plugins; import com.android.systemui.plugins.annotations.ProvidesInterface; @ProvidesInterface(version = PluginDependency.VERSION) public class PluginDependency { public static final int VERSION = 1; static DependencyProvider sProvider; public static <T> T get(Plugin p, Class<T> cls) { return sProvider.get(p, cls); } static abstract class DependencyProvider { abstract <T> T get(Plugin p, Class<T> cls); } } packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui; import android.app.PendingIntent; import android.app.PendingIntent; import android.content.Intent; import android.content.Intent; import com.android.systemui.plugins.ActivityStarter; /** /** * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but * delegates to an actual implementation such as StatusBar, assuming it exists. * delegates to an actual implementation such as StatusBar, assuming it exists. Loading packages/SystemUI/src/com/android/systemui/Dependency.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -25,8 +25,9 @@ import android.util.ArrayMap; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions; import com.android.systemui.assist.AssistManager; import com.android.systemui.assist.AssistManager; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.fragments.FragmentService; import com.android.systemui.fragments.FragmentService; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.PluginDependencyProvider; import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.PluginManager; import com.android.systemui.statusbar.phone.ConfigurationControllerImpl; import com.android.systemui.statusbar.phone.ConfigurationControllerImpl; import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl; import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl; Loading Loading @@ -238,6 +239,9 @@ public class Dependency extends SystemUI { mProviders.put(ExtensionController.class, () -> mProviders.put(ExtensionController.class, () -> new ExtensionControllerImpl()); new ExtensionControllerImpl()); mProviders.put(PluginDependencyProvider.class, () -> new PluginDependencyProvider(get(PluginManager.class))); // Put all dependencies above here so the factory can override them if it wants. // Put all dependencies above here so the factory can override them if it wants. SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); } } Loading packages/SystemUI/src/com/android/systemui/plugins/PluginDependencyProvider.java 0 → 100644 +50 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.systemui.plugins; import android.util.ArrayMap; import com.android.systemui.Dependency; import com.android.systemui.plugins.PluginDependency.DependencyProvider; public class PluginDependencyProvider extends DependencyProvider { private final ArrayMap<Class<?>, Object> mDependencies = new ArrayMap<>(); private final PluginManager mManager; public PluginDependencyProvider(PluginManager manager) { mManager = manager; PluginDependency.sProvider = this; } public <T> void allowPluginDependency(Class<T> cls) { allowPluginDependency(cls, Dependency.get(cls)); } public <T> void allowPluginDependency(Class<T> cls, T obj) { mDependencies.put(cls, obj); } @Override <T> T get(Plugin p, Class<T> cls) { if (!mManager.dependsOn(p, cls)) { throw new IllegalArgumentException(p.getClass() + " does not depend on " + cls); } if (!mDependencies.containsKey(cls)) { throw new IllegalArgumentException("Unknown dependency " + cls); } return (T) mDependencies.get(cls); } } Loading
packages/SystemUI/src/com/android/systemui/ActivityStarter.java→packages/SystemUI/plugin/src/com/android/systemui/plugins/ActivityStarter.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -12,17 +12,21 @@ * permissions and limitations under the License. * permissions and limitations under the License. */ */ package com.android.systemui; package com.android.systemui.plugins; import android.app.PendingIntent; import android.app.PendingIntent; import android.content.Intent; import android.content.Intent; import com.android.systemui.plugins.annotations.ProvidesInterface; /** /** * An interface to start activities. This is used as a callback from the views to * An interface to start activities. This is used as a callback from the views to * {@link PhoneStatusBar} to allow custom handling for starting the activity, i.e. dismissing the * {@link PhoneStatusBar} to allow custom handling for starting the activity, i.e. dismissing the * Keyguard. * Keyguard. */ */ @ProvidesInterface(version = ActivityStarter.VERSION) public interface ActivityStarter { public interface ActivityStarter { int VERSION = 1; void startPendingIntentDismissingKeyguard(PendingIntent intent); void startPendingIntentDismissingKeyguard(PendingIntent intent); void startActivity(Intent intent, boolean dismissShade); void startActivity(Intent intent, boolean dismissShade); Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/PluginDependency.java 0 → 100644 +31 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.systemui.plugins; import com.android.systemui.plugins.annotations.ProvidesInterface; @ProvidesInterface(version = PluginDependency.VERSION) public class PluginDependency { public static final int VERSION = 1; static DependencyProvider sProvider; public static <T> T get(Plugin p, Class<T> cls) { return sProvider.get(p, cls); } static abstract class DependencyProvider { abstract <T> T get(Plugin p, Class<T> cls); } }
packages/SystemUI/src/com/android/systemui/ActivityStarterDelegate.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -17,6 +17,8 @@ package com.android.systemui; import android.app.PendingIntent; import android.app.PendingIntent; import android.content.Intent; import android.content.Intent; import com.android.systemui.plugins.ActivityStarter; /** /** * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but * delegates to an actual implementation such as StatusBar, assuming it exists. * delegates to an actual implementation such as StatusBar, assuming it exists. Loading
packages/SystemUI/src/com/android/systemui/Dependency.java +5 −1 Original line number Original line Diff line number Diff line Loading @@ -25,8 +25,9 @@ import android.util.ArrayMap; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions; import com.android.systemui.assist.AssistManager; import com.android.systemui.assist.AssistManager; import com.android.systemui.fragments.FragmentHostManager; import com.android.systemui.fragments.FragmentService; import com.android.systemui.fragments.FragmentService; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.PluginDependencyProvider; import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.PluginManager; import com.android.systemui.statusbar.phone.ConfigurationControllerImpl; import com.android.systemui.statusbar.phone.ConfigurationControllerImpl; import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl; import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl; Loading Loading @@ -238,6 +239,9 @@ public class Dependency extends SystemUI { mProviders.put(ExtensionController.class, () -> mProviders.put(ExtensionController.class, () -> new ExtensionControllerImpl()); new ExtensionControllerImpl()); mProviders.put(PluginDependencyProvider.class, () -> new PluginDependencyProvider(get(PluginManager.class))); // Put all dependencies above here so the factory can override them if it wants. // Put all dependencies above here so the factory can override them if it wants. SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); } } Loading
packages/SystemUI/src/com/android/systemui/plugins/PluginDependencyProvider.java 0 → 100644 +50 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.android.systemui.plugins; import android.util.ArrayMap; import com.android.systemui.Dependency; import com.android.systemui.plugins.PluginDependency.DependencyProvider; public class PluginDependencyProvider extends DependencyProvider { private final ArrayMap<Class<?>, Object> mDependencies = new ArrayMap<>(); private final PluginManager mManager; public PluginDependencyProvider(PluginManager manager) { mManager = manager; PluginDependency.sProvider = this; } public <T> void allowPluginDependency(Class<T> cls) { allowPluginDependency(cls, Dependency.get(cls)); } public <T> void allowPluginDependency(Class<T> cls, T obj) { mDependencies.put(cls, obj); } @Override <T> T get(Plugin p, Class<T> cls) { if (!mManager.dependsOn(p, cls)) { throw new IllegalArgumentException(p.getClass() + " does not depend on " + cls); } if (!mDependencies.containsKey(cls)) { throw new IllegalArgumentException("Unknown dependency " + cls); } return (T) mDependencies.get(cls); } }