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
This commit is contained in:
Rakesh Iyer
2017-05-22 17:47:52 -07:00
parent fa5713a2c2
commit 97ff85838e
10 changed files with 207 additions and 6 deletions

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -18,4 +18,5 @@
-->
<resources>
<string name="unknown_user_label">Unknown</string>
<string name="start_driving">Start Driving</string>
</resources>

View File

@@ -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>

View File

@@ -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();
}
}

View File

@@ -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);
}