AndroidICS4.0----LockScreen锁屏流程

AndroidICS4.0----LockScreen锁屏流程
AndroidICS4.0----LockScreen锁屏流程

先来说说LockScreen分类;

一、无锁屏;

二、锁屏:

1、UnLockScreen:

图案锁、PIN锁,密码锁;

2、LockScreen:

波纹锁;

转载请表明出处:

https://www.360docs.net/doc/be13115796.html,/wdaming1986/article/details/7753206

有图有真相------>

接着我们来看看LockScreen的时序图:

综上所述:

1、createUnlockScreenFor()方法创建的是UnLockScreen界面,代码如下:

[java]view plaincopyprint?

1View createUnlockScreenFor(UnlockMode unlockMode) {

2 View unlockView = null;

3

4if (DEBUG) Log.d(TAG,

5"createUnlockScreenFor(" + unlockMode + "): mEnableFallback=" + mEnableFallback);

6

7if (unlockMode == UnlockMode.Pattern) {

8 PatternUnlockScreen view = new PatternUnlockScreen(

9 mContext,

10 mConfiguration,

11 mLockPatternUtils,

12 mUpdateMonitor,

13 mKeyguardScreenCallback,

14 mUpdateMonitor.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,

MSimTelephonyManager.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) {

32try {

33 unlockView = new AccountUnlockScreen(

34 mContext,

35 mConfiguration,

36 mUpdateMonitor,

37 mKeyguardScreenCallback,

38 mLockPatternUtils);

39 } catch (IllegalStateException e) {

40 Log.i(TAG, "Couldn't instantiate AccountUnlockScreen"

41 + " (IAccountsService isn't available)");

42// TODO: Need a more general way to provide a

43// platform-specific fallback UI here.

44// For now, if we can't 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// regular pattern unlock UI, regardless of the value of

50// mUnlockScreenMode or whether or not we're in the

51// "permanently locked" state.)

52return createUnlockScreenFor(UnlockMode.Pattern);

53 }

54 } else if (unlockMode == UnlockMode.Password) {

55 unlockView = new PasswordUnlockScreen(

56 mContext,

58 mLockPatternUtils,

59 mUpdateMonitor,

60 mKeyguardScreenCallback);

61 } else {

62throw new IllegalArgumentException("unknown unlock mode " +

unlockMode);

63 }

64 initializeTransportControlView(unlockView);

65 initializeFaceLockAreaView(unlockView); // Only shows view if FaceLock is

enabled

66

67 mUnlockScreenMode = unlockMode;

68return unlockView;

69 }

2、createLockScreen()就是创建LockScreen界面:

[java]view plaincopyprint?

70View createLockScreen() {

71/*View lockView = new LockScreen(

72 mContext,

73 mConfiguration,

74 mLockPatternUtils,

75 mUpdateMonitor,

76 mKeyguardScreenCallback);

77 initializeTransportControlView(lockView);

78 return lockView;*/

79

80long lockscreenType = 0;

81try{

82 lockscreenType = android.provider.Settings.Secure.

83 getLong(mContext.getContentResolver(),

"lockscreen.disabled");

84 }catch(Exception e){

85 e.printStackTrace();

86 }

87 View lockView = null;

88 lockView = new LockScreen(

89 mContext,

90 mConfiguration,

91 mLockPatternUtils,

93 mKeyguardScreenCallback);

94 initializeTransportControlView(lockView);

95return lockView;

96}

我们来看看锁屏界面的流程:

step 1:创建LockScreen.java类——>先看看构造函数:

[java]view plaincopyprint?

97LockScreen(Context context, Configuration configuration, Lo ckPatternUtils lockPatternUtils,

98 KeyguardUpdateMonitor updateMonitor,

99 KeyguardScreenCallback callback) {

100super(context);

101 mLockPatternUtils = lockPatternUtils;

102 mUpdateMonitor = updateMonitor;

103 mCallback = callback;

104

105 mEnableMenuKeyInLockScreen = shouldEnableMenuKey();

106

107 mCreationOrientation = configuration.orientation;

108

109 mKeyboardHidden = configuration.hardKeyboardHidden;

110

111if (LockPatternKeyguardView.DEBUG_CONFIGURATION) {

112 Log.v(TAG, "***** CREATING LOCK SCREEN", new RuntimeException());

113 Log.v(TAG, "Cur orient=" + mCreationOrientation

114 + " res orient=" +

context.getResources().getConfiguration().orientation);

115 }

116

117final LayoutInflater inflater = LayoutInflater.from(context);

118if (DBG) Log.v(TAG, "Creation orientation = " + mCreationOrientation);

119if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) { 120 inflater.inflate(https://www.360docs.net/doc/be13115796.html,yout.keyguard_screen_tab_unlock, this, true);

121 } else {

122 inflater.inflate(https://www.360docs.net/doc/be13115796.html,yout.keyguard_screen_tab_unlock_land, this, true);

123 }

124

125if (TelephonyManager.getDefault().isMultiSimEnabled()) {

126 mStatusViewManager = new MSimKeyguardStatusViewManager(this, mUpdateMonitor,

127 mLockPatternUtils, mCallback, false);

128 } else {

129 mStatusViewManager = new KeyguardStatusViewManager(this, mUpdateMonitor,

130 mLockPatternUtils, mCallback, false);

131 }

132

133 setFocusable(true);

134 setFocusableInTouchMode(true);

135 setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);

136

137 mAudioManager = (AudioManager)

mContext.getSystemService(Context.AUDIO_SERVICE);

138// modify by wangxianming in 2012-06-22

139if (mAudioManager != null) {

140 mSilentMode = isSilentMode();

141 }

142

143 mUnlockWidget = findViewById(R.id.unlock_widget);

144if (mUnlockWidget instanceof SlidingTab) {

145 SlidingTab slidingTabView = (SlidingTab) mUnlockWidget;

146 slidingTabView.setHoldAfterTrigger(true, false);

147 slidingTabView.setLeftHintText(R.string.lockscreen_unlock_label); 148 slidingTabView.setLeftTabResources(

149 R.drawable.ic_jog_dial_unlock,

150 R.drawable.jog_tab_target_green,

151 R.drawable.jog_tab_bar_left_unlock,

152 R.drawable.jog_tab_left_unlock);

153 SlidingTabMethods slidingTabMethods = new

SlidingTabMethods(slidingTabView);

154 slidingTabView.setOnTriggerListener(slidingTabMethods);

155 mUnlockWidgetMethods = slidingTabMethods;

156 } else if (mUnlockWidget instanceof WaveView) {

157 WaveView waveView = (WaveView) mUnlockWidget;

158 WaveViewMethods waveViewMethods = new WaveViewMethods(waveView); 159 waveView.setOnTriggerListener(waveViewMethods);

160 mUnlockWidgetMethods = waveViewMethods;

161 } else if (mUnlockWidget instanceof MultiWaveView) {

162 MultiWaveView multiWaveView = (MultiWaveView) mUnlockWidget;

163 MultiWaveViewMethods multiWaveViewMethods = new MultiWaveViewMethods(multiWaveView);

164 multiWaveView.setOnTriggerListener(multiWaveViewMethods);

165 mUnlockWidgetMethods = multiWaveViewMethods;

166 } else {

167throw new IllegalStateException("Unrecognized unlock widget: " + mUnlockWidget);

168 }

169

170// Update widget with initial ring state

171 mUnlockWidgetMethods.updateResources();

172

173if (DBG) Log.v(TAG, "*** LockScreen accel is "

174 + (mUnlockWidget.isHardwareAccelerated() ? "on":"off"));

175 }

Step 2:在Step 1步骤中根据横竖屏来加载横竖屏的布局:

[java]view plaincopyprint?

176if (mCreationOrientation != Configuration.ORIENTATION_LANDSCAPE) {

177 inflater.inflate(https://www.360docs.net/doc/be13115796.html,yout.keyguard_screen_tab_unlock, this, true);

178 } else {

179 inflater.inflate(https://www.360docs.net/doc/be13115796.html,yout.keyguard_screen_tab_unlock_land, this, true);

180 }

Step 3:来看看竖屏的布局文件的代码:

[java]view plaincopyprint?

181

182 xmlns:android="https://www.360docs.net/doc/be13115796.html,/apk/res/android"

183 android:orientation="vertical"

184 android:layout_width="match_parent"

185 android:layout_height="match_parent"

186 android:gravity="center_horizontal">

187

188

189

android:layout_marginTop="@dimen/keyguard_lockscreen_status_line_clockfont_top_m argin"

190 android:layout_marginBottom="12dip"

191

android:layout_marginRight="@dimen/keyguard_lockscreen_status_line_font_right_ma rgin"

192 android:layout_gravity="right">

193

194

196

197 android:layout_width="wrap_content"

198 android:layout_height="wrap_content"

199 android:singleLine="true"

200 android:ellipsize="none"

201 android:textSize="@dimen/keyguard_lockscreen_clock_font_size"

202 android:textAppearance="?android:attr/textAppearanceMedium"

203 android:layout_marginBottom="6dip"

204 android:textColor="@color/lockscreen_clock_background"

205 />

206

207

208 android:layout_width="wrap_content"

209 android:layout_height="wrap_content"

210 android:singleLine="true"

211 android:ellipsize="none"

212 android:textSize="@dimen/keyguard_lockscreen_clock_font_size"

213 android:textAppearance="?android:attr/textAppearanceMedium"

214 android:layout_marginBottom="6dip"

215 android:textColor="@color/lockscreen_clock_foreground"

216 android:layout_alignLeft="@id/timeDisplayBackground"

217 android:layout_alignTop="@id/timeDisplayBackground"

218 />

219

220

221

222

223 android:orientation="horizontal"

224 android:layout_gravity="right"

225

android:layout_marginRight="@dimen/keyguard_lockscreen_status_line_font_right_ma rgin">

226

227

228 android:id="@+id/date"

229 android:layout_width="wrap_content"

230 android:layout_height="wrap_content"

231 android:singleLine="true"

232 android:ellipsize="marquee"

233 android:textAppearance="?android:attr/textAppearanceMedium"

234

android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"

235 />

236

237

238 android:id="@+id/alarm_status"

239 android:layout_width="wrap_content"

240 android:layout_height="wrap_content"

241 android:layout_marginLeft="16dip"

242 android:singleLine="true"

243 android:ellipsize="marquee"

244 android:textAppearance="?android:attr/textAppearanceMedium"

245

android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"

246 android:drawablePadding="4dip"

247 />

248

249

250

251

252 android:id="@+id/status1"

253 android:layout_gravity="right"

254

android:layout_marginRight="@dimen/keyguard_lockscreen_status_line_font_right_ma rgin"

255 android:singleLine="true"

256 android:ellipsize="marquee"

257 android:textAppearance="?android:attr/textAppearanceMedium"

258 android:textSize="@dimen/keyguard_lockscreen_status_line_font_size" 259 android:drawablePadding="4dip"

260 />

261

262

263

264 android:layout_width="match_parent"

265 android:layout_height="302dip">

266

267

268 android:id="@+id/unlock_widget"

269 android:orientation="horizontal"

270 android:layout_width="match_parent"

271 android:layout_height="match_parent"

272 android:layout_alignParentBottom="true"

273

274 android:targetDrawables="@array/lockscreen_targets_with_camera" 275

android:targetDescriptions="@array/lockscreen_target_descriptions_with_camera" 276

android:directionDescriptions="@array/lockscreen_direction_descriptions"

277 android:handleDrawable="@drawable/ic_lockscreen_handle"

278 android:waveDrawable="@drawable/ic_lockscreen_outerring"

279

android:outerRadius="@dimen/multiwaveview_target_placement_radius"

280 android:snapMargin="@dimen/multiwaveview_snap_margin"

281 android:hitRadius="@dimen/multiwaveview_hit_radius"

282

android:rightChevronDrawable="@drawable/ic_lockscreen_chevron_right"

283 android:horizontalOffset="0dip"

284 android:verticalOffset="60dip"

285 android:feedbackCount="3"

286 android:vibrationDuration="20"

287 />

288

289

290 android:id="@+id/carrier"

291 android:layout_width="fill_parent"

292 android:layout_height="wrap_content"

293 android:layout_alignParentBottom="true"

294 android:layout_marginBottom="12dip"

295 android:gravity="center_horizontal"

296 android:singleLine="true"

297 android:ellipsize="marquee"

298 android:textAppearance="?android:attr/textAppearanceMedium"

299

android:textSize="@dimen/keyguard_lockscreen_status_line_font_size"

300 android:textColor="?android:attr/textColorSecondary"

301 />

302

303

304

305

306 android:orientation="horizontal"

307 android:layout_width="match_parent"

308 style="?android:attr/buttonBarStyle"

309 android:gravity="center"

310 android:weightSum="2">

311

312

相关文档
最新文档