process_android.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "base/process/process.h"
  5. #include "base/notreached.h"
  6. #include "base/process/internal_linux.h"
  7. namespace base {
  8. // static
  9. bool Process::CanBackgroundProcesses() {
  10. return false;
  11. }
  12. bool Process::IsProcessBackgrounded() const {
  13. // See SetProcessBackgrounded().
  14. DCHECK(IsValid());
  15. return false;
  16. }
  17. bool Process::SetProcessBackgrounded(bool value) {
  18. // Not implemented for POSIX systems other than Linux and Mac. With POSIX, if
  19. // we were to lower the process priority we wouldn't be able to raise it back
  20. // to its initial priority.
  21. NOTIMPLEMENTED();
  22. return false;
  23. }
  24. Time Process::CreationTime() const {
  25. // On Android, /proc is mounted (on recent-enough versions) with hidepid=2,
  26. // which hides other PIDs in /proc. This means that only /proc/self is
  27. // accessible. Instead of trying (and failing) to read the file, don't attempt
  28. // to read it. This also provides consistency across releases.
  29. int64_t start_ticks = is_current()
  30. ? internal::ReadProcSelfStatsAndGetFieldAsInt64(
  31. internal::VM_STARTTIME)
  32. : 0;
  33. if (!start_ticks)
  34. return Time();
  35. TimeDelta start_offset = internal::ClockTicksToTimeDelta(start_ticks);
  36. Time boot_time = internal::GetBootTime();
  37. if (boot_time.is_null())
  38. return Time();
  39. return Time(boot_time + start_offset);
  40. }
  41. } // namespace base