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

Commit

Permalink
Fixed randomize on boot setting being restored
Browse files Browse the repository at this point in the history
Closes #1164
  • Loading branch information
M66B committed Jan 26, 2014
1 parent a1a2447 commit 66bd1b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Test and beta releases will have experimental functions enabled by default.

**Next release**

* Fixed randomize on boot setting being restored ([issue](https://github.com/M66B/XPrivacy/issues/1164))

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)

**Version 1.99.13 TEST**
Expand Down
27 changes: 15 additions & 12 deletions src/biz/bokhorst/xprivacy/PrivacyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,17 @@ public void setSettingList(List<ParcelableSetting> listSetting) throws RemoteExc
@Override
@SuppressLint("DefaultLocale")
public ParcelableSetting getSetting(ParcelableSetting setting) throws RemoteException {
ParcelableSetting result = new ParcelableSetting(setting.uid, setting.name, setting.value);
try {
// No permissions enforced

// Check cache
if (mUseCache) {
if (mUseCache && setting.value != null) {
CSetting key = new CSetting(setting.uid, setting.name);
synchronized (mSettingCache) {
if (mSettingCache.containsKey(key)) {
setting.value = mSettingCache.get(key).getValue();
return setting;
result.value = mSettingCache.get(key).getValue();
return result;
}
}
}
Expand All @@ -604,11 +605,11 @@ public ParcelableSetting getSetting(ParcelableSetting setting) throws RemoteExce
// Fallback
if (db.getVersion() == 1) {
if (setting.uid == 0)
setting.value = PrivacyProvider.getSettingFallback(setting.name, null, false);
if (setting.value == null) {
setting.value = PrivacyProvider.getSettingFallback(
result.value = PrivacyProvider.getSettingFallback(setting.name, null, false);
if (result.value == null) {
result.value = PrivacyProvider.getSettingFallback(
String.format("%s.%d", setting.name, setting.uid), setting.value, false);
return setting;
return result;
}
}

Expand All @@ -626,7 +627,9 @@ public ParcelableSetting getSetting(ParcelableSetting setting) throws RemoteExce
stmtGetSetting.clearBindings();
stmtGetSetting.bindLong(1, setting.uid);
stmtGetSetting.bindString(2, setting.name);
setting.value = stmtGetSetting.simpleQueryForString();
String value = stmtGetSetting.simpleQueryForString();
if (value != null)
result.value = value;
}
} catch (SQLiteDoneException ignored) {
}
Expand All @@ -637,9 +640,9 @@ public ParcelableSetting getSetting(ParcelableSetting setting) throws RemoteExce
}

// Add to cache
if (mUseCache) {
if (mUseCache && result.value != null) {
CSetting key = new CSetting(setting.uid, setting.name);
key.setValue(setting.value);
key.setValue(result.value);
synchronized (mSettingCache) {
if (mSettingCache.containsKey(key))
mSettingCache.remove(key);
Expand All @@ -648,9 +651,9 @@ public ParcelableSetting getSetting(ParcelableSetting setting) throws RemoteExce
}
} catch (Throwable ex) {
Util.bug(null, ex);
return setting;
return result;
}
return setting;
return result;
}

@Override
Expand Down

0 comments on commit 66bd1b6

Please sign in to comment.