diff options
author | Kenny Root <kroot@google.com> | 2011-02-28 13:38:12 -0800 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2011-03-16 16:58:02 -0700 |
commit | bae45d9ae440e20d1a261e81b6acdf02130a305a (patch) | |
tree | 423fcd43df6b6992752f27429015d7142815a283 /src/com/android | |
parent | ac84e2fe02c861875382b28ba89da2f92d8a65f5 (diff) | |
download | packages_apps_packageinstaller-bae45d9ae440e20d1a261e81b6acdf02130a305a.zip packages_apps_packageinstaller-bae45d9ae440e20d1a261e81b6acdf02130a305a.tar.gz packages_apps_packageinstaller-bae45d9ae440e20d1a261e81b6acdf02130a305a.tar.bz2 |
More descriptive errors for install failures
Change-Id: Ica79bece0fd29c27126e1ee51daeac96affaa1ab
Diffstat (limited to 'src/com/android')
-rwxr-xr-x | src/com/android/packageinstaller/InstallAppProgress.java | 37 | ||||
-rwxr-xr-x | src/com/android/packageinstaller/UninstallAppProgress.java | 51 |
2 files changed, 73 insertions, 15 deletions
diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java index 45d8391..08a6d1d 100755 --- a/src/com/android/packageinstaller/InstallAppProgress.java +++ b/src/com/android/packageinstaller/InstallAppProgress.java @@ -32,6 +32,7 @@ import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources; import android.graphics.drawable.Drawable; +import android.graphics.drawable.LevelListDrawable; import android.net.Uri; import android.os.Bundle; import android.os.Handler; @@ -61,6 +62,7 @@ public class InstallAppProgress extends Activity implements View.OnClickListener private ProgressBar mProgressBar; private View mOkPanel; private TextView mStatusTextView; + private TextView mExplanationTextView; private Button mDoneButton; private Button mLaunchButton; private final int INSTALL_COMPLETE = 1; @@ -76,10 +78,12 @@ public class InstallAppProgress extends Activity implements View.OnClickListener mProgressBar.setVisibility(View.INVISIBLE); // Show the ok button int centerTextLabel; - Drawable centerTextDrawable = null; - if(msg.arg1 == PackageManager.INSTALL_SUCCEEDED) { + int centerExplanationLabel = -1; + LevelListDrawable centerTextDrawable = (LevelListDrawable) getResources() + .getDrawable(R.drawable.ic_result_status); + if (msg.arg1 == PackageManager.INSTALL_SUCCEEDED) { mLaunchButton.setVisibility(View.VISIBLE); - centerTextDrawable = getResources().getDrawable(R.drawable.button_indicator_finish); + centerTextDrawable.setLevel(0); centerTextLabel = R.string.install_done; // Enable or disable launch button mLaunchIntent = getPackageManager().getLaunchIntentForPackage( @@ -102,8 +106,8 @@ public class InstallAppProgress extends Activity implements View.OnClickListener return; } else { // Generic error handling for all other error codes. - centerTextDrawable = Resources.getSystem().getDrawable( - com.android.internal.R.drawable.ic_bullet_key_permission); + centerTextDrawable.setLevel(1); + centerExplanationLabel = getExplanationFromErrorCode(msg.arg1); centerTextLabel = R.string.install_failed; mLaunchButton.setVisibility(View.INVISIBLE); } @@ -114,6 +118,12 @@ public class InstallAppProgress extends Activity implements View.OnClickListener mStatusTextView.setCompoundDrawables(centerTextDrawable, null, null, null); } mStatusTextView.setText(centerTextLabel); + if (centerExplanationLabel != -1) { + mExplanationTextView.setText(centerExplanationLabel); + mExplanationTextView.setVisibility(View.VISIBLE); + } else { + mExplanationTextView.setVisibility(View.GONE); + } mDoneButton.setOnClickListener(InstallAppProgress.this); mOkPanel.setVisibility(View.VISIBLE); break; @@ -123,6 +133,22 @@ public class InstallAppProgress extends Activity implements View.OnClickListener } }; + private int getExplanationFromErrorCode(int errCode) { + Log.d(TAG, "Installation error code: " + errCode); + switch (errCode) { + case PackageManager.INSTALL_FAILED_INVALID_APK: + return R.string.install_failed_invalid_apk; + case PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: + return R.string.install_failed_inconsistent_certificates; + case PackageManager.INSTALL_FAILED_OLDER_SDK: + return R.string.install_failed_older_sdk; + case PackageManager.INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: + return R.string.install_failed_cpu_abi_incompatible; + default: + return -1; + } + } + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); @@ -194,6 +220,7 @@ public class InstallAppProgress extends Activity implements View.OnClickListener PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet); mStatusTextView = (TextView)findViewById(R.id.center_text); mStatusTextView.setText(R.string.installing); + mExplanationTextView = (TextView) findViewById(R.id.center_explanation); mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); mProgressBar.setIndeterminate(true); // Hide button till progress is being displayed diff --git a/src/com/android/packageinstaller/UninstallAppProgress.java b/src/com/android/packageinstaller/UninstallAppProgress.java index fd094cf..b4d7147 100755 --- a/src/com/android/packageinstaller/UninstallAppProgress.java +++ b/src/com/android/packageinstaller/UninstallAppProgress.java @@ -45,6 +45,7 @@ public class UninstallAppProgress extends Activity implements OnClickListener { private ApplicationInfo mAppInfo; private TextView mStatusTextView; private Button mOkButton; + private Button mDeviceManagerButton; private ProgressBar mProgressBar; private View mOkPanel; private volatile int mResultCode = -1; @@ -56,14 +57,30 @@ public class UninstallAppProgress extends Activity implements OnClickListener { switch (msg.what) { case UNINSTALL_COMPLETE: mResultCode = msg.arg1; + final String packageName = (String) msg.obj; + // Update the status text - if (msg.arg1 == SUCCEEDED) { - mStatusTextView.setText(R.string.uninstall_done); - } else { - mStatusTextView.setText(R.string.uninstall_failed); + final int statusText; + switch (msg.arg1) { + case PackageManager.DELETE_SUCCEEDED: + statusText = R.string.uninstall_done; + break; + case PackageManager.DELETE_FAILED_DEVICE_POLICY_MANAGER: + Log.d(TAG, "Uninstall failed because " + packageName + + " is a device admin"); + mDeviceManagerButton.setVisibility(View.VISIBLE); + statusText = R.string.uninstall_failed_device_policy_manager; + break; + default: + Log.d(TAG, "Uninstall failed for " + packageName + " with code " + + msg.arg1); + statusText = R.string.uninstall_failed; + break; } + mStatusTextView.setText(statusText); + + // Hide the progress bar; Show the ok button mProgressBar.setVisibility(View.INVISIBLE); - // Show the ok button mOkPanel.setVisibility(View.VISIBLE); break; default: @@ -71,7 +88,7 @@ public class UninstallAppProgress extends Activity implements OnClickListener { } } }; - + @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); @@ -83,7 +100,8 @@ public class UninstallAppProgress extends Activity implements OnClickListener { class PackageDeleteObserver extends IPackageDeleteObserver.Stub { public void packageDeleted(String packageName, int returnCode) { Message msg = mHandler.obtainMessage(UNINSTALL_COMPLETE); - msg.arg1 = returnCode == PackageManager.DELETE_SUCCEEDED ? SUCCEEDED : FAILED; + msg.arg1 = returnCode; + msg.obj = packageName; mHandler.sendMessage(msg); } } @@ -101,13 +119,26 @@ public class UninstallAppProgress extends Activity implements OnClickListener { // Initialize views View snippetView = findViewById(R.id.app_snippet); PackageUtil.initSnippetForInstalledApp(this, mAppInfo, snippetView); - mStatusTextView = (TextView)findViewById(R.id.center_text); + mStatusTextView = (TextView) findViewById(R.id.center_text); mStatusTextView.setText(R.string.uninstalling); + mDeviceManagerButton = (Button) findViewById(R.id.device_manager_button); + mDeviceManagerButton.setVisibility(View.GONE); + mDeviceManagerButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(); + intent.setClassName("com.android.settings", + "com.android.settings.Settings$DeviceAdminSettingsActivity"); + intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + finish(); + } + }); mProgressBar = (ProgressBar) findViewById(R.id.progress_bar); mProgressBar.setIndeterminate(true); // Hide button till progress is being displayed - mOkPanel = (View)findViewById(R.id.ok_panel); - mOkButton = (Button)findViewById(R.id.ok_button); + mOkPanel = (View) findViewById(R.id.ok_panel); + mOkButton = (Button) findViewById(R.id.ok_button); mOkButton.setOnClickListener(this); mOkPanel.setVisibility(View.INVISIBLE); PackageDeleteObserver observer = new PackageDeleteObserver(); |