The android keyguard lock screen cannot be displayed in full screen.

Source: Internet
Author: User

Keywords: Android keyguard lock screen cannot be displayed in full screen. The unlock page becomes smaller. Platform: s5pc110 s5pv210 System: android2.3 android2.3.4
Problem description: 
After the Board is burned for the first time (updated with the SD card), it cannot be displayed in full screen, but it is displayed in full screen after restart. After reading the screen on the Internet, the problem is as follows: Android lock screen program (frameworks/policies/base/phone/COM/Android/Internal/policy/impl) after the Board is burned for the first time, it cannot be displayed in full screen, but after restart, it is displayed in full screen. Tracking the code, I feel that the code for setting the screen size should be in lockpatternkeyguardview. java, but the log later found that there is no call function to draw the screen inside, please ask, thank you!

Symptom:

Solution 1: This method is widely seen on the Internet, but there are two problems on our platform, but some platforms will be good. We do not recommend using this method:
Solution 2: This method solves our problem. The test has not encountered any problem for so long: (recommended)


  Solution 1: This method is widely seen on the Internet, but there are two problems on our platform, but some platforms will be good. We do not recommend using this method:(1) only one side is unlocked when the screen is portrait, as shown in;
(2) When you press home for a long time, the program is opened recently and the screen is not displayed.

The change code is as follows:

frameworks\base\policy\src\com\android\internal\policy\impl\KeyguardViewManager.java. android2.3.4_GB_T34H\frameworks\base\core\java\android\content\res\CompatibilityInfo.javadiff --git a/phone/com/android/internal/policy/impl/KeyguardViewManager.java b/phone/com/android/internal/policy/impl/KeyguardViewManager.javaindex ba1d7f5..38bf161 100644--- a/phone/com/android/internal/policy/impl/KeyguardViewManager.java+++ b/phone/com/android/internal/policy/impl/KeyguardViewManager.java@@ -28,6 +28,8 @@ import android.view.ViewGroup;import android.view.ViewManager;import android.view.WindowManager;import android.widget.FrameLayout;+import android.view.Display;+import android.util.DisplayMetrics; /**  * Manages creating, showing, hiding and resetting the keyguard.  Calls back@@ -97,9 +99,21 @@ public class KeyguardViewManager implements KeyguardWindowController {         if (mKeyguardHost == null) {             if (DEBUG) Log.d(TAG, "keyguard host is null, creating it..."); +            WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);+            DisplayMetrics  dm = new DisplayMetrics();+            wm.getDefaultDisplay().getMetrics(dm);+            Display display = wm.getDefaultDisplay();++            int statusBarHeight = (int)Math.ceil( 25 * dm.density);+            int height = display.getHeight();+            int width = display.getWidth();++            Log.i(TAG, "Display width = " + width);+            Log.i(TAG, "Display height = " + height);+            Log.i(TAG, "Statusbar height = " + statusBarHeight);+             mKeyguardHost = new KeyguardViewHost(mContext, mCallback); -            final int stretch = ViewGroup.LayoutParams.MATCH_PARENT;             int flags = WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN                     | WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER                     | WindowManager.LayoutParams.FLAG_KEEP_SURFACE_WHILE_ANIMATING@@ -109,7 +123,7 @@ public class KeyguardViewManager implements KeyguardWindowController {                 flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;             }             WindowManager.LayoutParams lp = new WindowManager.LayoutParams(-                    stretch, stretch, WindowManager.LayoutParams.TYPE_KEYGUARD,+                    width, (height - statusBarHeight), WindowManager.LayoutParams.TYPE_KEYGUARD,                     flags, PixelFormat.TRANSLUCENT);             lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN;             lp.windowAnimations = com.android.internal.R.style.Animation_LockScreen;

Solution 2: This method solves our problem. The test has not encountered any problem for so long: (recommended)

1. android2.3.4 _ gb_t34h \ frameworks \ base \ core \ Java \ Android \ content \ res

Modify the following content in frameworks/base/CORE/Java/Android/content/RES/compatibilityinfo. Java:

public static void updateCompatibleScreenFrame(DisplayMetrics dm, int orientation,            Rect outRect) {        int width = dm.widthPixels;        int portraitHeight = (int) (DEFAULT_PORTRAIT_HEIGHT * dm.density + 0.5f);        int portraitWidth = (int) (DEFAULT_PORTRAIT_WIDTH * dm.density + 0.5f);        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {            int xOffset = (width - portraitHeight) / 2 ;            outRect.set(xOffset, 0, xOffset + portraitHeight, portraitWidth);        } else {            int xOffset = (width - portraitWidth) / 2 ;            outRect.set(xOffset, 0, xOffset + portraitWidth, portraitHeight);        }

Change the above program to the following one:
="

Public static voidupdatecompatiblescreenframe (displaymetrics DM, int orientation,

Rect outrect ){

Int width = DM. widthpixels;

Int portraitheight = (INT) (default_portrait_height * DM. Density + 0.5f );

Int portraitwidth = (INT) (default_portrait_width * DM. Density + 0.5f );

If (orientation = configuration. orientation_landscape ){

Int xoffset = (width-portraitheight)/2;

+ Outrect. Set (0, 0, 0 + DM. widthpixels, DM. heightpixels); // Add new code

-Outrect. Set (xoffset, 0, xoffset + portraitheight, portraitwidth); // Delete the original code

} Else

{

Int xoffset = (width-portraitwidth)/2;

+ Outrect. Set (0, 0, 0 + DM. widthpixels, DM. heightpixels); // Add new code

-Outrect. Set (xoffset, 0, xoffset + portraitwidth, portraitheight); // Delete the Code Section

}

}

The red part is the code we modified, and "-" is the original code we removed:

In frameworks/base/CORE/Java/Android/content/RES/compatibilityinfo. Java, the values default_portrait_height/default_portrait_width are important.

Print some values and analyze them as follows:

 dm.density = 1.5 portraitHeight = 720 portraitWidth = 480 dm.widthPixels = 1024 dm.heightPixels= 600 width = dm.widthPixels

The reason for the offset is:
Assume that the screen is horizontal:

Analysis under abnormal circumstances:

Xoffset = (width-portraitheight)/2 = (1024-720)/2 = 152

The original code in the program is
Outrect. Set (xoffset, 0, xoffset + portraitheight, portraitwidth );// Original code
Outrect. Set (152, 0,152 + 720,480 );
The xoffset has an offset between the left and right, as shown in:


After the changes, analyze them normally:

Calculated after modification:

Outrect. Set (0,
0, 0 + DM. widthpixels, DM. heightpixels );
Outrect. Set (0, 0, 0 + 1024,600 );


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.