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

Commit 712d157d authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6072377 from 721ba25c to qt-qpr2-release

Change-Id: I854218709b40c46152902a3334502af21eef62ea
parents f582d605 721ba25c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -161,7 +161,6 @@ public final class SelectionEvent implements Parcelable {
        mEntityType = in.readString();
        mWidgetVersion = in.readInt() > 0 ? in.readString() : null;
        mPackageName = in.readString();
        mUserId = in.readInt();
        mWidgetType = in.readString();
        mInvocationMethod = in.readInt();
        mResultId = in.readString();
@@ -175,6 +174,7 @@ public final class SelectionEvent implements Parcelable {
        mEnd = in.readInt();
        mSmartStart = in.readInt();
        mSmartEnd = in.readInt();
        mUserId = in.readInt();
    }

    @Override
@@ -188,7 +188,6 @@ public final class SelectionEvent implements Parcelable {
            dest.writeString(mWidgetVersion);
        }
        dest.writeString(mPackageName);
        dest.writeInt(mUserId);
        dest.writeString(mWidgetType);
        dest.writeInt(mInvocationMethod);
        dest.writeString(mResultId);
@@ -204,6 +203,7 @@ public final class SelectionEvent implements Parcelable {
        dest.writeInt(mEnd);
        dest.writeInt(mSmartStart);
        dest.writeInt(mSmartEnd);
        dest.writeInt(mUserId);
    }

    @Override
+129 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.app.ActivityManager;
import android.car.settings.CarSettings;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.net.Uri;
import android.provider.Settings;

import com.android.systemui.Dependency;

import java.util.ArrayList;

/**
 * A controller that monitors the status of SUW progress for each user.
 */
public class SUWProgressController {
    private static final Uri USER_SETUP_IN_PROGRESS_URI = Settings.Secure.getUriFor(
            CarSettings.Secure.KEY_SETUP_WIZARD_IN_PROGRESS);
    private final ArrayList<SUWProgressListener> mListeners = new ArrayList<>();
    private final ContentObserver mCarSettingsObserver = new ContentObserver(
            Dependency.get(Dependency.MAIN_HANDLER)) {
        @Override
        public void onChange(boolean selfChange, Uri uri, int userId) {
            if (USER_SETUP_IN_PROGRESS_URI.equals(uri)) {
                notifyUserSetupInProgressChanged();
            }
        }
    };
    private final ContentResolver mContentResolver;

    public SUWProgressController(Context context) {
        mContentResolver = context.getContentResolver();
    }

    /**
     * Returns {@code true} then SUW is in progress for the given user.
     */
    public boolean isUserSetupInProgress(int user) {
        return Settings.Secure.getIntForUser(mContentResolver,
                CarSettings.Secure.KEY_SETUP_WIZARD_IN_PROGRESS, /* def= */ 0, user) != 0;
    }

    /**
     * Returns {@code true} then SUW is in progress for the current user.
     */
    public boolean isCurrentUserSetupInProgress() {
        return isUserSetupInProgress(ActivityManager.getCurrentUser());
    }

    /**
     * Adds a {@link SUWProgressListener} callback.
     */
    public void addCallback(SUWProgressListener listener) {
        mListeners.add(listener);
        if (mListeners.size() == 1) {
            startListening(ActivityManager.getCurrentUser());
        }
        listener.onUserSetupInProgressChanged();
    }

    /**
     * Removes a {@link SUWProgressListener} callback.
     */
    public void removeCallback(SUWProgressListener listener) {
        mListeners.remove(listener);
        if (mListeners.size() == 0) {
            stopListening();
        }
    }

    private void startListening(int user) {
        mContentResolver.registerContentObserver(
                USER_SETUP_IN_PROGRESS_URI, /* notifyForDescendants= */ true, mCarSettingsObserver,
                user);
    }

    private void stopListening() {
        mContentResolver.unregisterContentObserver(mCarSettingsObserver);
    }

    /**
     * Allows SUWProgressController to switch its listeners to observe SUW progress for new user.
     */
    public void onUserSwitched() {
        if (mListeners.size() == 0) {
            return;
        }

        mContentResolver.unregisterContentObserver(mCarSettingsObserver);
        mContentResolver.registerContentObserver(
                USER_SETUP_IN_PROGRESS_URI, /* notifyForDescendants= */ true, mCarSettingsObserver,
                ActivityManager.getCurrentUser());
    }

    private void notifyUserSetupInProgressChanged() {
        for (int i = mListeners.size() - 1; i >= 0; --i) {
            mListeners.get(i).onUserSetupInProgressChanged();
        }
    }

    /**
     * A listener that listens for changes in SUW progress for a user.
     */
    public interface SUWProgressListener {
        /**
         * A callback for when a change occurs in SUW progress for a user.
         */
        default void onUserSetupInProgressChanged() {
        }
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ public class CarFacetButton extends LinearLayout {
                mComponentNames = componentNameString.split(FACET_FILTER_DELIMITER);
            }

            intent.putExtra(EXTRA_FACET_LAUNCH_PICKER, mSelected);
            setOnClickListener(getButtonClickListener(intent));

            if (longPressIntentString != null) {
@@ -124,10 +125,7 @@ public class CarFacetButton extends LinearLayout {

    /** Defines the behavior of a button click. */
    protected OnClickListener getButtonClickListener(Intent toSend) {
        return v -> {
            toSend.putExtra(EXTRA_FACET_LAUNCH_PICKER, mSelected);
            mContext.startActivityAsUser(toSend, UserHandle.CURRENT);
        };
        return v -> mContext.startActivityAsUser(toSend, UserHandle.CURRENT);
    }

    /** Defines the behavior of a long click. */
+63 −31
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.InputMethodService;
import android.media.AudioManager;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
@@ -72,6 +73,7 @@ import com.android.systemui.ForegroundServiceController;
import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.SystemUIFactory;
import com.android.systemui.car.SUWProgressController;
import com.android.systemui.classifier.FalsingLog;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.fragments.FragmentHostManager;
@@ -105,6 +107,7 @@ import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.KeyguardMonitor;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.UserSwitcherController;
import com.android.systemui.statusbar.policy.ZenModeController;
import com.android.systemui.volume.VolumeUI;
@@ -155,7 +158,9 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
    private CarFacetButtonController mCarFacetButtonController;
    private ActivityManagerWrapper mActivityManagerWrapper;
    private DeviceProvisionedController mDeviceProvisionedController;
    private SUWProgressController mSUWProgressController;
    private boolean mDeviceIsSetUpForUser = true;
    private boolean mIsUserSetupInProgress = false;
    private HvacController mHvacController;
    private DrivingStateHelper mDrivingStateHelper;
    private PowerManagerHelper mPowerManagerHelper;
@@ -273,7 +278,9 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        // get the provisioned state before calling the parent class since it's that flow that
        // builds the nav bar
        mDeviceProvisionedController = Dependency.get(DeviceProvisionedController.class);
        mSUWProgressController = new SUWProgressController(mContext);
        mDeviceIsSetUpForUser = mDeviceProvisionedController.isCurrentUserSetup();
        mIsUserSetupInProgress = mSUWProgressController.isCurrentUserSetupInProgress();

        // Keyboard related setup, before nav bars are created.
        mHideNavBarForKeyboard = mContext.getResources().getBoolean(
@@ -326,6 +333,13 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt

        mHvacController.connectToCarService();

        mSUWProgressController.addCallback(
                new SUWProgressController.SUWProgressListener() {
                    @Override
                    public void onUserSetupInProgressChanged() {
                        mHandler.post(() -> restartNavBarsIfNecessary());
                    }
                });
        mDeviceProvisionedController.addCallback(
                new DeviceProvisionedController.DeviceProvisionedListener() {
                    @Override
@@ -335,6 +349,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt

                    @Override
                    public void onUserSwitched() {
                        mSUWProgressController.onUserSwitched();
                        mHandler.post(() -> restartNavBarsIfNecessary());
                    }
                });
@@ -367,14 +382,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
                });
    }

    private void restartNavBarsIfNecessary() {
        boolean currentUserSetup = mDeviceProvisionedController.isCurrentUserSetup();
        if (mDeviceIsSetUpForUser != currentUserSetup) {
            mDeviceIsSetUpForUser = currentUserSetup;
            restartNavBars();
        }
    }

    @Override
    protected void getDependencies() {
        // Keyguard
@@ -384,6 +391,9 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt

        // Policy
        mZenController = Dependency.get(ZenModeController.class);
        if (Build.IS_USERDEBUG) {
            mNetworkController = Dependency.get(NetworkController.class);
        }

        // Icon
        mIconController = Dependency.get(StatusBarIconController.class);
@@ -424,6 +434,17 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        mContext.unregisterReceiver(mBootCompletedReceiver);
    }

    private void restartNavBarsIfNecessary() {
        boolean currentUserSetup = mDeviceProvisionedController.isCurrentUserSetup();
        boolean currentUserSetupInProgress = mSUWProgressController.isCurrentUserSetupInProgress();
        if (mIsUserSetupInProgress != currentUserSetupInProgress
                || mDeviceIsSetUpForUser != currentUserSetup) {
            mDeviceIsSetUpForUser = currentUserSetup;
            mIsUserSetupInProgress = currentUserSetupInProgress;
            restartNavBars();
        }
    }

    /**
     * Remove all content from navbars and rebuild them. Used to allow for different nav bars
     * before and after the device is provisioned. . Also for change of density and font size.
@@ -592,7 +613,7 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
                new HandleBarCloseNotificationGestureListener());

        mTopNavBarNotificationTouchListener = (v, event) -> {
            if (!mDeviceIsSetUpForUser) {
            if (!mDeviceIsSetUpForUser || mIsUserSetupInProgress) {
                return true;
            }
            boolean consumed = openGestureDetector.onTouchEvent(event);
@@ -626,7 +647,11 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        mCarUxRestrictionManagerWrapper = new CarUxRestrictionManagerWrapper();

        mNotificationDataManager = new NotificationDataManager();
        mNotificationDataManager.setOnUnseenCountUpdateListener(this::onUnseenCountUpdate);
        mNotificationDataManager.setOnUnseenCountUpdateListener(() -> {
            if (mNavigationBarView != null && mNotificationDataManager != null) {
                onUseenCountUpdate(mNotificationDataManager.getUnseenNotificationCount());
            }
        });

        mEnableHeadsUpNotificationWhenNotificationShadeOpen = mContext.getResources().getBoolean(
                R.bool.config_enableHeadsUpNotificationWhenNotificationShadeOpen);
@@ -752,13 +777,11 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
    }

    /**
     * This method is called whenever there is an update to the number of unseen notifications.
     * This method can be extended by OEMs to customize the desired logic.
     * This method is automatically called whenever there is an update to the number of unseen
     * notifications. This method can be extended by OEMs to customize the desired logic.
     */
    protected void onUnseenCountUpdate() {
        if (mNavigationBarView != null && mNotificationDataManager != null) {
            Boolean hasUnseen =
                    mNotificationDataManager.getUnseenNotificationCount() > 0;
    protected void onUseenCountUpdate(int unseenNotificationCount) {
        boolean hasUnseen = unseenNotificationCount > 0;

        if (mNavigationBarView != null) {
            mNavigationBarView.toggleNotificationUnseenIndicator(hasUnseen);
@@ -772,7 +795,6 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
            mRightNavigationBarView.toggleNotificationUnseenIndicator(hasUnseen);
        }
    }
    }

    /**
     * @return true if the notification panel is currently visible
@@ -932,22 +954,24 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
    }

    private void buildNavBarContent() {
        boolean shouldBuildNavBarContent = mDeviceIsSetUpForUser && !mIsUserSetupInProgress;

        // Always build top bar.
        buildTopBar((mDeviceIsSetUpForUser) ? R.layout.car_top_navigation_bar :
        buildTopBar(shouldBuildNavBarContent ? R.layout.car_top_navigation_bar :
                R.layout.car_top_navigation_bar_unprovisioned);

        if (mShowBottom) {
            buildBottomBar((mDeviceIsSetUpForUser) ? R.layout.car_navigation_bar :
            buildBottomBar(shouldBuildNavBarContent ? R.layout.car_navigation_bar :
                    R.layout.car_navigation_bar_unprovisioned);
        }

        if (mShowLeft) {
            buildLeft((mDeviceIsSetUpForUser) ? R.layout.car_left_navigation_bar :
            buildLeft(shouldBuildNavBarContent ? R.layout.car_left_navigation_bar :
                    R.layout.car_left_navigation_bar_unprovisioned);
        }

        if (mShowRight) {
            buildRight((mDeviceIsSetUpForUser) ? R.layout.car_right_navigation_bar :
            buildRight(shouldBuildNavBarContent ? R.layout.car_right_navigation_bar :
                    R.layout.car_right_navigation_bar_unprovisioned);
        }
    }
@@ -1317,6 +1341,12 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt
        mScrimController.setScrimBehindDrawable(mNotificationPanelBackground);
    }

    @Override
    public void onLocaleListChanged() {
        // TODO - We should not have to reload sysUI on locale change
        makeStatusBarView();
    }

    /**
     * Returns the {@link Drawable} that represents the wallpaper that the user has currently set.
     */
@@ -1570,8 +1600,10 @@ public class CarStatusBar extends StatusBar implements CarBatteryController.Batt

        @Override
        protected void setHeadsUpVisible() {
            // if the Notifications panel is showing don't show the Heads up
            if (!mEnableHeadsUpNotificationWhenNotificationShadeOpen && mPanelExpanded) {
            // if the Notifications panel is showing or SUW for user is in progress then don't show
            // heads up notifications
            if ((!mEnableHeadsUpNotificationWhenNotificationShadeOpen && mPanelExpanded)
                    || !mDeviceIsSetUpForUser || mIsUserSetupInProgress) {
                return;
            }

+2 −0
Original line number Diff line number Diff line
@@ -865,6 +865,8 @@ public class DisplayPolicy {
                if (canToastShowWhenLocked(callingPid)) {
                    attrs.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
                }
                // Toasts can't be clickable
                attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
                break;
        }