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

Commit e658cc21 authored by Anthony Chen's avatar Anthony Chen
Browse files

Add ability to set a custom background for auto.

Also, clear heads-up entries when switching to notifications panel. Auto
does not want any notifications to be pinned to the top.

Test: booted up android auto headunit
Bug: 33210494
Change-Id: If722a887f4bc0d4a91ca37d4e7de5af94ca0f8dd
parent 44a2b572
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -140,6 +140,9 @@ public class ScrimView extends View implements ConfigurationController.Configura
        mDrawable = drawable;
        mDrawable.setCallback(this);
        mDrawable.setBounds(getLeft(), getTop(), getRight(), getBottom());
        mDrawable.setAlpha((int) (255 * mViewAlpha));
        setDrawAsSrc(mDrawAsSrc);
        updateScreenSize();
        invalidate();
    }

+44 −5
Original line number Diff line number Diff line
@@ -23,9 +23,11 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -33,6 +35,7 @@ import android.view.ViewGroup.LayoutParams;
import android.view.ViewStub;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.android.systemui.BatteryMeterView;
import com.android.systemui.Dependency;
import com.android.systemui.R;
@@ -41,6 +44,7 @@ import com.android.systemui.fragments.FragmentHostManager;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.CollapsedStatusBarFragment;
import com.android.systemui.statusbar.phone.NavigationBarView;
@@ -62,6 +66,7 @@ public class CarStatusBar extends StatusBar implements

    private CarBatteryController mCarBatteryController;
    private BatteryMeterView mBatteryMeterView;
    private Drawable mNotificationPanelBackground;

    private ConnectedDeviceSignalController mConnectedDeviceSignalController;
    private CarNavigationBarView mNavigationBarView;
@@ -91,17 +96,18 @@ public class CarStatusBar extends StatusBar implements
    protected void makeStatusBarView() {
        super.makeStatusBarView();

        mNotificationPanelBackground = getDefaultWallpaper();
        mScrimController.setScrimBehindDrawable(mNotificationPanelBackground);

        FragmentHostManager manager = FragmentHostManager.get(mStatusBarWindow);
        manager.addTagListener(CollapsedStatusBarFragment.TAG, (tag, fragment) -> {
            mBatteryMeterView = ((BatteryMeterView) fragment.getView().findViewById(
                    R.id.battery));
            mBatteryMeterView = fragment.getView().findViewById(R.id.battery);

            // By default, the BatteryMeterView should not be visible. It will be toggled
            // when a device has connected by bluetooth.
            mBatteryMeterView.setVisibility(View.GONE);

            ViewStub stub = (ViewStub) fragment.getView().findViewById(
                    R.id.connected_device_signals_stub);
            ViewStub stub = fragment.getView().findViewById(R.id.connected_device_signals_stub);
            View signalsView = stub.inflate();

            // When a ViewStub if inflated, it does not respect the margins on the
@@ -256,7 +262,7 @@ public class CarStatusBar extends StatusBar implements
        if (userSwitcherController.useFullscreenUserSwitcher()) {
            mFullscreenUserSwitcher = new FullscreenUserSwitcher(this,
                    userSwitcherController,
                    (ViewStub) mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub));
                    mStatusBarWindow.findViewById(R.id.fullscreen_user_switcher_stub));
        } else {
            super.createUserSwitcher();
        }
@@ -314,6 +320,27 @@ public class CarStatusBar extends StatusBar implements
        return startActivityWithOptions(intent, options.toBundle());
    }

    @Override
    protected boolean shouldPeek(NotificationData.Entry entry, StatusBarNotification sbn) {
        // Because space is usually constrained in the auto use-case, there should not be a
        // pinned notification when the shade has been expanded. Ensure this by not pinning any
        // notification if the shade is already opened.
        if (mPanelExpanded) {
            return false;
        }

        return super.shouldPeek(entry, sbn);
    }

    @Override
    public void animateExpandNotificationsPanel() {
        // Because space is usually constrained in the auto use-case, there should not be a
        // pinned notification when the shade has been expanded. Ensure this by removing all heads-
        // up notifications.
        mHeadsUpManager.removeAllHeadsUpEntries();
        super.animateExpandNotificationsPanel();
    }

    /**
     * Ensures that relevant child views are appropriately recreated when the device's density
     * changes.
@@ -322,5 +349,17 @@ public class CarStatusBar extends StatusBar implements
    protected void onDensityOrFontScaleChanged() {
        super.onDensityOrFontScaleChanged();
        mController.onDensityOrFontScaleChanged();

        // Need to update the background on density changed in case the change was due to night
        // mode.
        mNotificationPanelBackground = getDefaultWallpaper();
        mScrimController.setScrimBehindDrawable(mNotificationPanelBackground);
    }

    /**
     * Returns the {@link Drawable} that represents the wallpaper that the user has currently set.
     */
    private Drawable getDefaultWallpaper() {
        return mContext.getDrawable(com.android.internal.R.drawable.default_wallpaper);
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.WallpaperManager;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.graphics.ColorUtils;
import android.util.Log;
import android.util.TypedValue;
@@ -260,6 +261,14 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
                : SCRIM_IN_FRONT_ALPHA;
    }

    /**
     * Sets the given drawable as the background of the scrim that shows up behind the
     * notifications.
     */
    public void setScrimBehindDrawable(Drawable drawable) {
        mScrimBehind.setDrawable(drawable);
    }

    protected void scheduleUpdate() {
        if (mUpdatePending) return;

+1 −1
Original line number Diff line number Diff line
@@ -716,7 +716,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    private NetworkController mNetworkController;
    private KeyguardMonitorImpl mKeyguardMonitor;
    private BatteryController mBatteryController;
    private boolean mPanelExpanded;
    protected boolean mPanelExpanded;
    private boolean mKeyguardRequested;
    private boolean mIsKeyguard;
    private LogMaker mStatusBarStateLog;
+6 −0
Original line number Diff line number Diff line
@@ -257,6 +257,12 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
        mEntryPool.release(remove);
    }

    public void removeAllHeadsUpEntries() {
        for (String key : mHeadsUpEntries.keySet()) {
            removeHeadsUpEntry(mHeadsUpEntries.get(key).entry);
        }
    }

    private void updatePinnedMode() {
        boolean hasPinnedNotification = hasPinnedNotificationInternal();
        if (hasPinnedNotification == mHasPinnedNotification) {