diff options
author | Dan Sandler <dsandler@android.com> | 2014-04-14 17:54:21 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-04-14 17:54:22 +0000 |
commit | 352e108259bcb3305f034cfb042287d43a5e8f80 (patch) | |
tree | 9335c30335ee0082a86bbdeb3fb5fdd75dfe24fc /packages/Keyguard | |
parent | db8b130a19484cb6018667905e64d42ab793654f (diff) | |
parent | f3e3140696ca775fe2f62868addb1eec2b1c18fa (diff) | |
download | frameworks_base-352e108259bcb3305f034cfb042287d43a5e8f80.zip frameworks_base-352e108259bcb3305f034cfb042287d43a5e8f80.tar.gz frameworks_base-352e108259bcb3305f034cfb042287d43a5e8f80.tar.bz2 |
Merge "Merge remote-tracking branch 'goog/master-lockscreen-dev'"
Diffstat (limited to 'packages/Keyguard')
56 files changed, 274 insertions, 2338 deletions
diff --git a/packages/Keyguard/Android.mk b/packages/Keyguard/Android.mk index 5b08674..1be44f9 100644 --- a/packages/Keyguard/Android.mk +++ b/packages/Keyguard/Android.mk @@ -19,7 +19,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-subdir-Iaidl-files) \ $(call all-proto-files-under,src) -LOCAL_PACKAGE_NAME := Keyguard +LOCAL_MODULE := Keyguard LOCAL_CERTIFICATE := platform @@ -30,6 +30,8 @@ LOCAL_PROGUARD_FLAG_FILES := proguard.flags LOCAL_PROTOC_OPTIMIZE_TYPE := nano LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors -include $(BUILD_PACKAGE) +LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res -#include $(call all-makefiles-under,$(LOCAL_PATH)) +include $(BUILD_STATIC_JAVA_LIBRARY) + +#include $(call all-makefiles-under,$(LOCAL_PATH))
\ No newline at end of file diff --git a/packages/Keyguard/AndroidManifest.xml b/packages/Keyguard/AndroidManifest.xml index b2d2ec5..352317d 100644 --- a/packages/Keyguard/AndroidManifest.xml +++ b/packages/Keyguard/AndroidManifest.xml @@ -46,8 +46,5 @@ android:persistent="true" android:supportsRtl="true"> - <service android:name=".KeyguardService" - android:exported="true" /> - </application> </manifest> diff --git a/packages/Keyguard/res/layout-land/keyguard_host_view.xml b/packages/Keyguard/res/layout-land/keyguard_host_view.xml index 9f1c1f0..1d596d3 100644 --- a/packages/Keyguard/res/layout-land/keyguard_host_view.xml +++ b/packages/Keyguard/res/layout-land/keyguard_host_view.xml @@ -21,7 +21,7 @@ and the security view. --> <com.android.keyguard.KeyguardHostView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_host_view" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/packages/Keyguard/res/layout-land/keyguard_simple_host_view.xml b/packages/Keyguard/res/layout-land/keyguard_simple_host_view.xml index ebd0a64..49b4212 100644 --- a/packages/Keyguard/res/layout-land/keyguard_simple_host_view.xml +++ b/packages/Keyguard/res/layout-land/keyguard_simple_host_view.xml @@ -21,7 +21,7 @@ and the security view. --> <com.android.keyguard.KeyguardSimpleHostView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_host_view" android:layout_width="match_parent" android:layout_height="match_parent"> diff --git a/packages/Keyguard/res/layout-land/keyguard_widget_pager.xml b/packages/Keyguard/res/layout-land/keyguard_widget_pager.xml index da31065..50c2709 100644 --- a/packages/Keyguard/res/layout-land/keyguard_widget_pager.xml +++ b/packages/Keyguard/res/layout-land/keyguard_widget_pager.xml @@ -19,7 +19,7 @@ <!-- This is the selector widget that allows the user to select an action. --> <com.android.keyguard.KeyguardWidgetCarousel - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:paddingLeft="25dp" android:paddingRight="25dp" diff --git a/packages/Keyguard/res/layout-port/keyguard_host_view.xml b/packages/Keyguard/res/layout-port/keyguard_host_view.xml index 136b296..8223db4 100644 --- a/packages/Keyguard/res/layout-port/keyguard_host_view.xml +++ b/packages/Keyguard/res/layout-port/keyguard_host_view.xml @@ -21,7 +21,7 @@ and the security view. --> <com.android.keyguard.KeyguardHostView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_host_view" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/packages/Keyguard/res/layout-port/keyguard_simple_host_view.xml b/packages/Keyguard/res/layout-port/keyguard_simple_host_view.xml index cba7667..ed600b0 100644 --- a/packages/Keyguard/res/layout-port/keyguard_simple_host_view.xml +++ b/packages/Keyguard/res/layout-port/keyguard_simple_host_view.xml @@ -21,7 +21,7 @@ and the security view. --> <com.android.keyguard.KeyguardSimpleHostView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_host_view" android:layout_width="match_parent" android:layout_height="match_parent"> diff --git a/packages/Keyguard/res/layout-port/keyguard_widget_pager.xml b/packages/Keyguard/res/layout-port/keyguard_widget_pager.xml index d0a07ca..6d7d864 100644 --- a/packages/Keyguard/res/layout-port/keyguard_widget_pager.xml +++ b/packages/Keyguard/res/layout-port/keyguard_widget_pager.xml @@ -19,7 +19,7 @@ <!-- This is the selector widget that allows the user to select an action. --> <com.android.keyguard.KeyguardWidgetPager - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/app_widget_container" android:paddingLeft="25dp" diff --git a/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml b/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml index 85f6b6d..ba2f3a6 100644 --- a/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml +++ b/packages/Keyguard/res/layout-sw600dp-port/keyguard_host_view.xml @@ -21,7 +21,7 @@ and the security view. --> <com.android.keyguard.KeyguardHostView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_host_view" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_account_view.xml b/packages/Keyguard/res/layout/keyguard_account_view.xml index 766effa..bde2ec6 100644 --- a/packages/Keyguard/res/layout/keyguard_account_view.xml +++ b/packages/Keyguard/res/layout/keyguard_account_view.xml @@ -18,7 +18,7 @@ --> <com.android.keyguard.KeyguardAccountView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_account_view" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_bouncer.xml b/packages/Keyguard/res/layout/keyguard_bouncer.xml new file mode 100644 index 0000000..dedf427 --- /dev/null +++ b/packages/Keyguard/res/layout/keyguard_bouncer.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?><!-- + ~ Copyright (C) 2014 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"> + + <View android:id="@+id/bouncer_background" + android:background="#aa000000" + android:clickable="true" + android:layout_width="match_parent" + android:layout_height="match_parent"/> + + <include layout="@layout/keyguard_simple_host_view" + android:layout_width="match_parent" + android:layout_height="match_parent"/> +</FrameLayout> + diff --git a/packages/Keyguard/res/layout/keyguard_face_unlock_view.xml b/packages/Keyguard/res/layout/keyguard_face_unlock_view.xml index 94c68a5..8c8ec7a 100644 --- a/packages/Keyguard/res/layout/keyguard_face_unlock_view.xml +++ b/packages/Keyguard/res/layout/keyguard_face_unlock_view.xml @@ -20,7 +20,7 @@ <!-- This is the screen that allows the user to unlock by showing their face. --> <com.android.keyguard.KeyguardFaceUnlockView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_face_unlock_view" android:orientation="vertical" android:layout_width="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_multi_user_selector.xml b/packages/Keyguard/res/layout/keyguard_multi_user_selector.xml index c1d5326..83036ab 100644 --- a/packages/Keyguard/res/layout/keyguard_multi_user_selector.xml +++ b/packages/Keyguard/res/layout/keyguard_multi_user_selector.xml @@ -17,7 +17,7 @@ */ --> <com.android.keyguard.KeyguardMultiUserSelectorView - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" androidprv:layout_childType="userSwitcher" android:id="@+id/keyguard_user_selector" diff --git a/packages/Keyguard/res/layout/keyguard_password_view.xml b/packages/Keyguard/res/layout/keyguard_password_view.xml index d8012bf..ed3f0e0 100644 --- a/packages/Keyguard/res/layout/keyguard_password_view.xml +++ b/packages/Keyguard/res/layout/keyguard_password_view.xml @@ -18,7 +18,7 @@ --> <com.android.keyguard.KeyguardPasswordView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_password_view" android:orientation="vertical" android:layout_width="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_pattern_view.xml b/packages/Keyguard/res/layout/keyguard_pattern_view.xml index 0c9380c..3d7820f 100644 --- a/packages/Keyguard/res/layout/keyguard_pattern_view.xml +++ b/packages/Keyguard/res/layout/keyguard_pattern_view.xml @@ -22,7 +22,7 @@ is the portrait layout. --> <com.android.keyguard.KeyguardPatternView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_pattern_view" android:orientation="vertical" android:layout_width="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_pin_view.xml b/packages/Keyguard/res/layout/keyguard_pin_view.xml index 00c6a21..a804c8c 100644 --- a/packages/Keyguard/res/layout/keyguard_pin_view.xml +++ b/packages/Keyguard/res/layout/keyguard_pin_view.xml @@ -19,7 +19,7 @@ <com.android.keyguard.KeyguardPINView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_pin_view" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_presentation.xml b/packages/Keyguard/res/layout/keyguard_presentation.xml index 7df0b70..ab676aa 100644 --- a/packages/Keyguard/res/layout/keyguard_presentation.xml +++ b/packages/Keyguard/res/layout/keyguard_presentation.xml @@ -20,7 +20,7 @@ <!-- This is a view that shows general status information in Keyguard. --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/presentation" android:layout_width="match_parent" android:layout_height="match_parent"> diff --git a/packages/Keyguard/res/layout/keyguard_selector_view.xml b/packages/Keyguard/res/layout/keyguard_selector_view.xml index 6cb5e67..d3064ed 100644 --- a/packages/Keyguard/res/layout/keyguard_selector_view.xml +++ b/packages/Keyguard/res/layout/keyguard_selector_view.xml @@ -20,7 +20,7 @@ <!-- This is the selector widget that allows the user to select an action. --> <com.android.keyguard.KeyguardSelectorView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_selector_view" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_sim_pin_view.xml b/packages/Keyguard/res/layout/keyguard_sim_pin_view.xml index eccac19..e96220e 100644 --- a/packages/Keyguard/res/layout/keyguard_sim_pin_view.xml +++ b/packages/Keyguard/res/layout/keyguard_sim_pin_view.xml @@ -19,7 +19,7 @@ <!-- This is the SIM PIN view that allows the user to enter a SIM PIN to unlock the device. --> <com.android.keyguard.KeyguardSimPinView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_sim_pin_view" android:orientation="vertical" android:layout_width="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_sim_puk_view.xml b/packages/Keyguard/res/layout/keyguard_sim_puk_view.xml index fe37203..bf15ba0 100644 --- a/packages/Keyguard/res/layout/keyguard_sim_puk_view.xml +++ b/packages/Keyguard/res/layout/keyguard_sim_puk_view.xml @@ -20,7 +20,7 @@ carrier-provided PUK code and entering a new SIM PIN for it. --> <com.android.keyguard.KeyguardSimPukView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_sim_puk_view" android:orientation="vertical" android:layout_width="match_parent" diff --git a/packages/Keyguard/res/layout/keyguard_status_area.xml b/packages/Keyguard/res/layout/keyguard_status_area.xml index 98ba512..2730517 100644 --- a/packages/Keyguard/res/layout/keyguard_status_area.xml +++ b/packages/Keyguard/res/layout/keyguard_status_area.xml @@ -20,7 +20,7 @@ <!-- This is a view that shows general status information in Keyguard. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" diff --git a/packages/Keyguard/res/layout/keyguard_status_view.xml b/packages/Keyguard/res/layout/keyguard_status_view.xml index a4d298a..3b3a069 100644 --- a/packages/Keyguard/res/layout/keyguard_status_view.xml +++ b/packages/Keyguard/res/layout/keyguard_status_view.xml @@ -18,43 +18,38 @@ --> <!-- This is a view that shows general status information in Keyguard. --> -<com.android.keyguard.KeyguardWidgetFrame +<com.android.keyguard.KeyguardStatusView xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res/com.android.keyguard" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" android:id="@+id/keyguard_status_view" + android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" androidprv:layout_maxWidth="@dimen/keyguard_security_width" androidprv:layout_maxHeight="@dimen/keyguard_security_height" - android:gravity="center"> - - <com.android.keyguard.KeyguardStatusView - android:id="@+id/keyguard_status_view_face_palm" - android:orientation="vertical" + android:gravity="center_horizontal|top" + android:layout_marginTop="32dp" + android:layout_marginBottom="32dp" + android:contentDescription="@string/keyguard_accessibility_status"> + <LinearLayout android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center_horizontal|top" - android:contentDescription="@string/keyguard_accessibility_status"> - <LinearLayout - android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center_horizontal|top" + android:orientation="vertical" + android:focusable="true"> + <TextClock + android:id="@+id/clock_view" + android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal|top" - android:orientation="vertical" - android:focusable="true"> - <TextClock - android:id="@+id/clock_view" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_horizontal|top" - android:textColor="@color/clock_white" - android:singleLine="true" - style="@style/widget_big_thin" - android:format12Hour="@string/keyguard_widget_12_hours_format" - android:format24Hour="@string/keyguard_widget_24_hours_format" - android:baselineAligned="true" - android:layout_marginBottom="@dimen/bottom_text_spacing_digital" /> + android:textColor="@color/clock_white" + android:singleLine="true" + style="@style/widget_big_thin" + android:format12Hour="@string/keyguard_widget_12_hours_format" + android:format24Hour="@string/keyguard_widget_24_hours_format" + android:baselineAligned="true" + android:layout_marginBottom="@dimen/bottom_text_spacing_digital" /> - <include layout="@layout/keyguard_status_area" /> - </LinearLayout> - </com.android.keyguard.KeyguardStatusView> -</com.android.keyguard.KeyguardWidgetFrame> + <include layout="@layout/keyguard_status_area" /> + </LinearLayout> +</com.android.keyguard.KeyguardStatusView> diff --git a/packages/Keyguard/res/values-sk/strings.xml b/packages/Keyguard/res/values-sk/strings.xml index 89ac293..cdf8ca9 100644 --- a/packages/Keyguard/res/values-sk/strings.xml +++ b/packages/Keyguard/res/values-sk/strings.xml @@ -35,7 +35,7 @@ <string name="keyguard_low_battery" msgid="8143808018719173859">"Pripojte nabíjačku."</string> <string name="keyguard_instructions_when_pattern_disabled" msgid="1332288268600329841">"Telefón odomknete stlačením tlačidla Menu."</string> <string name="keyguard_network_locked_message" msgid="9169717779058037168">"Sieť je zablokovaná"</string> - <string name="keyguard_missing_sim_message_short" msgid="494980561304211931">"Nie je vložená karta SIM"</string> + <string name="keyguard_missing_sim_message_short" msgid="494980561304211931">"Nie je vložená karta SIM."</string> <string name="keyguard_missing_sim_message" product="tablet" msgid="1445849005909260039">"V tablete nie je žiadna karta SIM."</string> <string name="keyguard_missing_sim_message" product="default" msgid="3481110395508637643">"V telefóne nie je žiadna karta SIM."</string> <string name="keyguard_missing_sim_instructions" msgid="5210891509995942250">"Vložte kartu SIM."</string> diff --git a/packages/Keyguard/res/values-vi/strings.xml b/packages/Keyguard/res/values-vi/strings.xml index c775467..19eb4c5 100644 --- a/packages/Keyguard/res/values-vi/strings.xml +++ b/packages/Keyguard/res/values-vi/strings.xml @@ -75,7 +75,7 @@ <string name="keyguard_accessibility_transport_thumbs_down_description" msgid="8101433677192177861">"Bài hát được đánh dấu không thích"</string> <string name="keyguard_accessibility_transport_heart_description" msgid="2336943232474689887">"Trái tim"</string> <string name="keyguard_accessibility_show_bouncer" msgid="5425837272418176176">"Mở khóa để tiếp tục"</string> - <string name="keyguard_accessibility_hide_bouncer" msgid="7896992171878309358">"Quá trình chạy bị hủy"</string> + <string name="keyguard_accessibility_hide_bouncer" msgid="7896992171878309358">"Quá trình khởi chạy bị hủy"</string> <string name="keyguard_accessibility_delete_widget_start" msgid="4096550552634391451">"Thả <xliff:g id="WIDGET_INDEX">%1$s</xliff:g> để xóa."</string> <string name="keyguard_accessibility_delete_widget_end" msgid="508833506780909393">"<xliff:g id="WIDGET_INDEX">%1$s</xliff:g> sẽ không bị xóa."</string> <string name="password_keyboard_label_symbol_key" msgid="992280756256536042">"?123"</string> diff --git a/packages/Keyguard/res/values/dimens.xml b/packages/Keyguard/res/values/dimens.xml index 71e9924..c05f834 100644 --- a/packages/Keyguard/res/values/dimens.xml +++ b/packages/Keyguard/res/values/dimens.xml @@ -158,7 +158,7 @@ <dimen name="bottom_text_spacing_digital">-8dp</dimen> <dimen name="label_font_size">14dp</dimen> <dimen name="widget_label_font_size">14dp</dimen> - <dimen name="widget_big_font_size">80dp</dimen> + <dimen name="widget_big_font_size">60dp</dimen> <dimen name="big_font_size">120dp</dimen> </resources> diff --git a/packages/Keyguard/res/values/styles.xml b/packages/Keyguard/res/values/styles.xml index 80fcf75..4a034aa 100644 --- a/packages/Keyguard/res/values/styles.xml +++ b/packages/Keyguard/res/values/styles.xml @@ -56,8 +56,7 @@ <!-- Built-in clock widget stuff --> <style name="widget_label"> <item name="android:textStyle">bold</item> - <item name="android:textAllCaps">true</item> - <item name="android:fontFamily">sans-serif-condensed</item> + <item name="android:fontFamily">sans-serif-light</item> <item name="android:textSize">@dimen/widget_label_font_size</item> </style> <style name="big_thin"> diff --git a/packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java b/packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java index 74e6f33..2bf74ea 100644 --- a/packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java +++ b/packages/Keyguard/src/com/android/keyguard/CameraWidgetFrame.java @@ -38,7 +38,7 @@ import com.android.keyguard.KeyguardActivityLauncher.CameraWidgetInfo; public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnClickListener { private static final String TAG = CameraWidgetFrame.class.getSimpleName(); - private static final boolean DEBUG = KeyguardHostView.DEBUG; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private static final int WIDGET_ANIMATION_DURATION = 250; // ms private static final int WIDGET_WAIT_DURATION = 400; // ms private static final int RECOVERY_DELAY = 1000; // ms @@ -113,12 +113,14 @@ public class CameraWidgetFrame extends KeyguardWidgetFrame implements View.OnCli private final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() { private boolean mShowing; - void onKeyguardVisibilityChanged(boolean showing) { + + @Override + public void onKeyguardVisibilityChanged(boolean showing) { if (mShowing == showing) return; mShowing = showing; CameraWidgetFrame.this.onKeyguardVisibilityChanged(mShowing); - }; + } }; private static final class FixedSizeFrameLayout extends FrameLayout { diff --git a/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java b/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java index fd56613..4ed37d4 100644 --- a/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java +++ b/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java @@ -48,10 +48,11 @@ public class EmergencyButton extends Button { updateEmergencyCallButton(simState, phoneState); } - void onPhoneStateChanged(int phoneState) { + @Override + public void onPhoneStateChanged(int phoneState) { State simState = KeyguardUpdateMonitor.getInstance(mContext).getSimState(); updateEmergencyCallButton(simState, phoneState); - }; + } }; private LockPatternUtils mLockPatternUtils; private PowerManager mPowerManager; diff --git a/packages/Keyguard/src/com/android/keyguard/FaceUnlock.java b/packages/Keyguard/src/com/android/keyguard/FaceUnlock.java index de839c6..2f14003 100644 --- a/packages/Keyguard/src/com/android/keyguard/FaceUnlock.java +++ b/packages/Keyguard/src/com/android/keyguard/FaceUnlock.java @@ -37,8 +37,9 @@ import android.view.View; public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback { - private static final boolean DEBUG = false; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private static final String TAG = "FULLockscreen"; + private static final String FACE_LOCK_PACKAGE = "com.android.facelock"; private final Context mContext; private final LockPatternUtils mLockPatternUtils; @@ -128,7 +129,8 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback { if (!mBoundToService) { Log.d(TAG, "Binding to Face Unlock service for user=" + mLockPatternUtils.getCurrentUser()); - mContext.bindServiceAsUser(new Intent(IFaceLockInterface.class.getName()), + mContext.bindServiceAsUser( + new Intent(IFaceLockInterface.class.getName()).setPackage(FACE_LOCK_PACKAGE), mConnection, Context.BIND_AUTO_CREATE, new UserHandle(mLockPatternUtils.getCurrentUser())); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java index 3950159..4b386b6 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java @@ -231,7 +231,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (mCallback != null) { - mCallback.userActivity(KeyguardViewManager.DIGIT_PRESS_WAKE_MILLIS); + mCallback.userActivity(KeyguardConstants.DIGIT_PRESS_WAKE_MILLIS); } } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java index 0d5e477..25f3383 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardActivityLauncher.java @@ -43,7 +43,7 @@ import java.util.List; public abstract class KeyguardActivityLauncher { private static final String TAG = KeyguardActivityLauncher.class.getSimpleName(); - private static final boolean DEBUG = KeyguardHostView.DEBUG; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private static final String META_DATA_KEYGUARD_LAYOUT = "com.android.keyguard.layout"; private static final Intent SECURE_CAMERA_INTENT = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE) diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java b/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java new file mode 100644 index 0000000..bfa95f3 --- /dev/null +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardConstants.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2014 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.keyguard; + +/** + * Defines constants for the Keyguard. + */ +public class KeyguardConstants { + + /** + * Turns on debugging information for the whole Keyguard. This is very verbose and should only + * be used temporarily for debugging. + */ + public static final boolean DEBUG = false; + + /** Timeout used for key presses. */ + public static final int DIGIT_PRESS_WAKE_MILLIS = 5000; +} diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardDisplayManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardDisplayManager.java index 6bcbd6c..55f965c 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardDisplayManager.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardDisplayManager.java @@ -30,18 +30,18 @@ import android.view.WindowManager; public class KeyguardDisplayManager { protected static final String TAG = "KeyguardDisplayManager"; - private static boolean DEBUG = KeyguardViewMediator.DEBUG; + private static boolean DEBUG = KeyguardConstants.DEBUG; Presentation mPresentation; private MediaRouter mMediaRouter; private Context mContext; private boolean mShowing; - KeyguardDisplayManager(Context context) { + public KeyguardDisplayManager(Context context) { mContext = context; mMediaRouter = (MediaRouter) mContext.getSystemService(Context.MEDIA_ROUTER_SERVICE); } - void show() { + public void show() { if (!mShowing) { if (DEBUG) Slog.v(TAG, "show"); mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY, @@ -51,7 +51,7 @@ public class KeyguardDisplayManager { mShowing = true; } - void hide() { + public void hide() { if (mShowing) { if (DEBUG) Slog.v(TAG, "hide"); mMediaRouter.removeCallback(mMediaRouterCallback); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java index c2cd32f..900d16e 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardFaceUnlockView.java @@ -36,7 +36,7 @@ import java.lang.Math; public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecurityView { private static final String TAG = "FULKeyguardFaceUnlockView"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private KeyguardSecurityCallback mKeyguardSecurityCallback; private LockPatternUtils mLockPatternUtils; private BiometricSensorUnlock mBiometricUnlock; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java index 2e76f19..7cfd684 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java @@ -61,7 +61,7 @@ import java.util.List; public class KeyguardHostView extends KeyguardViewBase { private static final String TAG = "KeyguardHostView"; - public static boolean DEBUG = KeyguardViewMediator.DEBUG; + public static boolean DEBUG = KeyguardConstants.DEBUG; public static boolean DEBUGXPORT = true; // debug music transport control // Transport control states. @@ -118,7 +118,7 @@ public class KeyguardHostView extends KeyguardViewBase { void userActivity(); } - /*package*/ interface OnDismissAction { + public interface OnDismissAction { /* returns true if the dismiss should be deferred */ boolean onDismiss(); } @@ -241,7 +241,7 @@ public class KeyguardHostView extends KeyguardViewBase { } } @Override - void onMusicClientIdChanged( + public void onMusicClientIdChanged( int clientGeneration, boolean clearing, android.app.PendingIntent intent) { // Set transport state to invisible until we know music is playing (below) if (DEBUGXPORT && (mClientGeneration != clientGeneration || clearing)) { @@ -449,7 +449,7 @@ public class KeyguardHostView extends KeyguardViewBase { } @Override - protected void setLockPatternUtils(LockPatternUtils utils) { + public void setLockPatternUtils(LockPatternUtils utils) { super.setLockPatternUtils(utils); getSecurityContainer().updateSecurityViews(mViewStateManager.isBouncing()); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java b/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java index aa2ae0e..3aec55c 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java @@ -37,7 +37,7 @@ import android.widget.TextView; class KeyguardMultiUserAvatar extends FrameLayout { private static final String TAG = KeyguardMultiUserAvatar.class.getSimpleName(); - private static final boolean DEBUG = KeyguardHostView.DEBUG; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private ImageView mUserImage; private TextView mUserName; @@ -123,7 +123,7 @@ class KeyguardMultiUserAvatar extends FrameLayout { mUserName = (TextView) findViewById(R.id.keyguard_user_name); mFramed = (KeyguardCircleFramedDrawable) - KeyguardViewMediator.getAvatarCache().get(user.id); + MultiUserAvatarCache.getInstance().get(user.id); // If we can't find it or the params don't match, create the drawable again if (mFramed == null @@ -143,7 +143,7 @@ class KeyguardMultiUserAvatar extends FrameLayout { mFramed = new KeyguardCircleFramedDrawable(icon, (int) mIconSize, mFrameColor, mStroke, mFrameShadowColor, mShadowRadius, mHighlightColor); - KeyguardViewMediator.getAvatarCache().put(user.id, mFramed); + MultiUserAvatarCache.getInstance().put(user.id, mFramed); } mFramed.reset(); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java index 14de6dd..b4308c6 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardPatternView.java @@ -44,7 +44,7 @@ import java.util.List; public class KeyguardPatternView extends LinearLayout implements KeyguardSecurityView { private static final String TAG = "SecurityPatternView"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = KeyguardConstants.DEBUG; // how long before we clear the wrong pattern private static final int PATTERN_CLEAR_TIMEOUT_MS = 2000; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java index 0f62100..8425c48 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -30,7 +30,7 @@ import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardSecurityModel.SecurityMode; public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSecurityView { - private static final boolean DEBUG = KeyguardViewMediator.DEBUG; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private static final String TAG = "KeyguardSecurityView"; private KeyguardSecurityModel mSecurityModel; private boolean mEnableFallback; // TODO: This should get the value from KeyguardPatternView diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityViewFlipper.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityViewFlipper.java index 70a0e44..07239d1 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityViewFlipper.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityViewFlipper.java @@ -38,7 +38,7 @@ import com.android.internal.widget.LockPatternUtils; */ public class KeyguardSecurityViewFlipper extends ViewFlipper implements KeyguardSecurityView { private static final String TAG = "KeyguardSecurityViewFlipper"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private Rect mTempRect = new Rect(); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSelectorView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSelectorView.java index 97aec68..03e7b07 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSelectorView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSelectorView.java @@ -36,7 +36,6 @@ import com.android.internal.widget.multiwaveview.GlowPadView; import com.android.internal.widget.multiwaveview.GlowPadView.OnTriggerListener; public class KeyguardSelectorView extends LinearLayout implements KeyguardSecurityView { - private static final boolean DEBUG = KeyguardHostView.DEBUG; private static final String TAG = "SecuritySelectorView"; private static final String ASSIST_ICON_METADATA_NAME = "com.android.systemui.action_assist_icon"; @@ -57,12 +56,10 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri public void onTrigger(View v, int target) { final int resId = mGlowPadView.getResourceIdForTarget(target); - switch (resId) { - case R.drawable.ic_lockscreen_unlock_phantom: - case R.drawable.ic_lockscreen_unlock: - mCallback.userActivity(0); - mCallback.dismiss(false); - break; + if (resId == R.drawable.ic_lockscreen_unlock_phantom + || resId == R.drawable.ic_lockscreen_unlock) { + mCallback.userActivity(0); + mCallback.dismiss(false); } } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardService.java b/packages/Keyguard/src/com/android/keyguard/KeyguardService.java deleted file mode 100644 index 36b2446..0000000 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardService.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2013 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.keyguard; - -import java.io.FileDescriptor; -import java.io.PrintWriter; - -import android.app.Service; -import android.content.Intent; -import static android.content.pm.PackageManager.PERMISSION_GRANTED; - -import android.os.Binder; -import android.os.Bundle; -import android.os.Debug; -import android.os.IBinder; -import android.util.Log; -import android.view.MotionEvent; - -import com.android.internal.policy.IKeyguardService; -import com.android.internal.policy.IKeyguardExitCallback; -import com.android.internal.policy.IKeyguardShowCallback; -import com.android.internal.widget.LockPatternUtils; - -public class KeyguardService extends Service { - static final String TAG = "KeyguardService"; - static final String PERMISSION = android.Manifest.permission.CONTROL_KEYGUARD; - private KeyguardViewMediator mKeyguardViewMediator; - - @Override - public void onCreate() { - if (mKeyguardViewMediator == null) { - mKeyguardViewMediator = new KeyguardViewMediator( - KeyguardService.this, new LockPatternUtils(KeyguardService.this)); - } - Log.v(TAG, "onCreate()"); - } - - @Override - public IBinder onBind(Intent intent) { - return mBinder; - } - - @Override - protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - // TODO - } - - void checkPermission() { - if (getBaseContext().checkCallingOrSelfPermission(PERMISSION) != PERMISSION_GRANTED) { - Log.w(TAG, "Caller needs permission '" + PERMISSION + "' to call " + Debug.getCaller()); - throw new SecurityException("Access denied to process: " + Binder.getCallingPid() - + ", must have permission " + PERMISSION); - } - } - - private final IKeyguardService.Stub mBinder = new IKeyguardService.Stub() { - public boolean isShowing() { - return mKeyguardViewMediator.isShowing(); - } - public boolean isSecure() { - return mKeyguardViewMediator.isSecure(); - } - public boolean isShowingAndNotHidden() { - return mKeyguardViewMediator.isShowingAndNotHidden(); - } - public boolean isInputRestricted() { - return mKeyguardViewMediator.isInputRestricted(); - } - public void verifyUnlock(IKeyguardExitCallback callback) { - mKeyguardViewMediator.verifyUnlock(callback); - } - public void keyguardDone(boolean authenticated, boolean wakeup) { - checkPermission(); - mKeyguardViewMediator.keyguardDone(authenticated, wakeup); - } - public void setHidden(boolean isHidden) { - checkPermission(); - mKeyguardViewMediator.setHidden(isHidden); - } - public void dismiss() { - mKeyguardViewMediator.dismiss(); - } - public void onDreamingStarted() { - checkPermission(); - mKeyguardViewMediator.onDreamingStarted(); - } - public void onDreamingStopped() { - checkPermission(); - mKeyguardViewMediator.onDreamingStopped(); - } - public void onScreenTurnedOff(int reason) { - checkPermission(); - mKeyguardViewMediator.onScreenTurnedOff(reason); - } - public void onScreenTurnedOn(IKeyguardShowCallback callback) { - checkPermission(); - mKeyguardViewMediator.onScreenTurnedOn(callback); - } - public void setKeyguardEnabled(boolean enabled) { - checkPermission(); - mKeyguardViewMediator.setKeyguardEnabled(enabled); - } - public boolean isDismissable() { - return mKeyguardViewMediator.isDismissable(); - } - public void onSystemReady() { - checkPermission(); - mKeyguardViewMediator.onSystemReady(); - } - public void doKeyguardTimeout(Bundle options) { - checkPermission(); - mKeyguardViewMediator.doKeyguardTimeout(options); - } - public void setCurrentUser(int userId) { - checkPermission(); - mKeyguardViewMediator.setCurrentUser(userId); - } - public void showAssistant() { - checkPermission(); - mKeyguardViewMediator.showAssistant(); - } - public void dispatch(MotionEvent event) { - checkPermission(); - mKeyguardViewMediator.dispatch(event); - } - public void launchCamera() { - checkPermission(); - mKeyguardViewMediator.launchCamera(); - } - public void onBootCompleted() { - checkPermission(); - mKeyguardViewMediator.onBootCompleted(); - } - }; - -} - diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java index ae7ac97..d6a4f52 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java @@ -41,7 +41,7 @@ import android.widget.TextView.OnEditorActionListener; public class KeyguardSimPinView extends KeyguardAbsKeyInputView implements KeyguardSecurityView, OnEditorActionListener, TextWatcher { private static final String LOG_TAG = "KeyguardSimPinView"; - private static final boolean DEBUG = KeyguardViewMediator.DEBUG; + private static final boolean DEBUG = KeyguardConstants.DEBUG; public static final String TAG = "KeyguardSimPinView"; private ProgressDialog mSimUnlockProgressDialog = null; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java index ca4f811..04cbde1 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimPukView.java @@ -42,7 +42,7 @@ import com.android.internal.telephony.PhoneConstants; public class KeyguardSimPukView extends KeyguardAbsKeyInputView implements KeyguardSecurityView, OnEditorActionListener, TextWatcher { private static final String LOG_TAG = "KeyguardSimPukView"; - private static final boolean DEBUG = KeyguardViewMediator.DEBUG; + private static final boolean DEBUG = KeyguardConstants.DEBUG; public static final String TAG = "KeyguardSimPukView"; private ProgressDialog mSimUnlockProgressDialog = null; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java index cf983cb..5d5168c 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSimpleHostView.java @@ -38,11 +38,6 @@ public class KeyguardSimpleHostView extends KeyguardViewBase { } @Override - public void verifyUnlock() { - // TODO Auto-generated method stub - } - - @Override public void cleanUp() { // TODO Auto-generated method stub } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java index 0bfee38..ae55c4a 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java @@ -33,7 +33,7 @@ import com.android.internal.widget.LockPatternUtils; import java.util.Locale; public class KeyguardStatusView extends GridLayout { - private static final boolean DEBUG = KeyguardViewMediator.DEBUG; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private static final String TAG = "KeyguardStatusView"; private LockPatternUtils mLockPatternUtils; @@ -50,22 +50,22 @@ public class KeyguardStatusView extends GridLayout { } @Override - void onKeyguardVisibilityChanged(boolean showing) { + public void onKeyguardVisibilityChanged(boolean showing) { if (showing) { if (DEBUG) Slog.v(TAG, "refresh statusview showing:" + showing); refresh(); } - }; + } @Override public void onScreenTurnedOn() { setEnableMarquee(true); - }; + } @Override public void onScreenTurnedOff(int why) { setEnableMarquee(false); - }; + } }; public KeyguardStatusView(Context context) { diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java index a7cd909..0d472ae 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java @@ -60,7 +60,7 @@ import java.util.TimeZone; public class KeyguardTransportControlView extends FrameLayout { private static final int RESET_TO_METADATA_DELAY = 5000; - protected static final boolean DEBUG = false; + protected static final boolean DEBUG = KeyguardConstants.DEBUG; protected static final String TAG = "TransportControlView"; private static final boolean ANIMATE_TRANSITIONS = true; diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 88c78ab..73c2840 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -72,7 +72,7 @@ import java.util.ArrayList; public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private static final String TAG = "KeyguardUpdateMonitor"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private static final boolean DEBUG_SIM_STATES = DEBUG || false; private static final int FAILED_BIOMETRIC_UNLOCK_ATTEMPTS_BEFORE_BACKUP = 3; private static final int LOW_BATTERY_THRESHOLD = 20; @@ -679,7 +679,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { * broadcast and hence not handle the event. This method is ultimately called by * PhoneWindowManager in this case. */ - protected void dispatchBootCompleted() { + public void dispatchBootCompleted() { mHandler.sendEmptyMessage(MSG_BOOT_COMPLETED); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 556711b..862931e 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -20,7 +20,7 @@ import android.app.admin.DevicePolicyManager; import android.graphics.Bitmap; import android.media.AudioManager; import android.os.SystemClock; -import android.util.Log; +import android.telephony.TelephonyManager; import android.view.WindowManagerPolicy; import com.android.internal.telephony.IccCardConstants; @@ -28,7 +28,7 @@ import com.android.internal.telephony.IccCardConstants; /** * Callback for general information relevant to lock screen. */ -class KeyguardUpdateMonitorCallback { +public class KeyguardUpdateMonitorCallback { private static final long VISIBILITY_CHANGED_COLLAPSE_MS = 1000; private long mVisibilityChangedCalled; @@ -40,12 +40,12 @@ class KeyguardUpdateMonitorCallback { * * @param status current battery status */ - void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { } + public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) { } /** * Called once per minute or when the time changes. */ - void onTimeChanged() { } + public void onTimeChanged() { } /** * Called when the carrier PLMN or SPN changes. @@ -54,14 +54,14 @@ class KeyguardUpdateMonitorCallback { * be displayed. * @param spn The service provider name. May be null if it shouldn't be displayed. */ - void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) { } + public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) { } /** * Called when the ringer mode changes. * @param state the current ringer state, as defined in * {@link AudioManager#RINGER_MODE_CHANGED_ACTION} */ - void onRingerModeChanged(int state) { } + public void onRingerModeChanged(int state) { } /** * Called when the phone state changes. String will be one of: @@ -69,15 +69,15 @@ class KeyguardUpdateMonitorCallback { * {@link TelephonyManager@EXTRA_STATE_RINGING} * {@link TelephonyManager#EXTRA_STATE_OFFHOOK */ - void onPhoneStateChanged(int phoneState) { } + public void onPhoneStateChanged(int phoneState) { } /** * Called when the visibility of the keyguard changes. * @param showing Indicates if the keyguard is now visible. */ - void onKeyguardVisibilityChanged(boolean showing) { } + public void onKeyguardVisibilityChanged(boolean showing) { } - void onKeyguardVisibilityChangedRaw(boolean showing) { + public void onKeyguardVisibilityChangedRaw(boolean showing) { final long now = SystemClock.elapsedRealtime(); if (showing == mShowing && (now - mVisibilityChangedCalled) < VISIBILITY_CHANGED_COLLAPSE_MS) return; @@ -90,44 +90,44 @@ class KeyguardUpdateMonitorCallback { * Called when visibility of lockscreen clock changes, such as when * obscured by a widget. */ - void onClockVisibilityChanged() { } + public void onClockVisibilityChanged() { } /** * Called when the device becomes provisioned */ - void onDeviceProvisioned() { } + public void onDeviceProvisioned() { } /** * Called when the device policy changes. * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED} */ - void onDevicePolicyManagerStateChanged() { } + public void onDevicePolicyManagerStateChanged() { } /** * Called when the user change begins. */ - void onUserSwitching(int userId) { } + public void onUserSwitching(int userId) { } /** * Called when the user change is complete. */ - void onUserSwitchComplete(int userId) { } + public void onUserSwitchComplete(int userId) { } /** * Called when the SIM state changes. * @param simState */ - void onSimStateChanged(IccCardConstants.State simState) { } + public void onSimStateChanged(IccCardConstants.State simState) { } /** * Called when a user is removed. */ - void onUserRemoved(int userId) { } + public void onUserRemoved(int userId) { } /** * Called when the user's info changed. */ - void onUserInfoChanged(int userId) { } + public void onUserInfoChanged(int userId) { } /** * Called when boot completed. @@ -135,12 +135,12 @@ class KeyguardUpdateMonitorCallback { * Note, this callback will only be received if boot complete occurs after registering with * KeyguardUpdateMonitor. */ - void onBootCompleted() { } + public void onBootCompleted() { } /** * Called when audio client attaches or detaches from AudioManager. */ - void onMusicClientIdChanged(int clientGeneration, boolean clearing, PendingIntent intent) { } + public void onMusicClientIdChanged(int clientGeneration, boolean clearing, PendingIntent intent) { } /** * Called when the audio playback state changes. diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java index 78f4506..bc0f364 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewBase.java @@ -60,7 +60,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa private AudioManager mAudioManager; private TelephonyManager mTelephonyManager = null; - protected KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback; + protected ViewMediatorCallback mViewMediatorCallback; protected LockPatternUtils mLockPatternUtils; private OnDismissAction mDismissAction; @@ -68,7 +68,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa // they will be handled here for specific media types such as music, otherwise // the audio service will bring up the volume dialog. private static final boolean KEYGUARD_MANAGES_VOLUME = true; - private static final boolean DEBUG = false; + public static final boolean DEBUG = KeyguardConstants.DEBUG; private static final String TAG = "KeyguardViewBase"; private KeyguardSecurityContainer mSecurityContainer; @@ -107,7 +107,6 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa mSecurityContainer.setSecurityCallback(this); mSecurityContainer.showPrimarySecurityScreen(false); // mSecurityContainer.updateSecurityViews(false /* not bouncing */); - setBackButtonEnabled(false); } /** @@ -120,15 +119,11 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa /** * Dismisses the keyguard by going to the next screen or making it gone. + * + * @return True if the keyguard is done. */ - public void dismiss() { - dismiss(false); - } - - private void setBackButtonEnabled(boolean enabled) { - setSystemUiVisibility(enabled ? - getSystemUiVisibility() & ~View.STATUS_BAR_DISABLE_BACK : - getSystemUiVisibility() | View.STATUS_BAR_DISABLE_BACK); + public boolean dismiss() { + return dismiss(false); } protected void showBouncer(boolean show) { @@ -141,8 +136,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa public boolean handleBackKey() { if (mSecurityContainer.getCurrentSecuritySelection() == SecurityMode.Account) { - // go back to primary screen and re-disable back - setBackButtonEnabled(false); + // go back to primary screen mSecurityContainer.showPrimarySecurityScreen(false /*turningOff*/); return true; } @@ -205,12 +199,6 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa @Override public void onSecurityModeChanged(SecurityMode securityMode, boolean needsInput) { - // Enable or disable the back button based on security mode - if (securityMode == SecurityMode.Account && !mLockPatternUtils.isPermanentlyLocked()) { - // we're showing account as a backup, provide a way to get back to primary - setBackButtonEnabled(true); - } - if (mViewMediatorCallback != null) { mViewMediatorCallback.setNeedsInput(needsInput); } @@ -231,7 +219,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa /** * Called when the screen turned off. */ - protected void onScreenTurnedOff() { + public void onScreenTurnedOff() { if (DEBUG) Log.d(TAG, String.format("screen off, instance %s at %s", Integer.toHexString(hashCode()), SystemClock.uptimeMillis())); // Once the screen turns off, we no longer consider this to be first boot and we want the @@ -245,7 +233,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa /** * Called when the screen turned on. */ - protected void onScreenTurnedOn() { + public void onScreenTurnedOn() { if (DEBUG) Log.d(TAG, "screen on, instance " + Integer.toHexString(hashCode())); mSecurityContainer.showPrimarySecurityScreen(false); mSecurityContainer.onResume(KeyguardSecurityView.SCREEN_ON); @@ -433,8 +421,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa return false; } - public void setViewMediatorCallback( - KeyguardViewMediator.ViewMediatorCallback viewMediatorCallback) { + public void setViewMediatorCallback(ViewMediatorCallback viewMediatorCallback) { mViewMediatorCallback = viewMediatorCallback; // Update ViewMediator with the current input method requirements mViewMediatorCallback.setNeedsInput(mSecurityContainer.needsInput()); @@ -484,7 +471,7 @@ public abstract class KeyguardViewBase extends FrameLayout implements SecurityCa mActivityLauncher.launchCamera(getHandler(), null); } - protected void setLockPatternUtils(LockPatternUtils utils) { + public void setLockPatternUtils(LockPatternUtils utils) { mLockPatternUtils = utils; mSecurityContainer.setLockPatternUtils(utils); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java deleted file mode 100644 index 5b35ba8..0000000 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewManager.java +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright (C) 2007 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.keyguard; - -import android.graphics.Bitmap; -import android.graphics.drawable.BitmapDrawable; - -import com.android.internal.policy.IKeyguardShowCallback; -import com.android.internal.widget.LockPatternUtils; -import com.android.keyguard.analytics.KeyguardAnalytics; - -import org.xmlpull.v1.XmlPullParser; - -import android.app.ActivityManager; -import android.content.ContentResolver; -import android.content.Context; -import android.content.pm.ActivityInfo; -import android.content.res.Configuration; -import android.content.res.Resources; -import android.graphics.Canvas; -import android.graphics.ColorFilter; -import android.graphics.PixelFormat; -import android.graphics.PorterDuff; -import android.graphics.Rect; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.os.IBinder; -import android.os.Parcelable; -import android.os.RemoteException; -import android.os.SystemProperties; -import android.provider.Settings; -import android.util.Log; -import android.util.Slog; -import android.util.SparseArray; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewManager; -import android.view.WindowManager; -import android.widget.FrameLayout; - -/** - * Manages creating, showing, hiding and resetting the keyguard. Calls back - * via {@link KeyguardViewMediator.ViewMediatorCallback} to poke - * the wake lock and report that the keyguard is done, which is in turn, - * reported to this class by the current {@link KeyguardViewBase}. - */ -public class KeyguardViewManager { - private final static boolean DEBUG = KeyguardViewMediator.DEBUG; - private static String TAG = "KeyguardViewManager"; - public final static String IS_SWITCHING_USER = "is_switching_user"; - - // Delay dismissing keyguard to allow animations to complete. - private static final int HIDE_KEYGUARD_DELAY = 500; - - // Timeout used for keypresses - static final int DIGIT_PRESS_WAKE_MILLIS = 5000; - private static final boolean ENABLE_SIMPLE_KEYGUARD = false; - - private final Context mContext; - private final ViewManager mViewManager; - private final KeyguardViewMediator.ViewMediatorCallback mViewMediatorCallback; - private final KeyguardAnalytics.Callback mAnalyticsCallback; - - private WindowManager.LayoutParams mWindowLayoutParams; - private boolean mNeedsInput = false; - - private ViewManagerHost mKeyguardHost; - private KeyguardViewBase mKeyguardView; - - private boolean mScreenOn = false; - private LockPatternUtils mLockPatternUtils; - - private KeyguardUpdateMonitorCallback mBackgroundChanger = new KeyguardUpdateMonitorCallback() { - @Override - public void onSetBackground(Bitmap bmp) { - mKeyguardHost.setCustomBackground(bmp != null ? - new BitmapDrawable(mContext.getResources(), bmp) : null); - updateShowWallpaper(bmp == null); - } - }; - - public interface ShowListener { - void onShown(IBinder windowToken); - }; - - /** - * @param context Used to create views. - * @param viewManager Keyguard will be attached to this. - * @param callback Used to notify of changes. - * @param lockPatternUtils - */ - public KeyguardViewManager(Context context, ViewManager viewManager, - KeyguardViewMediator.ViewMediatorCallback callback, - LockPatternUtils lockPatternUtils, KeyguardAnalytics.Callback analyticsCallback) { - mContext = context; - mViewManager = viewManager; - mViewMediatorCallback = callback; - mLockPatternUtils = lockPatternUtils; - mAnalyticsCallback = analyticsCallback; - } - - /** - * Show the keyguard. Will handle creating and attaching to the view manager - * lazily. - */ - public synchronized void show(Bundle options) { - if (DEBUG) Log.d(TAG, "show(); mKeyguardView==" + mKeyguardView); - if (mAnalyticsCallback != null) { - mAnalyticsCallback.onShow(); - } - - boolean enableScreenRotation = shouldEnableScreenRotation(); - - maybeCreateKeyguardLocked(enableScreenRotation, false, options); - maybeEnableScreenRotation(enableScreenRotation); - - // Disable common aspects of the system/status/navigation bars that are not appropriate or - // useful on any keyguard screen but can be re-shown by dialogs or SHOW_WHEN_LOCKED - // activities. Other disabled bits are handled by the KeyguardViewMediator talking - // directly to the status bar service. - int visFlags = View.STATUS_BAR_DISABLE_HOME; - if (shouldEnableTranslucentDecor()) { - mWindowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS - | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION; - } - if (DEBUG) Log.v(TAG, "show:setSystemUiVisibility(" + Integer.toHexString(visFlags)+")"); - mKeyguardHost.setSystemUiVisibility(visFlags); - - mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); - mKeyguardHost.setVisibility(View.VISIBLE); - mKeyguardView.show(); - mKeyguardView.requestFocus(); - } - - private boolean shouldEnableScreenRotation() { - Resources res = mContext.getResources(); - return SystemProperties.getBoolean("lockscreen.rot_override",false) - || res.getBoolean(R.bool.config_enableLockScreenRotation); - } - - private boolean shouldEnableTranslucentDecor() { - Resources res = mContext.getResources(); - return res.getBoolean(R.bool.config_enableLockScreenTranslucentDecor); - } - - class ViewManagerHost extends FrameLayout { - private static final int BACKGROUND_COLOR = 0x70000000; - - private Drawable mCustomBackground; - - // This is a faster way to draw the background on devices without hardware acceleration - private final Drawable mBackgroundDrawable = new Drawable() { - @Override - public void draw(Canvas canvas) { - if (mCustomBackground != null) { - final Rect bounds = mCustomBackground.getBounds(); - final int vWidth = getWidth(); - final int vHeight = getHeight(); - - final int restore = canvas.save(); - canvas.translate(-(bounds.width() - vWidth) / 2, - -(bounds.height() - vHeight) / 2); - mCustomBackground.draw(canvas); - canvas.restoreToCount(restore); - } else { - canvas.drawColor(BACKGROUND_COLOR, PorterDuff.Mode.SRC); - } - } - - @Override - public void setAlpha(int alpha) { - } - - @Override - public void setColorFilter(ColorFilter cf) { - } - - @Override - public int getOpacity() { - return PixelFormat.TRANSLUCENT; - } - }; - - public ViewManagerHost(Context context) { - super(context); - setBackground(mBackgroundDrawable); - } - - public void setCustomBackground(Drawable d) { - mCustomBackground = d; - if (d != null) { - d.setColorFilter(BACKGROUND_COLOR, PorterDuff.Mode.SRC_OVER); - } - computeCustomBackgroundBounds(); - invalidate(); - } - - private void computeCustomBackgroundBounds() { - if (mCustomBackground == null) return; // Nothing to do - if (!isLaidOut()) return; // We'll do this later - - final int bgWidth = mCustomBackground.getIntrinsicWidth(); - final int bgHeight = mCustomBackground.getIntrinsicHeight(); - final int vWidth = getWidth(); - final int vHeight = getHeight(); - - final float bgAspect = (float) bgWidth / bgHeight; - final float vAspect = (float) vWidth / vHeight; - - if (bgAspect > vAspect) { - mCustomBackground.setBounds(0, 0, (int) (vHeight * bgAspect), vHeight); - } else { - mCustomBackground.setBounds(0, 0, vWidth, (int) (vWidth / bgAspect)); - } - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - computeCustomBackgroundBounds(); - } - - @Override - protected void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - if (mKeyguardHost.getVisibility() == View.VISIBLE) { - // only propagate configuration messages if we're currently showing - maybeCreateKeyguardLocked(shouldEnableScreenRotation(), true, null); - } else { - if (DEBUG) Log.v(TAG, "onConfigurationChanged: view not visible"); - } - } - - @Override - public boolean dispatchKeyEvent(KeyEvent event) { - if (mKeyguardView != null) { - // Always process back and menu keys, regardless of focus - if (event.getAction() == KeyEvent.ACTION_DOWN) { - int keyCode = event.getKeyCode(); - if (keyCode == KeyEvent.KEYCODE_BACK && mKeyguardView.handleBackKey()) { - return true; - } else if (keyCode == KeyEvent.KEYCODE_MENU && mKeyguardView.handleMenuKey()) { - return true; - } - } - // Always process media keys, regardless of focus - if (mKeyguardView.dispatchKeyEvent(event)) { - return true; - } - } - return super.dispatchKeyEvent(event); - } - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - boolean result = false; - if (mAnalyticsCallback != null) { - result = mAnalyticsCallback.onTouchEvent(ev, getWidth(), getHeight()) || result; - } - return super.dispatchTouchEvent(ev) || result; - } - } - - SparseArray<Parcelable> mStateContainer = new SparseArray<Parcelable>(); - private int mCurrentLayout; - - private void maybeCreateKeyguardLocked(boolean enableScreenRotation, boolean force, - Bundle options) { - if (mKeyguardHost != null) { - mKeyguardHost.saveHierarchyState(mStateContainer); - } - - if (mKeyguardHost == null) { - if (DEBUG) Log.d(TAG, "keyguard host is null, creating it..."); - - mKeyguardHost = new ViewManagerHost(mContext); - - int flags = WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN - | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR - | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN - | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; - - if (!mNeedsInput) { - flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; - } - - final int stretch = ViewGroup.LayoutParams.MATCH_PARENT; - final int type = WindowManager.LayoutParams.TYPE_KEYGUARD; - WindowManager.LayoutParams lp = new WindowManager.LayoutParams( - stretch, stretch, type, flags, PixelFormat.TRANSLUCENT); - lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; - lp.windowAnimations = R.style.Animation_LockScreen; - lp.screenOrientation = enableScreenRotation ? - ActivityInfo.SCREEN_ORIENTATION_USER : ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; - - if (ActivityManager.isHighEndGfx()) { - lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; - lp.privateFlags |= - WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; - } - lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SET_NEEDS_MENU_KEY; - lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY; - lp.setTitle("Keyguard"); - mWindowLayoutParams = lp; - mViewManager.addView(mKeyguardHost, lp); - - KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mBackgroundChanger); - } - - if (force || mKeyguardView == null) { - mKeyguardHost.setCustomBackground(null); - mKeyguardHost.removeAllViews(); - int layout = (allowNotificationsOnSecureKeyguard() && ENABLE_SIMPLE_KEYGUARD) - ? R.layout.keyguard_simple_host_view - : R.layout.keyguard_host_view; - if (mCurrentLayout != layout) { - mStateContainer.clear(); // don't restore to the wrong view hierarchy - mCurrentLayout = layout; - } - mKeyguardView = inflateKeyguardView(options, layout); - mKeyguardView.requestFocus(); - } - updateUserActivityTimeoutInWindowLayoutParams(); - mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); - - mKeyguardHost.restoreHierarchyState(mStateContainer); - } - - private boolean allowNotificationsOnSecureKeyguard() { - ContentResolver cr = mContext.getContentResolver(); - return Settings.Global.getInt(cr, Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, 0) == 1; - } - - private KeyguardViewBase inflateKeyguardView(Bundle options, int layoutId) { - View v = mKeyguardHost.findViewById(R.id.keyguard_host_view); - if (v != null) { - mKeyguardHost.removeView(v); - } - final LayoutInflater inflater = LayoutInflater.from(mContext); - View view = inflater.inflate(layoutId, mKeyguardHost, true); - KeyguardViewBase keyguard = (KeyguardViewBase) view.findViewById(R.id.keyguard_host_view); - keyguard.setLockPatternUtils(mLockPatternUtils); - keyguard.setViewMediatorCallback(mViewMediatorCallback); - keyguard.onUserSwitching(options != null && options.getBoolean(IS_SWITCHING_USER)); - keyguard.onCreateOptions(options); - return keyguard; - } - - public void updateUserActivityTimeout() { - updateUserActivityTimeoutInWindowLayoutParams(); - mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); - } - - private void updateUserActivityTimeoutInWindowLayoutParams() { - // Use the user activity timeout requested by the keyguard view, if any. - if (mKeyguardView != null) { - long timeout = mKeyguardView.getUserActivityTimeout(); - if (timeout >= 0) { - mWindowLayoutParams.userActivityTimeout = timeout; - return; - } - } - - // Otherwise, use the default timeout. - mWindowLayoutParams.userActivityTimeout = KeyguardViewMediator.AWAKE_INTERVAL_DEFAULT_MS; - } - - private void maybeEnableScreenRotation(boolean enableScreenRotation) { - // TODO: move this outside - if (enableScreenRotation) { - if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen On!"); - mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER; - } else { - if (DEBUG) Log.d(TAG, "Rotation sensor for lock screen Off!"); - mWindowLayoutParams.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; - } - mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); - } - - void updateShowWallpaper(boolean show) { - if (show) { - mWindowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; - } else { - mWindowLayoutParams.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; - } - mWindowLayoutParams.format = show ? PixelFormat.TRANSLUCENT : PixelFormat.OPAQUE; - - mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); - } - - public void setNeedsInput(boolean needsInput) { - mNeedsInput = needsInput; - if (mWindowLayoutParams != null) { - if (needsInput) { - mWindowLayoutParams.flags &= - ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; - } else { - mWindowLayoutParams.flags |= - WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; - } - - try { - mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams); - } catch (java.lang.IllegalArgumentException e) { - // TODO: Ensure this method isn't called on views that are changing... - Log.w(TAG,"Can't update input method on " + mKeyguardHost + " window not attached"); - } - } - } - - /** - * Reset the state of the view. - */ - public synchronized void reset(Bundle options) { - if (DEBUG) Log.d(TAG, "reset()"); - // User might have switched, check if we need to go back to keyguard - // TODO: It's preferable to stay and show the correct lockscreen or unlock if none - maybeCreateKeyguardLocked(shouldEnableScreenRotation(), true, options); - } - - public synchronized void onScreenTurnedOff() { - if (DEBUG) Log.d(TAG, "onScreenTurnedOff()"); - mScreenOn = false; - if (mKeyguardView != null) { - mKeyguardView.onScreenTurnedOff(); - } - } - - public synchronized void onScreenTurnedOn(final IKeyguardShowCallback callback) { - if (DEBUG) Log.d(TAG, "onScreenTurnedOn()"); - mScreenOn = true; - - // If keyguard is not showing, we need to inform PhoneWindowManager with a null - // token so it doesn't wait for us to draw... - final IBinder token = isShowing() ? mKeyguardHost.getWindowToken() : null; - - if (DEBUG && token == null) Slog.v(TAG, "send wm null token: " - + (mKeyguardHost == null ? "host was null" : "not showing")); - - if (mKeyguardView != null) { - mKeyguardView.onScreenTurnedOn(); - - // Caller should wait for this window to be shown before turning - // on the screen. - if (callback != null) { - if (mKeyguardHost.getVisibility() == View.VISIBLE) { - // Keyguard may be in the process of being shown, but not yet - // updated with the window manager... give it a chance to do so. - mKeyguardHost.post(new Runnable() { - @Override - public void run() { - try { - callback.onShown(token); - } catch (RemoteException e) { - Slog.w(TAG, "Exception calling onShown():", e); - } - } - }); - } else { - try { - callback.onShown(token); - } catch (RemoteException e) { - Slog.w(TAG, "Exception calling onShown():", e); - } - } - } - } else if (callback != null) { - try { - callback.onShown(token); - } catch (RemoteException e) { - Slog.w(TAG, "Exception calling onShown():", e); - } - } - if (mAnalyticsCallback != null) { - mAnalyticsCallback.onScreenOn(); - } - } - - public synchronized void verifyUnlock() { - if (DEBUG) Log.d(TAG, "verifyUnlock()"); - show(null); - mKeyguardView.verifyUnlock(); - } - - /** - * Hides the keyguard view - */ - public synchronized void hide() { - if (DEBUG) Log.d(TAG, "hide()"); - - if (mAnalyticsCallback != null) { - mAnalyticsCallback.onHide(); - } - - if (mKeyguardHost != null) { - mKeyguardHost.setVisibility(View.GONE); - - // We really only want to preserve keyguard state for configuration changes. Hence - // we should clear state of widgets (e.g. Music) when we hide keyguard so it can - // start with a fresh state when we return. - mStateContainer.clear(); - - // Don't do this right away, so we can let the view continue to animate - // as it goes away. - if (mKeyguardView != null) { - final KeyguardViewBase lastView = mKeyguardView; - mKeyguardView = null; - mKeyguardHost.postDelayed(new Runnable() { - @Override - public void run() { - synchronized (KeyguardViewManager.this) { - lastView.cleanUp(); - // Let go of any large bitmaps. - mKeyguardHost.setCustomBackground(null); - updateShowWallpaper(true); - mKeyguardHost.removeView(lastView); - mViewMediatorCallback.keyguardGone(); - } - } - }, HIDE_KEYGUARD_DELAY); - } - } - } - - /** - * Dismisses the keyguard by going to the next screen or making it gone. - */ - public synchronized void dismiss() { - if (mScreenOn) { - mKeyguardView.dismiss(); - } - } - - /** - * @return Whether the keyguard is showing - */ - public synchronized boolean isShowing() { - return (mKeyguardHost != null && mKeyguardHost.getVisibility() == View.VISIBLE); - } - - public void showAssistant() { - if (mKeyguardView != null) { - mKeyguardView.showAssistant(); - } - } - - public void dispatch(MotionEvent event) { - if (mKeyguardView != null) { - mKeyguardView.onExternalMotionEvent(event); - } - } - - public void launchCamera() { - if (mKeyguardView != null) { - mKeyguardView.launchCamera(); - } - } -} diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java deleted file mode 100644 index 354d13f..0000000 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java +++ /dev/null @@ -1,1458 +0,0 @@ -/* - * Copyright (C) 2007 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.keyguard; - -import com.android.internal.policy.IKeyguardExitCallback; -import com.android.internal.policy.IKeyguardShowCallback; -import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; -import static com.android.keyguard.analytics.KeyguardAnalytics.SessionTypeAdapter; - -import android.app.Activity; -import android.app.ActivityManagerNative; -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.app.SearchManager; -import android.app.StatusBarManager; -import android.content.BroadcastReceiver; -import android.content.ContentResolver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.media.AudioManager; -import android.media.SoundPool; -import android.os.Build; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; -import android.os.PowerManager; -import android.os.RemoteException; -import android.os.SystemClock; -import android.os.SystemProperties; -import android.os.UserHandle; -import android.os.UserManager; -import android.provider.Settings; -import android.telephony.TelephonyManager; -import android.util.EventLog; -import android.util.Log; -import android.util.Slog; -import android.view.MotionEvent; -import android.view.WindowManager; -import android.view.WindowManagerPolicy; - -import com.android.internal.telephony.IccCardConstants; -import com.android.internal.widget.LockPatternUtils; -import com.android.keyguard.analytics.Session; -import com.android.keyguard.analytics.KeyguardAnalytics; - -import java.io.File; - - -/** - * Mediates requests related to the keyguard. This includes queries about the - * state of the keyguard, power management events that effect whether the keyguard - * should be shown or reset, callbacks to the phone window manager to notify - * it of when the keyguard is showing, and events from the keyguard view itself - * stating that the keyguard was succesfully unlocked. - * - * Note that the keyguard view is shown when the screen is off (as appropriate) - * so that once the screen comes on, it will be ready immediately. - * - * Example queries about the keyguard: - * - is {movement, key} one that should wake the keygaurd? - * - is the keyguard showing? - * - are input events restricted due to the state of the keyguard? - * - * Callbacks to the phone window manager: - * - the keyguard is showing - * - * Example external events that translate to keyguard view changes: - * - screen turned off -> reset the keyguard, and show it so it will be ready - * next time the screen turns on - * - keyboard is slid open -> if the keyguard is not secure, hide it - * - * Events from the keyguard view: - * - user succesfully unlocked keyguard -> hide keyguard view, and no longer - * restrict input events. - * - * Note: in addition to normal power managment events that effect the state of - * whether the keyguard should be showing, external apps and services may request - * that the keyguard be disabled via {@link #setKeyguardEnabled(boolean)}. When - * false, this will override all other conditions for turning on the keyguard. - * - * Threading and synchronization: - * This class is created by the initialization routine of the {@link WindowManagerPolicy}, - * and runs on its thread. The keyguard UI is created from that thread in the - * constructor of this class. The apis may be called from other threads, including the - * {@link com.android.server.input.InputManagerService}'s and {@link android.view.WindowManager}'s. - * Therefore, methods on this class are synchronized, and any action that is pointed - * directly to the keyguard UI is posted to a {@link Handler} to ensure it is taken on the UI - * thread of the keyguard. - */ -public class KeyguardViewMediator { - private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000; - final static boolean DEBUG = false; - private static final boolean ENABLE_ANALYTICS = Build.IS_DEBUGGABLE; - private final static boolean DBG_WAKE = false; - - private final static String TAG = "KeyguardViewMediator"; - - private static final String DELAYED_KEYGUARD_ACTION = - "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; - - // used for handler messages - private static final int SHOW = 2; - private static final int HIDE = 3; - private static final int RESET = 4; - private static final int VERIFY_UNLOCK = 5; - private static final int NOTIFY_SCREEN_OFF = 6; - private static final int NOTIFY_SCREEN_ON = 7; - private static final int KEYGUARD_DONE = 9; - private static final int KEYGUARD_DONE_DRAWING = 10; - private static final int KEYGUARD_DONE_AUTHENTICATING = 11; - private static final int SET_HIDDEN = 12; - private static final int KEYGUARD_TIMEOUT = 13; - private static final int SHOW_ASSISTANT = 14; - private static final int DISPATCH_EVENT = 15; - private static final int LAUNCH_CAMERA = 16; - private static final int DISMISS = 17; - - /** - * The default amount of time we stay awake (used for all key input) - */ - protected static final int AWAKE_INTERVAL_DEFAULT_MS = 10000; - - /** - * How long to wait after the screen turns off due to timeout before - * turning on the keyguard (i.e, the user has this much time to turn - * the screen back on without having to face the keyguard). - */ - private static final int KEYGUARD_LOCK_AFTER_DELAY_DEFAULT = 5000; - - /** - * How long we'll wait for the {@link ViewMediatorCallback#keyguardDoneDrawing()} - * callback before unblocking a call to {@link #setKeyguardEnabled(boolean)} - * that is reenabling the keyguard. - */ - private static final int KEYGUARD_DONE_DRAWING_TIMEOUT_MS = 2000; - - /** - * Allow the user to expand the status bar when the keyguard is engaged - * (without a pattern or password). - */ - private static final boolean ENABLE_INSECURE_STATUS_BAR_EXPAND = true; - - /** - * Allow the user to expand the status bar when a SECURE keyguard is engaged - * and {@link Settings.Global#LOCK_SCREEN_SHOW_NOTIFICATIONS} is set - * (private notifications will be masked). - */ - private static final boolean ENABLE_SECURE_STATUS_BAR_EXPAND = true; - - /** - * Default value of {@link Settings.Global#LOCK_SCREEN_SHOW_NOTIFICATIONS}. - */ - private static final boolean ALLOW_NOTIFICATIONS_DEFAULT = false; - - /** - * Secure setting whether analytics are collected on the keyguard. - */ - private static final String KEYGUARD_ANALYTICS_SETTING = "keyguard_analytics"; - - /** The stream type that the lock sounds are tied to. */ - private int mMasterStreamType; - - private Context mContext; - private AlarmManager mAlarmManager; - private AudioManager mAudioManager; - private StatusBarManager mStatusBarManager; - private boolean mSwitchingUser; - - private boolean mSystemReady; - - // Whether the next call to playSounds() should be skipped. Defaults to - // true because the first lock (on boot) should be silent. - private boolean mSuppressNextLockSound = true; - - - /** High level access to the power manager for WakeLocks */ - private PowerManager mPM; - - /** UserManager for querying number of users */ - private UserManager mUserManager; - - /** SearchManager for determining whether or not search assistant is available */ - private SearchManager mSearchManager; - - /** - * Used to keep the device awake while to ensure the keyguard finishes opening before - * we sleep. - */ - private PowerManager.WakeLock mShowKeyguardWakeLock; - - private KeyguardViewManager mKeyguardViewManager; - - private final KeyguardAnalytics mKeyguardAnalytics; - - // these are protected by synchronized (this) - - /** - * External apps (like the phone app) can tell us to disable the keygaurd. - */ - private boolean mExternallyEnabled = true; - - /** - * Remember if an external call to {@link #setKeyguardEnabled} with value - * false caused us to hide the keyguard, so that we need to reshow it once - * the keygaurd is reenabled with another call with value true. - */ - private boolean mNeedToReshowWhenReenabled = false; - - // cached value of whether we are showing (need to know this to quickly - // answer whether the input should be restricted) - private boolean mShowing; - - // true if the keyguard is hidden by another window - private boolean mHidden = false; - - /** - * Helps remember whether the screen has turned on since the last time - * it turned off due to timeout. see {@link #onScreenTurnedOff(int)} - */ - private int mDelayedShowingSequence; - - /** - * If the user has disabled the keyguard, then requests to exit, this is - * how we'll ultimately let them know whether it was successful. We use this - * var being non-null as an indicator that there is an in progress request. - */ - private IKeyguardExitCallback mExitSecureCallback; - - // the properties of the keyguard - - private KeyguardUpdateMonitor mUpdateMonitor; - - private boolean mScreenOn; - - // last known state of the cellular connection - private String mPhoneState = TelephonyManager.EXTRA_STATE_IDLE; - - /** - * we send this intent when the keyguard is dismissed. - */ - private static final Intent USER_PRESENT_INTENT = new Intent(Intent.ACTION_USER_PRESENT) - .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING - | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); - - /** - * {@link #setKeyguardEnabled} waits on this condition when it reenables - * the keyguard. - */ - private boolean mWaitingUntilKeyguardVisible = false; - private LockPatternUtils mLockPatternUtils; - private boolean mKeyguardDonePending = false; - - private SoundPool mLockSounds; - private int mLockSoundId; - private int mUnlockSoundId; - private int mLockSoundStreamId; - - /** - * Tracks value of {@link Settings.Global#LOCK_SCREEN_SHOW_NOTIFICATIONS}. - */ - private boolean mAllowNotificationsWhenSecure; - - /** - * The volume applied to the lock/unlock sounds. - */ - private final float mLockSoundVolume; - - /** - * For managing external displays - */ - private KeyguardDisplayManager mKeyguardDisplayManager; - - /** - * Cache of avatar drawables, for use by KeyguardMultiUserAvatar. - */ - private static MultiUserAvatarCache sMultiUserAvatarCache = new MultiUserAvatarCache(); - - /** - * The callback used by the keyguard view to tell the {@link KeyguardViewMediator} - * various things. - */ - public interface ViewMediatorCallback { - /** - * Reports user activity and requests that the screen stay on. - */ - void userActivity(); - - /** - * Reports user activity and requests that the screen stay on for at least - * the specified amount of time. - * @param millis The amount of time in millis. This value is currently ignored. - */ - void userActivity(long millis); - - /** - * Report that the keyguard is done. - * @param authenticated Whether the user securely got past the keyguard. - * the only reason for this to be false is if the keyguard was instructed - * to appear temporarily to verify the user is supposed to get past the - * keyguard, and the user fails to do so. - */ - void keyguardDone(boolean authenticated); - - /** - * Report that the keyguard is done drawing. - */ - void keyguardDoneDrawing(); - - /** - * Tell ViewMediator that the current view needs IME input - * @param needsInput - */ - void setNeedsInput(boolean needsInput); - - /** - * Tell view mediator that the keyguard view's desired user activity timeout - * has changed and needs to be reapplied to the window. - */ - void onUserActivityTimeoutChanged(); - - /** - * Report that the keyguard is dismissable, pending the next keyguardDone call. - */ - void keyguardDonePending(); - - /** - * Report when keyguard is actually gone - */ - void keyguardGone(); - } - - KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { - - @Override - public void onUserSwitching(int userId) { - // Note that the mLockPatternUtils user has already been updated from setCurrentUser. - // We need to force a reset of the views, since lockNow (called by - // ActivityManagerService) will not reconstruct the keyguard if it is already showing. - synchronized (KeyguardViewMediator.this) { - mSwitchingUser = true; - resetStateLocked(null); - adjustStatusBarLocked(); - // When we switch users we want to bring the new user to the biometric unlock even - // if the current user has gone to the backup. - KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(true); - } - } - - @Override - public void onUserSwitchComplete(int userId) { - mSwitchingUser = false; - } - - @Override - public void onUserRemoved(int userId) { - mLockPatternUtils.removeUser(userId); - sMultiUserAvatarCache.clear(userId); - } - - @Override - public void onUserInfoChanged(int userId) { - sMultiUserAvatarCache.clear(userId); - } - - @Override - void onPhoneStateChanged(int phoneState) { - synchronized (KeyguardViewMediator.this) { - if (TelephonyManager.CALL_STATE_IDLE == phoneState // call ending - && !mScreenOn // screen off - && mExternallyEnabled) { // not disabled by any app - - // note: this is a way to gracefully reenable the keyguard when the call - // ends and the screen is off without always reenabling the keyguard - // each time the screen turns off while in call (and having an occasional ugly - // flicker while turning back on the screen and disabling the keyguard again). - if (DEBUG) Log.d(TAG, "screen is off and call ended, let's make sure the " - + "keyguard is showing"); - doKeyguardLocked(null); - } - } - }; - - @Override - public void onClockVisibilityChanged() { - adjustStatusBarLocked(); - } - - @Override - public void onDeviceProvisioned() { - sendUserPresentBroadcast(); - } - - @Override - public void onSimStateChanged(IccCardConstants.State simState) { - if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState); - - switch (simState) { - case NOT_READY: - case ABSENT: - // only force lock screen in case of missing sim if user hasn't - // gone through setup wizard - synchronized (this) { - if (!mUpdateMonitor.isDeviceProvisioned()) { - if (!isShowing()) { - if (DEBUG) Log.d(TAG, "ICC_ABSENT isn't showing," - + " we need to show the keyguard since the " - + "device isn't provisioned yet."); - doKeyguardLocked(null); - } else { - resetStateLocked(null); - } - } - } - break; - case PIN_REQUIRED: - case PUK_REQUIRED: - synchronized (this) { - if (!isShowing()) { - if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't " - + "showing; need to show keyguard so user can enter sim pin"); - doKeyguardLocked(null); - } else { - resetStateLocked(null); - } - } - break; - case PERM_DISABLED: - synchronized (this) { - if (!isShowing()) { - if (DEBUG) Log.d(TAG, "PERM_DISABLED and " - + "keygaurd isn't showing."); - doKeyguardLocked(null); - } else { - if (DEBUG) Log.d(TAG, "PERM_DISABLED, resetStateLocked to" - + "show permanently disabled message in lockscreen."); - resetStateLocked(null); - } - } - break; - case READY: - synchronized (this) { - if (isShowing()) { - resetStateLocked(null); - } - } - break; - } - } - - }; - - ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() { - public void userActivity() { - KeyguardViewMediator.this.userActivity(); - } - - public void userActivity(long holdMs) { - KeyguardViewMediator.this.userActivity(holdMs); - } - - public void keyguardDone(boolean authenticated) { - KeyguardViewMediator.this.keyguardDone(authenticated, true); - } - - public void keyguardDoneDrawing() { - mHandler.sendEmptyMessage(KEYGUARD_DONE_DRAWING); - } - - @Override - public void setNeedsInput(boolean needsInput) { - mKeyguardViewManager.setNeedsInput(needsInput); - } - - @Override - public void onUserActivityTimeoutChanged() { - mKeyguardViewManager.updateUserActivityTimeout(); - } - - @Override - public void keyguardDonePending() { - mKeyguardDonePending = true; - } - - @Override - public void keyguardGone() { - mKeyguardDisplayManager.hide(); - } - }; - - private void userActivity() { - userActivity(AWAKE_INTERVAL_DEFAULT_MS); - } - - public void userActivity(long holdMs) { - // We ignore the hold time. Eventually we should remove it. - // Instead, the keyguard window has an explicit user activity timeout set on it. - mPM.userActivity(SystemClock.uptimeMillis(), false); - } - - /** - * Construct a KeyguardViewMediator - * @param context - * @param lockPatternUtils optional mock interface for LockPatternUtils - */ - public KeyguardViewMediator(Context context, LockPatternUtils lockPatternUtils) { - mContext = context; - mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE); - mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); - mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard"); - mShowKeyguardWakeLock.setReferenceCounted(false); - - mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION)); - - mKeyguardDisplayManager = new KeyguardDisplayManager(context); - - mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - - mUpdateMonitor = KeyguardUpdateMonitor.getInstance(context); - - mLockPatternUtils = lockPatternUtils != null - ? lockPatternUtils : new LockPatternUtils(mContext); - mLockPatternUtils.setCurrentUser(UserHandle.USER_OWNER); - - // Assume keyguard is showing (unless it's disabled) until we know for sure... - mShowing = (mUpdateMonitor.isDeviceProvisioned() || mLockPatternUtils.isSecure()) - && !mLockPatternUtils.isLockScreenDisabled(); - - WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); - final ContentResolver cr = mContext.getContentResolver(); - - if (ENABLE_ANALYTICS && !LockPatternUtils.isSafeModeEnabled() && - Settings.Secure.getInt(cr, KEYGUARD_ANALYTICS_SETTING, 0) == 1) { - mKeyguardAnalytics = new KeyguardAnalytics(context, new SessionTypeAdapter() { - - @Override - public int getSessionType() { - return mLockPatternUtils.isSecure() && !mUpdateMonitor.getUserHasTrust( - mLockPatternUtils.getCurrentUser()) - ? Session.TYPE_KEYGUARD_SECURE - : Session.TYPE_KEYGUARD_INSECURE; - } - }, new File(mContext.getCacheDir(), "keyguard_analytics.bin")); - } else { - mKeyguardAnalytics = null; - } - mKeyguardViewManager = new KeyguardViewManager(context, wm, mViewMediatorCallback, - mLockPatternUtils, - mKeyguardAnalytics != null ? mKeyguardAnalytics.getCallback() : null); - - mScreenOn = mPM.isScreenOn(); - - mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0); - String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND); - if (soundPath != null) { - mLockSoundId = mLockSounds.load(soundPath, 1); - } - if (soundPath == null || mLockSoundId == 0) { - Log.w(TAG, "failed to load lock sound from " + soundPath); - } - soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND); - if (soundPath != null) { - mUnlockSoundId = mLockSounds.load(soundPath, 1); - } - if (soundPath == null || mUnlockSoundId == 0) { - Log.w(TAG, "failed to load unlock sound from " + soundPath); - } - int lockSoundDefaultAttenuation = context.getResources().getInteger( - com.android.internal.R.integer.config_lockSoundVolumeDb); - mLockSoundVolume = (float)Math.pow(10, (float)lockSoundDefaultAttenuation/20); - } - - /** - * Let us know that the system is ready after startup. - */ - public void onSystemReady() { - mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); - synchronized (this) { - if (DEBUG) Log.d(TAG, "onSystemReady"); - mSystemReady = true; - mUpdateMonitor.registerCallback(mUpdateCallback); - - // Suppress biometric unlock right after boot until things have settled if it is the - // selected security method, otherwise unsuppress it. It must be unsuppressed if it is - // not the selected security method for the following reason: if the user starts - // without a screen lock selected, the biometric unlock would be suppressed the first - // time they try to use it. - // - // Note that the biometric unlock will still not show if it is not the selected method. - // Calling setAlternateUnlockEnabled(true) simply says don't suppress it if it is the - // selected method. - if (mLockPatternUtils.usingBiometricWeak() - && mLockPatternUtils.isBiometricWeakInstalled()) { - if (DEBUG) Log.d(TAG, "suppressing biometric unlock during boot"); - mUpdateMonitor.setAlternateUnlockEnabled(false); - } else { - mUpdateMonitor.setAlternateUnlockEnabled(true); - } - - doKeyguardLocked(null); - } - // Most services aren't available until the system reaches the ready state, so we - // send it here when the device first boots. - maybeSendUserPresentBroadcast(); - } - - /** - * Called to let us know the screen was turned off. - * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, - * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT} or - * {@link WindowManagerPolicy#OFF_BECAUSE_OF_PROX_SENSOR}. - */ - public void onScreenTurnedOff(int why) { - synchronized (this) { - mScreenOn = false; - if (DEBUG) Log.d(TAG, "onScreenTurnedOff(" + why + ")"); - - mKeyguardDonePending = false; - - // Lock immediately based on setting if secure (user has a pin/pattern/password). - // This also "locks" the device when not secure to provide easy access to the - // camera while preventing unwanted input. - final boolean lockImmediately = - mLockPatternUtils.getPowerButtonInstantlyLocks() || !mLockPatternUtils.isSecure(); - - if (mExitSecureCallback != null) { - if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled"); - try { - mExitSecureCallback.onKeyguardExitResult(false); - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); - } - mExitSecureCallback = null; - if (!mExternallyEnabled) { - hideLocked(); - } - } else if (mShowing) { - notifyScreenOffLocked(); - resetStateLocked(null); - } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT - || (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) { - doKeyguardLaterLocked(); - } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) { - // Do not enable the keyguard if the prox sensor forced the screen off. - } else { - doKeyguardLocked(null); - } - if (ENABLE_ANALYTICS && mKeyguardAnalytics != null) { - mKeyguardAnalytics.getCallback().onScreenOff(); - } - } - KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurndOff(why); - } - - private void doKeyguardLaterLocked() { - // if the screen turned off because of timeout or the user hit the power button - // and we don't need to lock immediately, set an alarm - // to enable it a little bit later (i.e, give the user a chance - // to turn the screen back on within a certain window without - // having to unlock the screen) - final ContentResolver cr = mContext.getContentResolver(); - - // From DisplaySettings - long displayTimeout = Settings.System.getInt(cr, SCREEN_OFF_TIMEOUT, - KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT); - - // From SecuritySettings - final long lockAfterTimeout = Settings.Secure.getInt(cr, - Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, - KEYGUARD_LOCK_AFTER_DELAY_DEFAULT); - - // From DevicePolicyAdmin - final long policyTimeout = mLockPatternUtils.getDevicePolicyManager() - .getMaximumTimeToLock(null, mLockPatternUtils.getCurrentUser()); - - long timeout; - if (policyTimeout > 0) { - // policy in effect. Make sure we don't go beyond policy limit. - displayTimeout = Math.max(displayTimeout, 0); // ignore negative values - timeout = Math.min(policyTimeout - displayTimeout, lockAfterTimeout); - } else { - timeout = lockAfterTimeout; - } - - if (timeout <= 0) { - // Lock now - mSuppressNextLockSound = true; - doKeyguardLocked(null); - } else { - // Lock in the future - long when = SystemClock.elapsedRealtime() + timeout; - Intent intent = new Intent(DELAYED_KEYGUARD_ACTION); - intent.putExtra("seq", mDelayedShowingSequence); - PendingIntent sender = PendingIntent.getBroadcast(mContext, - 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); - mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender); - if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " - + mDelayedShowingSequence); - } - } - - private void cancelDoKeyguardLaterLocked() { - mDelayedShowingSequence++; - } - - /** - * Let's us know the screen was turned on. - */ - public void onScreenTurnedOn(IKeyguardShowCallback callback) { - synchronized (this) { - mScreenOn = true; - cancelDoKeyguardLaterLocked(); - if (DEBUG) Log.d(TAG, "onScreenTurnedOn, seq = " + mDelayedShowingSequence); - if (callback != null) { - notifyScreenOnLocked(callback); - } - } - KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurnedOn(); - maybeSendUserPresentBroadcast(); - } - - private void maybeSendUserPresentBroadcast() { - if (mSystemReady && mLockPatternUtils.isLockScreenDisabled() - && !mUserManager.isUserSwitcherEnabled()) { - // Lock screen is disabled because the user has set the preference to "None". - // In this case, send out ACTION_USER_PRESENT here instead of in - // handleKeyguardDone() - sendUserPresentBroadcast(); - } - } - - /** - * A dream started. We should lock after the usual screen-off lock timeout but only - * if there is a secure lock pattern. - */ - public void onDreamingStarted() { - synchronized (this) { - if (mScreenOn && mLockPatternUtils.isSecure()) { - doKeyguardLaterLocked(); - } - } - } - - /** - * A dream stopped. - */ - public void onDreamingStopped() { - synchronized (this) { - if (mScreenOn) { - cancelDoKeyguardLaterLocked(); - } - } - } - - /** - * Same semantics as {@link WindowManagerPolicy#enableKeyguard}; provide - * a way for external stuff to override normal keyguard behavior. For instance - * the phone app disables the keyguard when it receives incoming calls. - */ - public void setKeyguardEnabled(boolean enabled) { - synchronized (this) { - if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")"); - - mExternallyEnabled = enabled; - - if (!enabled && mShowing) { - if (mExitSecureCallback != null) { - if (DEBUG) Log.d(TAG, "in process of verifyUnlock request, ignoring"); - // we're in the process of handling a request to verify the user - // can get past the keyguard. ignore extraneous requests to disable / reenable - return; - } - - // hiding keyguard that is showing, remember to reshow later - if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, " - + "disabling status bar expansion"); - mNeedToReshowWhenReenabled = true; - hideLocked(); - } else if (enabled && mNeedToReshowWhenReenabled) { - // reenabled after previously hidden, reshow - if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling " - + "status bar expansion"); - mNeedToReshowWhenReenabled = false; - - if (mExitSecureCallback != null) { - if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting"); - try { - mExitSecureCallback.onKeyguardExitResult(false); - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); - } - mExitSecureCallback = null; - resetStateLocked(null); - } else { - showLocked(null); - - // block until we know the keygaurd is done drawing (and post a message - // to unblock us after a timeout so we don't risk blocking too long - // and causing an ANR). - mWaitingUntilKeyguardVisible = true; - mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_DRAWING, KEYGUARD_DONE_DRAWING_TIMEOUT_MS); - if (DEBUG) Log.d(TAG, "waiting until mWaitingUntilKeyguardVisible is false"); - while (mWaitingUntilKeyguardVisible) { - try { - wait(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - if (DEBUG) Log.d(TAG, "done waiting for mWaitingUntilKeyguardVisible"); - } - } - } - } - - /** - * @see android.app.KeyguardManager#exitKeyguardSecurely - */ - public void verifyUnlock(IKeyguardExitCallback callback) { - synchronized (this) { - if (DEBUG) Log.d(TAG, "verifyUnlock"); - if (!mUpdateMonitor.isDeviceProvisioned()) { - // don't allow this api when the device isn't provisioned - if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned"); - try { - callback.onKeyguardExitResult(false); - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); - } - } else if (mExternallyEnabled) { - // this only applies when the user has externally disabled the - // keyguard. this is unexpected and means the user is not - // using the api properly. - Log.w(TAG, "verifyUnlock called when not externally disabled"); - try { - callback.onKeyguardExitResult(false); - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); - } - } else if (mExitSecureCallback != null) { - // already in progress with someone else - try { - callback.onKeyguardExitResult(false); - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); - } - } else { - mExitSecureCallback = callback; - verifyUnlockLocked(); - } - } - } - - /** - * Is the keyguard currently showing? - */ - public boolean isShowing() { - return mShowing; - } - - /** - * Is the keyguard currently showing and not being force hidden? - */ - public boolean isShowingAndNotHidden() { - return mShowing && !mHidden; - } - - /** - * Notify us when the keyguard is hidden by another window - */ - public void setHidden(boolean isHidden) { - if (DEBUG) Log.d(TAG, "setHidden " + isHidden); - mUpdateMonitor.sendKeyguardVisibilityChanged(!isHidden); - mHandler.removeMessages(SET_HIDDEN); - Message msg = mHandler.obtainMessage(SET_HIDDEN, (isHidden ? 1 : 0), 0); - mHandler.sendMessage(msg); - } - - /** - * Handles SET_HIDDEN message sent by setHidden() - */ - private void handleSetHidden(boolean isHidden) { - synchronized (KeyguardViewMediator.this) { - if (mHidden != isHidden) { - mHidden = isHidden; - updateActivityLockScreenState(); - adjustStatusBarLocked(); - } - if (ENABLE_ANALYTICS && mKeyguardAnalytics != null) { - mKeyguardAnalytics.getCallback().onSetHidden(isHidden); - } - } - } - - /** - * Used by PhoneWindowManager to enable the keyguard due to a user activity timeout. - * This must be safe to call from any thread and with any window manager locks held. - */ - public void doKeyguardTimeout(Bundle options) { - mHandler.removeMessages(KEYGUARD_TIMEOUT); - Message msg = mHandler.obtainMessage(KEYGUARD_TIMEOUT, options); - mHandler.sendMessage(msg); - } - - /** - * Given the state of the keyguard, is the input restricted? - * Input is restricted when the keyguard is showing, or when the keyguard - * was suppressed by an app that disabled the keyguard or we haven't been provisioned yet. - */ - public boolean isInputRestricted() { - return mShowing || mNeedToReshowWhenReenabled || !mUpdateMonitor.isDeviceProvisioned(); - } - - /** - * Enable the keyguard if the settings are appropriate. - */ - private void doKeyguardLocked(Bundle options) { - // if another app is disabling us, don't show - if (!mExternallyEnabled) { - if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled"); - - // note: we *should* set mNeedToReshowWhenReenabled=true here, but that makes - // for an occasional ugly flicker in this situation: - // 1) receive a call with the screen on (no keyguard) or make a call - // 2) screen times out - // 3) user hits key to turn screen back on - // instead, we reenable the keyguard when we know the screen is off and the call - // ends (see the broadcast receiver below) - // TODO: clean this up when we have better support at the window manager level - // for apps that wish to be on top of the keyguard - return; - } - - // note whether notification access should be allowed - mAllowNotificationsWhenSecure = ENABLE_SECURE_STATUS_BAR_EXPAND - && 0 != Settings.Global.getInt( - mContext.getContentResolver(), - Settings.Global.LOCK_SCREEN_SHOW_NOTIFICATIONS, - ALLOW_NOTIFICATIONS_DEFAULT ? 1 : 0); - - // if the keyguard is already showing, don't bother - if (mKeyguardViewManager.isShowing()) { - if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing"); - return; - } - - // if the setup wizard hasn't run yet, don't show - final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim", - false); - final boolean provisioned = mUpdateMonitor.isDeviceProvisioned(); - final IccCardConstants.State state = mUpdateMonitor.getSimState(); - final boolean lockedOrMissing = state.isPinLocked() - || ((state == IccCardConstants.State.ABSENT - || state == IccCardConstants.State.PERM_DISABLED) - && requireSim); - - if (!lockedOrMissing && !provisioned) { - if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned" - + " and the sim is not locked or missing"); - return; - } - - if (!mUserManager.isUserSwitcherEnabled() - && mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) { - if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off"); - return; - } - - if (mLockPatternUtils.checkVoldPassword()) { - if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted"); - // Without this, settings is not enabled until the lock screen first appears - hideLocked(); - return; - } - - if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen"); - showLocked(options); - } - - /** - * Dismiss the keyguard through the security layers. - */ - public void handleDismiss() { - if (mShowing && !mHidden) { - mKeyguardViewManager.dismiss(); - } - } - - public void dismiss() { - mHandler.sendEmptyMessage(DISMISS); - } - - /** - * Send message to keyguard telling it to reset its state. - * @param options options about how to show the keyguard - * @see #handleReset() - */ - private void resetStateLocked(Bundle options) { - if (DEBUG) Log.e(TAG, "resetStateLocked"); - Message msg = mHandler.obtainMessage(RESET, options); - mHandler.sendMessage(msg); - } - - /** - * Send message to keyguard telling it to verify unlock - * @see #handleVerifyUnlock() - */ - private void verifyUnlockLocked() { - if (DEBUG) Log.d(TAG, "verifyUnlockLocked"); - mHandler.sendEmptyMessage(VERIFY_UNLOCK); - } - - - /** - * Send a message to keyguard telling it the screen just turned on. - * @see #onScreenTurnedOff(int) - * @see #handleNotifyScreenOff - */ - private void notifyScreenOffLocked() { - if (DEBUG) Log.d(TAG, "notifyScreenOffLocked"); - mHandler.sendEmptyMessage(NOTIFY_SCREEN_OFF); - } - - /** - * Send a message to keyguard telling it the screen just turned on. - * @see #onScreenTurnedOn() - * @see #handleNotifyScreenOn - */ - private void notifyScreenOnLocked(IKeyguardShowCallback result) { - if (DEBUG) Log.d(TAG, "notifyScreenOnLocked"); - Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_ON, result); - mHandler.sendMessage(msg); - } - - /** - * Send message to keyguard telling it to show itself - * @see #handleShow() - */ - private void showLocked(Bundle options) { - if (DEBUG) Log.d(TAG, "showLocked"); - // ensure we stay awake until we are finished displaying the keyguard - mShowKeyguardWakeLock.acquire(); - Message msg = mHandler.obtainMessage(SHOW, options); - mHandler.sendMessage(msg); - } - - /** - * Send message to keyguard telling it to hide itself - * @see #handleHide() - */ - private void hideLocked() { - if (DEBUG) Log.d(TAG, "hideLocked"); - Message msg = mHandler.obtainMessage(HIDE); - mHandler.sendMessage(msg); - } - - public boolean isSecure() { - return mLockPatternUtils.isSecure() - || KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure(); - } - - /** - * Update the newUserId. Call while holding WindowManagerService lock. - * NOTE: Should only be called by KeyguardViewMediator in response to the user id changing. - * - * @param newUserId The id of the incoming user. - */ - public void setCurrentUser(int newUserId) { - mLockPatternUtils.setCurrentUser(newUserId); - } - - private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (DELAYED_KEYGUARD_ACTION.equals(intent.getAction())) { - final int sequence = intent.getIntExtra("seq", 0); - if (DEBUG) Log.d(TAG, "received DELAYED_KEYGUARD_ACTION with seq = " - + sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence); - synchronized (KeyguardViewMediator.this) { - if (mDelayedShowingSequence == sequence) { - // Don't play lockscreen SFX if the screen went off due to timeout. - mSuppressNextLockSound = true; - doKeyguardLocked(null); - } - } - } - } - }; - - public void keyguardDone(boolean authenticated, boolean wakeup) { - if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")"); - EventLog.writeEvent(70000, 2); - synchronized (this) { - mKeyguardDonePending = false; - } - Message msg = mHandler.obtainMessage(KEYGUARD_DONE, authenticated ? 1 : 0, wakeup ? 1 : 0); - mHandler.sendMessage(msg); - } - - /** - * This handler will be associated with the policy thread, which will also - * be the UI thread of the keyguard. Since the apis of the policy, and therefore - * this class, can be called by other threads, any action that directly - * interacts with the keyguard ui should be posted to this handler, rather - * than called directly. - */ - private Handler mHandler = new Handler(Looper.myLooper(), null, true /*async*/) { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case SHOW: - handleShow((Bundle) msg.obj); - break; - case HIDE: - handleHide(); - break; - case RESET: - handleReset((Bundle) msg.obj); - break; - case VERIFY_UNLOCK: - handleVerifyUnlock(); - break; - case NOTIFY_SCREEN_OFF: - handleNotifyScreenOff(); - break; - case NOTIFY_SCREEN_ON: - handleNotifyScreenOn((IKeyguardShowCallback) msg.obj); - break; - case KEYGUARD_DONE: - handleKeyguardDone(msg.arg1 != 0, msg.arg2 != 0); - break; - case KEYGUARD_DONE_DRAWING: - handleKeyguardDoneDrawing(); - break; - case KEYGUARD_DONE_AUTHENTICATING: - keyguardDone(true, true); - break; - case SET_HIDDEN: - handleSetHidden(msg.arg1 != 0); - break; - case KEYGUARD_TIMEOUT: - synchronized (KeyguardViewMediator.this) { - doKeyguardLocked((Bundle) msg.obj); - } - break; - case SHOW_ASSISTANT: - handleShowAssistant(); - break; - case DISPATCH_EVENT: - handleDispatchEvent((MotionEvent) msg.obj); - break; - case LAUNCH_CAMERA: - handleLaunchCamera(); - break; - case DISMISS: - handleDismiss(); - break; - } - } - }; - - /** - * @see #keyguardDone - * @see #KEYGUARD_DONE - */ - private void handleKeyguardDone(boolean authenticated, boolean wakeup) { - if (DEBUG) Log.d(TAG, "handleKeyguardDone"); - - if (authenticated) { - mUpdateMonitor.clearFailedUnlockAttempts(); - } - - if (mExitSecureCallback != null) { - try { - mExitSecureCallback.onKeyguardExitResult(authenticated); - } catch (RemoteException e) { - Slog.w(TAG, "Failed to call onKeyguardExitResult(" + authenticated + ")", e); - } - - mExitSecureCallback = null; - - if (authenticated) { - // after succesfully exiting securely, no need to reshow - // the keyguard when they've released the lock - mExternallyEnabled = true; - mNeedToReshowWhenReenabled = false; - } - } - - handleHide(); - sendUserPresentBroadcast(); - } - - protected void handleLaunchCamera() { - mKeyguardViewManager.launchCamera(); - } - - protected void handleDispatchEvent(MotionEvent event) { - mKeyguardViewManager.dispatch(event); - } - - private void sendUserPresentBroadcast() { - final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser()); - mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, currentUser); - } - - /** - * @see #keyguardDoneDrawing - * @see #KEYGUARD_DONE_DRAWING - */ - private void handleKeyguardDoneDrawing() { - synchronized(this) { - if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing"); - if (mWaitingUntilKeyguardVisible) { - if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing: notifying mWaitingUntilKeyguardVisible"); - mWaitingUntilKeyguardVisible = false; - notifyAll(); - - // there will usually be two of these sent, one as a timeout, and one - // as a result of the callback, so remove any remaining messages from - // the queue - mHandler.removeMessages(KEYGUARD_DONE_DRAWING); - } - } - } - - private void playSounds(boolean locked) { - // User feedback for keyguard. - - if (mSuppressNextLockSound) { - mSuppressNextLockSound = false; - return; - } - - final ContentResolver cr = mContext.getContentResolver(); - if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1) { - final int whichSound = locked - ? mLockSoundId - : mUnlockSoundId; - mLockSounds.stop(mLockSoundStreamId); - // Init mAudioManager - if (mAudioManager == null) { - mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); - if (mAudioManager == null) return; - mMasterStreamType = mAudioManager.getMasterStreamType(); - } - // If the stream is muted, don't play the sound - if (mAudioManager.isStreamMute(mMasterStreamType)) return; - - mLockSoundStreamId = mLockSounds.play(whichSound, - mLockSoundVolume, mLockSoundVolume, 1/*priortiy*/, 0/*loop*/, 1.0f/*rate*/); - } - } - - private void updateActivityLockScreenState() { - try { - ActivityManagerNative.getDefault().setLockScreenShown(mShowing && !mHidden); - } catch (RemoteException e) { - } - } - - /** - * Handle message sent by {@link #showLocked}. - * @see #SHOW - */ - private void handleShow(Bundle options) { - synchronized (KeyguardViewMediator.this) { - if (!mSystemReady) { - if (DEBUG) Log.d(TAG, "ignoring handleShow because system is not ready."); - return; - } else { - if (DEBUG) Log.d(TAG, "handleShow"); - } - - mKeyguardViewManager.show(options); - mShowing = true; - mKeyguardDonePending = false; - updateActivityLockScreenState(); - adjustStatusBarLocked(); - userActivity(); - try { - ActivityManagerNative.getDefault().closeSystemDialogs("lock"); - } catch (RemoteException e) { - } - - // Do this at the end to not slow down display of the keyguard. - playSounds(true); - - mShowKeyguardWakeLock.release(); - } - mKeyguardDisplayManager.show(); - } - - /** - * Handle message sent by {@link #hideLocked()} - * @see #HIDE - */ - private void handleHide() { - synchronized (KeyguardViewMediator.this) { - if (DEBUG) Log.d(TAG, "handleHide"); - - // only play "unlock" noises if not on a call (since the incall UI - // disables the keyguard) - if (TelephonyManager.EXTRA_STATE_IDLE.equals(mPhoneState)) { - playSounds(false); - } - - mKeyguardViewManager.hide(); - mShowing = false; - mKeyguardDonePending = false; - updateActivityLockScreenState(); - adjustStatusBarLocked(); - } - } - - private void adjustStatusBarLocked() { - if (mStatusBarManager == null) { - mStatusBarManager = (StatusBarManager) - mContext.getSystemService(Context.STATUS_BAR_SERVICE); - } - if (mStatusBarManager == null) { - Log.w(TAG, "Could not get status bar manager"); - } else { - // Disable aspects of the system/status/navigation bars that must not be re-enabled by - // windows that appear on top, ever - int flags = StatusBarManager.DISABLE_NONE; - if (mShowing) { - // Permanently disable components not available when keyguard is enabled - // (like recents). Temporary enable/disable (e.g. the "back" button) are - // done in KeyguardHostView. - flags |= StatusBarManager.DISABLE_RECENT; - if ((isSecure() && !mAllowNotificationsWhenSecure) - || !ENABLE_INSECURE_STATUS_BAR_EXPAND) { - // showing secure lockscreen; disable expanding. - flags |= StatusBarManager.DISABLE_EXPAND; - } - if (isSecure()) { - // showing secure lockscreen; disable ticker and switch private notifications - // to show their public versions, if available. - flags |= StatusBarManager.DISABLE_PRIVATE_NOTIFICATIONS; - } - if (!isAssistantAvailable()) { - flags |= StatusBarManager.DISABLE_SEARCH; - } - } - - if (DEBUG) { - Log.d(TAG, "adjustStatusBarLocked: mShowing=" + mShowing + " mHidden=" + mHidden - + " isSecure=" + isSecure() + " --> flags=0x" + Integer.toHexString(flags)); - } - - if (!(mContext instanceof Activity)) { - mStatusBarManager.disable(flags); - } - } - } - - /** - * Handle message sent by {@link #resetStateLocked(Bundle)} - * @see #RESET - */ - private void handleReset(Bundle options) { - if (options == null) { - options = new Bundle(); - } - options.putBoolean(KeyguardViewManager.IS_SWITCHING_USER, mSwitchingUser); - synchronized (KeyguardViewMediator.this) { - if (DEBUG) Log.d(TAG, "handleReset"); - mKeyguardViewManager.reset(options); - } - } - - /** - * Handle message sent by {@link #verifyUnlock} - * @see #VERIFY_UNLOCK - */ - private void handleVerifyUnlock() { - synchronized (KeyguardViewMediator.this) { - if (DEBUG) Log.d(TAG, "handleVerifyUnlock"); - mKeyguardViewManager.verifyUnlock(); - mShowing = true; - updateActivityLockScreenState(); - } - } - - /** - * Handle message sent by {@link #notifyScreenOffLocked()} - * @see #NOTIFY_SCREEN_OFF - */ - private void handleNotifyScreenOff() { - synchronized (KeyguardViewMediator.this) { - if (DEBUG) Log.d(TAG, "handleNotifyScreenOff"); - mKeyguardViewManager.onScreenTurnedOff(); - } - } - - /** - * Handle message sent by {@link #notifyScreenOnLocked()} - * @see #NOTIFY_SCREEN_ON - */ - private void handleNotifyScreenOn(IKeyguardShowCallback callback) { - synchronized (KeyguardViewMediator.this) { - if (DEBUG) Log.d(TAG, "handleNotifyScreenOn"); - mKeyguardViewManager.onScreenTurnedOn(callback); - } - } - - public boolean isDismissable() { - return mKeyguardDonePending || !isSecure(); - } - - public void showAssistant() { - Message msg = mHandler.obtainMessage(SHOW_ASSISTANT); - mHandler.sendMessage(msg); - } - - public void handleShowAssistant() { - mKeyguardViewManager.showAssistant(); - } - - private boolean isAssistantAvailable() { - return mSearchManager != null - && mSearchManager.getAssistIntent(mContext, false, UserHandle.USER_CURRENT) != null; - } - - public static MultiUserAvatarCache getAvatarCache() { - return sMultiUserAvatarCache; - } - - public void dispatch(MotionEvent event) { - Message msg = mHandler.obtainMessage(DISPATCH_EVENT, event); - mHandler.sendMessage(msg); - } - - public void launchCamera() { - Message msg = mHandler.obtainMessage(LAUNCH_CAMERA); - mHandler.sendMessage(msg); - } - - public void onBootCompleted() { - mUpdateMonitor.dispatchBootCompleted(); - } -} diff --git a/packages/Keyguard/src/com/android/keyguard/MultiUserAvatarCache.java b/packages/Keyguard/src/com/android/keyguard/MultiUserAvatarCache.java index 9930e72..7128211 100644 --- a/packages/Keyguard/src/com/android/keyguard/MultiUserAvatarCache.java +++ b/packages/Keyguard/src/com/android/keyguard/MultiUserAvatarCache.java @@ -22,12 +22,21 @@ import java.util.HashMap; public class MultiUserAvatarCache { + private static MultiUserAvatarCache sInstance; + private final HashMap<Integer, Drawable> mCache; - public MultiUserAvatarCache() { + private MultiUserAvatarCache() { mCache = new HashMap<Integer, Drawable>(); } + public static MultiUserAvatarCache getInstance() { + if (sInstance == null) { + sInstance = new MultiUserAvatarCache(); + } + return sInstance; + } + public void clear(int userId) { mCache.remove(userId); } diff --git a/packages/Keyguard/src/com/android/keyguard/PagedView.java b/packages/Keyguard/src/com/android/keyguard/PagedView.java index d233ee9..b42a085 100644 --- a/packages/Keyguard/src/com/android/keyguard/PagedView.java +++ b/packages/Keyguard/src/com/android/keyguard/PagedView.java @@ -56,7 +56,7 @@ import java.util.ArrayList; public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarchyChangeListener { private static final int WARP_SNAP_DURATION = 160; private static final String TAG = "WidgetPagedView"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = KeyguardConstants.DEBUG; private static final boolean DEBUG_WARP = false; protected static final int INVALID_PAGE = -1; private static final int WARP_PEEK_ANIMATION_DURATION = 150; diff --git a/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java b/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java index 3d515ce..ab9286b 100644 --- a/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java +++ b/packages/Keyguard/src/com/android/keyguard/SlidingChallengeLayout.java @@ -45,7 +45,7 @@ import android.widget.Scroller; */ public class SlidingChallengeLayout extends ViewGroup implements ChallengeLayout { private static final String TAG = "SlidingChallengeLayout"; - private static final boolean DEBUG = false; + private static final boolean DEBUG = KeyguardConstants.DEBUG; // The drag handle is measured in dp above & below the top edge of the // challenge view; these parameters change based on whether the challenge diff --git a/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java new file mode 100644 index 0000000..1f23785 --- /dev/null +++ b/packages/Keyguard/src/com/android/keyguard/ViewMediatorCallback.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2014 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.keyguard; + +/** + * The callback used by the keyguard view to tell the {@link KeyguardViewMediator} + * various things. + */ +public interface ViewMediatorCallback { + /** + * Reports user activity and requests that the screen stay on. + */ + void userActivity(); + + /** + * Reports user activity and requests that the screen stay on for at least + * the specified amount of time. + * @param millis The amount of time in millis. This value is currently ignored. + */ + void userActivity(long millis); + + /** + * Report that the keyguard is done. + * @param authenticated Whether the user securely got past the keyguard. + * the only reason for this to be false is if the keyguard was instructed + * to appear temporarily to verify the user is supposed to get past the + * keyguard, and the user fails to do so. + */ + void keyguardDone(boolean authenticated); + + /** + * Report that the keyguard is done drawing. + */ + void keyguardDoneDrawing(); + + /** + * Tell ViewMediator that the current view needs IME input + * @param needsInput + */ + void setNeedsInput(boolean needsInput); + + /** + * Tell view mediator that the keyguard view's desired user activity timeout + * has changed and needs to be reapplied to the window. + */ + void onUserActivityTimeoutChanged(); + + /** + * Report that the keyguard is dismissable, pending the next keyguardDone call. + */ + void keyguardDonePending(); + + /** + * Report when keyguard is actually gone + */ + void keyguardGone(); +} diff --git a/packages/Keyguard/src/com/android/keyguard/analytics/KeyguardAnalytics.java b/packages/Keyguard/src/com/android/keyguard/analytics/KeyguardAnalytics.java index 55750cc..20af2f1 100644 --- a/packages/Keyguard/src/com/android/keyguard/analytics/KeyguardAnalytics.java +++ b/packages/Keyguard/src/com/android/keyguard/analytics/KeyguardAnalytics.java @@ -80,7 +80,7 @@ public class KeyguardAnalytics implements SensorEventListener { public void onScreenOn(); public void onScreenOff(); public boolean onTouchEvent(MotionEvent ev, int width, int height); - public void onSetHidden(boolean hidden); + public void onSetOccluded(boolean hidden); } public interface SessionTypeAdapter { @@ -256,11 +256,11 @@ public class KeyguardAnalytics implements SensorEventListener { } @Override - public void onSetHidden(boolean hidden) { + public void onSetOccluded(boolean hidden) { synchronized (KeyguardAnalytics.this) { if (hidden != mHidden) { if (DEBUG) { - Log.d(TAG, "onSetHidden(" + hidden + ")"); + Log.d(TAG, "onSetOccluded(" + hidden + ")"); } mHidden = hidden; if (hidden) { |