summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Rakesh Iyer <rni@google.com> 2017-05-22 17:47:52 -0700
committer Rakesh Iyer <rni@google.com> 2017-05-23 11:23:17 -0700
commit97ff85838e21c18fbfc2e509bcc92049716ab97c (patch)
treec5606d65439ace2396e6a7c0ab918e52fcdbdd28
parentfa5713a2c2a11ad6a32ab69194eebe038f32cf94 (diff)
Best effort dismissal of the login screen.
This change adds in two mechanisms to dismiss the login screen that shows up on boot. The first is a countdown timer and the second is a start driving button. Both of them behave in the same way that once the timer runs out or if the button is clicked, the system will automatically try to select a user and get the system running. Right now the implementation of selecting a user is a bit trivial, it just tries to drop the keyguard on the currently running user. Bug: 36454400 Test: 1. Booted mojave, watched progress bar make progress and automatically log in user. 2. Booted mojave, clicked the start driving button and watch the keyguard dismiss itself. Change-Id: If22f4c3c7e21aadf2951b9c0cd8b97a4b474b349
-rw-r--r--packages/SystemUI/res/drawable/car_progress_bar.xml30
-rw-r--r--packages/SystemUI/res/drawable/car_round_button.xml21
-rw-r--r--packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml17
-rw-r--r--packages/SystemUI/res/values/colors_car.xml24
-rw-r--r--packages/SystemUI/res/values/dimens_car.xml9
-rw-r--r--packages/SystemUI/res/values/integers_car.xml22
-rw-r--r--packages/SystemUI/res/values/strings_car.xml1
-rw-r--r--packages/SystemUI/res/values/styles_car.xml34
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java53
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java2
10 files changed, 207 insertions, 6 deletions
diff --git a/packages/SystemUI/res/drawable/car_progress_bar.xml b/packages/SystemUI/res/drawable/car_progress_bar.xml
new file mode 100644
index 000000000000..742fca7d19fd
--- /dev/null
+++ b/packages/SystemUI/res/drawable/car_progress_bar.xml
@@ -0,0 +1,30 @@
+<!--
+ 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
+-->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@android:id/background">
+ <shape>
+ <solid android:color="@color/car_user_switcher_progress_bgcolor" />
+ </shape>
+ </item>
+
+ <item android:id="@android:id/progress">
+ <clip>
+ <shape>
+ <solid android:color="@color/car_user_switcher_progress_fgcolor" />
+ </shape>
+ </clip>
+ </item>
+</layer-list>
diff --git a/packages/SystemUI/res/drawable/car_round_button.xml b/packages/SystemUI/res/drawable/car_round_button.xml
new file mode 100644
index 000000000000..5f4deb3e6be3
--- /dev/null
+++ b/packages/SystemUI/res/drawable/car_round_button.xml
@@ -0,0 +1,21 @@
+<!--
+ 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
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+
+ <solid android:color="@color/car_start_driving_background" />
+ <corners android:radius="@dimen/car_start_driving_corner_radius" />
+</shape>
diff --git a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml
index a66f767d0ce7..e0438369762c 100644
--- a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml
+++ b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml
@@ -20,6 +20,14 @@
android:layout_height="match_parent"
android:visibility="gone">
+ <ProgressBar
+ android:id="@+id/countdown_progress"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/car_user_switcher_progress_bar_height"
+ style="@style/CarUserSwitcher.ProgressBar"
+ android:layout_marginTop="@dimen/car_user_switcher_progress_bar_margin_top"
+ android:layout_alignParentTop="true"/>
+
<com.android.systemui.statusbar.car.UserGridView
android:id="@+id/user_grid"
android:layout_width="match_parent"
@@ -34,4 +42,13 @@
android:layout_height="@dimen/car_page_indicator_dot_diameter"
android:layout_marginTop="@dimen/car_page_indicator_margin_top"
android:layout_below="@+id/user_grid" />
+
+ <Button
+ android:id="@+id/start_driving"
+ android:layout_width="wrap_content"
+ android:layout_height="@dimen/car_start_driving_height"
+ android:text="@string/start_driving"
+ style="@style/CarUserSwitcher.StartDrivingButton"
+ android:layout_alignParentBottom="true"
+ android:layout_centerHorizontal="true" />
</RelativeLayout>
diff --git a/packages/SystemUI/res/values/colors_car.xml b/packages/SystemUI/res/values/colors_car.xml
new file mode 100644
index 000000000000..4faf252817ee
--- /dev/null
+++ b/packages/SystemUI/res/values/colors_car.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 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.
+ */
+-->
+<resources>
+ <color name="car_user_switcher_progress_bgcolor">#00000000</color> <!-- Transparent -->
+ <color name="car_user_switcher_progress_fgcolor">#80CBC4</color> <!-- Teal 200 -->
+ <color name="car_start_driving_background">#FAFAFA</color> <!-- Grey 50 -->
+ <color name="car_start_driving_text">#212121</color> <!-- Grey 900 -->
+</resources>
diff --git a/packages/SystemUI/res/values/dimens_car.xml b/packages/SystemUI/res/values/dimens_car.xml
index a0be999e5b1d..d5d4e10d12ae 100644
--- a/packages/SystemUI/res/values/dimens_car.xml
+++ b/packages/SystemUI/res/values/dimens_car.xml
@@ -22,11 +22,18 @@
<dimen name="car_fullscreen_user_pod_margin_above_text">24dp</dimen>
<dimen name="car_fullscreen_user_pod_image_avatar_width">192dp</dimen>
<dimen name="car_fullscreen_user_pod_image_avatar_height">192dp</dimen>
- <dimen name="car_fullscreen_user_pod_text_size">40sp</dimen>
+ <dimen name="car_fullscreen_user_pod_text_size">40sp</dimen> <!-- B1 -->
<dimen name="car_navigation_button_width">64dp</dimen>
<dimen name="car_navigation_bar_width">760dp</dimen>
<dimen name="car_page_indicator_dot_diameter">12dp</dimen>
<dimen name="car_page_indicator_margin_top">32dp</dimen>
+
+ <dimen name="car_user_switcher_progress_bar_height">6dp</dimen>
+ <dimen name="car_user_switcher_progress_bar_margin_top">@dimen/status_bar_height</dimen>
+ <dimen name="car_start_driving_corner_radius">16dp</dimen>
+ <dimen name="car_start_driving_padding_side">30dp</dimen>
+ <dimen name="car_start_driving_height">80dp</dimen>
+ <dimen name="car_start_driving_text_size">32sp</dimen> <!-- B2 -->
</resources>
diff --git a/packages/SystemUI/res/values/integers_car.xml b/packages/SystemUI/res/values/integers_car.xml
new file mode 100644
index 000000000000..320ee9f66c79
--- /dev/null
+++ b/packages/SystemUI/res/values/integers_car.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <integer name="car_user_switcher_timeout_ms">15000</integer>
+ <!-- This values less than ProgressBar.PROGRESS_ANIM_DURATION for a smooth animation. -->
+ <integer name="car_user_switcher_anim_update_ms">60</integer>
+</resources>
diff --git a/packages/SystemUI/res/values/strings_car.xml b/packages/SystemUI/res/values/strings_car.xml
index e3f329a085e8..658eb4fb3a8c 100644
--- a/packages/SystemUI/res/values/strings_car.xml
+++ b/packages/SystemUI/res/values/strings_car.xml
@@ -18,4 +18,5 @@
-->
<resources>
<string name="unknown_user_label">Unknown</string>
+ <string name="start_driving">Start Driving</string>
</resources>
diff --git a/packages/SystemUI/res/values/styles_car.xml b/packages/SystemUI/res/values/styles_car.xml
new file mode 100644
index 000000000000..c66792ca6a15
--- /dev/null
+++ b/packages/SystemUI/res/values/styles_car.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <style name="CarUserSwitcher.ProgressBar" parent="@android:style/Widget.ProgressBar.Horizontal">
+ <item name="android:progressDrawable">@drawable/car_progress_bar</item>
+ <item name="android:min">0</item>
+ <item name="android:max">@integer/car_user_switcher_timeout_ms</item>
+ <item name="android:progress">0</item>
+ <item name="android:interpolator">@android:anim/linear_interpolator</item>
+ </style>
+
+ <style name="CarUserSwitcher.StartDrivingButton" parent="@android:style/Widget.Material.Button">
+ <item name="android:background">@drawable/car_round_button</item>
+ <item name="android:textSize">@dimen/car_start_driving_text_size</item>
+ <item name="android:textColor">@color/car_start_driving_text</item>
+ <item name="android:paddingLeft">@dimen/car_start_driving_padding_side</item>
+ <item name="android:paddingRight">@dimen/car_start_driving_padding_side</item>
+ </style>
+</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
index bcad78706a0a..d84a731e232e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
@@ -16,8 +16,11 @@
package com.android.systemui.statusbar.car;
+import android.content.res.Resources;
+import android.os.CountDownTimer;
import android.view.View;
import android.view.ViewStub;
+import android.widget.ProgressBar;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.StatusBar;
@@ -27,10 +30,14 @@ import com.android.systemui.statusbar.policy.UserSwitcherController;
* Manages the fullscreen user switcher.
*/
public class FullscreenUserSwitcher {
+ private final View mContainer;
+ private final UserGridView mUserGridView;
+ private final UserSwitcherController mUserSwitcherController;
+ private final ProgressBar mProgressBar;
+ private final int mLoginTimeoutMs;
+ private final int mAnimUpdateIntervalMs;
- private View mContainer;
- private UserGridView mUserGridView;
- private UserSwitcherController mUserSwitcherController;
+ private CountDownTimer mTimer;
public FullscreenUserSwitcher(StatusBar statusBar,
UserSwitcherController userSwitcherController,
@@ -42,6 +49,16 @@ public class FullscreenUserSwitcher {
PageIndicator pageIndicator = mContainer.findViewById(R.id.user_switcher_page_indicator);
pageIndicator.setupWithViewPager(mUserGridView);
+
+ mProgressBar = mContainer.findViewById(R.id.countdown_progress);
+ Resources res = mContainer.getResources();
+ mLoginTimeoutMs = res.getInteger(R.integer.car_user_switcher_timeout_ms);
+ mAnimUpdateIntervalMs = res.getInteger(R.integer.car_user_switcher_anim_update_ms);
+
+ mContainer.findViewById(R.id.start_driving).setOnClickListener(v -> {
+ cancelTimer();
+ automaticallySelectUser();
+ });
}
public void onUserSwitched(int newUserId) {
@@ -50,10 +67,38 @@ public class FullscreenUserSwitcher {
public void show() {
mContainer.setVisibility(View.VISIBLE);
+ cancelTimer();
+ mTimer = new CountDownTimer(mLoginTimeoutMs, mAnimUpdateIntervalMs) {
+ @Override
+ public void onTick(long msUntilFinished) {
+ int elapsed = mLoginTimeoutMs - (int) msUntilFinished;
+ mProgressBar.setProgress((int) elapsed, true /* animate */);
+ }
+
+ @Override
+ public void onFinish() {
+ mProgressBar.setProgress(mLoginTimeoutMs, true /* animate */);
+ automaticallySelectUser();
+ }
+ };
+ mTimer.start();
}
public void hide() {
+ cancelTimer();
mContainer.setVisibility(View.GONE);
}
-}
+ private void cancelTimer() {
+ if (mTimer != null) {
+ mTimer.cancel();
+ mTimer = null;
+ }
+ }
+
+ private void automaticallySelectUser() {
+ // TODO: Switch according to some policy. This implementation just tries to drop the
+ // keyguard for the current user.
+ mUserGridView.showOfflineAuthUi();
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java
index 972dc3708f90..46f55eeaae8f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/UserGridView.java
@@ -70,7 +70,7 @@ public class UserGridView extends ViewPager {
mPendingUserId = UserHandle.USER_NULL;
}
- private void showOfflineAuthUi() {
+ void showOfflineAuthUi() {
// TODO: Show keyguard UI in-place.
mStatusBar.executeRunnableDismissingKeyguard(null, null, true, true, true);
}