/// <summary> /// Attempts to install on the device /// </summary> /// <param name="busybox">The path to the busybox binary to install.</param> /// <returns><c>true</c>, if successful; otherwise, <c>false</c></returns> public bool Install(String busybox) { busybox.ThrowIfNullOrWhiteSpace("busybox"); FileEntry bb = null; try { Device.ExecuteShellCommand(BUSYBOX_COMMAND, NullOutputReceiver.Instance); return(true); } catch { // we are just checking if it is already installed so we really expect it to wind up here. } try { MountPoint mp = Device.MountPoints["/data"]; bool isRO = mp.IsReadOnly; Device.RemountMountPoint(Device.MountPoints["/data"], false); FileEntry path = null; try { path = Device.FileListingService.FindFileEntry(BUSYBOX_BIN); } catch (FileNotFoundException) { // path doesn't exist, so we make it. Device.FileSystem.MakeDirectory(BUSYBOX_BIN); // attempt to get the FileEntry after the directory has been made path = Device.FileListingService.FindFileEntry(BUSYBOX_BIN); } Device.FileSystem.Chmod(path.FullPath, "0755"); String bbPath = LinuxPath.Combine(path.FullPath, BUSYBOX_COMMAND); Device.FileSystem.Copy(busybox, bbPath); bb = Device.FileListingService.FindFileEntry(bbPath); Device.FileSystem.Chmod(bb.FullPath, "0755"); Device.ExecuteShellCommand("{0}/busybox --install {0}", new ConsoleOutputReceiver( ), path.FullPath); // check if this path exists in the path already if (Device.EnvironmentVariables.ContainsKey("PATH")) { var paths = Device.EnvironmentVariables["PATH"].Split(':'); var found = paths.Where(p => String.Compare(p, BUSYBOX_BIN, false) == 0).Count( ) > 0; // we didnt find it, so add it. if (!found) { // this doesn't seem to actually work Device.ExecuteShellCommand(@"echo \ Mad Bee buxybox >> /init.rc", NullOutputReceiver.Instance); Device.ExecuteShellCommand(@"echo export PATH={0}:\$PATH >> /init.rc", NullOutputReceiver.Instance, BUSYBOX_BIN); } } if (mp.IsReadOnly != isRO) { // Put it back, if we changed it Device.RemountMountPoint(mp, isRO); } Device.ExecuteShellCommand("sync", NullOutputReceiver.Instance); } catch (Exception) { throw; } CheckForBusyBox( ); return(true); }
/// <summary> /// Gets the apk file entry. /// </summary> /// <param name="package">The package.</param> /// <returns></returns> public FileEntry GetApkFileEntry(String package) { return(FileEntry.Find(this.Device, GetApkPath(package))); }