installKioskPolicy static method

Future<DVDeviceKiosk?> installKioskPolicy(
  1. DVKioskPolicy policy, {
  2. Future<String?> readSecret(
    1. String name
    )?,
  3. Future<void> clear(
    1. Set<DVKioskClearable> what
    )?,
})

Installs the declared device-scope kiosk policy: makes the kiosk, enters it and asks the platform to hold it. A disabled policy installs nothing. Called by the generated runtime at start.

clear performs session.clearOnReset. Without one the framework's own default runs, which empties the client cache, signs out and empties the shared store as the policy names them. That default was missing entirely: the runtime called a callback nobody supplied, so every entry in clearOnReset was read, validated, reported by doctor and then dropped. An application that knows its own session state supplies this and replaces the default rather than adding to it.

Implementation

static Future<DVDeviceKiosk?> installKioskPolicy(
  DVKioskPolicy policy, {
  Future<String?> Function(String name)? readSecret,
  Future<void> Function(Set<DVKioskClearable> what)? clear,
}) async {
  await uninstallKioskPolicy();
  if (!policy.enabled) return null;
  final DVDeviceKiosk kiosk = DVDeviceKiosk(
    runtime: DVKioskRuntime(
      policy,
      readSecret: readSecret,
      lifecycle: DV.lifecycle,
      clear: clear ?? dvClearKioskSession,
    ),
    target: DVWindowManager.kioskTargetHere(),
  );
  _deviceKiosk = kiosk;
  await kiosk.resume();
  return kiosk;
}