Skip to content

Commit

Permalink
StrictMode DiskReadViolation fix
Browse files Browse the repository at this point in the history
sometimes apps has really strict access policy (ie. Google Search Box)
we temporarily allow disk access for them.
  • Loading branch information
Palatis committed Apr 8, 2020
1 parent 1655c45 commit 3b4e40a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.content.pm.PackageInfo;
import android.os.StrictMode;
import android.os.UserHandle;

import java.util.Locale;
Expand Down Expand Up @@ -82,7 +83,11 @@ private static boolean isDebuggable(final String packageName, int user) {
CONFIG_PATH_FORMAT,
user, packageName
);
return SELinuxHelper.getAppDataFileService().checkFileExists(path);

final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
boolean state = SELinuxHelper.getAppDataFileService().checkFileExists(path);
StrictMode.setThreadPolicy(oldPolicy);
return state;
}

}

0 comments on commit 3b4e40a

Please sign in to comment.