Merge "Revert "Checkbox for removing contributes files""

This commit is contained in:
TreeHugger Robot
2019-03-22 01:15:20 +00:00
committed by Android (Google) Code Review
8 changed files with 7 additions and 92 deletions

View File

@@ -112,7 +112,6 @@ applications that come with the platform
<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>

View File

@@ -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" />

View File

@@ -35,16 +35,6 @@
android:layout_height="wrap_content"
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"

View File

@@ -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>

View File

@@ -50,8 +50,6 @@ public class UninstallUninstalling extends Activity implements
"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 @@ public class UninstallUninstalling extends Activity implements
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 @@ public class UninstallUninstalling extends Activity implements
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 {

View File

@@ -285,7 +285,7 @@ public class UninstallerActivity extends Activity {
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 @@ public class UninstallerActivity extends Activity {
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 @@ public class UninstallerActivity extends Activity {
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(

View File

@@ -36,7 +36,6 @@ import android.os.UserHandle;
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,56 +53,8 @@ public class UninstallAlertDialogFragment extends DialogFragment implements
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.
*
@@ -212,8 +163,6 @@ public class UninstallAlertDialogFragment extends DialogFragment implements
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 @@ public class UninstallAlertDialogFragment extends DialogFragment implements
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 class UninstallAlertDialogFragment extends DialogFragment implements
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();

View File

@@ -99,7 +99,7 @@ public class UninstallAlertFragment extends GuidedStepFragment {
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();