Bug 1510615 - Replace hardcoded /data/data paths or supress lint warning where not replaceable r=geckoview-reviewers,snorp

Differential Revision: https://phabricator.services.mozilla.com/D67980

--HG--
extra : moz-landing-system : lando
This commit is contained in:
owlishDeveloper 2020-03-26 17:26:21 +00:00
Родитель d7433f922a
Коммит 7671f3baf7
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -5,6 +5,7 @@
package org.mozilla.gecko;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
@ -376,6 +377,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
* @param exc An exception
* @return Whether the exception was successfully reported
*/
@SuppressLint("SdCardPath")
protected boolean reportException(final Thread thread, final Throwable exc) {
final Context context = getAppContext();
final String id = UUID.randomUUID().toString();

Просмотреть файл

@ -10,6 +10,7 @@ import org.mozilla.gecko.annotation.JNITarget;
import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.gecko.util.HardwareUtils;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
@ -322,14 +323,16 @@ public final class GeckoLoader {
final StringBuilder message = new StringBuilder("LOAD ");
message.append(lib);
final String packageDataDir = context.getApplicationInfo().dataDir;
// These might differ. If so, we know why the library won't load!
HardwareUtils.init(context);
message.append(": ABI: " + HardwareUtils.getLibrariesABI() + ", " + getCPUABI());
message.append(": Data: " + context.getApplicationInfo().dataDir);
message.append(": Data: " + packageDataDir);
try {
final boolean appLibExists = new File("/data/app-lib/" + androidPackageName + "/lib" + lib + ".so").exists();
final boolean dataDataExists = new File("/data/data/" + androidPackageName + "/lib/lib" + lib + ".so").exists();
final boolean dataDataExists = new File(packageDataDir + "/lib/lib" + lib + ".so").exists();
message.append(", ax=" + appLibExists);
message.append(", ddx=" + dataDataExists);
} catch (Throwable e) {
@ -337,8 +340,8 @@ public final class GeckoLoader {
}
try {
final String dashOne = "/data/data/" + androidPackageName + "-1";
final String dashTwo = "/data/data/" + androidPackageName + "-2";
final String dashOne = packageDataDir + "-1";
final String dashTwo = packageDataDir + "-2";
final boolean dashOneExists = new File(dashOne).exists();
final boolean dashTwoExists = new File(dashTwo).exists();
message.append(", -1x=" + dashOneExists);
@ -407,6 +410,7 @@ public final class GeckoLoader {
}
}
@SuppressLint("SdCardPath")
public static void doLoadLibrary(final Context context, final String lib) {
final Throwable e = doLoadLibraryExpected(context, lib);
if (e == null) {