Loading packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialog.java 0 → 100644 +41 −0 Original line number 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.VolumeDialog.Callback; import com.android.systemui.plugins.annotations.DependsOn; import com.android.systemui.plugins.annotations.ProvidesInterface; /** * This interface is really just a stub for initialization/teardown, actual handling of * when to show will be done through {@link VolumeDialogController} */ @ProvidesInterface(action = VolumeDialog.ACTION, version = VolumeDialog.VERSION) @DependsOn(target = Callback.class) public interface VolumeDialog extends Plugin { String ACTION = "com.android.systemui.action.PLUGIN_VOLUME"; int VERSION = 1; void init(int windowType, Callback callback); void destroy(); @ProvidesInterface(version = VERSION) public interface Callback { int VERSION = 1; void onZenSettingsClicked(); void onZenPrioritySettingsClicked(); } } packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialogController.java 0 → 100644 +176 −0 Original line number 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.annotation.IntegerRes; import android.content.ComponentName; import android.media.AudioManager; import android.media.AudioSystem; import android.os.Handler; import android.util.SparseArray; import com.android.systemui.plugins.VolumeDialogController.Callbacks; import com.android.systemui.plugins.VolumeDialogController.State; import com.android.systemui.plugins.VolumeDialogController.StreamState; import com.android.systemui.plugins.annotations.DependsOn; import com.android.systemui.plugins.annotations.ProvidesInterface; /** * Manages the VolumeDialog. * * Accessible through {@link PluginDependency} */ @ProvidesInterface(version = VolumeDialogController.VERSION) @DependsOn(target = StreamState.class) @DependsOn(target = State.class) @DependsOn(target = Callbacks.class) public interface VolumeDialogController { int VERSION = 1; void setActiveStream(int stream); void setStreamVolume(int stream, int userLevel); void setRingerMode(int ringerModeNormal, boolean external); boolean hasVibrator(); void vibrate(); AudioManager getAudioManager(); void notifyVisible(boolean visible); void addCallback(Callbacks callbacks, Handler handler); void removeCallback(Callbacks callbacks); void userActivity(); void getState(); @ProvidesInterface(version = StreamState.VERSION) public static final class StreamState { public static final int VERSION = 1; public boolean dynamic; public int level; public int levelMin; public int levelMax; public boolean muted; public boolean muteSupported; public @IntegerRes int name; public String remoteLabel; public boolean routedToBluetooth; public StreamState copy() { final StreamState rt = new StreamState(); rt.dynamic = dynamic; rt.level = level; rt.levelMin = levelMin; rt.levelMax = levelMax; rt.muted = muted; rt.muteSupported = muteSupported; rt.name = name; rt.remoteLabel = remoteLabel; rt.routedToBluetooth = routedToBluetooth; return rt; } } @ProvidesInterface(version = State.VERSION) public static final class State { public static final int VERSION = 1; public static int NO_ACTIVE_STREAM = -1; public final SparseArray<StreamState> states = new SparseArray<>(); public int ringerModeInternal; public int ringerModeExternal; public int zenMode; public ComponentName effectsSuppressor; public String effectsSuppressorName; public int activeStream = NO_ACTIVE_STREAM; public State copy() { final State rt = new State(); for (int i = 0; i < states.size(); i++) { rt.states.put(states.keyAt(i), states.valueAt(i).copy()); } rt.ringerModeExternal = ringerModeExternal; rt.ringerModeInternal = ringerModeInternal; rt.zenMode = zenMode; if (effectsSuppressor != null) { rt.effectsSuppressor = effectsSuppressor.clone(); } rt.effectsSuppressorName = effectsSuppressorName; rt.activeStream = activeStream; return rt; } @Override public String toString() { return toString(0); } public String toString(int indent) { final StringBuilder sb = new StringBuilder("{"); if (indent > 0) sep(sb, indent); for (int i = 0; i < states.size(); i++) { if (i > 0) { sep(sb, indent); } final int stream = states.keyAt(i); final StreamState ss = states.valueAt(i); sb.append(AudioSystem.streamToString(stream)).append(":").append(ss.level) .append('[').append(ss.levelMin).append("..").append(ss.levelMax) .append(']'); if (ss.muted) sb.append(" [MUTED]"); if (ss.dynamic) sb.append(" [DYNAMIC]"); } sep(sb, indent); sb.append("ringerModeExternal:").append(ringerModeExternal); sep(sb, indent); sb.append("ringerModeInternal:").append(ringerModeInternal); sep(sb, indent); sb.append("zenMode:").append(zenMode); sep(sb, indent); sb.append("effectsSuppressor:").append(effectsSuppressor); sep(sb, indent); sb.append("effectsSuppressorName:").append(effectsSuppressorName); sep(sb, indent); sb.append("activeStream:").append(activeStream); if (indent > 0) sep(sb, indent); return sb.append('}').toString(); } private static void sep(StringBuilder sb, int indent) { if (indent > 0) { sb.append('\n'); for (int i = 0; i < indent; i++) { sb.append(' '); } } else { sb.append(','); } } } @ProvidesInterface(version = Callbacks.VERSION) public interface Callbacks { int VERSION = 1; void onShowRequested(int reason); void onDismissRequested(int reason); void onStateChanged(State state); void onLayoutDirectionChanged(int layoutDirection); void onConfigurationChanged(); void onShowVibrateHint(); void onShowSilentHint(); void onScreenOff(); void onShowSafetyWarning(int flags); void onAccessibilityModeChanged(Boolean showA11yStream); } } packages/SystemUI/src/com/android/systemui/Dependency.java +5 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.PluginDependencyProvider; import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.PluginManagerImpl; import com.android.systemui.plugins.VolumeDialogController; import com.android.systemui.statusbar.phone.ConfigurationControllerImpl; import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl; import com.android.systemui.statusbar.phone.ManagedProfileController; Loading Loading @@ -79,6 +80,7 @@ import com.android.systemui.tuner.TunerServiceImpl; import com.android.systemui.util.leak.GarbageMonitor; import com.android.systemui.util.leak.LeakDetector; import com.android.systemui.util.leak.LeakReporter; import com.android.systemui.volume.VolumeDialogControllerImpl; import java.io.FileDescriptor; import java.io.PrintWriter; Loading Loading @@ -252,6 +254,9 @@ public class Dependency extends SystemUI { mProviders.put(LocalBluetoothManager.class, () -> LocalBluetoothManager.getInstance(mContext, null)); mProviders.put(VolumeDialogController.class, () -> new VolumeDialogControllerImpl(mContext)); // Put all dependencies above here so the factory can override them if it wants. SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); } Loading packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +1 −7 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui; import android.content.ComponentName; import android.content.Context; import android.util.ArrayMap; import android.util.Log; Loading @@ -39,7 +38,7 @@ import com.android.systemui.qs.QSTileHost; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.volume.VolumeDialogController; import com.android.systemui.volume.VolumeDialogControllerImpl; /** * Class factory to provide customizable SystemUI components. Loading Loading @@ -89,11 +88,6 @@ public class SystemUIFactory { return new ScrimController(lightBarController, scrimBehind, scrimInFront, headsUpScrim); } public VolumeDialogController createVolumeDialogController(Context context, ComponentName name) { return new VolumeDialogController(context, name); } public NotificationIconAreaController createNotificationIconAreaController(Context context, StatusBar statusBar) { return new NotificationIconAreaController(context, statusBar); Loading packages/SystemUI/src/com/android/systemui/car/CarSystemUIFactory.java +7 −5 Original line number Diff line number Diff line Loading @@ -15,11 +15,12 @@ */ package com.android.systemui.car; import android.content.ComponentName; import android.content.Context; import android.util.ArrayMap; import com.android.systemui.Dependency.DependencyProvider; import com.android.systemui.SystemUIFactory; import com.android.systemui.volume.VolumeDialogController; import com.android.systemui.plugins.VolumeDialogController; import com.android.systemui.volume.car.CarVolumeDialogController; /** Loading @@ -27,8 +28,9 @@ import com.android.systemui.volume.car.CarVolumeDialogController; */ public class CarSystemUIFactory extends SystemUIFactory { @Override public VolumeDialogController createVolumeDialogController(Context context, ComponentName name) { return new CarVolumeDialogController(context, name); public void injectDependencies(ArrayMap<Object, DependencyProvider> providers, Context context) { super.injectDependencies(providers, context); providers.put(VolumeDialogController.class, () -> new CarVolumeDialogController(context)); } } Loading
packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialog.java 0 → 100644 +41 −0 Original line number 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.VolumeDialog.Callback; import com.android.systemui.plugins.annotations.DependsOn; import com.android.systemui.plugins.annotations.ProvidesInterface; /** * This interface is really just a stub for initialization/teardown, actual handling of * when to show will be done through {@link VolumeDialogController} */ @ProvidesInterface(action = VolumeDialog.ACTION, version = VolumeDialog.VERSION) @DependsOn(target = Callback.class) public interface VolumeDialog extends Plugin { String ACTION = "com.android.systemui.action.PLUGIN_VOLUME"; int VERSION = 1; void init(int windowType, Callback callback); void destroy(); @ProvidesInterface(version = VERSION) public interface Callback { int VERSION = 1; void onZenSettingsClicked(); void onZenPrioritySettingsClicked(); } }
packages/SystemUI/plugin/src/com/android/systemui/plugins/VolumeDialogController.java 0 → 100644 +176 −0 Original line number 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.annotation.IntegerRes; import android.content.ComponentName; import android.media.AudioManager; import android.media.AudioSystem; import android.os.Handler; import android.util.SparseArray; import com.android.systemui.plugins.VolumeDialogController.Callbacks; import com.android.systemui.plugins.VolumeDialogController.State; import com.android.systemui.plugins.VolumeDialogController.StreamState; import com.android.systemui.plugins.annotations.DependsOn; import com.android.systemui.plugins.annotations.ProvidesInterface; /** * Manages the VolumeDialog. * * Accessible through {@link PluginDependency} */ @ProvidesInterface(version = VolumeDialogController.VERSION) @DependsOn(target = StreamState.class) @DependsOn(target = State.class) @DependsOn(target = Callbacks.class) public interface VolumeDialogController { int VERSION = 1; void setActiveStream(int stream); void setStreamVolume(int stream, int userLevel); void setRingerMode(int ringerModeNormal, boolean external); boolean hasVibrator(); void vibrate(); AudioManager getAudioManager(); void notifyVisible(boolean visible); void addCallback(Callbacks callbacks, Handler handler); void removeCallback(Callbacks callbacks); void userActivity(); void getState(); @ProvidesInterface(version = StreamState.VERSION) public static final class StreamState { public static final int VERSION = 1; public boolean dynamic; public int level; public int levelMin; public int levelMax; public boolean muted; public boolean muteSupported; public @IntegerRes int name; public String remoteLabel; public boolean routedToBluetooth; public StreamState copy() { final StreamState rt = new StreamState(); rt.dynamic = dynamic; rt.level = level; rt.levelMin = levelMin; rt.levelMax = levelMax; rt.muted = muted; rt.muteSupported = muteSupported; rt.name = name; rt.remoteLabel = remoteLabel; rt.routedToBluetooth = routedToBluetooth; return rt; } } @ProvidesInterface(version = State.VERSION) public static final class State { public static final int VERSION = 1; public static int NO_ACTIVE_STREAM = -1; public final SparseArray<StreamState> states = new SparseArray<>(); public int ringerModeInternal; public int ringerModeExternal; public int zenMode; public ComponentName effectsSuppressor; public String effectsSuppressorName; public int activeStream = NO_ACTIVE_STREAM; public State copy() { final State rt = new State(); for (int i = 0; i < states.size(); i++) { rt.states.put(states.keyAt(i), states.valueAt(i).copy()); } rt.ringerModeExternal = ringerModeExternal; rt.ringerModeInternal = ringerModeInternal; rt.zenMode = zenMode; if (effectsSuppressor != null) { rt.effectsSuppressor = effectsSuppressor.clone(); } rt.effectsSuppressorName = effectsSuppressorName; rt.activeStream = activeStream; return rt; } @Override public String toString() { return toString(0); } public String toString(int indent) { final StringBuilder sb = new StringBuilder("{"); if (indent > 0) sep(sb, indent); for (int i = 0; i < states.size(); i++) { if (i > 0) { sep(sb, indent); } final int stream = states.keyAt(i); final StreamState ss = states.valueAt(i); sb.append(AudioSystem.streamToString(stream)).append(":").append(ss.level) .append('[').append(ss.levelMin).append("..").append(ss.levelMax) .append(']'); if (ss.muted) sb.append(" [MUTED]"); if (ss.dynamic) sb.append(" [DYNAMIC]"); } sep(sb, indent); sb.append("ringerModeExternal:").append(ringerModeExternal); sep(sb, indent); sb.append("ringerModeInternal:").append(ringerModeInternal); sep(sb, indent); sb.append("zenMode:").append(zenMode); sep(sb, indent); sb.append("effectsSuppressor:").append(effectsSuppressor); sep(sb, indent); sb.append("effectsSuppressorName:").append(effectsSuppressorName); sep(sb, indent); sb.append("activeStream:").append(activeStream); if (indent > 0) sep(sb, indent); return sb.append('}').toString(); } private static void sep(StringBuilder sb, int indent) { if (indent > 0) { sb.append('\n'); for (int i = 0; i < indent; i++) { sb.append(' '); } } else { sb.append(','); } } } @ProvidesInterface(version = Callbacks.VERSION) public interface Callbacks { int VERSION = 1; void onShowRequested(int reason); void onDismissRequested(int reason); void onStateChanged(State state); void onLayoutDirectionChanged(int layoutDirection); void onConfigurationChanged(); void onShowVibrateHint(); void onShowSilentHint(); void onScreenOff(); void onShowSafetyWarning(int flags); void onAccessibilityModeChanged(Boolean showA11yStream); } }
packages/SystemUI/src/com/android/systemui/Dependency.java +5 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.PluginDependencyProvider; import com.android.systemui.plugins.PluginManager; import com.android.systemui.plugins.PluginManagerImpl; import com.android.systemui.plugins.VolumeDialogController; import com.android.systemui.statusbar.phone.ConfigurationControllerImpl; import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl; import com.android.systemui.statusbar.phone.ManagedProfileController; Loading Loading @@ -79,6 +80,7 @@ import com.android.systemui.tuner.TunerServiceImpl; import com.android.systemui.util.leak.GarbageMonitor; import com.android.systemui.util.leak.LeakDetector; import com.android.systemui.util.leak.LeakReporter; import com.android.systemui.volume.VolumeDialogControllerImpl; import java.io.FileDescriptor; import java.io.PrintWriter; Loading Loading @@ -252,6 +254,9 @@ public class Dependency extends SystemUI { mProviders.put(LocalBluetoothManager.class, () -> LocalBluetoothManager.getInstance(mContext, null)); mProviders.put(VolumeDialogController.class, () -> new VolumeDialogControllerImpl(mContext)); // Put all dependencies above here so the factory can override them if it wants. SystemUIFactory.getInstance().injectDependencies(mProviders, mContext); } Loading
packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +1 −7 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui; import android.content.ComponentName; import android.content.Context; import android.util.ArrayMap; import android.util.Log; Loading @@ -39,7 +38,7 @@ import com.android.systemui.qs.QSTileHost; import com.android.systemui.statusbar.phone.ScrimController; import com.android.systemui.statusbar.phone.StatusBarIconController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.volume.VolumeDialogController; import com.android.systemui.volume.VolumeDialogControllerImpl; /** * Class factory to provide customizable SystemUI components. Loading Loading @@ -89,11 +88,6 @@ public class SystemUIFactory { return new ScrimController(lightBarController, scrimBehind, scrimInFront, headsUpScrim); } public VolumeDialogController createVolumeDialogController(Context context, ComponentName name) { return new VolumeDialogController(context, name); } public NotificationIconAreaController createNotificationIconAreaController(Context context, StatusBar statusBar) { return new NotificationIconAreaController(context, statusBar); Loading
packages/SystemUI/src/com/android/systemui/car/CarSystemUIFactory.java +7 −5 Original line number Diff line number Diff line Loading @@ -15,11 +15,12 @@ */ package com.android.systemui.car; import android.content.ComponentName; import android.content.Context; import android.util.ArrayMap; import com.android.systemui.Dependency.DependencyProvider; import com.android.systemui.SystemUIFactory; import com.android.systemui.volume.VolumeDialogController; import com.android.systemui.plugins.VolumeDialogController; import com.android.systemui.volume.car.CarVolumeDialogController; /** Loading @@ -27,8 +28,9 @@ import com.android.systemui.volume.car.CarVolumeDialogController; */ public class CarSystemUIFactory extends SystemUIFactory { @Override public VolumeDialogController createVolumeDialogController(Context context, ComponentName name) { return new CarVolumeDialogController(context, name); public void injectDependencies(ArrayMap<Object, DependencyProvider> providers, Context context) { super.injectDependencies(providers, context); providers.put(VolumeDialogController.class, () -> new CarVolumeDialogController(context)); } }