Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38ea50c6 authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Checkbox for removing contributes files

Apps might have contributed files. During uninstall the files are
usually left on the system. To avoid filling up the storage we allow the
user to delete the files during uninstall.

Bug: 112002130
Test: Uninstalled an app that contributed files
Change-Id: I7e71ed524055bdda91ce9e66f995540363ceb229
parent b4815ebf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ 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"/>
    </privapp-permissions>

    <privapp-permissions package="com.android.permissioncontroller">
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
    <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="com.google.android.permission.INSTALL_WEARABLE_PACKAGES" />

+47 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2018 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<!-- Check box that is displayed in the activity resolver UI for the user
     to make their selection the preferred activity. -->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="?android:attr/alertDialogTheme"
    android:orientation="vertical"
    android:paddingTop="8dp"
    android:paddingStart="?android:attr/dialogPreferredPadding"
    android:paddingEnd="?android:attr/dialogPreferredPadding"
    android:clipToPadding="false">

    <TextView
        android:id="@+id/message"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        style="@android:style/TextAppearance.Material.Subhead" />

    <CheckBox
        android:id="@+id/checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginStart="-8dp"
        android:paddingLeft="8sp"
        style="@android:style/TextAppearance.Material.Subhead" />

</LinearLayout>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -119,6 +119,8 @@
    <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 for the notification channel containing notifications for current uninstall operations [CHAR LIMIT=40] -->
    <string name="uninstalling_notification_channel">Running uninstalls</string>
+9 −2
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ 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";

    private int mUninstallId;
    private ApplicationInfo mAppInfo;
@@ -72,6 +74,8 @@ 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);
                UserHandle user = getIntent().getParcelableExtra(Intent.EXTRA_USER);

                // Show dialog, which is the whole UI
@@ -95,12 +99,15 @@ public class UninstallUninstalling extends Activity implements
                PendingIntent pendingIntent = PendingIntent.getBroadcast(this, mUninstallId,
                        broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);

                int flags = allUsers ? PackageManager.DELETE_ALL_USERS : 0;
                flags |= clearContributedFiles ? PackageManager.DELETE_CONTRIBUTED_MEDIA : 0;

                try {
                    ActivityThread.getPackageManager().getPackageInstaller().uninstall(
                            new VersionedPackage(mAppInfo.packageName,
                                    PackageManager.VERSION_CODE_HIGHEST),
                            getPackageName(), allUsers ? PackageManager.DELETE_ALL_USERS : 0,
                            pendingIntent.getIntentSender(), user.getIdentifier());
                            getPackageName(), flags, pendingIntent.getIntentSender(),
                            user.getIdentifier());
                } catch (RemoteException e) {
                    e.rethrowFromSystemServer();
                }
Loading