diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b475843f..47ab6d4a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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** diff --git a/src/biz/bokhorst/xprivacy/ActivityApp.java b/src/biz/bokhorst/xprivacy/ActivityApp.java index 073982bae..bae1b6c1c 100644 --- a/src/biz/bokhorst/xprivacy/ActivityApp.java +++ b/src/biz/bokhorst/xprivacy/ActivityApp.java @@ -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; } @@ -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))); } diff --git a/src/biz/bokhorst/xprivacy/ActivityMain.java b/src/biz/bokhorst/xprivacy/ActivityMain.java index f38310f68..c8256bf10 100644 --- a/src/biz/bokhorst/xprivacy/ActivityMain.java +++ b/src/biz/bokhorst/xprivacy/ActivityMain.java @@ -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) @@ -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); @@ -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) { diff --git a/src/biz/bokhorst/xprivacy/ActivityShare.java b/src/biz/bokhorst/xprivacy/ActivityShare.java index 837ee74e3..5217ed5c0 100644 --- a/src/biz/bokhorst/xprivacy/ActivityShare.java +++ b/src/biz/bokhorst/xprivacy/ActivityShare.java @@ -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 diff --git a/src/biz/bokhorst/xprivacy/ApplicationInfoEx.java b/src/biz/bokhorst/xprivacy/ApplicationInfoEx.java index 4e0d032a8..626e8ea5d 100644 --- a/src/biz/bokhorst/xprivacy/ApplicationInfoEx.java +++ b/src/biz/bokhorst/xprivacy/ApplicationInfoEx.java @@ -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) @@ -101,7 +102,7 @@ public static List 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); } @@ -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); } @@ -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; } diff --git a/src/biz/bokhorst/xprivacy/PackageChange.java b/src/biz/bokhorst/xprivacy/PackageChange.java index 7e496f7fc..898602649 100644 --- a/src/biz/bokhorst/xprivacy/PackageChange.java +++ b/src/biz/bokhorst/xprivacy/PackageChange.java @@ -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)) @@ -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); @@ -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)) { diff --git a/src/biz/bokhorst/xprivacy/Util.java b/src/biz/bokhorst/xprivacy/Util.java index 371c7a99a..32ddd533c 100644 --- a/src/biz/bokhorst/xprivacy/Util.java +++ b/src/biz/bokhorst/xprivacy/Util.java @@ -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)) {