1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17 package com.android.systemui.keyguard; 18 19 import static android.content.pm.PackageManager.PERMISSION_GRANTED; 20 import static android.view.Display.DEFAULT_DISPLAY; 21 import static android.view.RemoteAnimationTarget.MODE_CLOSING; 22 import static android.view.RemoteAnimationTarget.MODE_OPENING; 23 import static android.view.WindowManager.TRANSIT_CLOSE; 24 import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY; 25 import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_LOCKED; 26 import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY; 27 import static android.view.WindowManager.TRANSIT_KEYGUARD_OCCLUDE; 28 import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; 29 import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY; 30 import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER; 31 import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_OCCLUDE; 32 import static android.view.WindowManager.TRANSIT_OLD_KEYGUARD_UNOCCLUDE; 33 import static android.view.WindowManager.TRANSIT_OLD_NONE; 34 import static android.view.WindowManager.TRANSIT_OPEN; 35 import static android.view.WindowManager.TRANSIT_TO_BACK; 36 import static android.view.WindowManager.TRANSIT_TO_FRONT; 37 import static android.view.WindowManager.TransitionFlags; 38 import static android.view.WindowManager.TransitionOldType; 39 import static android.view.WindowManager.TransitionType; 40 import static android.window.TransitionInfo.FLAG_OCCLUDES_KEYGUARD; 41 42 import android.app.ActivityManager; 43 import android.app.ActivityTaskManager; 44 import android.app.Service; 45 import android.app.WindowConfiguration; 46 import android.content.Intent; 47 import android.graphics.Point; 48 import android.graphics.Rect; 49 import android.os.Binder; 50 import android.os.Bundle; 51 import android.os.Debug; 52 import android.os.IBinder; 53 import android.os.PowerManager; 54 import android.os.Process; 55 import android.os.RemoteException; 56 import android.os.SystemProperties; 57 import android.os.Trace; 58 import android.util.Log; 59 import android.util.Slog; 60 import android.view.IRemoteAnimationFinishedCallback; 61 import android.view.IRemoteAnimationRunner; 62 import android.view.RemoteAnimationAdapter; 63 import android.view.RemoteAnimationDefinition; 64 import android.view.RemoteAnimationTarget; 65 import android.view.SurfaceControl; 66 import android.view.WindowManager; 67 import android.view.WindowManagerPolicyConstants; 68 import android.window.IRemoteTransition; 69 import android.window.IRemoteTransitionFinishedCallback; 70 import android.window.RemoteTransition; 71 import android.window.TransitionFilter; 72 import android.window.TransitionInfo; 73 74 import com.android.internal.policy.IKeyguardDismissCallback; 75 import com.android.internal.policy.IKeyguardDrawnCallback; 76 import com.android.internal.policy.IKeyguardExitCallback; 77 import com.android.internal.policy.IKeyguardService; 78 import com.android.internal.policy.IKeyguardStateCallback; 79 import com.android.systemui.SystemUIApplication; 80 import com.android.wm.shell.transition.ShellTransitions; 81 import com.android.wm.shell.transition.Transitions; 82 83 import java.util.ArrayList; 84 85 import javax.inject.Inject; 86 87 public class KeyguardService extends Service { 88 static final String TAG = "KeyguardService"; 89 static final String PERMISSION = android.Manifest.permission.CONTROL_KEYGUARD; 90 91 /** 92 * Run Keyguard animation as remote animation in System UI instead of local animation in 93 * the server process. 94 * 95 * 0: Runs all keyguard animation as local animation 96 * 1: Only runs keyguard going away animation as remote animation 97 * 2: Runs all keyguard animation as remote animation 98 * 99 * Note: Must be consistent with WindowManagerService. 100 */ 101 private static final String ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY = 102 "persist.wm.enable_remote_keyguard_animation"; 103 104 private static final int sEnableRemoteKeyguardAnimation = 105 SystemProperties.getInt(ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY, 1); 106 107 /** 108 * @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY 109 */ 110 public static boolean sEnableRemoteKeyguardGoingAwayAnimation = 111 sEnableRemoteKeyguardAnimation >= 1; 112 113 /** 114 * @see #ENABLE_REMOTE_KEYGUARD_ANIMATION_PROPERTY 115 */ 116 public static boolean sEnableRemoteKeyguardOccludeAnimation = 117 sEnableRemoteKeyguardAnimation >= 2; 118 119 private final KeyguardViewMediator mKeyguardViewMediator; 120 private final KeyguardLifecyclesDispatcher mKeyguardLifecyclesDispatcher; 121 private final ShellTransitions mShellTransitions; 122 newModeToLegacyMode(int newMode)123 private static int newModeToLegacyMode(int newMode) { 124 switch (newMode) { 125 case WindowManager.TRANSIT_OPEN: 126 case WindowManager.TRANSIT_TO_FRONT: 127 return MODE_OPENING; 128 case WindowManager.TRANSIT_CLOSE: 129 case WindowManager.TRANSIT_TO_BACK: 130 return MODE_CLOSING; 131 default: 132 return 2; // MODE_CHANGING 133 } 134 } 135 wrap(TransitionInfo info, boolean wallpapers)136 private static RemoteAnimationTarget[] wrap(TransitionInfo info, boolean wallpapers) { 137 final ArrayList<RemoteAnimationTarget> out = new ArrayList<>(); 138 for (int i = 0; i < info.getChanges().size(); i++) { 139 boolean changeIsWallpaper = 140 (info.getChanges().get(i).getFlags() & TransitionInfo.FLAG_IS_WALLPAPER) != 0; 141 if (wallpapers != changeIsWallpaper) continue; 142 143 final TransitionInfo.Change change = info.getChanges().get(i); 144 final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo(); 145 final int taskId = taskInfo != null ? change.getTaskInfo().taskId : -1; 146 boolean isNotInRecents; 147 WindowConfiguration windowConfiguration = null; 148 if (taskInfo != null) { 149 if (taskInfo.getConfiguration() != null) { 150 windowConfiguration = 151 change.getTaskInfo().getConfiguration().windowConfiguration; 152 } 153 isNotInRecents = !change.getTaskInfo().isRunning; 154 } else { 155 isNotInRecents = true; 156 } 157 Rect localBounds = new Rect(change.getEndAbsBounds()); 158 localBounds.offsetTo(change.getEndRelOffset().x, change.getEndRelOffset().y); 159 160 out.add(new RemoteAnimationTarget( 161 taskId, 162 newModeToLegacyMode(change.getMode()), 163 change.getLeash(), 164 (change.getFlags() & TransitionInfo.FLAG_TRANSLUCENT) != 0 165 || (change.getFlags() & TransitionInfo.FLAG_SHOW_WALLPAPER) != 0, 166 null /* clipRect */, 167 new Rect(0, 0, 0, 0) /* contentInsets */, 168 info.getChanges().size() - i, 169 new Point(), localBounds, new Rect(change.getEndAbsBounds()), 170 windowConfiguration, isNotInRecents, null /* startLeash */, 171 change.getStartAbsBounds(), taskInfo, false /* allowEnterPip */)); 172 } 173 return out.toArray(new RemoteAnimationTarget[out.size()]); 174 } 175 getTransitionOldType(@ransitionType int type, @TransitionFlags int flags, RemoteAnimationTarget[] apps)176 private static @TransitionOldType int getTransitionOldType(@TransitionType int type, 177 @TransitionFlags int flags, RemoteAnimationTarget[] apps) { 178 if (type == TRANSIT_KEYGUARD_GOING_AWAY 179 || (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0) { 180 return apps.length == 0 ? TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER 181 : TRANSIT_OLD_KEYGUARD_GOING_AWAY; 182 } else if (type == TRANSIT_KEYGUARD_OCCLUDE) { 183 return TRANSIT_OLD_KEYGUARD_OCCLUDE; 184 } else if (type == TRANSIT_KEYGUARD_UNOCCLUDE) { 185 return TRANSIT_OLD_KEYGUARD_UNOCCLUDE; 186 } else { 187 Slog.d(TAG, "Unexpected transit type: " + type); 188 return TRANSIT_OLD_NONE; 189 } 190 } 191 wrap(IRemoteAnimationRunner runner)192 private static IRemoteTransition wrap(IRemoteAnimationRunner runner) { 193 return new IRemoteTransition.Stub() { 194 @Override 195 public void startAnimation(IBinder transition, TransitionInfo info, 196 SurfaceControl.Transaction t, IRemoteTransitionFinishedCallback finishCallback) 197 throws RemoteException { 198 Slog.d(TAG, "Starts IRemoteAnimationRunner: info=" + info); 199 final RemoteAnimationTarget[] apps = wrap(info, false /* wallpapers */); 200 final RemoteAnimationTarget[] wallpapers = wrap(info, true /* wallpapers */); 201 final RemoteAnimationTarget[] nonApps = new RemoteAnimationTarget[0]; 202 203 // TODO: Remove this, and update alpha value in the IAnimationRunner. 204 for (TransitionInfo.Change change : info.getChanges()) { 205 t.setAlpha(change.getLeash(), 1.0f); 206 } 207 t.apply(); 208 runner.onAnimationStart(getTransitionOldType(info.getType(), info.getFlags(), apps), 209 apps, wallpapers, nonApps, 210 new IRemoteAnimationFinishedCallback.Stub() { 211 @Override 212 public void onAnimationFinished() throws RemoteException { 213 Slog.d(TAG, "Finish IRemoteAnimationRunner."); 214 finishCallback.onTransitionFinished(null /* wct */, null /* t */); 215 } 216 } 217 ); 218 } 219 220 public void mergeAnimation(IBinder transition, TransitionInfo info, 221 SurfaceControl.Transaction t, IBinder mergeTarget, 222 IRemoteTransitionFinishedCallback finishCallback) { 223 224 } 225 }; 226 } 227 228 @Inject 229 public KeyguardService(KeyguardViewMediator keyguardViewMediator, 230 KeyguardLifecyclesDispatcher keyguardLifecyclesDispatcher, 231 ShellTransitions shellTransitions) { 232 super(); 233 mKeyguardViewMediator = keyguardViewMediator; 234 mKeyguardLifecyclesDispatcher = keyguardLifecyclesDispatcher; 235 mShellTransitions = shellTransitions; 236 237 if (shellTransitions != null && Transitions.ENABLE_SHELL_TRANSITIONS) { 238 // Nothing here. Initialization for this happens in onCreate. 239 } else { 240 RemoteAnimationDefinition definition = new RemoteAnimationDefinition(); 241 if (sEnableRemoteKeyguardGoingAwayAnimation) { 242 final RemoteAnimationAdapter exitAnimationAdapter = 243 new RemoteAnimationAdapter(mExitAnimationRunner, 0, 0); 244 definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY, 245 exitAnimationAdapter); 246 definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER, 247 exitAnimationAdapter); 248 } 249 if (sEnableRemoteKeyguardOccludeAnimation) { 250 final RemoteAnimationAdapter occludeAnimationAdapter = 251 new RemoteAnimationAdapter(mOccludeAnimationRunner, 0, 0); 252 definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_OCCLUDE, 253 occludeAnimationAdapter); 254 definition.addRemoteAnimation(TRANSIT_OLD_KEYGUARD_UNOCCLUDE, 255 occludeAnimationAdapter); 256 } 257 ActivityTaskManager.getInstance().registerRemoteAnimationsForDisplay( 258 DEFAULT_DISPLAY, definition); 259 } 260 } 261 262 @Override 263 public void onCreate() { 264 ((SystemUIApplication) getApplication()).startServicesIfNeeded(); 265 266 if (mShellTransitions == null || !Transitions.ENABLE_SHELL_TRANSITIONS) { 267 return; 268 } 269 if (sEnableRemoteKeyguardGoingAwayAnimation) { 270 Slog.d(TAG, "KeyguardService registerRemote: TRANSIT_KEYGUARD_GOING_AWAY"); 271 TransitionFilter f = new TransitionFilter(); 272 f.mFlags = TRANSIT_FLAG_KEYGUARD_GOING_AWAY; 273 mShellTransitions.registerRemote(f, 274 new RemoteTransition(wrap(mExitAnimationRunner), getIApplicationThread())); 275 } 276 if (sEnableRemoteKeyguardOccludeAnimation) { 277 Slog.d(TAG, "KeyguardService registerRemote: TRANSIT_KEYGUARD_(UN)OCCLUDE"); 278 // Register for occluding 279 TransitionFilter f = new TransitionFilter(); 280 f.mFlags = TRANSIT_FLAG_KEYGUARD_LOCKED; 281 f.mRequirements = new TransitionFilter.Requirement[]{ 282 new TransitionFilter.Requirement(), new TransitionFilter.Requirement()}; 283 // First require at-least one app showing that occludes. 284 f.mRequirements[0].mMustBeIndependent = false; 285 f.mRequirements[0].mFlags = FLAG_OCCLUDES_KEYGUARD; 286 f.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT}; 287 // Then require that we aren't closing any occludes (because this would mean a 288 // regular task->task or activity->activity animation not involving keyguard). 289 f.mRequirements[1].mNot = true; 290 f.mRequirements[1].mMustBeIndependent = false; 291 f.mRequirements[1].mFlags = FLAG_OCCLUDES_KEYGUARD; 292 f.mRequirements[1].mModes = new int[]{TRANSIT_CLOSE, TRANSIT_TO_BACK}; 293 mShellTransitions.registerRemote(f, 294 new RemoteTransition(mOccludeAnimation, getIApplicationThread())); 295 296 // Now register for un-occlude. 297 f = new TransitionFilter(); 298 f.mFlags = TRANSIT_FLAG_KEYGUARD_LOCKED; 299 f.mRequirements = new TransitionFilter.Requirement[]{ 300 new TransitionFilter.Requirement(), new TransitionFilter.Requirement()}; 301 // First require at-least one app going-away (doesn't need occlude flag 302 // as that is implicit by it having been visible and we don't want to exclude 303 // cases where we are un-occluding because the app removed its showWhenLocked 304 // capability at runtime). 305 f.mRequirements[1].mMustBeIndependent = false; 306 f.mRequirements[1].mModes = new int[]{TRANSIT_CLOSE, TRANSIT_TO_BACK}; 307 f.mRequirements[1].mMustBeTask = true; 308 // Then require that we aren't opening any occludes (otherwise we'd remain 309 // occluded). 310 f.mRequirements[0].mNot = true; 311 f.mRequirements[0].mMustBeIndependent = false; 312 f.mRequirements[0].mFlags = FLAG_OCCLUDES_KEYGUARD; 313 f.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT}; 314 mShellTransitions.registerRemote(f, 315 new RemoteTransition(mUnoccludeAnimation, getIApplicationThread())); 316 } 317 } 318 319 @Override 320 public IBinder onBind(Intent intent) { 321 return mBinder; 322 } 323 324 void checkPermission() { 325 // Avoid deadlock by avoiding calling back into the system process. 326 if (Binder.getCallingUid() == Process.SYSTEM_UID) return; 327 328 // Otherwise,explicitly check for caller permission ... 329 if (getBaseContext().checkCallingOrSelfPermission(PERMISSION) != PERMISSION_GRANTED) { 330 Log.w(TAG, "Caller needs permission '" + PERMISSION + "' to call " + Debug.getCaller()); 331 throw new SecurityException("Access denied to process: " + Binder.getCallingPid() 332 + ", must have permission " + PERMISSION); 333 } 334 } 335 336 private final IRemoteAnimationRunner.Stub mExitAnimationRunner = 337 new IRemoteAnimationRunner.Stub() { 338 @Override // Binder interface 339 public void onAnimationStart(@WindowManager.TransitionOldType int transit, 340 RemoteAnimationTarget[] apps, 341 RemoteAnimationTarget[] wallpapers, 342 RemoteAnimationTarget[] nonApps, 343 IRemoteAnimationFinishedCallback finishedCallback) { 344 Trace.beginSection("mExitAnimationRunner.onAnimationStart#startKeyguardExitAnimation"); 345 checkPermission(); 346 mKeyguardViewMediator.startKeyguardExitAnimation(transit, apps, wallpapers, 347 nonApps, finishedCallback); 348 Trace.endSection(); 349 } 350 351 @Override // Binder interface 352 public void onAnimationCancelled() { 353 mKeyguardViewMediator.cancelKeyguardExitAnimation(); 354 } 355 }; 356 357 private final IRemoteAnimationRunner.Stub mOccludeAnimationRunner = 358 new IRemoteAnimationRunner.Stub() { 359 @Override // Binder interface 360 public void onAnimationStart(@WindowManager.TransitionOldType int transit, 361 RemoteAnimationTarget[] apps, 362 RemoteAnimationTarget[] wallpapers, 363 RemoteAnimationTarget[] nonApps, 364 IRemoteAnimationFinishedCallback finishedCallback) { 365 Slog.d(TAG, "mOccludeAnimationRunner.onAnimationStart: transit=" + transit); 366 try { 367 if (transit == TRANSIT_OLD_KEYGUARD_OCCLUDE) { 368 mBinder.setOccluded(true /* isOccluded */, true /* animate */); 369 } else if (transit == TRANSIT_OLD_KEYGUARD_UNOCCLUDE) { 370 mBinder.setOccluded(false /* isOccluded */, false /* animate */); 371 } 372 // TODO(bc-unlock): Implement (un)occlude animation. 373 finishedCallback.onAnimationFinished(); 374 } catch (RemoteException e) { 375 Slog.e(TAG, "RemoteException"); 376 } 377 } 378 379 @Override // Binder interface 380 public void onAnimationCancelled() { 381 } 382 }; 383 384 final IRemoteTransition mOccludeAnimation = new IRemoteTransition.Stub() { 385 @Override 386 public void startAnimation(IBinder transition, TransitionInfo info, 387 SurfaceControl.Transaction t, IRemoteTransitionFinishedCallback finishCallback) 388 throws RemoteException { 389 t.apply(); 390 mBinder.setOccluded(true /* isOccluded */, true /* animate */); 391 finishCallback.onTransitionFinished(null /* wct */, null /* wctCB */); 392 } 393 394 @Override 395 public void mergeAnimation(IBinder transition, TransitionInfo info, 396 SurfaceControl.Transaction t, IBinder mergeTarget, 397 IRemoteTransitionFinishedCallback finishCallback) { 398 } 399 }; 400 401 final IRemoteTransition mUnoccludeAnimation = new IRemoteTransition.Stub() { 402 @Override 403 public void startAnimation(IBinder transition, TransitionInfo info, 404 SurfaceControl.Transaction t, IRemoteTransitionFinishedCallback finishCallback) 405 throws RemoteException { 406 t.apply(); 407 mBinder.setOccluded(false /* isOccluded */, true /* animate */); 408 finishCallback.onTransitionFinished(null /* wct */, null /* wctCB */); 409 } 410 411 @Override 412 public void mergeAnimation(IBinder transition, TransitionInfo info, 413 SurfaceControl.Transaction t, IBinder mergeTarget, 414 IRemoteTransitionFinishedCallback finishCallback) { 415 } 416 }; 417 418 private final IKeyguardService.Stub mBinder = new IKeyguardService.Stub() { 419 420 @Override // Binder interface 421 public void addStateMonitorCallback(IKeyguardStateCallback callback) { 422 checkPermission(); 423 mKeyguardViewMediator.addStateMonitorCallback(callback); 424 } 425 426 @Override // Binder interface 427 public void verifyUnlock(IKeyguardExitCallback callback) { 428 Trace.beginSection("KeyguardService.mBinder#verifyUnlock"); 429 checkPermission(); 430 mKeyguardViewMediator.verifyUnlock(callback); 431 Trace.endSection(); 432 } 433 434 @Override // Binder interface 435 public void setOccluded(boolean isOccluded, boolean animate) { 436 Trace.beginSection("KeyguardService.mBinder#setOccluded"); 437 checkPermission(); 438 mKeyguardViewMediator.setOccluded(isOccluded, animate); 439 Trace.endSection(); 440 } 441 442 @Override // Binder interface 443 public void dismiss(IKeyguardDismissCallback callback, CharSequence message) { 444 checkPermission(); 445 mKeyguardViewMediator.dismiss(callback, message); 446 } 447 448 @Override // Binder interface 449 public void onDreamingStarted() { 450 checkPermission(); 451 mKeyguardViewMediator.onDreamingStarted(); 452 } 453 454 @Override // Binder interface 455 public void onDreamingStopped() { 456 checkPermission(); 457 mKeyguardViewMediator.onDreamingStopped(); 458 } 459 460 @Override // Binder interface 461 public void onStartedGoingToSleep(@PowerManager.GoToSleepReason int pmSleepReason) { 462 checkPermission(); 463 mKeyguardViewMediator.onStartedGoingToSleep( 464 WindowManagerPolicyConstants.translateSleepReasonToOffReason(pmSleepReason)); 465 mKeyguardLifecyclesDispatcher.dispatch( 466 KeyguardLifecyclesDispatcher.STARTED_GOING_TO_SLEEP, pmSleepReason); 467 } 468 469 @Override // Binder interface 470 public void onFinishedGoingToSleep( 471 @PowerManager.GoToSleepReason int pmSleepReason, boolean cameraGestureTriggered) { 472 checkPermission(); 473 mKeyguardViewMediator.onFinishedGoingToSleep( 474 WindowManagerPolicyConstants.translateSleepReasonToOffReason(pmSleepReason), 475 cameraGestureTriggered); 476 mKeyguardLifecyclesDispatcher.dispatch( 477 KeyguardLifecyclesDispatcher.FINISHED_GOING_TO_SLEEP); 478 } 479 480 @Override // Binder interface 481 public void onStartedWakingUp( 482 @PowerManager.WakeReason int pmWakeReason, boolean cameraGestureTriggered) { 483 Trace.beginSection("KeyguardService.mBinder#onStartedWakingUp"); 484 checkPermission(); 485 mKeyguardViewMediator.onStartedWakingUp(cameraGestureTriggered); 486 mKeyguardLifecyclesDispatcher.dispatch( 487 KeyguardLifecyclesDispatcher.STARTED_WAKING_UP, pmWakeReason); 488 Trace.endSection(); 489 } 490 491 @Override // Binder interface 492 public void onFinishedWakingUp() { 493 Trace.beginSection("KeyguardService.mBinder#onFinishedWakingUp"); 494 checkPermission(); 495 mKeyguardLifecyclesDispatcher.dispatch(KeyguardLifecyclesDispatcher.FINISHED_WAKING_UP); 496 Trace.endSection(); 497 } 498 499 @Override // Binder interface 500 public void onScreenTurningOn(IKeyguardDrawnCallback callback) { 501 Trace.beginSection("KeyguardService.mBinder#onScreenTurningOn"); 502 checkPermission(); 503 mKeyguardViewMediator.onScreenTurningOn(callback); 504 mKeyguardLifecyclesDispatcher.dispatch(KeyguardLifecyclesDispatcher.SCREEN_TURNING_ON); 505 Trace.endSection(); 506 } 507 508 @Override // Binder interface 509 public void onScreenTurnedOn() { 510 Trace.beginSection("KeyguardService.mBinder#onScreenTurnedOn"); 511 checkPermission(); 512 mKeyguardViewMediator.onScreenTurnedOn(); 513 mKeyguardLifecyclesDispatcher.dispatch(KeyguardLifecyclesDispatcher.SCREEN_TURNED_ON); 514 Trace.endSection(); 515 } 516 517 @Override // Binder interface 518 public void onScreenTurningOff() { 519 checkPermission(); 520 mKeyguardLifecyclesDispatcher.dispatch(KeyguardLifecyclesDispatcher.SCREEN_TURNING_OFF); 521 } 522 523 @Override // Binder interface 524 public void onScreenTurnedOff() { 525 checkPermission(); 526 mKeyguardViewMediator.onScreenTurnedOff(); 527 mKeyguardLifecyclesDispatcher.dispatch(KeyguardLifecyclesDispatcher.SCREEN_TURNED_OFF); 528 } 529 530 @Override // Binder interface 531 public void setKeyguardEnabled(boolean enabled) { 532 checkPermission(); 533 mKeyguardViewMediator.setKeyguardEnabled(enabled); 534 } 535 536 @Override // Binder interface 537 public void onSystemReady() { 538 Trace.beginSection("KeyguardService.mBinder#onSystemReady"); 539 checkPermission(); 540 mKeyguardViewMediator.onSystemReady(); 541 Trace.endSection(); 542 } 543 544 @Override // Binder interface 545 public void doKeyguardTimeout(Bundle options) { 546 checkPermission(); 547 mKeyguardViewMediator.doKeyguardTimeout(options); 548 } 549 550 @Override // Binder interface 551 public void setSwitchingUser(boolean switching) { 552 checkPermission(); 553 mKeyguardViewMediator.setSwitchingUser(switching); 554 } 555 556 @Override // Binder interface 557 public void setCurrentUser(int userId) { 558 checkPermission(); 559 mKeyguardViewMediator.setCurrentUser(userId); 560 } 561 562 @Override 563 public void onBootCompleted() { 564 checkPermission(); 565 mKeyguardViewMediator.onBootCompleted(); 566 } 567 568 /** 569 * @deprecated When remote animation is enabled, this won't be called anymore. Use 570 * {@code IRemoteAnimationRunner#onAnimationStart} instead. 571 */ 572 @Deprecated 573 @Override 574 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { 575 Trace.beginSection("KeyguardService.mBinder#startKeyguardExitAnimation"); 576 checkPermission(); 577 mKeyguardViewMediator.startKeyguardExitAnimation(startTime, fadeoutDuration); 578 Trace.endSection(); 579 } 580 581 @Override 582 public void onShortPowerPressedGoHome() { 583 checkPermission(); 584 mKeyguardViewMediator.onShortPowerPressedGoHome(); 585 } 586 }; 587 } 588 589