Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Jul 4, 2014
1 parent 3529d62 commit 6ebe44c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
13 changes: 5 additions & 8 deletions src/biz/bokhorst/xprivacy/ApplicationInfoEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ public class ApplicationInfoEx implements Comparable<ApplicationInfoEx> {

// Cache
private Drawable mIcon = null;
private boolean mInternet = false;
private boolean mInternetDetermined = false;
private boolean mFrozen = false;
private boolean mFrozenDetermined = false;
private Boolean mInternet = null;
private Boolean mFrozen = null;
private long mInstallTime = -1;
private long mUpdateTime = -1;

Expand Down Expand Up @@ -159,20 +157,20 @@ public Drawable getIcon(Context context) {
}

public boolean hasInternet(Context context) {
if (!mInternetDetermined) {
if (mInternet == null) {
mInternet = false;
PackageManager pm = context.getPackageManager();
for (ApplicationInfo appInfo : mMapAppInfo.values())
if (pm.checkPermission("android.permission.INTERNET", appInfo.packageName) == PackageManager.PERMISSION_GRANTED) {
mInternet = true;
break;
}
mInternetDetermined = true;
}
return mInternet;
}

public boolean isFrozen(Context context) {
if (!mFrozenDetermined) {
if (mFrozen == null) {
PackageManager pm = context.getPackageManager();
boolean enabled = false;
for (ApplicationInfo appInfo : mMapAppInfo.values())
Expand All @@ -185,7 +183,6 @@ public boolean isFrozen(Context context) {
} catch (IllegalArgumentException ignored) {
}
mFrozen = !enabled;
mFrozenDetermined = true;
}
return mFrozen;
}
Expand Down
11 changes: 6 additions & 5 deletions src/biz/bokhorst/xprivacy/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public class Util {
private static boolean mPro = false;
private static boolean mLog = true;
private static boolean mLogDetermined = false;
private static boolean mHasLBE = false;
private static boolean mHasLBEDetermined = false;
private static Boolean mHasLBE = null;

private static Version MIN_PRO_VERSION = new Version("1.12");
private static String LICENSE_FILE_NAME = "XPrivacy_license.txt";
Expand Down Expand Up @@ -369,15 +368,17 @@ public static void viewUri(Context context, Uri uri) {
}

public static boolean hasLBE() {
if (!mHasLBEDetermined) {
mHasLBEDetermined = true;
if (mHasLBE == null) {
mHasLBE = false;
try {
File apps = new File(Environment.getDataDirectory() + File.separator + "app");
File[] files = (apps == null ? null : apps.listFiles());
if (files != null)
for (File file : files)
if (file.getName().startsWith("com.lbe.security"))
if (file.getName().startsWith("com.lbe.security")) {
mHasLBE = true;
break;
}
} catch (Throwable ex) {
Util.bug(null, ex);
}
Expand Down

0 comments on commit 6ebe44c

Please sign in to comment.