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

Commit

Permalink
Do not restrict the Pro enabler on new install
Browse files Browse the repository at this point in the history
Fixes #812
  • Loading branch information
M66B committed Nov 23, 2013
1 parent b3d9306 commit 97d51c4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
**Next release**

* Allow fetching restrictions for system applications per application
* Do not restrict the [Pro enabler](https://play.google.com/store/apps/details?id=biz.bokhorst.xprivacy.pro) on new install ([issue](https://github.com/M66B/XPrivacy/issues/812))

**Version 1.10.21 BETA**

Expand Down
4 changes: 2 additions & 2 deletions src/biz/bokhorst/xprivacy/ActivityApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void onCreate(Bundle savedInstanceState) {

// Get app info
mAppInfo = new ApplicationInfoEx(this, packageName);
if (!mAppInfo.getIsInstalled()) {
if (!mAppInfo.isInstalled()) {
finish();
return;
}
Expand All @@ -148,7 +148,7 @@ public void onClick(View view) {
tvAppName.setText(mAppInfo.toString());

// Background color
if (mAppInfo.getIsSystem()) {
if (mAppInfo.isSystem()) {
LinearLayout llInfo = (LinearLayout) findViewById(R.id.llInfo);
llInfo.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous)));
}
Expand Down
10 changes: 4 additions & 6 deletions src/biz/bokhorst/xprivacy/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,12 @@ else if (PrivacyManager.hasPermission(mContext, xAppInfo.getPackageName(), mRest
// Get if user
boolean user = false;
if (fUser)
user = !xAppInfo.getIsSystem();
user = !xAppInfo.isSystem();

// Get if system
boolean system = false;
if (fSystem)
system = xAppInfo.getIsSystem();
system = xAppInfo.isSystem();

// Match application
if ((fName.equals("") ? true : contains) && (fUsed ? used : true) && (fInternet ? internet : true)
Expand Down Expand Up @@ -1220,7 +1220,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
final ApplicationInfoEx xAppInfo = getItem(holder.position);

// Set background color
if (xAppInfo.getIsSystem())
if (xAppInfo.isSystem())
holder.row.setBackgroundColor(getResources().getColor(getThemed(R.attr.color_dangerous)));
else
holder.row.setBackgroundColor(Color.TRANSPARENT);
Expand Down Expand Up @@ -1261,10 +1261,8 @@ public void onClick(View view) {

private void checkLicense() {
if (Util.hasProLicense(this) == null) {
if (Util.isProInstalled(this))
if (Util.isProEnablerInstalled(this))
try {
int uid = getPackageManager().getApplicationInfo("biz.bokhorst.xprivacy.pro", 0).uid;
PrivacyManager.deleteRestrictions(this, uid);
Util.log(null, Log.INFO, "Licensing: check");
startActivityForResult(new Intent("biz.bokhorst.xprivacy.pro.CHECK"), ACTIVITY_LICENSE);
} catch (Throwable ex) {
Expand Down
2 changes: 1 addition & 1 deletion src/biz/bokhorst/xprivacy/ActivityShare.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ protected Object doInBackground(String... params) {

// Process applications
for (ApplicationInfoEx appInfo : lstApp)
if (!appInfo.getIsSystem() || params[0] != null) {
if (!appInfo.isSystem() || params[0] != null) {
publishProgress(appInfo.getPackageName());

// Encode package
Expand Down
11 changes: 6 additions & 5 deletions src/biz/bokhorst/xprivacy/ApplicationInfoEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ private void Initialize(Context context, ApplicationInfo appInfo) {

// Get if system application
mSystem = ((appInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0);
mSystem = mSystem || appInfo.packageName.equals(ApplicationInfoEx.class.getPackage().getName());
mSystem = mSystem || appInfo.packageName.equals(context.getPackageName());
mSystem = mSystem || appInfo.packageName.equals(context.getPackageName() + ".pro");
mSystem = mSystem || appInfo.packageName.equals("de.robv.android.xposed.installer");

// Get if frozen (not enabled)
Expand Down Expand Up @@ -101,7 +102,7 @@ public static List<ApplicationInfoEx> getXApplicationList(Context context, Progr
mapApp.put(xAppInfo.getUid(), xAppInfo);
listApp.add(xAppInfo);
} else
yAppInfo.AddApplicationName(getApplicationName(listAppInfo.get(app), pm));
yAppInfo.addApplicationName(getApplicationName(listAppInfo.get(app), pm));
} catch (Throwable ex) {
Util.bug(null, ex);
}
Expand All @@ -115,7 +116,7 @@ private static String getApplicationName(ApplicationInfo appInfo, PackageManager
return (String) pm.getApplicationLabel(appInfo);
}

private void AddApplicationName(String Name) {
private void addApplicationName(String Name) {
mListApplicationName.add(Name);
Collections.sort(mListApplicationName);
}
Expand Down Expand Up @@ -148,11 +149,11 @@ public String getVersion() {
return mVersion;
}

public boolean getIsSystem() {
public boolean isSystem() {
return mSystem;
}

public boolean getIsInstalled() {
public boolean isInstalled() {
return mInstalled;
}

Expand Down
14 changes: 5 additions & 9 deletions src/biz/bokhorst/xprivacy/PackageChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,11 @@ public void onReceive(Context context, Intent intent) {
// Check action
if (intent.getAction().equals(Intent.ACTION_PACKAGE_ADDED)) {
// Get data
boolean system = false;
PackageInfo pInfo = null;
PackageManager pm = context.getPackageManager();
pInfo = pm.getPackageInfo(packageName, 0);
system = (pInfo.applicationInfo.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0;
ApplicationInfoEx appInfo = new ApplicationInfoEx(context, packageName);

if (fSystem ? !system : true) {
if (fSystem ? !appInfo.isSystem() : true) {
// Default deny new user apps
if (!system && !replacing) {
if (!appInfo.isSystem() && !replacing) {
// Check for existing restrictions
boolean someRestricted = false;
for (boolean restricted : PrivacyManager.getRestricted(context, uid))
Expand Down Expand Up @@ -82,7 +78,7 @@ public void onReceive(Context context, Intent intent) {
// Title
String title = String.format("%s %s %s",
context.getString(replacing ? R.string.msg_update : R.string.msg_new),
pm.getApplicationLabel(pInfo.applicationInfo), pInfo.versionName);
appInfo.getFirstApplicationName(), appInfo.getVersion());

// Build notification
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
Expand All @@ -97,7 +93,7 @@ public void onReceive(Context context, Intent intent) {
Notification notification = notificationBuilder.build();

// Notify
notificationManager.notify(pInfo.applicationInfo.uid, notification);
notificationManager.notify(appInfo.getUid(), notification);
}
}
} else if (intent.getAction().equals(Intent.ACTION_PACKAGE_REPLACED)) {
Expand Down
2 changes: 1 addition & 1 deletion src/biz/bokhorst/xprivacy/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private static boolean hasValidProEnablerSignature(Context context) {
.checkSignatures(context.getPackageName(), context.getPackageName() + ".pro") == PackageManager.SIGNATURE_MATCH);
}

public static boolean isProInstalled(Context context) {
public static boolean isProEnablerInstalled(Context context) {
Version version = getProEnablerVersion(context);
if (version != null && isValidProEnablerVersion(version) && hasValidProEnablerSignature(context)
&& hasValidFingerPrint(context)) {
Expand Down

0 comments on commit 97d51c4

Please sign in to comment.