summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSuchi Amalapurapu <asuchitra@google.com>2009-09-01 14:35:25 -0700
committerSuchi Amalapurapu <asuchitra@google.com>2009-09-08 14:53:10 -0700
commitd9b773b7041894e37c1b6f62d6b221dd3c8e4c43 (patch)
treec82c8491f9f1435c0125a1958b474608acabeef2 /src
parent0d2388f6983b79a8e46e1d2aee2f1ccefbe900ab (diff)
downloadandroid_packages_apps_PackageInstaller-d9b773b7041894e37c1b6f62d6b221dd3c8e4c43.tar.gz
android_packages_apps_PackageInstaller-d9b773b7041894e37c1b6f62d6b221dd3c8e4c43.tar.bz2
android_packages_apps_PackageInstaller-d9b773b7041894e37c1b6f62d6b221dd3c8e4c43.zip
Fix screen flow issues in pacakge installer/uninstaller.
The main activity was managing the state transitions during installation/uninstallation which was actually not needed. Just make the activities independent and start sub activities without waiting for activity result codes in the main activity. If the user enables development setting to immediately destroy activities, and sideloads an app, the ActivityManager tries to destroy the main activity while it starts sub activities to finish installation and this results in UI bizarreness based on the current state of the installer. Also move InstallConfirmation to the main activity. Converge InstallDone and InstallProgress into one screen. Just enable or disable launch/close buttons. This is how it should have been in the first place.. Same set of issues with uninstall code path as well.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppConfirmation.java126
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppDone.java109
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppProgress.java82
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java150
-rwxr-xr-xsrc/com/android/packageinstaller/UninstallerActivity.java25
5 files changed, 130 insertions, 362 deletions
diff --git a/src/com/android/packageinstaller/InstallAppConfirmation.java b/src/com/android/packageinstaller/InstallAppConfirmation.java
deleted file mode 100755
index 5a65e568..00000000
--- a/src/com/android/packageinstaller/InstallAppConfirmation.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-**
-** Copyright 2007, 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.
-*/
-package com.android.packageinstaller;
-
-import com.android.packageinstaller.R;
-import java.util.ArrayList;
-import android.widget.AppSecurityPermissions;
-import android.app.Activity;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageParser;
-import android.content.pm.PermissionInfo;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-/**
- * This activity corresponds to a confirmation screen that is displayed when the user tries
- * to install an application bundled as an apk file.
- * The intent that launches this activity should include the application information object
- * of the application(to be installed) and a list of permission strings associated
- * with the application. This information is displayed on the screen and installation is either
- * continued or canceled based on the user response(click ok or cancel).
- */
-public class InstallAppConfirmation extends Activity implements View.OnClickListener {
- private final String TAG="InstallAppConfirmation";
- private boolean localLOGV = false;
- private Button mOk;
- private Button mCancel;
- private ApplicationInfo mAppInfo;
- private Uri mPkgURI;
- private View mContentView;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- Intent intent = getIntent();
- if(localLOGV) Log.i(TAG, "intent="+intent);
- mAppInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
- mPkgURI = intent.getData();
- if(localLOGV) Log.i(TAG, "mAppInfo = "+mAppInfo);
- initView();
- }
-
- public void initView() {
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- String unknown = getString(R.string.unknown);
- //set description
- String desc = getString(R.string.security_settings_desc);
- if(desc == null) {
- desc = unknown;
- }
- LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- mContentView = inflater.inflate(R.layout.install_confirm, null);
- setContentView(mContentView);
- //initialize views
- PackageUtil.initSnippetForNewApp(this, mAppInfo, R.id.app_snippet, mPkgURI);
- if(desc != null) {
- ((TextView)findViewById(R.id.security_settings_desc)).setText(desc);
- }
-
-
- LinearLayout permsView = (LinearLayout) mContentView.findViewById(
- R.id.permissions_section);
- boolean permVisible = false;
- PackageParser.Package pkg = PackageUtil.getPackageInfo(mPkgURI);
- if(pkg != null) {
- AppSecurityPermissions asp = new AppSecurityPermissions(this, pkg);
- if(asp.getPermissionCount() > 0) {
- permVisible = true;
- permsView.setVisibility(View.VISIBLE);
- LinearLayout securityList = (LinearLayout) permsView.findViewById(
- R.id.security_settings_list);
- securityList.addView(asp.getPermissionsView());
- }
- }
- if(!permVisible){
- permsView.setVisibility(View.GONE);
- }
- mOk = (Button)findViewById(R.id.ok_button);
- mCancel = (Button)findViewById(R.id.cancel_button);
- mOk.setOnClickListener(this);
- mCancel.setOnClickListener(this);
- }
-
- public void setResultAndReturn(int result) {
- if(result == RESULT_CANCELED) Log.i(TAG, "Result has been canceled");
- if(result == RESULT_OK) Log.i(TAG, "result ok");
- setResult(result);
- finish();
- }
-
- public void onClick(View v) {
- int result = RESULT_CANCELED;
- if(v == mOk) {
- result = RESULT_OK;
- setResultAndReturn(result);
- } else if(v == mCancel) {
- result = RESULT_CANCELED;
- setResultAndReturn(result);
- }
- }
-}
diff --git a/src/com/android/packageinstaller/InstallAppDone.java b/src/com/android/packageinstaller/InstallAppDone.java
deleted file mode 100755
index 36bd7e0f..00000000
--- a/src/com/android/packageinstaller/InstallAppDone.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-**
-** Copyright 2007, 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.
-*/
-package com.android.packageinstaller;
-
-import com.android.packageinstaller.R;
-import android.app.Activity;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.view.Window;
-import android.widget.Button;
-import android.widget.TextView;
-
-/**
- * This activity corresponds to a install status screen that is displayed
- * when the user tries
- * to install an application bundled as an apk file. The screen
- * has two buttons to either launch the newly installed application
- * or close the screen. The installation result and the package uri are passed through the
- * intent that launches the activity.
- */
-public class InstallAppDone extends Activity implements View.OnClickListener {
- private final String TAG="InstallAppDone";
- private boolean localLOGV = false;
- private ApplicationInfo mAppInfo;
- private Uri mPkgURI;
- private Button mDoneButton;
- private Button mLaunchButton;
- private boolean installFlag;
- private Intent mLaunchIntent;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- Intent intent = getIntent();
- mAppInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO);
- mPkgURI = intent.getData();
- installFlag = intent.getBooleanExtra(PackageUtil.INTENT_ATTR_INSTALL_STATUS, true);
- if(localLOGV) Log.i(TAG, "installFlag="+installFlag);
- initView();
- }
-
- public void initView() {
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- String unknown = getString(R.string.unknown);
- setContentView(R.layout.install_done);
- // Initialize views
- PackageUtil.initSnippetForInstalledApp(this, mAppInfo, R.id.app_snippet);
- TextView centerText = (TextView)findViewById(R.id.center_text);
- mDoneButton = (Button)findViewById(R.id.done_button);
- mLaunchButton = (Button)findViewById(R.id.launch_button);
- int centerTextDrawableId;
- int centerTextLabel;
- if(installFlag) {
- mLaunchButton.setVisibility(View.VISIBLE);
- centerTextDrawableId = R.drawable.button_indicator_finish;
- centerTextLabel = R.string.install_done;
- // Enable or disable launch button
- mLaunchIntent = getPackageManager().getLaunchIntentForPackage(
- mAppInfo.packageName);
- if(mLaunchIntent != null) {
- mLaunchButton.setOnClickListener(this);
- } else {
- mLaunchButton.setEnabled(false);
- }
- } else {
- centerTextDrawableId = com.android.internal.R.drawable.ic_bullet_key_permission;
- centerTextLabel = R.string.install_failed;
- mLaunchButton.setVisibility(View.INVISIBLE);
- }
- Drawable centerTextDrawable = getResources().getDrawable(centerTextDrawableId);
- centerTextDrawable.setBounds(0, 0,
- centerTextDrawable.getIntrinsicWidth(),
- centerTextDrawable.getIntrinsicHeight());
- centerText.setCompoundDrawables(centerTextDrawable, null, null, null);
- centerText.setText(getString(centerTextLabel));
- mDoneButton.setOnClickListener(this);
- }
-
- public void onClick(View v) {
- if(v == mDoneButton) {
- Log.i(TAG, "Finished installing "+mAppInfo);
- finish();
- } else if(v == mLaunchButton) {
- startActivity(mLaunchIntent);
- finish();
- }
- }
-}
diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java
index 28abd3cc..c5a3c5b5 100755
--- a/src/com/android/packageinstaller/InstallAppProgress.java
+++ b/src/com/android/packageinstaller/InstallAppProgress.java
@@ -17,6 +17,7 @@
package com.android.packageinstaller;
import com.android.packageinstaller.R;
+
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
@@ -24,12 +25,16 @@ import android.content.pm.IPackageInstallObserver;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
+import android.view.View;
import android.view.Window;
+import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -41,19 +46,56 @@ import android.widget.TextView;
* codes defined in PackageManager. If the package being installed already exists,
* the existing package is replaced with the new one.
*/
-public class InstallAppProgress extends Activity {
+public class InstallAppProgress extends Activity implements View.OnClickListener {
private final String TAG="InstallAppProgress";
private boolean localLOGV = false;
private ApplicationInfo mAppInfo;
private Uri mPackageURI;
private ProgressBar mProgressBar;
+ private View mOkPanel;
+ private TextView mStatusTextView;
+ private Button mDoneButton;
+ private Button mLaunchButton;
+ final static int SUCCEEDED = 1;
+ final static int FAILED = 0;
private final int INSTALL_COMPLETE = 1;
+ private Intent mLaunchIntent;
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case INSTALL_COMPLETE:
- //finish the activity posting result
- setResultAndFinish(msg.arg1);
+ // Update the status text
+ mProgressBar.setVisibility(View.INVISIBLE);
+ // Show the ok button
+ int centerTextLabel;
+ Drawable centerTextDrawable = null;
+ if(msg.arg1 == SUCCEEDED) {
+ mLaunchButton.setVisibility(View.VISIBLE);
+ centerTextDrawable = getResources().getDrawable(R.drawable.button_indicator_finish);
+ centerTextLabel = R.string.install_done;
+ // Enable or disable launch button
+ mLaunchIntent = getPackageManager().getLaunchIntentForPackage(
+ mAppInfo.packageName);
+ if(mLaunchIntent != null) {
+ mLaunchButton.setOnClickListener(InstallAppProgress.this);
+ } else {
+ mLaunchButton.setEnabled(false);
+ }
+ } else {
+ centerTextDrawable = Resources.getSystem().getDrawable(
+ com.android.internal.R.drawable.ic_bullet_key_permission);
+ centerTextLabel = R.string.install_failed;
+ mLaunchButton.setVisibility(View.INVISIBLE);
+ }
+ if (centerTextDrawable != null) {
+ centerTextDrawable.setBounds(0, 0,
+ centerTextDrawable.getIntrinsicWidth(),
+ centerTextDrawable.getIntrinsicHeight());
+ mStatusTextView.setCompoundDrawables(centerTextDrawable, null, null, null);
+ }
+ mStatusTextView.setText(centerTextLabel);
+ mDoneButton.setOnClickListener(InstallAppProgress.this);
+ mOkPanel.setVisibility(View.VISIBLE);
break;
default:
break;
@@ -77,23 +119,21 @@ public class InstallAppProgress extends Activity {
mHandler.sendMessage(msg);
}
}
-
- void setResultAndFinish(int retCode) {
- Intent data = new Intent();
- setResult(retCode);
- finish();
- }
-
+
public void initView() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
- String unknown = getString(R.string.unknown);
setContentView(R.layout.op_progress);
- //initialize views
- PackageUtil.initSnippetForNewApp(this, mAppInfo, R.id.app_snippet, mPackageURI);
- TextView installTextView = (TextView)findViewById(R.id.center_text);
- installTextView.setText(R.string.installing);
+ // Initialize views
+ PackageUtil.initSnippetForInstalledApp(this, mAppInfo, R.id.app_snippet);
+ mStatusTextView = (TextView)findViewById(R.id.center_text);
+ mStatusTextView.setText(R.string.installing);
mProgressBar = (ProgressBar) findViewById(R.id.progress_bar);
mProgressBar.setIndeterminate(true);
+ // Hide button till progress is being displayed
+ mOkPanel = (View)findViewById(R.id.buttons_panel);
+ mDoneButton = (Button)findViewById(R.id.done_button);
+ mLaunchButton = (Button)findViewById(R.id.launch_button);
+ mOkPanel.setVisibility(View.INVISIBLE);
// Set flag to replace package if already existing
int installFlags = 0;
PackageManager pm = getPackageManager();
@@ -106,7 +146,7 @@ public class InstallAppProgress extends Activity {
} catch (NameNotFoundException e) {
}
if((installFlags & PackageManager.INSTALL_REPLACE_EXISTING )!= 0) {
- Log.w(TAG, "Replacing package:"+mAppInfo.packageName);
+ Log.w(TAG, "Replacing package:" + mAppInfo.packageName);
}
String installerPackageName = getIntent().getStringExtra(
Intent.EXTRA_INSTALLER_PACKAGE_NAME);
@@ -114,4 +154,14 @@ public class InstallAppProgress extends Activity {
PackageInstallObserver observer = new PackageInstallObserver();
pm.installPackage(mPackageURI, observer, installFlags, installerPackageName);
}
+
+ public void onClick(View v) {
+ if(v == mDoneButton) {
+ Log.i(TAG, "Finished installing "+mAppInfo);
+ finish();
+ } else if(v == mLaunchButton) {
+ startActivity(mLaunchIntent);
+ finish();
+ }
+ }
}
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index 9b487d13..d63c98ee 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -44,7 +44,13 @@ import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
import android.util.Log;
+import android.view.View;
import android.view.Window;
+import android.view.View.OnClickListener;
+import android.widget.AppSecurityPermissions;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.TextView;
/*
* This activity is launched when a new application is installed via side loading
@@ -56,28 +62,30 @@ import android.view.Window;
* Based on the user response the package is then installed by launching InstallAppConfirm
* sub activity. All state transitions are handled in this activity
*/
-public class PackageInstallerActivity extends Activity implements OnCancelListener {
- private static final int INSTALL_INITIAL = 0;
- private static final int INSTALL_CONFIRM = 1;
- private static final int INSTALL_PROGRESS = 2;
- private static final int INSTALL_DONE = 3;
+public class PackageInstallerActivity extends Activity implements OnCancelListener, OnClickListener {
private static final String TAG = "PackageInstaller";
private Uri mPackageURI;
private boolean localLOGV = false;
- private int mCurrentState = INSTALL_INITIAL;
PackageManager mPm;
+ private boolean mReplacing = false;
private PackageParser.Package mPkgInfo;
private File mTmpFile;
private static final int SUCCEEDED = 1;
private static final int FAILED = 0;
// Broadcast receiver for clearing cache
- ClearCacheReceiver mClearCacheReceiver;
+ ClearCacheReceiver mClearCacheReceiver = null;
private static final int HANDLER_BASE_MSG_IDX = 0;
private static final int FREE_SPACE = HANDLER_BASE_MSG_IDX + 1;
// ApplicationInfo object primarily used for already existing applications
private ApplicationInfo mAppInfo = null;
+ // View for install progress
+ View mInstallConfirm;
+ // Buttons to indicate user acceptance
+ private Button mOk;
+ private Button mCancel;
+
// Dialog identifiers used in showDialog
private static final int DLG_BASE = 0;
private static final int DLG_REPLACE_APP = DLG_BASE + 1;
@@ -90,7 +98,9 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
public void handleMessage(Message msg) {
switch (msg.what) {
case FREE_SPACE:
- unregisterReceiver(mClearCacheReceiver);
+ if (mClearCacheReceiver != null) {
+ unregisterReceiver(mClearCacheReceiver);
+ }
if(msg.arg1 == SUCCEEDED) {
makeTempCopyAndInstall();
} else {
@@ -102,47 +112,29 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
}
}
};
-
- private void startInstallActivityClass(int requestCode, Class<?> cls) {
- Intent newIntent = new Intent();
- startInstallActivityClass(newIntent, requestCode, cls);
- }
-
- private void startInstallActivityClass(Intent newIntent, int requestCode, Class<?> cls) {
- newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO,
- mPkgInfo.applicationInfo);
- newIntent.setData(mPackageURI);
- newIntent.setClass(this, cls);
- String installerPackageName = getIntent().getStringExtra(
- Intent.EXTRA_INSTALLER_PACKAGE_NAME);
- if (installerPackageName != null) {
- newIntent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, installerPackageName);
+ private void startInstallConfirm() {
+ LinearLayout permsSection = (LinearLayout) mInstallConfirm.findViewById(R.id.permissions_section);
+ LinearLayout securityList = (LinearLayout) permsSection.findViewById(
+ R.id.security_settings_list);
+ boolean permVisible = false;
+ if(mPkgInfo != null) {
+ AppSecurityPermissions asp = new AppSecurityPermissions(this, mPkgInfo);
+ if(asp.getPermissionCount() > 0) {
+ permVisible = true;
+ securityList.addView(asp.getPermissionsView());
+ }
}
-
- if(localLOGV) Log.i(TAG, "downloaded app uri="+mPackageURI);
- startActivityForResult(newIntent, requestCode);
+ if(!permVisible){
+ securityList.setVisibility(View.INVISIBLE);
+ }
+ mInstallConfirm.setVisibility(View.VISIBLE);
+ mOk = (Button)findViewById(R.id.ok_button);
+ mCancel = (Button)findViewById(R.id.cancel_button);
+ mOk.setOnClickListener(this);
+ mCancel.setOnClickListener(this);
}
- private void startInstallConfirm() {
- Intent newIntent = new Intent();
- newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO,
- mPkgInfo.applicationInfo);
- newIntent.setData(mPackageURI);
- newIntent.setClass(this, InstallAppConfirmation.class);
- startActivityForResult(newIntent, INSTALL_CONFIRM);
- }
-
- private void startInstallProgress() {
- startInstallActivityClass(INSTALL_PROGRESS, InstallAppProgress.class);
- }
-
- private void startInstallDone() {
- Intent newIntent = new Intent(Intent.ACTION_VIEW);
- newIntent.putExtra(PackageUtil.INTENT_ATTR_INSTALL_STATUS, true);
- startInstallActivityClass(newIntent, INSTALL_DONE, InstallAppDone.class);
- }
-
private void showDialogInner(int id) {
// TODO better fix for this? Remove dialog so that it gets created again
removeDialog(id);
@@ -163,6 +155,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
startInstallConfirm();
+ mReplacing = true;
}})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -335,7 +328,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
}
@Override
- public void onCreate(Bundle icicle) {
+ protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
//get intent information
final Intent intent = getIntent();
@@ -353,6 +346,8 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
//set view
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.install_start);
+ mInstallConfirm = findViewById(R.id.install_confirm_panel);
+ mInstallConfirm.setVisibility(View.INVISIBLE);
PackageUtil.initSnippetForNewApp(this, mPkgInfo.applicationInfo,
R.id.app_snippet, mPackageURI);
//check setting
@@ -378,51 +373,30 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
deleteFile(mTmpFile.getName());
}
}
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- boolean finish = true;
- boolean removeTmpFile = false;
- switch(requestCode) {
- case INSTALL_CONFIRM:
- if (resultCode == RESULT_OK) {
- finish = false;
- mCurrentState = INSTALL_PROGRESS;
- startInstallProgress();
- } else {
- removeTmpFile = true;
- }
- break;
- case INSTALL_PROGRESS:
- finish = false;
- mCurrentState = INSTALL_DONE;
- if (resultCode == PackageManager.INSTALL_SUCCEEDED) {
- //start the next screen to show final status of installation
- startInstallDone();
- } else {
- showDialogInner(DLG_INSTALL_ERROR);
- }
- // Now that the package is installed just delete the temp file
- removeTmpFile = true;
- break;
- case INSTALL_DONE:
- //neednt check for result code here
- break;
- default:
- break;
- }
- if ((removeTmpFile) && (mTmpFile != null)) {
- deleteFile(mTmpFile.getName());
- }
- if (finish) {
- //finish off this activity to return to the previous activity that launched it
- if (localLOGV) Log.i(TAG, "Finishing off activity");
- finish();
- }
- }
// Generic handling when pressing back key
public void onCancel(DialogInterface dialog) {
finish();
}
+
+ public void onClick(View v) {
+ if(v == mOk) {
+ // Start subactivity to actually install the application
+ Intent newIntent = new Intent();
+ newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO,
+ mPkgInfo.applicationInfo);
+ newIntent.setData(mPackageURI);
+ newIntent.setClass(this, InstallAppProgress.class);
+ String installerPackageName = getIntent().getStringExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME);
+ if (installerPackageName != null) {
+ newIntent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, installerPackageName);
+ }
+ if(localLOGV) Log.i(TAG, "downloaded app uri="+mPackageURI);
+ startActivity(newIntent);
+ finish();
+ } else if(v == mCancel) {
+ // Cancel and finish
+ finish();
+ }
+ }
}
diff --git a/src/com/android/packageinstaller/UninstallerActivity.java b/src/com/android/packageinstaller/UninstallerActivity.java
index c6b6eb8f..065da8b5 100755
--- a/src/com/android/packageinstaller/UninstallerActivity.java
+++ b/src/com/android/packageinstaller/UninstallerActivity.java
@@ -43,8 +43,6 @@ public class UninstallerActivity extends Activity implements OnClickListener,
DialogInterface.OnCancelListener {
private static final String TAG = "UninstallerActivity";
private boolean localLOGV = false;
- // Request code
- private static final int UNINSTALL_PROGRESS = 1;
PackageManager mPm;
private ApplicationInfo mAppInfo;
private Button mOk;
@@ -54,11 +52,7 @@ public class UninstallerActivity extends Activity implements OnClickListener,
private static final int DLG_BASE = 0;
private static final int DLG_APP_NOT_FOUND = DLG_BASE + 1;
private static final int DLG_UNINSTALL_FAILED = DLG_BASE + 2;
-
- private void showDialogInner(int id) {
- showDialog(id);
- }
-
+
@Override
public Dialog onCreateDialog(int id) {
switch (id) {
@@ -98,7 +92,7 @@ public class UninstallerActivity extends Activity implements OnClickListener,
newIntent.putExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO,
mAppInfo);
newIntent.setClass(this, UninstallAppProgress.class);
- startActivityForResult(newIntent, UNINSTALL_PROGRESS);
+ startActivity(newIntent);
}
@Override
@@ -146,21 +140,6 @@ public class UninstallerActivity extends Activity implements OnClickListener,
}
}
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode != UNINSTALL_PROGRESS) {
- return;
- }
- // Start the next screen to show final status of installation
- if (resultCode != UninstallAppProgress.SUCCEEDED) {
- showDialogInner(DLG_UNINSTALL_FAILED);
- } else {
- // Finish off this activity
- if (localLOGV) Log.i(TAG, "Finishing off activity");
- finish();
- }
- }
-
public void onClick(View v) {
if(v == mOk) {
//initiate next screen