Package 

Class BuilderImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      long timeout
      private int flags
    • Method Summary

      Modifier and Type Method Description
      Shell.Builder setTimeout(long t) Set the maximum time to wait for shell verification.
      Shell.Builder setFlags(int f) Set flags to control how a new {@code Shell} will be constructed.
      Shell.Builder setCommands(Array<String> c) Set the commands that will be used to create a new {@code Shell}.
      void setInitializersImpl(Array<Class<out Shell.Initializer>> clz)
      ShellImpl build(Process process) Combine all of the options that have been set and build a new {@code Shell} instancewith the provided process.
      ShellImpl build() Combine all of the options that have been set and build a new {@code Shell} instance.
      • Methods inherited from class com.topjohnwu.superuser.Shell.Builder

        build, build, build, create, setCommands, setContext, setFlags, setInitializers, setTimeout
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setTimeout

        @NonNull() Shell.Builder setTimeout(long t)

        Set the maximum time to wait for shell verification.

        After the timeout occurs and the shell still has no response,the shell process will be force-closed and throw NoShellException.

      • build

        @NonNull() ShellImpl build(Process process)

        Combine all of the options that have been set and build a new {@code Shell} instancewith the provided process.

        Parameters:
        process - a shell Process that has already been created.
      • build

        @NonNull() ShellImpl build()

        Combine all of the options that have been set and build a new {@code Shell} instance.

        If not setCommands, there are 3 methods to construct a Unix shell;if any method fails, it will fallback to the next method:

        • If FLAG_NON_ROOT_SHELL is not set and FLAG_MOUNT_MASTER is set, construct a Unix shell by calling {@code su --mount-master}.It may fail if the root implementation does not support mount master.
        • If FLAG_NON_ROOT_SHELL is not set, construct a Unix shell by calling{@code su}. It may fail if the device is not rooted, or root permission isnot granted.
        • Construct a Unix shell by calling {@code sh}. This would never fail in normalconditions, but should it fail, it will throw NoShellException
        The developer should check the status of the returned {@code Shell} with getStatus since it may be constructed with calling {@code sh}.

        If setCommands is called, the provided commands will be used tocreate a new Process directly. If the process fails to create, or the processis not a valid shell, it will throw NoShellException.