Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 765276b8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Do not mount the whole Android/data and Android/obb anymore" into rvc-dev

parents 5d685f52 3a3d0177
Loading
Loading
Loading
Loading
+5 −15
Original line number Original line Diff line number Diff line
@@ -1555,22 +1555,15 @@ static void isolateJitProfile(JNIEnv* env, jobjectArray pkg_data_info_list,
static void BindMountStorageToLowerFs(const userid_t user_id, const char* dir_name,
static void BindMountStorageToLowerFs(const userid_t user_id, const char* dir_name,
    const char* package, fail_fn_t fail_fn) {
    const char* package, fail_fn_t fail_fn) {


  bool hasPackage = (package != nullptr);
  bool hasSdcardFs = IsFilesystemSupported("sdcardfs");
  bool hasSdcardFs = IsFilesystemSupported("sdcardfs");
  std::string source;
  std::string source;
  if (hasSdcardFs) {
  if (hasSdcardFs) {
    source = hasPackage ?
    source = StringPrintf("/mnt/runtime/default/emulated/%d/%s/%s", user_id, dir_name, package);
        StringPrintf("/mnt/runtime/default/emulated/%d/%s/%s", user_id, dir_name, package) :
        StringPrintf("/mnt/runtime/default/emulated/%d/%s", user_id, dir_name);
  } else {
  } else {
    source = hasPackage ?
    source = StringPrintf("/mnt/pass_through/%d/emulated/%d/%s/%s",
        StringPrintf("/mnt/pass_through/%d/emulated/%d/%s/%s",
        user_id, user_id, dir_name, package);
            user_id, user_id, dir_name, package) :
        StringPrintf("/mnt/pass_through/%d/emulated/%d/%s", user_id, user_id, dir_name);
  }
  }
  std::string target = hasPackage ?
  std::string target = StringPrintf("/storage/emulated/%d/%s/%s", user_id, dir_name, package);
      StringPrintf("/storage/emulated/%d/%s/%s", user_id, dir_name, package) :
      StringPrintf("/storage/emulated/%d/%s", user_id, dir_name);


  if (access(source.c_str(), F_OK) != 0) {
  if (access(source.c_str(), F_OK) != 0) {
    fail_fn(CREATE_ERROR("Error accessing %s: %s", source.c_str(), strerror(errno)));
    fail_fn(CREATE_ERROR("Error accessing %s: %s", source.c_str(), strerror(errno)));
@@ -1594,10 +1587,7 @@ static void BindMountStorageDirs(JNIEnv* env, jobjectArray pkg_data_info_list,
  int size = (pkg_data_info_list != nullptr) ? env->GetArrayLength(pkg_data_info_list) : 0;
  int size = (pkg_data_info_list != nullptr) ? env->GetArrayLength(pkg_data_info_list) : 0;


  if (size == 0) {
  if (size == 0) {
    // App data isolation is not enabled for this process, so we bind mount to whole obb/ dir.
    fail_fn(CREATE_ERROR("Data package list cannot be empty"));
    BindMountStorageToLowerFs(user_id, "Android/obb", /* package */ nullptr, fail_fn);
    BindMountStorageToLowerFs(user_id, "Android/data", /* package */ nullptr, fail_fn);
    return;
  }
  }


  // Bind mount each package obb directory
  // Bind mount each package obb directory