diff options
author | Suchi Amalapurapu <asuchitra@google.com> | 2009-09-08 14:56:22 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-09-08 14:56:22 -0700 |
commit | 99f149851cd024f19ea6477d74c898cef7163e5e (patch) | |
tree | c82c8491f9f1435c0125a1958b474608acabeef2 | |
parent | a0cb9eac540c2252fd1bfc69e44481ce61872886 (diff) | |
parent | d9b773b7041894e37c1b6f62d6b221dd3c8e4c43 (diff) | |
download | android_packages_apps_PackageInstaller-99f149851cd024f19ea6477d74c898cef7163e5e.tar.gz android_packages_apps_PackageInstaller-99f149851cd024f19ea6477d74c898cef7163e5e.tar.bz2 android_packages_apps_PackageInstaller-99f149851cd024f19ea6477d74c898cef7163e5e.zip |
am d9b773b7: 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 f
Merge commit 'd9b773b7041894e37c1b6f62d6b221dd3c8e4c43' into eclair-plus-aosp
* commit 'd9b773b7041894e37c1b6f62d6b221dd3c8e4c43':
Fix screen flow issues in pacakge installer/uninstaller.
-rwxr-xr-x | res/layout/install_confirm.xml | 6 | ||||
-rwxr-xr-x | res/layout/install_done.xml | 71 | ||||
-rwxr-xr-x | res/layout/install_start.xml | 8 | ||||
-rwxr-xr-x | res/layout/op_progress.xml | 86 | ||||
-rwxr-xr-x | src/com/android/packageinstaller/InstallAppConfirmation.java | 126 | ||||
-rwxr-xr-x | src/com/android/packageinstaller/InstallAppDone.java | 109 | ||||
-rwxr-xr-x | src/com/android/packageinstaller/InstallAppProgress.java | 82 | ||||
-rw-r--r-- | src/com/android/packageinstaller/PackageInstallerActivity.java | 150 | ||||
-rwxr-xr-x | src/com/android/packageinstaller/UninstallerActivity.java | 25 |
9 files changed, 199 insertions, 464 deletions
diff --git a/res/layout/install_confirm.xml b/res/layout/install_confirm.xml index bfda97dc..524a468f 100755 --- a/res/layout/install_confirm.xml +++ b/res/layout/install_confirm.xml @@ -25,11 +25,8 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" - android:layout_height="fill_parent"> + android:layout_height="wrap_content"> - <include - layout="@layout/app_details" - android:id="@+id/app_snippet"/> <TextView android:id="@+id/install_confirm_question" android:layout_width="wrap_content" @@ -55,6 +52,7 @@ android:orientation="vertical"> <TextView android:id="@+id/security_settings_desc" + android:text="@string/security_settings_desc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" diff --git a/res/layout/install_done.xml b/res/layout/install_done.xml deleted file mode 100755 index e33f57b7..00000000 --- a/res/layout/install_done.xml +++ /dev/null @@ -1,71 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2008 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. ---> - -<RelativeLayout - xmlns:android="http://schemas.android.com/apk/res/android" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> - - <include - layout="@layout/app_details" - android:gravity="top" - android:id="@+id/app_snippet" /> - <TextView - android:id="@+id/center_text" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:paddingLeft="20dip" - android:paddingTop="36dip" - android:drawablePadding="6dip" - android:layout_below="@id/app_snippet" - android:textColor="?android:attr/textColorSecondary" - android:textAppearance="?android:attr/textAppearanceMedium"/> - - <!-- Launch and close buttons. --> - <LinearLayout - android:background="@color/title_background" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:layout_alignParentBottom="true" - android:orientation="horizontal"> - <Button - android:id="@+id/launch_button" - android:text="@string/launch" - android:layout_width="150dip" - android:paddingLeft="6dip" - android:layout_gravity="left" - android:layout_weight="0.4" - android:layout_height="wrap_content"/> - <!-- Spacer --> - <View - android:id="@+id/buttons_spacer_left" - android:layout_width="0dip" - android:layout_height="wrap_content" - android:visibility="gone" - android:layout_weight="0.2" /> - <Button - android:id="@+id/done_button" - android:layout_width="150dip" - android:paddingRight="6dip" - android:layout_gravity="right" - android:text="@string/done" - android:layout_weight="0.4" - android:layout_height="wrap_content"/> - </LinearLayout> - -</RelativeLayout> - - diff --git a/res/layout/install_start.xml b/res/layout/install_start.xml index 1ef0ab5d..d95daa64 100755 --- a/res/layout/install_start.xml +++ b/res/layout/install_start.xml @@ -14,14 +14,18 @@ limitations under the License. --> -<RelativeLayout +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <include layout="@layout/app_details" android:id="@+id/app_snippet"/> -</RelativeLayout> + <include + layout="@layout/install_confirm" + android:id="@+id/install_confirm_panel"/> +</LinearLayout> diff --git a/res/layout/op_progress.xml b/res/layout/op_progress.xml index b957fdf7..aaab8686 100755 --- a/res/layout/op_progress.xml +++ b/res/layout/op_progress.xml @@ -14,33 +14,69 @@ limitations under the License. --> -<LinearLayout +<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" android:layout_width="fill_parent" - android:layout_height="wrap_content"> - - <include - layout="@layout/app_details" - android:id="@+id/app_snippet"/> - <ProgressBar - android:id="@+id/progress_bar" - style="?android:attr/progressBarStyleHorizontal" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:paddingTop="24dip" - android:paddingLeft="24dip" - android:paddingRight="24dip" - android:max="100" /> - <TextView - android:id="@+id/center_text" + android:layout_height="fill_parent" + android:fillViewport="true"> + <RelativeLayout android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:paddingLeft="24dip" - android:paddingTop="16dip" - android:text="@string/installing" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="?android:attr/textColorSecondary"/> -</LinearLayout> + android:layout_height="fill_parent"> + <include + layout="@layout/app_details" + android:id="@+id/app_snippet"/> + <TextView + android:id="@+id/center_text" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:text="@string/installing" + android:paddingLeft="16dip" + android:textAppearance="?android:attr/textAppearanceMedium"/> + <ProgressBar + android:id="@+id/progress_bar" + style="?android:attr/progressBarStyleHorizontal" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:paddingTop="24dip" + android:paddingLeft="16dip" + android:paddingRight="16dip" + android:layout_below="@id/center_text" + android:max="100" /> + <!-- Launch and close buttons. --> + <LinearLayout + android:id="@+id/buttons_panel" + android:background="@color/title_background" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:orientation="horizontal"> + <Button + android:id="@+id/launch_button" + android:text="@string/launch" + android:layout_width="150dip" + android:paddingLeft="6dip" + android:layout_gravity="left" + android:layout_weight="0.4" + android:layout_height="wrap_content"/> + <!-- Spacer --> + <View + android:id="@+id/buttons_spacer_left" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:visibility="gone" + android:layout_weight="0.2" /> + <Button + android:id="@+id/done_button" + android:layout_width="150dip" + android:paddingRight="6dip" + android:layout_gravity="right" + android:text="@string/done" + android:layout_weight="0.4" + android:layout_height="wrap_content"/> + </LinearLayout> + </RelativeLayout> +</ScrollView> 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 |