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

Commit 751ea275 authored by Jakob Schneider's avatar Jakob Schneider
Browse files

Show real installerTitle for the unarchive permission dialog.

Test: manual
Bug: 322550030
Change-Id: Idc45544059a1272d39858b805578fff610355f57
parent 4ee4e6bc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -272,7 +272,7 @@
    <!-- The title of a dialog which asks the user to restore (i.e. re-install, re-download) an app
         after parts of the app have been previously moved into the cloud for temporary storage.
         "installername" is the app that will facilitate the download of the app. [CHAR LIMIT=50] -->
    <string name="unarchive_application_title">Restore <xliff:g id="appname" example="Bird Game">%1$s</xliff:g> from <xliff:g id="installername" example="App Store">%1$s</xliff:g>?</string>
    <string name="unarchive_application_title">Restore <xliff:g id="appname" example="Bird Game">%1$s</xliff:g> from <xliff:g id="installername" example="App Store">%2$s</xliff:g>?</string>
    <!-- After the user confirms the dialog, a download will start. [CHAR LIMIT=none] -->
    <string name="unarchive_body_text">This app will begin to download in the background</string>
    <!-- The action to restore (i.e. re-install, re-download) an app after parts of the app have been previously moved
+21 −3
Original line number Diff line number Diff line
@@ -25,10 +25,12 @@ import android.app.DialogFragment;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.IntentSender;
import android.content.pm.InstallSourceInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Process;
import android.text.TextUtils;
import android.util.Log;

import androidx.annotation.NonNull;
@@ -97,14 +99,30 @@ public class UnarchiveActivity extends Activity {
            String appTitle = pm.getApplicationInfo(mPackageName,
                    PackageManager.ApplicationInfoFlags.of(
                            MATCH_ARCHIVED_PACKAGES)).loadLabel(pm).toString();
            // TODO(ag/25387215) Get the real installer title here after fixing getInstallSource for
            //  archived apps.
            showDialogFragment(appTitle, "installerTitle");
            String installerTitle = getResponsibleInstallerTitle(pm,
                    pm.getInstallSourceInfo(mPackageName));
            showDialogFragment(appTitle, installerTitle);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Invalid packageName: " + e.getMessage());
        }
    }

    private String getResponsibleInstallerTitle(PackageManager pm,
            InstallSourceInfo installSource)
            throws PackageManager.NameNotFoundException {
        String packageName = TextUtils.isEmpty(installSource.getUpdateOwnerPackageName())
                ? installSource.getInstallingPackageName()
                : installSource.getUpdateOwnerPackageName();
        if (packageName == null) {
            // Should be unreachable.
            Log.e(TAG, "Installer not found.");
            setResult(Activity.RESULT_FIRST_USER);
            finish();
            return "";
        }
        return pm.getApplicationInfo(packageName, /* flags= */ 0).loadLabel(pm).toString();
    }

    @NonNull
    private String[] getRequestedPermissions(String callingPackage) {
        String[] requestedPermissions = null;