Show progress user unlocking is delayed
Sometimes it takes a while to unlock a user, for example, after an OTA. In these cases, we show a progress bar in FallbackHome so the user knows that something is happening. Fixes: 30213213 Change-Id: Ie36a9b3107c32ff46a8890818d1f26ccf310ee6c
This commit is contained in:
47
res/layout/fallback_home_finishing_boot.xml
Normal file
47
res/layout/fallback_home_finishing_boot.xml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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
|
||||||
|
-->
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#80000000"
|
||||||
|
android:forceHasOverlappingRendering="false">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_gravity="center">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:text="@*android:string/android_upgrading_complete"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:theme="@style/FallbackHomeProgressBar"
|
||||||
|
style="@android:style/Widget.Material.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12.75dp"
|
||||||
|
android:indeterminate="true"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</FrameLayout>
|
@@ -281,7 +281,7 @@
|
|||||||
<item name="suwListItemIconColor">?android:attr/colorAccent</item>
|
<item name="suwListItemIconColor">?android:attr/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="FallbackHome" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
|
<style name="FallbackHome" parent="@android:style/Theme.DeviceDefault.NoActionBar">
|
||||||
<item name="android:windowBackground">@android:color/transparent</item>
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
<item name="android:colorBackgroundCacheHint">@null</item>
|
<item name="android:colorBackgroundCacheHint">@null</item>
|
||||||
<item name="android:windowShowWallpaper">true</item>
|
<item name="android:windowShowWallpaper">true</item>
|
||||||
@@ -302,4 +302,7 @@
|
|||||||
<item name="android:navigationBarColor">#00000000</item>
|
<item name="android:navigationBarColor">#00000000</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="FallbackHomeProgressBar" parent="FallbackHome">
|
||||||
|
<item name="android:colorControlActivated">?android:attr/textColorPrimary</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -25,15 +26,37 @@ import android.content.pm.ResolveInfo;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.os.PowerManager;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
import android.view.WindowManager.LayoutParams;
|
||||||
|
import android.view.animation.AnimationUtils;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class FallbackHome extends Activity {
|
public class FallbackHome extends Activity {
|
||||||
private static final String TAG = "FallbackHome";
|
private static final String TAG = "FallbackHome";
|
||||||
|
private static final int PROGRESS_TIMEOUT = 2000;
|
||||||
|
|
||||||
|
private boolean mProvisioned;
|
||||||
|
|
||||||
|
private final Runnable mProgressTimeoutRunnable = () -> {
|
||||||
|
View v = getLayoutInflater().inflate(
|
||||||
|
R.layout.fallback_home_finishing_boot, null /* root */);
|
||||||
|
setContentView(v);
|
||||||
|
v.setAlpha(0f);
|
||||||
|
v.animate()
|
||||||
|
.alpha(1f)
|
||||||
|
.setDuration(500)
|
||||||
|
.setInterpolator(AnimationUtils.loadInterpolator(
|
||||||
|
this, android.R.interpolator.fast_out_slow_in))
|
||||||
|
.start();
|
||||||
|
getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -41,11 +64,15 @@ public class FallbackHome extends Activity {
|
|||||||
|
|
||||||
// Set ourselves totally black before the device is provisioned so that
|
// Set ourselves totally black before the device is provisioned so that
|
||||||
// we don't flash the wallpaper before SUW
|
// we don't flash the wallpaper before SUW
|
||||||
if (Settings.Global.getInt(getContentResolver(),
|
mProvisioned = Settings.Global.getInt(getContentResolver(),
|
||||||
Settings.Global.DEVICE_PROVISIONED, 0) == 0) {
|
Settings.Global.DEVICE_PROVISIONED, 0) != 0;
|
||||||
|
if (!mProvisioned) {
|
||||||
setTheme(R.style.FallbackHome_SetupWizard);
|
setTheme(R.style.FallbackHome_SetupWizard);
|
||||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||||
|
} else {
|
||||||
|
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||||
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
|
registerReceiver(mReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
|
||||||
@@ -53,6 +80,19 @@ public class FallbackHome extends Activity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (mProvisioned) {
|
||||||
|
mHandler.postDelayed(mProgressTimeoutRunnable, PROGRESS_TIMEOUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
mHandler.removeCallbacks(mProgressTimeoutRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
unregisterReceiver(mReceiver);
|
unregisterReceiver(mReceiver);
|
||||||
@@ -75,6 +115,8 @@ public class FallbackHome extends Activity {
|
|||||||
mHandler.sendEmptyMessageDelayed(0, 500);
|
mHandler.sendEmptyMessageDelayed(0, 500);
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "User unlocked and real home found; let's go!");
|
Log.d(TAG, "User unlocked and real home found; let's go!");
|
||||||
|
getSystemService(PowerManager.class).userActivity(
|
||||||
|
SystemClock.uptimeMillis(), false);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user