[计算机软件及应用]AndroidICS40锁屏流程.doc

上传人:音乐台 文档编号:1991440 上传时间:2019-01-28 格式:DOC 页数:32 大小:755.77KB
返回 下载 相关 举报
[计算机软件及应用]AndroidICS40锁屏流程.doc_第1页
第1页 / 共32页
[计算机软件及应用]AndroidICS40锁屏流程.doc_第2页
第2页 / 共32页
[计算机软件及应用]AndroidICS40锁屏流程.doc_第3页
第3页 / 共32页
亲,该文档总共32页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《[计算机软件及应用]AndroidICS40锁屏流程.doc》由会员分享,可在线阅读,更多相关《[计算机软件及应用]AndroidICS40锁屏流程.doc(32页珍藏版)》请在三一文库上搜索。

1、淄博怡源网络科技有限公司先来说说LockScreen分类;一、无锁屏;二、锁屏:1、UnLockScreen:图案锁、 PIN锁, 密码锁;2、LockScreen:波纹锁;接着我们来看看LockScreen的时序图: 综上所述:1、createUnlockScreenFor()方法创建的是UnLockScreen界面,代码如下:java view plaincopyprint?1. View createUnlockScreenFor(UnlockMode unlockMode) 2. View unlockView = null; 3.4. if (DEBUG) Log.d(TAG, 5.

2、 createUnlockScreenFor( + unlockMode + ): mEnableFallback= + mEnableFallback); 6.7. if (unlockMode = UnlockMode.Pattern) 8. PatternUnlockScreen view = new PatternUnlockScreen( 9. mContext, 10. mConfiguration, 11. mLockPatternUtils, 12. mUpdateMonitor, 13. mKeyguardScreenCallback, 14. mUpdateMonitor.

3、getFailedAttempts(); 15. view.setEnableFallback(mEnableFallback); 16. unlockView = view; 17. else if (unlockMode = UnlockMode.SimPuk) 18. unlockView = new SimPukUnlockScreen( 19. mContext, 20. mConfiguration, 21. mUpdateMonitor, 22. mKeyguardScreenCallback, 23. mLockPatternUtils, MSimTelephonyManage

4、r.getDefault().getDefaultSubscription(); 24. else if (unlockMode = UnlockMode.SimPin) 25. unlockView = new SimUnlockScreen( 26. mContext, 27. mConfiguration, 28. mUpdateMonitor, 29. mKeyguardScreenCallback, 30. mLockPatternUtils); 31. else if (unlockMode = UnlockMode.Account) 32. try 33. unlockView

5、= new AccountUnlockScreen( 34. mContext, 35. mConfiguration, 36. mUpdateMonitor, 37. mKeyguardScreenCallback, 38. mLockPatternUtils); 39. catch (IllegalStateException e) 40. Log.i(TAG, Couldnt instantiate AccountUnlockScreen 41. + (IAccountsService isnt available); 42. / TODO: Need a more general wa

6、y to provide a 43. / platform-specific fallback UI here. 44. / For now, if we cant display the account login 45. / unlock UI, just bring back the regular Pattern unlock mode. 46.47. / (We do this by simply returning a regular UnlockScreen 48. / here. This means that the user will still see the 49. /

7、 regular pattern unlock UI, regardless of the value of 50. / mUnlockScreenMode or whether or not were in the 51. / permanently locked state.) 52. return createUnlockScreenFor(UnlockMode.Pattern); 53. 54. else if (unlockMode = UnlockMode.Password) 55. unlockView = new PasswordUnlockScreen( 56. mConte

8、xt, 57. mConfiguration, 58. mLockPatternUtils, 59. mUpdateMonitor, 60. mKeyguardScreenCallback); 61. else 62. throw new IllegalArgumentException(unknown unlock mode + unlockMode); 63. 64. initializeTransportControlView(unlockView); 65. initializeFaceLockAreaView(unlockView); / Only shows view if Fac

9、eLock is enabled 66.67. mUnlockScreenMode = unlockMode; 68. return unlockView; 69. 2、createLockScreen()就是创建LockScreen界面:java view plaincopyprint?1. View createLockScreen() 2. /*View lockView = new LockScreen( 3. mContext, 4. mConfiguration, 5. mLockPatternUtils, 6. mUpdateMonitor, 7. mKeyguardScreen

10、Callback); 8. initializeTransportControlView(lockView); 9. return lockView;*/ 10.11. long lockscreenType = 0; 12. try 13. lockscreenType = android.provider.Settings.Secure. 14. getLong(mContext.getContentResolver(), lockscreen.disabled); 15. catch(Exception e) 16. e.printStackTrace(); 17. 18. View l

11、ockView = null; 19. lockView = new LockScreen( 20. mContext, 21. mConfiguration, 22. mLockPatternUtils, 23. mUpdateMonitor, 24. mKeyguardScreenCallback); 25. initializeTransportControlView(lockView); 26. return lockView; 27. 我们来看看锁屏界面的流程:step 1:创建LockScreen.java类先看看构造函数:java view plaincopyprint?1. L

12、ockScreen(Context context, Configuration configuration, LockPatternUtils lockPatternUtils, 2. KeyguardUpdateMonitor updateMonitor, 3. KeyguardScreenCallback callback) 4. super(context); 5. mLockPatternUtils = lockPatternUtils; 6. mUpdateMonitor = updateMonitor; 7. mCallback = callback; 8.9. mEnableM

13、enuKeyInLockScreen = shouldEnableMenuKey(); 10.11. mCreationOrientation = configuration.orientation; 12.13. mKeyboardHidden = configuration.hardKeyboardHidden; 14.15. if (LockPatternKeyguardView.DEBUG_CONFIGURATION) 16. Log.v(TAG, * CREATING LOCK SCREEN, new RuntimeException(); 17. Log.v(TAG, Cur or

14、ient= + mCreationOrientation 18. + res orient= + context.getResources().getConfiguration().orientation); 19. 20.21. final LayoutInflater inflater = LayoutInflater.from(context); 22. if (DBG) Log.v(TAG, Creation orientation = + mCreationOrientation); 23. if (mCreationOrientation != Configuration.ORIE

15、NTATION_LANDSCAPE) 24. inflater.inflate(R.layout.keyguard_screen_tab_unlock, this, true); 25. else 26. inflater.inflate(R.layout.keyguard_screen_tab_unlock_land, this, true); 27. 28.29. if (TelephonyManager.getDefault().isMultiSimEnabled() 30. mStatusViewManager = new MSimKeyguardStatusViewManager(t

16、his, mUpdateMonitor, 31. mLockPatternUtils, mCallback, false); 32. else 33. mStatusViewManager = new KeyguardStatusViewManager(this, mUpdateMonitor, 34. mLockPatternUtils, mCallback, false); 35. 36.37. setFocusable(true); 38. setFocusableInTouchMode(true); 39. setDescendantFocusability(ViewGroup.FOC

17、US_BLOCK_DESCENDANTS); 40.41. mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); 42. / modify by wangxianming in 2012-06-22 43. if (mAudioManager != null) 44. mSilentMode = isSilentMode(); 45. 46.47. mUnlockWidget = findViewById(R.id.unlock_widget); 48. if (mUnlockWidge

18、t instanceof SlidingTab) 49. SlidingTab slidingTabView = (SlidingTab) mUnlockWidget; 50. slidingTabView.setHoldAfterTrigger(true, false); 51. slidingTabView.setLeftHintText(R.string.lockscreen_unlock_label); 52. slidingTabView.setLeftTabResources( 53. R.drawable.ic_jog_dial_unlock, 54. R.drawable.jo

19、g_tab_target_green, 55. R.drawable.jog_tab_bar_left_unlock, 56. R.drawable.jog_tab_left_unlock); 57. SlidingTabMethods slidingTabMethods = new SlidingTabMethods(slidingTabView); 58. slidingTabView.setOnTriggerListener(slidingTabMethods); 59. mUnlockWidgetMethods = slidingTabMethods; 60. else if (mUn

20、lockWidget instanceof WaveView) 61. WaveView waveView = (WaveView) mUnlockWidget; 62. WaveViewMethods waveViewMethods = new WaveViewMethods(waveView); 63. waveView.setOnTriggerListener(waveViewMethods); 64. mUnlockWidgetMethods = waveViewMethods; 65. else if (mUnlockWidget instanceof MultiWaveView)

21、66. MultiWaveView multiWaveView = (MultiWaveView) mUnlockWidget; 67. MultiWaveViewMethods multiWaveViewMethods = new MultiWaveViewMethods(multiWaveView); 68. multiWaveView.setOnTriggerListener(multiWaveViewMethods); 69. mUnlockWidgetMethods = multiWaveViewMethods; 70. else 71. throw new IllegalState

22、Exception(Unrecognized unlock widget: + mUnlockWidget); 72. 73.74. / Update widget with initial ring state 75. mUnlockWidgetMethods.updateResources(); 76.77. if (DBG) Log.v(TAG, * LockScreen accel is 78. + (mUnlockWidget.isHardwareAccelerated() ? on:off); 79. Step 2:在Step 1步骤中根据横竖屏来加载横竖屏的布局:java vie

23、w plaincopyprint?1. if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) 2. inflater.inflate(R.layout.keyguard_screen_tab_unlock, this, true); 3. else 4. inflater.inflate(R.layout.keyguard_screen_tab_unlock_land, this, true); 5. Step 3:来看看竖屏的布局文件的代码:java view plaincopyprint?1. 7. 8. 13.1

24、4. 16. 26.27. 39.40. 41.42. 46. 47. 56. 57. 68.69. 70. 71. 81.82. 83. 86. 87. 108. 109. 122.123. 124.125. 131. 132. 144.145. 146.147. Step 4:在Step 3中重点看com.android.internal.widget.multiwaveview.MultiWaveView这个自定义的view,这个view是处理ICS4.0锁屏的拖拽的功能,具体代码如下:java view plaincopyprint?1. public MultiWaveView(Co

25、ntext context, AttributeSet attrs) 2. super(context, attrs); 3. Resources res = context.getResources(); 4. 。 。 5. 加载资源 6. 。 。 7. 通过onMeasure()来计算自定义view的大小:java view plaincopyprint?1. protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) 2. final int minimumWidth = getSuggestedMinimu

26、mWidth(); 3. final int minimumHeight = getSuggestedMinimumHeight(); 4. int viewWidth = resolveMeasured(widthMeasureSpec, minimumWidth); 5. int viewHeight = resolveMeasured(heightMeasureSpec, minimumHeight); 6. setMeasuredDimension(viewWidth, viewHeight); 7. 通过onLayout()来加载布局:java view plaincopyprint

27、?1. protected void onLayout(boolean changed, int left, int top, int right, int bottom) 2. super.onLayout(changed, left, top, right, bottom); 3. final int width = right - left; 4. final int height = bottom - top; 5. float newWaveCenterX = mHorizontalOffset + Math.max(width, mOuterRing.getWidth() ) / 2; 6. float newWaveCenterY = mVerticalOffset + Math.max(height, mOuterRing.getHeight() / 2; 7. if (newWaveCenterX != mWaveCenterX | newWaveCenterY != mWaveCenterY) 8. if (mWaveCenterX = 0 & mWaveCenterY = 0) 9. performInitialLayout(newWaveCenterX, newWaveCenterY); 10. 11. mWaveCenterX = newWaveCen

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1