summaryrefslogtreecommitdiff
path: root/packages/PackageInstaller/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/PackageInstaller/src')
-rwxr-xr-xpackages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java52
-rw-r--r--packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java99
-rw-r--r--packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java5
3 files changed, 63 insertions, 93 deletions
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java b/packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java
index 935cb372029d..1d0ae9912d97 100755
--- a/packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/InstallInstalling.java
@@ -35,7 +35,6 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
-import android.widget.ProgressBar;
import com.android.internal.app.AlertActivity;
import com.android.internal.content.PackageHelper;
@@ -61,9 +60,6 @@ public class InstallInstalling extends AlertActivity {
private static final String BROADCAST_ACTION =
"com.android.packageinstaller.ACTION_INSTALL_COMMIT";
- /** Listens to changed to the session and updates progress bar */
- private PackageInstaller.SessionCallback mSessionCallback;
-
/** Task that sends the package to the package installer */
private InstallingAsyncTask mInstallingTask;
@@ -185,8 +181,6 @@ public class InstallInstalling extends AlertActivity {
}
mCancelButton = mAlert.getButton(DialogInterface.BUTTON_NEGATIVE);
-
- mSessionCallback = new InstallSessionCallback();
}
}
@@ -222,13 +216,6 @@ public class InstallInstalling extends AlertActivity {
}
@Override
- protected void onStart() {
- super.onStart();
-
- getPackageManager().getPackageInstaller().registerSessionCallback(mSessionCallback);
- }
-
- @Override
protected void onResume() {
super.onResume();
@@ -264,13 +251,6 @@ public class InstallInstalling extends AlertActivity {
}
@Override
- protected void onStop() {
- super.onStop();
-
- getPackageManager().getPackageInstaller().unregisterSessionCallback(mSessionCallback);
- }
-
- @Override
protected void onDestroy() {
if (mInstallingTask != null) {
mInstallingTask.cancel(true);
@@ -306,38 +286,6 @@ public class InstallInstalling extends AlertActivity {
}
}
-
- private class InstallSessionCallback extends PackageInstaller.SessionCallback {
- @Override
- public void onCreated(int sessionId) {
- // empty
- }
-
- @Override
- public void onBadgingChanged(int sessionId) {
- // empty
- }
-
- @Override
- public void onActiveChanged(int sessionId, boolean active) {
- // empty
- }
-
- @Override
- public void onProgressChanged(int sessionId, float progress) {
- if (sessionId == mSessionId) {
- ProgressBar progressBar = requireViewById(R.id.progress);
- progressBar.setMax(Integer.MAX_VALUE);
- progressBar.setProgress((int) (Integer.MAX_VALUE * progress));
- }
- }
-
- @Override
- public void onFinished(int sessionId, boolean success) {
- // empty, finish is handled by InstallResultReceiver
- }
- }
-
/**
* Send the package to the package installer and then register a event result observer that
* will call {@link #launchFinishBasedOnResult(int, int, String)}
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java b/packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java
index 705d3f4bdf87..38c06dd48b85 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/InstallSuccess.java
@@ -41,6 +41,15 @@ import java.util.List;
public class InstallSuccess extends AlertActivity {
private static final String LOG_TAG = InstallSuccess.class.getSimpleName();
+ @Nullable
+ private PackageUtil.AppSnippet mAppSnippet;
+
+ @Nullable
+ private String mAppPackageName;
+
+ @Nullable
+ private Intent mLaunchIntent;
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -55,59 +64,73 @@ public class InstallSuccess extends AlertActivity {
Intent intent = getIntent();
ApplicationInfo appInfo =
intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
+ mAppPackageName = appInfo.packageName;
Uri packageURI = intent.getData();
// Set header icon and title
- PackageUtil.AppSnippet as;
PackageManager pm = getPackageManager();
if ("package".equals(packageURI.getScheme())) {
- as = new PackageUtil.AppSnippet(pm.getApplicationLabel(appInfo),
+ mAppSnippet = new PackageUtil.AppSnippet(pm.getApplicationLabel(appInfo),
pm.getApplicationIcon(appInfo));
} else {
File sourceFile = new File(packageURI.getPath());
- as = PackageUtil.getAppSnippet(this, appInfo, sourceFile);
+ mAppSnippet = PackageUtil.getAppSnippet(this, appInfo, sourceFile);
}
- mAlert.setIcon(as.icon);
- mAlert.setTitle(as.label);
- mAlert.setView(R.layout.install_content_view);
- mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.launch), null,
- null);
- mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.done),
- (ignored, ignored2) -> {
- if (appInfo.packageName != null) {
- Log.i(LOG_TAG, "Finished installing " + appInfo.packageName);
- }
- finish();
- }, null);
- setupAlert();
- requireViewById(R.id.install_success).setVisibility(View.VISIBLE);
- // Enable or disable "launch" button
- Intent launchIntent = getPackageManager().getLaunchIntentForPackage(
- appInfo.packageName);
- boolean enabled = false;
- if (launchIntent != null) {
- List<ResolveInfo> list = getPackageManager().queryIntentActivities(launchIntent,
- 0);
- if (list != null && list.size() > 0) {
- enabled = true;
- }
- }
+ mLaunchIntent = getPackageManager().getLaunchIntentForPackage(mAppPackageName);
+
+ bindUi();
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ bindUi();
+ }
- Button launchButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
- if (enabled) {
- launchButton.setOnClickListener(view -> {
- try {
- startActivity(launchIntent);
- } catch (ActivityNotFoundException | SecurityException e) {
- Log.e(LOG_TAG, "Could not start activity", e);
+ private void bindUi() {
+ if (mAppSnippet == null) {
+ return;
+ }
+
+ mAlert.setIcon(mAppSnippet.icon);
+ mAlert.setTitle(mAppSnippet.label);
+ mAlert.setView(R.layout.install_content_view);
+ mAlert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.launch), null,
+ null);
+ mAlert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.done),
+ (ignored, ignored2) -> {
+ if (mAppPackageName != null) {
+ Log.i(LOG_TAG, "Finished installing " + mAppPackageName);
}
finish();
- });
- } else {
- launchButton.setEnabled(false);
+ }, null);
+ setupAlert();
+ requireViewById(R.id.install_success).setVisibility(View.VISIBLE);
+ // Enable or disable "launch" button
+ boolean enabled = false;
+ if (mLaunchIntent != null) {
+ List<ResolveInfo> list = getPackageManager().queryIntentActivities(mLaunchIntent,
+ 0);
+ if (list != null && list.size() > 0) {
+ enabled = true;
}
}
+
+ Button launchButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE);
+ if (enabled) {
+ launchButton.setOnClickListener(view -> {
+ try {
+ startActivity(mLaunchIntent);
+ } catch (ActivityNotFoundException | SecurityException e) {
+ Log.e(LOG_TAG, "Could not start activity", e);
+ }
+ finish();
+ });
+ } else {
+ launchButton.setEnabled(false);
+ }
}
}
diff --git a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
index b0c316908a10..4578597a5a9d 100644
--- a/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/packages/PackageInstaller/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -123,9 +123,8 @@ public class PackageInstallerActivity extends AlertActivity {
View viewToEnable;
if (mAppInfo != null) {
- viewToEnable = (mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
- ? requireViewById(R.id.install_confirm_question_update_system)
- : requireViewById(R.id.install_confirm_question_update);
+ viewToEnable = requireViewById(R.id.install_confirm_question_update);
+ mOk.setText(R.string.update);
} else {
// This is a new application with no permissions.
viewToEnable = requireViewById(R.id.install_confirm_question);