Merge "Revert "Checkbox for removing contributes files""
diff --git a/data/etc/privapp-permissions-platform.xml b/data/etc/privapp-permissions-platform.xml
index 5e119e2..a0d14f9 100644
--- a/data/etc/privapp-permissions-platform.xml
+++ b/data/etc/privapp-permissions-platform.xml
@@ -112,7 +112,6 @@
<permission name="android.permission.MANAGE_USERS"/>
<permission name="android.permission.UPDATE_APP_OPS_STATS"/>
<permission name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME"/>
- <permission name="android.permission.CLEAR_APP_USER_DATA"/>
<permission name="android.permission.PACKAGE_USAGE_STATS"/>
</privapp-permissions>
diff --git a/packages/PackageInstaller/AndroidManifest.xml b/packages/PackageInstaller/AndroidManifest.xml
index a69b412..62535b6 100644
--- a/packages/PackageInstaller/AndroidManifest.xml
+++ b/packages/PackageInstaller/AndroidManifest.xml
@@ -15,7 +15,6 @@
<uses-permission android:name="android.permission.MANAGE_APP_OPS_MODES" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="android.permission.SUBSTITUTE_NOTIFICATION_APP_NAME" />
- <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
<uses-permission android:name="com.google.android.permission.INSTALL_WEARABLE_PACKAGES" />
diff --git a/packages/PackageInstaller/res/layout/uninstall_content_view.xml b/packages/PackageInstaller/res/layout/uninstall_content_view.xml
index 2f8966c..5666c0e 100644
--- a/packages/PackageInstaller/res/layout/uninstall_content_view.xml
+++ b/packages/PackageInstaller/res/layout/uninstall_content_view.xml
@@ -36,16 +36,6 @@
style="@android:style/TextAppearance.Material.Subhead" />
<CheckBox
- android:id="@+id/clearContributedFiles"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:layout_marginStart="-8dp"
- android:paddingLeft="8sp"
- android:visibility="gone"
- style="@android:style/TextAppearance.Material.Subhead" />
-
- <CheckBox
android:id="@+id/keepData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/packages/PackageInstaller/res/values/strings.xml b/packages/PackageInstaller/res/values/strings.xml
index a05a219..797656e 100644
--- a/packages/PackageInstaller/res/values/strings.xml
+++ b/packages/PackageInstaller/res/values/strings.xml
@@ -119,8 +119,6 @@
<string name="uninstall_update_text">Replace this app with the factory version? All data will be removed.</string>
<!-- [CHAR LIMIT=none] -->
<string name="uninstall_update_text_multiuser">Replace this app with the factory version? All data will be removed. This affects all users of this device, including those with work profiles.</string>
- <!-- Label of a checkbox that allows to remove the files contributed by app during uninstall [CHAR LIMIT=none] -->
- <string name="uninstall_remove_contributed_files">Also remove <xliff:g id="size" example="1.5MB">%1$s</xliff:g> of associated media files.</string>
<!-- Label of a checkbox that allows to keep the data (e.g. files, settings) of the app on uninstall [CHAR LIMIT=none] -->
<string name="uninstall_keep_data">Keep <xliff:g id="size" example="1.5MB">%1$s</xliff:g> of app data.</string>
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/UninstallUninstalling.java b/packages/PackageInstaller/src/com/android/packageinstaller/UninstallUninstalling.java
index 63d8c5a8..c4dceb4 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/UninstallUninstalling.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/UninstallUninstalling.java
@@ -50,8 +50,6 @@
"com.android.packageinstaller.ACTION_UNINSTALL_COMMIT";
static final String EXTRA_APP_LABEL = "com.android.packageinstaller.extra.APP_LABEL";
- static final String EXTRA_CLEAR_CONTRIBUTED_FILES =
- "com.android.packageinstaller.extra.CLEAR_CONTRIBUTED_FILES";
static final String EXTRA_KEEP_DATA = "com.android.packageinstaller.extra.KEEP_DATA";
private int mUninstallId;
@@ -75,8 +73,6 @@
if (savedInstanceState == null) {
boolean allUsers = getIntent().getBooleanExtra(Intent.EXTRA_UNINSTALL_ALL_USERS,
false);
- boolean clearContributedFiles = getIntent().getBooleanExtra(
- EXTRA_CLEAR_CONTRIBUTED_FILES, false);
boolean keepData = getIntent().getBooleanExtra(EXTRA_KEEP_DATA, false);
UserHandle user = getIntent().getParcelableExtra(Intent.EXTRA_USER);
@@ -102,7 +98,6 @@
broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
int flags = allUsers ? PackageManager.DELETE_ALL_USERS : 0;
- flags |= clearContributedFiles ? PackageManager.DELETE_CONTRIBUTED_MEDIA : 0;
flags |= keepData ? PackageManager.DELETE_KEEP_DATA : 0;
try {
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java
index 5419449..be778e9 100755
--- a/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/UninstallerActivity.java
@@ -285,7 +285,7 @@
fragment.show(ft, "dialog");
}
- public void startUninstallProgress(boolean clearContributedFiles, boolean keepData) {
+ public void startUninstallProgress(boolean keepData) {
boolean returnResult = getIntent().getBooleanExtra(Intent.EXTRA_RETURN_RESULT, false);
CharSequence label = mDialogInfo.appInfo.loadSafeLabel(getPackageManager());
@@ -310,8 +310,6 @@
newIntent.putExtra(Intent.EXTRA_UNINSTALL_ALL_USERS, mDialogInfo.allUsers);
newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO, mDialogInfo.appInfo);
newIntent.putExtra(UninstallUninstalling.EXTRA_APP_LABEL, label);
- newIntent.putExtra(UninstallUninstalling.EXTRA_CLEAR_CONTRIBUTED_FILES,
- clearContributedFiles);
newIntent.putExtra(UninstallUninstalling.EXTRA_KEEP_DATA, keepData);
newIntent.putExtra(PackageInstaller.EXTRA_CALLBACK, mDialogInfo.callback);
@@ -362,7 +360,6 @@
Log.i(TAG, "Uninstalling extras=" + broadcastIntent.getExtras());
int flags = mDialogInfo.allUsers ? PackageManager.DELETE_ALL_USERS : 0;
- flags |= clearContributedFiles ? PackageManager.DELETE_CONTRIBUTED_MEDIA : 0;
flags |= keepData ? PackageManager.DELETE_KEEP_DATA : 0;
ActivityThread.getPackageManager().getPackageInstaller().uninstall(
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java b/packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java
index 499da75..0a37cc6 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/handheld/UninstallAlertDialogFragment.java
@@ -36,7 +36,6 @@
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
-import android.provider.MediaStore;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -54,57 +53,9 @@
DialogInterface.OnClickListener {
private static final String LOG_TAG = UninstallAlertDialogFragment.class.getSimpleName();
- private @Nullable CheckBox mClearContributedFiles;
private @Nullable CheckBox mKeepData;
/**
- * Get number of bytes of the files contributed by the package.
- *
- * @param pkg The package that might have contributed files.
- * @param user The user the package belongs to.
- *
- * @return The number of bytes.
- */
- private long getContributedMediaSizeForUser(@NonNull String pkg, @NonNull UserHandle user) {
- try {
- return MediaStore.getContributedMediaSize(getContext(), pkg, user);
- } catch (IOException e) {
- Log.e(LOG_TAG, "Cannot determine amount of contributes files for " + pkg
- + " (user " + user + ")", e);
- return 0;
- }
- }
-
- /**
- * Get number of bytes of the files contributed by the package.
- *
- * @param pkg The package that might have contributed files.
- * @param user The user the package belongs to or {@code null} if files of all users should be
- * counted.
- *
- * @return The number of bytes.
- */
- private long getContributedMediaSize(@NonNull String pkg, @Nullable UserHandle user) {
- UserManager userManager = getContext().getSystemService(UserManager.class);
-
- long contributedFileSize = 0;
-
- if (user == null) {
- List<UserInfo> users = userManager.getUsers();
-
- int numUsers = users.size();
- for (int i = 0; i < numUsers; i++) {
- contributedFileSize += getContributedMediaSizeForUser(pkg,
- UserHandle.of(users.get(i).id));
- }
- } else {
- contributedFileSize = getContributedMediaSizeForUser(pkg, user);
- }
-
- return contributedFileSize;
- }
-
- /**
* Get number of bytes of the app data of the package.
*
* @param pkg The package that might have app data.
@@ -212,8 +163,6 @@
dialogBuilder.setNegativeButton(android.R.string.cancel, this);
String pkg = dialogInfo.appInfo.packageName;
- long contributedFileSize = getContributedMediaSize(pkg,
- dialogInfo.allUsers ? null : dialogInfo.user);
boolean suggestToKeepAppData;
try {
@@ -230,28 +179,17 @@
appDataSize = getAppDataSize(pkg, dialogInfo.allUsers ? null : dialogInfo.user);
}
- if (contributedFileSize == 0 && appDataSize == 0) {
+ if (appDataSize == 0) {
dialogBuilder.setMessage(messageBuilder.toString());
} else {
LayoutInflater inflater = getContext().getSystemService(LayoutInflater.class);
ViewGroup content = (ViewGroup) inflater.inflate(R.layout.uninstall_content_view, null);
((TextView) content.requireViewById(R.id.message)).setText(messageBuilder.toString());
-
- if (contributedFileSize != 0) {
- mClearContributedFiles = content.requireViewById(R.id.clearContributedFiles);
- mClearContributedFiles.setVisibility(View.VISIBLE);
- mClearContributedFiles.setText(
- getString(R.string.uninstall_remove_contributed_files,
- formatFileSize(getContext(), contributedFileSize)));
- }
-
- if (appDataSize != 0) {
- mKeepData = content.requireViewById(R.id.keepData);
- mKeepData.setVisibility(View.VISIBLE);
- mKeepData.setText(getString(R.string.uninstall_keep_data,
- formatFileSize(getContext(), appDataSize)));
- }
+ mKeepData = content.requireViewById(R.id.keepData);
+ mKeepData.setVisibility(View.VISIBLE);
+ mKeepData.setText(getString(R.string.uninstall_keep_data,
+ formatFileSize(getContext(), appDataSize)));
dialogBuilder.setView(content);
}
@@ -263,7 +201,6 @@
public void onClick(DialogInterface dialog, int which) {
if (which == Dialog.BUTTON_POSITIVE) {
((UninstallerActivity) getActivity()).startUninstallProgress(
- mClearContributedFiles != null && mClearContributedFiles.isChecked(),
mKeepData != null && mKeepData.isChecked());
} else {
((UninstallerActivity) getActivity()).dispatchAborted();
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/television/UninstallAlertFragment.java b/packages/PackageInstaller/src/com/android/packageinstaller/television/UninstallAlertFragment.java
index ac5fd76..21d25f5 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/television/UninstallAlertFragment.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/television/UninstallAlertFragment.java
@@ -99,7 +99,7 @@
public void onGuidedActionClicked(GuidedAction action) {
if (isAdded()) {
if (action.getId() == GuidedAction.ACTION_ID_OK) {
- ((UninstallerActivity) getActivity()).startUninstallProgress(false, false);
+ ((UninstallerActivity) getActivity()).startUninstallProgress(false);
getActivity().finish();
} else {
((UninstallerActivity) getActivity()).dispatchAborted();