Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 634acb97 authored by Yao Chen's avatar Yao Chen
Browse files

Add CarVolumeDialogController in SystemUI for Android Auto.

Cars usually have an external audio module. When Android is serving as
the car's headunit, users should be able to adjust the car's volume
through SystemUI. The following changes are made to make it work:

+ Load VolumeDialogController from SystemUIFactory
+ Added CarSystemUIFactory
+ Added CarVolumeDialogController which extends VolumeDialogController
  and it uses CarAudioManager as source of truth for volume controls.
+ Some refactor in VolumeDialogController to make it easier for
subclasses to override volume controls.

Note that CarAudioManager does not completely replace AudioManager.
Majority of code in VolumeDialogController still applies in the car use
case, so I made CarVolumeDialogController a subclass of
VolumeDialogController instead of making them peers.

Bug: 27595951

Change-Id: Id4adec7281e41aa71f3de034e5b88a32a89be305
parent ca643bfe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
    SystemUI-proto-tags

LOCAL_JAVA_LIBRARIES := telephony-common
LOCAL_JAVA_LIBRARIES += android.car

LOCAL_PACKAGE_NAME := SystemUI
LOCAL_CERTIFICATE := platform
+3 −0
Original line number Diff line number Diff line
@@ -162,6 +162,9 @@
    <!-- It's like, reality, but, you know, virtual -->
    <uses-permission android:name="android.permission.ACCESS_VR_MANAGER" />

    <!-- To control car audio module volume -->
    <uses-permission android:name="android.car.permission.CAR_CONTROL_AUDIO_VOLUME" />

    <application
        android:name=".SystemUIApplication"
        android:persistent="true"
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
-keep class com.android.systemui.statusbar.car.CarStatusBar
-keep class com.android.systemui.statusbar.phone.PhoneStatusBar
-keep class com.android.systemui.statusbar.tv.TvStatusBar
-keep class com.android.systemui.car.CarSystemUIFactory
-keep class com.android.systemui.SystemUIFactory

-keepclassmembers class ** {
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui;

import android.content.ComponentName;
import android.content.Context;
import android.util.Log;
import android.view.View;
@@ -46,6 +47,7 @@ import com.android.systemui.statusbar.policy.SecurityController;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.volume.VolumeDialogController;

/**
 * Class factory to provide customizable SystemUI components.
@@ -93,6 +95,11 @@ public class SystemUIFactory {
        return new ScrimController(scrimBehind, scrimInFront, headsUpScrim);
    }

    public VolumeDialogController createVolumeDialogController(Context context,
            ComponentName name) {
        return new VolumeDialogController(context, name);
    }

    public NotificationIconAreaController createNotificationIconAreaController(Context context,
            PhoneStatusBar phoneStatusBar) {
        return new NotificationIconAreaController(context, phoneStatusBar);
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.car;

import android.content.ComponentName;
import android.content.Context;

import com.android.systemui.SystemUIFactory;
import com.android.systemui.volume.VolumeDialogController;
import com.android.systemui.volume.car.CarVolumeDialogController;

/**
 * Class factory to provide car specific SystemUI components.
 */
public class CarSystemUIFactory extends SystemUIFactory {
    @Override
    public VolumeDialogController createVolumeDialogController(Context context,
            ComponentName name) {
        return new CarVolumeDialogController(context, name);
    }
}
Loading