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

Commit

Permalink
Easier pro license file import
Browse files Browse the repository at this point in the history
Fixed #1658
  • Loading branch information
M66B committed May 17, 2014
1 parent 89f3a23 commit 770a81d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 23 deletions.
10 changes: 10 additions & 0 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />

<data android:scheme="file" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*XPrivacy_license.txt" />
</intent-filter>
</activity>
<activity
android:name=".ActivityApp"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Changelog
* Fixed displaying contacts without display name ([issue](/../../issues/1660))
* Fixed on demand restricting for dangerous methods with whitelists ([issue](/../../issues/1653))
* Not storing salt into database anymore for increased privacy ([issue](/../../issues/1661))
* Easier pro license file import ([issue](/../../issues/1658))

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

Expand Down
5 changes: 5 additions & 0 deletions src/biz/bokhorst/xprivacy/ActivityMain.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package biz.bokhorst.xprivacy;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -169,6 +170,10 @@ protected void onCreate(Bundle savedInstanceState) {
if (salt != null && salt.equals(Build.SERIAL))
PrivacyManager.setSetting(userId, PrivacyManager.cSettingSalt, null);

// Import license file
if (getIntent().getAction().equals(Intent.ACTION_VIEW))
Util.importProLicense(new File(getIntent().getData().getEncodedPath()));

// Set layout
setContentView(R.layout.mainlist);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Expand Down
51 changes: 28 additions & 23 deletions src/biz/bokhorst/xprivacy/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,33 @@ public static String[] getProLicenseUnchecked() {
if (!licenseFile.exists())
licenseFile = new File(storageDir + File.separator + ".xprivacy" + File.separator + LICENSE_FILE_NAME);

String importedLicense = importProLicense(licenseFile);

// Check license file
licenseFile = new File(importedLicense);
if (licenseFile.exists()) {
// Read license
try {
IniFile iniFile = new IniFile(licenseFile);
String name = iniFile.get("name", "");
String email = iniFile.get("email", "");
String signature = iniFile.get("signature", "");
if (name == null || email == null || signature == null)
return null;
else
return new String[] { name, email, signature };
} catch (FileNotFoundException ex) {
return null;
} catch (Throwable ex) {
bug(null, ex);
return null;
}
} else
Util.log(null, Log.INFO, "Licensing: no license file");
return null;
}

public static String importProLicense(File licenseFile) {
// Get imported license file name
String importedLicense = getUserDataDirectory(Process.myUid()) + File.separator + LICENSE_FILE_NAME;

Expand Down Expand Up @@ -269,29 +296,7 @@ public static String[] getProLicenseUnchecked() {
Util.bug(null, ex);
}
}

// Check license file
licenseFile = new File(importedLicense);
if (licenseFile.exists()) {
// Read license
try {
IniFile iniFile = new IniFile(licenseFile);
String name = iniFile.get("name", "");
String email = iniFile.get("email", "");
String signature = iniFile.get("signature", "");
if (name == null || email == null || signature == null)
return null;
else
return new String[] { name, email, signature };
} catch (FileNotFoundException ex) {
return null;
} catch (Throwable ex) {
bug(null, ex);
return null;
}
} else
Util.log(null, Log.INFO, "Licensing: no license file");
return null;
return importedLicense;
}

public static Version getProEnablerVersion(Context context) {
Expand Down

0 comments on commit 770a81d

Please sign in to comment.