Merge branch 'new-ui/uninstall-fixes' into 'master'
System app uninstall prevention, fixes crash. See merge request !478
This commit is contained in:
commit
41d7e830d3
@ -960,6 +960,27 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* System apps aren't uninstallable, only their updates are.
|
||||
*/
|
||||
public boolean isUninstallable(Context context) {
|
||||
if (this.isInstalled()) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
ApplicationInfo appInfo;
|
||||
try {
|
||||
appInfo = pm.getApplicationInfo(this.packageName,
|
||||
PackageManager.GET_UNINSTALLED_PACKAGES);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean isSystem = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
|
||||
return !isSystem && this.isInstalled();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeByte(this.compatible ? (byte) 1 : (byte) 0);
|
||||
|
@ -47,7 +47,7 @@ public class InstallerFactory {
|
||||
|
||||
|
||||
Installer installer;
|
||||
if (!apk.apkName.endsWith(".apk")) {
|
||||
if (apk.apkName != null && !apk.apkName.endsWith(".apk")) {
|
||||
String msg = context.getString(R.string.install_error_not_yet_supported, apk.apkName);
|
||||
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
|
||||
Utils.debugLog(TAG, msg);
|
||||
|
@ -469,7 +469,7 @@ public class AppDetailsRecyclerViewAdapter
|
||||
}
|
||||
updateAntiFeaturesWarning();
|
||||
buttonSecondaryView.setText(R.string.menu_uninstall);
|
||||
buttonSecondaryView.setVisibility(app.isInstalled() ? View.VISIBLE : View.INVISIBLE);
|
||||
buttonSecondaryView.setVisibility(app.isUninstallable(context) ? View.VISIBLE : View.INVISIBLE);
|
||||
buttonSecondaryView.setOnClickListener(onUnInstallClickListener);
|
||||
buttonPrimaryView.setText(R.string.menu_install);
|
||||
buttonPrimaryView.setVisibility(versions.size() > 0 ? View.VISIBLE : View.GONE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user