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

Commit

Permalink
Improved remove legacy salt
Browse files Browse the repository at this point in the history
Refs #1699
  • Loading branch information
M66B committed Jun 3, 2014
1 parent bb65d45 commit e00181f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
7 changes: 0 additions & 7 deletions src/biz/bokhorst/xprivacy/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
Expand Down Expand Up @@ -169,12 +168,6 @@ protected void onCreate(Bundle savedInstanceState) {
if (getIntent().getAction().equals(Intent.ACTION_VIEW))
Util.importProLicense(new File(getIntent().getData().getEncodedPath()));

// Delete legacy salt
String def = (Build.SERIAL == null ? "" : Build.SERIAL);
String salt = PrivacyManager.getSetting(userId, PrivacyManager.cSettingSalt, null, false);
if (def.equals(salt))
PrivacyManager.setSetting(userId, PrivacyManager.cSettingSalt, null);

// Set layout
setContentView(R.layout.mainlist);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Expand Down
7 changes: 6 additions & 1 deletion src/biz/bokhorst/xprivacy/ActivityShare.java
Original file line number Diff line number Diff line change
Expand Up @@ -1155,12 +1155,17 @@ public void startElement(String uri, String localName, String qName, Attributes

@Override
public void endElement(String uri, String localName, String qName) {
if (qName.equals("XPrivacy"))
if (qName.equals("XPrivacy")) {
if (lastUid > 0) {
PrivacyManager.updateState(lastUid);
boolean restart = !PrivacyManager.getRestartStates(lastUid, null).equals(mOldState);
setState(lastUid, STATE_SUCCESS, restart ? getString(R.string.msg_restart) : null);
}

// Cleanup salt
int userId = Util.getUserId(Process.myUid());
PrivacyManager.removeLegacySalt(userId);
}
}

private int getUid(int id) {
Expand Down
9 changes: 8 additions & 1 deletion src/biz/bokhorst/xprivacy/PrivacyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,14 @@ public static void deleteUsage(int uid) {

public static String getSalt(int userId) {
String def = (Build.SERIAL == null ? "" : Build.SERIAL);
return getSetting(userId, PrivacyManager.cSettingSalt, def, true);
return getSetting(userId, cSettingSalt, def, true);
}

public static void removeLegacySalt(int userId) {
String def = (Build.SERIAL == null ? "" : Build.SERIAL);
String salt = getSetting(userId, cSettingSalt, null, false);
if (def.equals(salt))
setSetting(userId, cSettingSalt, null);
}

public static boolean getSettingBool(int uid, String name, boolean defaultValue, boolean useCache) {
Expand Down
4 changes: 4 additions & 0 deletions src/biz/bokhorst/xprivacy/UpdateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ private static void upgrade(Context context) throws NameNotFoundException {
} else
Util.log(null, Log.WARN, "Noting to upgrade version=" + sVersion);

// Finalize
PrivacyManager.setSetting(userId, PrivacyManager.cSettingVersion, currentVersion);

// Cleanup
PrivacyManager.removeLegacySalt(userId);
}

private static void randomize(Context context) {
Expand Down

0 comments on commit e00181f

Please sign in to comment.