Loading packages/PackageInstaller/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ android:exported="false" /> <activity android:name=".PackageInstallerActivity" android:theme="@style/Theme.AlertDialogActivity.NoAnimation" android:exported="false" /> <activity android:name=".InstallInstalling" Loading packages/PackageInstaller/res/values/themes.xml +2 −2 Original line number Diff line number Diff line Loading @@ -32,8 +32,8 @@ <item name="android:windowNoTitle">true</item> </style> <style name="Theme.AlertDialogActivity.NoDim"> <item name="android:windowNoTitle">true</item> <style name="Theme.AlertDialogActivity.NoDim" parent="@style/Theme.AlertDialogActivity.NoActionBar"> <item name="android:backgroundDimAmount">0</item> </style> Loading packages/PackageInstaller/src/com/android/packageinstaller/InstallFailed.java +20 −12 Original line number Diff line number Diff line Loading @@ -36,12 +36,14 @@ import androidx.annotation.Nullable; /** * Installation failed: Return status code to the caller or display failure UI to user */ public class InstallFailed extends AlertActivity { public class InstallFailed extends Activity { private static final String LOG_TAG = InstallFailed.class.getSimpleName(); /** Label of the app that failed to install */ private CharSequence mLabel; private AlertDialog mDialog; /** * Unhide the appropriate label for the statusCode. * Loading @@ -53,19 +55,19 @@ public class InstallFailed extends AlertActivity { View viewToEnable; switch (statusCode) { case PackageInstaller.STATUS_FAILURE_BLOCKED: viewToEnable = requireViewById(R.id.install_failed_blocked); viewToEnable = mDialog.requireViewById(R.id.install_failed_blocked); break; case PackageInstaller.STATUS_FAILURE_CONFLICT: viewToEnable = requireViewById(R.id.install_failed_conflict); viewToEnable = mDialog.requireViewById(R.id.install_failed_conflict); break; case PackageInstaller.STATUS_FAILURE_INCOMPATIBLE: viewToEnable = requireViewById(R.id.install_failed_incompatible); viewToEnable = mDialog.requireViewById(R.id.install_failed_incompatible); break; case PackageInstaller.STATUS_FAILURE_INVALID: viewToEnable = requireViewById(R.id.install_failed_invalid_apk); viewToEnable = mDialog.requireViewById(R.id.install_failed_invalid_apk); break; default: viewToEnable = requireViewById(R.id.install_failed); viewToEnable = mDialog.requireViewById(R.id.install_failed); break; } Loading Loading @@ -105,12 +107,18 @@ public class InstallFailed extends AlertActivity { // Store label for dialog mLabel = as.label; mAlert.setIcon(as.icon); mAlert.setTitle(as.label); mAlert.setView(R.layout.install_content_view); mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.done), (ignored, ignored2) -> finish(), null); setupAlert(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(as.icon); builder.setTitle(as.label); builder.setView(R.layout.install_content_view); builder.setPositiveButton(getString(R.string.done), (ignored, ignored2) -> finish()); builder.setOnCancelListener(dialog -> { finish(); }); mDialog = builder.create(); mDialog.show(); // Show out of space dialog if needed if (statusCode == PackageInstaller.STATUS_FAILURE_STORAGE) { Loading packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java +17 −9 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.packageinstaller; import static com.android.packageinstaller.PackageInstallerActivity.EXTRA_APP_SNIPPET; import static com.android.packageinstaller.PackageInstallerActivity.EXTRA_STAGED_SESSION_ID; import android.app.Activity; import android.app.AlertDialog; import android.app.PendingIntent; import android.content.DialogInterface; import android.content.Intent; Loading @@ -43,7 +45,7 @@ import java.io.IOException; * <p>This has two phases: First send the data to the package manager, then wait until the package * manager processed the result.</p> */ public class InstallInstalling extends AlertActivity { public class InstallInstalling extends Activity { private static final String LOG_TAG = InstallInstalling.class.getSimpleName(); private static final String SESSION_ID = "com.android.packageinstaller.SESSION_ID"; Loading @@ -67,6 +69,8 @@ public class InstallInstalling extends AlertActivity { /** The button that can cancel this dialog */ private Button mCancelButton; private AlertDialog mDialog; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading @@ -90,10 +94,12 @@ public class InstallInstalling extends AlertActivity { PackageUtil.AppSnippet as = getIntent() .getParcelableExtra(EXTRA_APP_SNIPPET, PackageUtil.AppSnippet.class); mAlert.setIcon(as.icon); mAlert.setTitle(as.label); mAlert.setView(R.layout.install_content_view); mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(as.icon); builder.setTitle(as.label); builder.setView(R.layout.install_content_view); builder.setNegativeButton(getString(R.string.cancel), (ignored, ignored2) -> { if (mInstallingTask != null) { mInstallingTask.cancel(true); Loading @@ -106,9 +112,11 @@ public class InstallInstalling extends AlertActivity { setResult(RESULT_CANCELED); finish(); }, null); setupAlert(); requireViewById(R.id.installing).setVisibility(View.VISIBLE); }); builder.setCancelable(false); mDialog = builder.create(); mDialog.show(); mDialog.requireViewById(R.id.installing).setVisibility(View.VISIBLE); if (savedInstanceState != null) { mSessionId = savedInstanceState.getInt(SESSION_ID); Loading Loading @@ -145,7 +153,7 @@ public class InstallInstalling extends AlertActivity { } } mCancelButton = mAlert.getButton(DialogInterface.BUTTON_NEGATIVE); mCancelButton = mDialog.getButton(DialogInterface.BUTTON_NEGATIVE); } } Loading packages/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java +28 −10 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ import java.io.OutputStream; * If a package gets installed from a content URI this step stages the installation session * reading bytes from the URI. */ public class InstallStaging extends AlertActivity { public class InstallStaging extends Activity { private static final String LOG_TAG = InstallStaging.class.getSimpleName(); private static final String STAGED_SESSION_ID = "STAGED_SESSION_ID"; Loading @@ -65,6 +65,8 @@ public class InstallStaging extends AlertActivity { /** The session the package is in */ private int mStagedSessionId; private AlertDialog mDialog; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading @@ -72,10 +74,13 @@ public class InstallStaging extends AlertActivity { mInstaller = getPackageManager().getPackageInstaller(); setFinishOnTouchOutside(true); mAlert.setIcon(R.drawable.ic_file_download); mAlert.setTitle(getString(R.string.app_name_unknown)); mAlert.setView(R.layout.install_content_view); mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.drawable.ic_file_download); builder.setTitle(getString(R.string.app_name_unknown)); builder.setView(R.layout.install_content_view); builder.setNegativeButton(getString(R.string.cancel), (ignored, ignored2) -> { if (mStagingTask != null) { mStagingTask.cancel(true); Loading @@ -85,9 +90,21 @@ public class InstallStaging extends AlertActivity { setResult(RESULT_CANCELED); finish(); }, null); setupAlert(); requireViewById(R.id.staging).setVisibility(View.VISIBLE); }); builder.setOnCancelListener(dialog -> { if (mStagingTask != null) { mStagingTask.cancel(true); } cleanupStagingSession(); setResult(RESULT_CANCELED); finish(); }); mDialog = builder.create(); mDialog.show(); mDialog.requireViewById(com.android.packageinstaller.R.id.staging) .setVisibility(View.VISIBLE); if (savedInstanceState != null) { mStagedSessionId = savedInstanceState.getInt(STAGED_SESSION_ID, 0); Loading Loading @@ -275,8 +292,9 @@ public class InstallStaging extends AlertActivity { @Override protected void onPreExecute() { final long sizeBytes = getContentSizeBytes(); mProgressBar = sizeBytes > 0 ? requireViewById(R.id.progress_indeterminate) : null; if (sizeBytes > 0 && mDialog != null) { mProgressBar = mDialog.requireViewById(R.id.progress_indeterminate); } if (mProgressBar != null) { mProgressBar.setProgress(0); mProgressBar.setMax(100); Loading Loading
packages/PackageInstaller/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ android:exported="false" /> <activity android:name=".PackageInstallerActivity" android:theme="@style/Theme.AlertDialogActivity.NoAnimation" android:exported="false" /> <activity android:name=".InstallInstalling" Loading
packages/PackageInstaller/res/values/themes.xml +2 −2 Original line number Diff line number Diff line Loading @@ -32,8 +32,8 @@ <item name="android:windowNoTitle">true</item> </style> <style name="Theme.AlertDialogActivity.NoDim"> <item name="android:windowNoTitle">true</item> <style name="Theme.AlertDialogActivity.NoDim" parent="@style/Theme.AlertDialogActivity.NoActionBar"> <item name="android:backgroundDimAmount">0</item> </style> Loading
packages/PackageInstaller/src/com/android/packageinstaller/InstallFailed.java +20 −12 Original line number Diff line number Diff line Loading @@ -36,12 +36,14 @@ import androidx.annotation.Nullable; /** * Installation failed: Return status code to the caller or display failure UI to user */ public class InstallFailed extends AlertActivity { public class InstallFailed extends Activity { private static final String LOG_TAG = InstallFailed.class.getSimpleName(); /** Label of the app that failed to install */ private CharSequence mLabel; private AlertDialog mDialog; /** * Unhide the appropriate label for the statusCode. * Loading @@ -53,19 +55,19 @@ public class InstallFailed extends AlertActivity { View viewToEnable; switch (statusCode) { case PackageInstaller.STATUS_FAILURE_BLOCKED: viewToEnable = requireViewById(R.id.install_failed_blocked); viewToEnable = mDialog.requireViewById(R.id.install_failed_blocked); break; case PackageInstaller.STATUS_FAILURE_CONFLICT: viewToEnable = requireViewById(R.id.install_failed_conflict); viewToEnable = mDialog.requireViewById(R.id.install_failed_conflict); break; case PackageInstaller.STATUS_FAILURE_INCOMPATIBLE: viewToEnable = requireViewById(R.id.install_failed_incompatible); viewToEnable = mDialog.requireViewById(R.id.install_failed_incompatible); break; case PackageInstaller.STATUS_FAILURE_INVALID: viewToEnable = requireViewById(R.id.install_failed_invalid_apk); viewToEnable = mDialog.requireViewById(R.id.install_failed_invalid_apk); break; default: viewToEnable = requireViewById(R.id.install_failed); viewToEnable = mDialog.requireViewById(R.id.install_failed); break; } Loading Loading @@ -105,12 +107,18 @@ public class InstallFailed extends AlertActivity { // Store label for dialog mLabel = as.label; mAlert.setIcon(as.icon); mAlert.setTitle(as.label); mAlert.setView(R.layout.install_content_view); mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.done), (ignored, ignored2) -> finish(), null); setupAlert(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(as.icon); builder.setTitle(as.label); builder.setView(R.layout.install_content_view); builder.setPositiveButton(getString(R.string.done), (ignored, ignored2) -> finish()); builder.setOnCancelListener(dialog -> { finish(); }); mDialog = builder.create(); mDialog.show(); // Show out of space dialog if needed if (statusCode == PackageInstaller.STATUS_FAILURE_STORAGE) { Loading
packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java +17 −9 Original line number Diff line number Diff line Loading @@ -19,6 +19,8 @@ package com.android.packageinstaller; import static com.android.packageinstaller.PackageInstallerActivity.EXTRA_APP_SNIPPET; import static com.android.packageinstaller.PackageInstallerActivity.EXTRA_STAGED_SESSION_ID; import android.app.Activity; import android.app.AlertDialog; import android.app.PendingIntent; import android.content.DialogInterface; import android.content.Intent; Loading @@ -43,7 +45,7 @@ import java.io.IOException; * <p>This has two phases: First send the data to the package manager, then wait until the package * manager processed the result.</p> */ public class InstallInstalling extends AlertActivity { public class InstallInstalling extends Activity { private static final String LOG_TAG = InstallInstalling.class.getSimpleName(); private static final String SESSION_ID = "com.android.packageinstaller.SESSION_ID"; Loading @@ -67,6 +69,8 @@ public class InstallInstalling extends AlertActivity { /** The button that can cancel this dialog */ private Button mCancelButton; private AlertDialog mDialog; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading @@ -90,10 +94,12 @@ public class InstallInstalling extends AlertActivity { PackageUtil.AppSnippet as = getIntent() .getParcelableExtra(EXTRA_APP_SNIPPET, PackageUtil.AppSnippet.class); mAlert.setIcon(as.icon); mAlert.setTitle(as.label); mAlert.setView(R.layout.install_content_view); mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(as.icon); builder.setTitle(as.label); builder.setView(R.layout.install_content_view); builder.setNegativeButton(getString(R.string.cancel), (ignored, ignored2) -> { if (mInstallingTask != null) { mInstallingTask.cancel(true); Loading @@ -106,9 +112,11 @@ public class InstallInstalling extends AlertActivity { setResult(RESULT_CANCELED); finish(); }, null); setupAlert(); requireViewById(R.id.installing).setVisibility(View.VISIBLE); }); builder.setCancelable(false); mDialog = builder.create(); mDialog.show(); mDialog.requireViewById(R.id.installing).setVisibility(View.VISIBLE); if (savedInstanceState != null) { mSessionId = savedInstanceState.getInt(SESSION_ID); Loading Loading @@ -145,7 +153,7 @@ public class InstallInstalling extends AlertActivity { } } mCancelButton = mAlert.getButton(DialogInterface.BUTTON_NEGATIVE); mCancelButton = mDialog.getButton(DialogInterface.BUTTON_NEGATIVE); } } Loading
packages/PackageInstaller/src/com/android/packageinstaller/InstallStaging.java +28 −10 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ import java.io.OutputStream; * If a package gets installed from a content URI this step stages the installation session * reading bytes from the URI. */ public class InstallStaging extends AlertActivity { public class InstallStaging extends Activity { private static final String LOG_TAG = InstallStaging.class.getSimpleName(); private static final String STAGED_SESSION_ID = "STAGED_SESSION_ID"; Loading @@ -65,6 +65,8 @@ public class InstallStaging extends AlertActivity { /** The session the package is in */ private int mStagedSessionId; private AlertDialog mDialog; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Loading @@ -72,10 +74,13 @@ public class InstallStaging extends AlertActivity { mInstaller = getPackageManager().getPackageInstaller(); setFinishOnTouchOutside(true); mAlert.setIcon(R.drawable.ic_file_download); mAlert.setTitle(getString(R.string.app_name_unknown)); mAlert.setView(R.layout.install_content_view); mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setIcon(R.drawable.ic_file_download); builder.setTitle(getString(R.string.app_name_unknown)); builder.setView(R.layout.install_content_view); builder.setNegativeButton(getString(R.string.cancel), (ignored, ignored2) -> { if (mStagingTask != null) { mStagingTask.cancel(true); Loading @@ -85,9 +90,21 @@ public class InstallStaging extends AlertActivity { setResult(RESULT_CANCELED); finish(); }, null); setupAlert(); requireViewById(R.id.staging).setVisibility(View.VISIBLE); }); builder.setOnCancelListener(dialog -> { if (mStagingTask != null) { mStagingTask.cancel(true); } cleanupStagingSession(); setResult(RESULT_CANCELED); finish(); }); mDialog = builder.create(); mDialog.show(); mDialog.requireViewById(com.android.packageinstaller.R.id.staging) .setVisibility(View.VISIBLE); if (savedInstanceState != null) { mStagedSessionId = savedInstanceState.getInt(STAGED_SESSION_ID, 0); Loading Loading @@ -275,8 +292,9 @@ public class InstallStaging extends AlertActivity { @Override protected void onPreExecute() { final long sizeBytes = getContentSizeBytes(); mProgressBar = sizeBytes > 0 ? requireViewById(R.id.progress_indeterminate) : null; if (sizeBytes > 0 && mDialog != null) { mProgressBar = mDialog.requireViewById(R.id.progress_indeterminate); } if (mProgressBar != null) { mProgressBar.setProgress(0); mProgressBar.setMax(100); Loading