Skip to content

Commit

Permalink
Use OSSDK foreground app information
Browse files Browse the repository at this point in the history
Summary: The OSSDK gives us a better API for getting the current foreground app.  It doesn't seem to have the issues of the previous implementation.

Differential Revision: D20568949

fbshipit-source-id: e76dda627b66ff4e4f2dd1525de19b225c9a57a9
  • Loading branch information
SeyelentEco authored and facebook-github-bot committed Mar 21, 2020
1 parent 47b5b4c commit ad0e3bf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions java/com/facebook/soloader/SoLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ public class SoLoader {
*/
public static final int SOLOADER_SKIP_MERGED_JNI_ONLOAD = (1 << 4);

/** System Apps ignore PREFER_ANDROID_LIBS_DIRECTORY. Don't do that for this app. */
public static final int SOLOADER_DONT_TREAT_AS_SYSTEMAPP = (1 << 5);

@GuardedBy("sSoSourcesLock")
private static int sFlags;

Expand Down Expand Up @@ -192,7 +195,7 @@ public static void init(Context context, int flags, @Nullable SoFileLoader soFil
throws IOException {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
isSystemApp = checkIfSystemApp(context);
isSystemApp = checkIfSystemApp(context, flags);
initSoLoader(soFileLoader);
initSoSources(context, flags, soFileLoader);
if (!NativeLoader.isInitialized()) {
Expand Down Expand Up @@ -444,7 +447,11 @@ private static Method getNativeLoadRuntimeMethod() {
}
}

private static boolean checkIfSystemApp(Context context) {
private static boolean checkIfSystemApp(Context context, int flags) {
if ((flags & SOLOADER_DONT_TREAT_AS_SYSTEMAPP) != 0) {
return false;
}

return (context != null)
&& (context.getApplicationInfo().flags
& (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP))
Expand Down

0 comments on commit ad0e3bf

Please sign in to comment.