summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2010-01-12 15:19:16 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2010-01-12 15:19:16 -0800
commit6402fbaf2417995808088e134f8f2b313c77535b (patch)
tree690a7e6da39d3d6a25fe5897ba1375a359a8c598
parentfbd1a24320290e9b4106e6f758a0fe98d6974a97 (diff)
downloadandroid_packages_apps_PackageInstaller-6402fbaf2417995808088e134f8f2b313c77535b.tar.gz
android_packages_apps_PackageInstaller-6402fbaf2417995808088e134f8f2b313c77535b.tar.bz2
android_packages_apps_PackageInstaller-6402fbaf2417995808088e134f8f2b313c77535b.zip
android-2.1_r1 snapshot
-rw-r--r--AndroidManifest.xml12
-rw-r--r--res/values-da/strings.xml10
-rw-r--r--res/values-ru/strings.xml2
-rw-r--r--res/values-zh-rCN/strings.xml2
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppProgress.java86
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java57
-rw-r--r--src/com/android/packageinstaller/PackageUtil.java28
7 files changed, 106 insertions, 91 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 21131455..ab4562bc 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -7,7 +7,8 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<application android:label="@string/app_name">
- <activity android:name=".PackageInstallerActivity">
+ <activity android:name=".PackageInstallerActivity"
+ android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
@@ -16,9 +17,11 @@
<data android:mimeType="application/vnd.android.package-archive" />
</intent-filter>
</activity>
- <activity android:name=".InstallAppProgress">
+ <activity android:name=".InstallAppProgress"
+ android:configChanges="orientation|keyboardHidden">
</activity>
- <activity android:name=".UninstallerActivity">
+ <activity android:name=".UninstallerActivity"
+ android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.DELETE" />
@@ -26,7 +29,8 @@
<data android:scheme="package" />
</intent-filter>
</activity>
- <activity android:name=".UninstallAppProgress">
+ <activity android:name=".UninstallAppProgress"
+ android:configChanges="orientation|keyboardHidden">
</activity>
</application>
</manifest>
diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml
index 68cd23f2..01c31eef 100644
--- a/res/values-da/strings.xml
+++ b/res/values-da/strings.xml
@@ -17,8 +17,8 @@
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name" msgid="1998766462707453166">"Pakkeinstallationsprogram"</string>
<string name="install" msgid="5896438203900042068">"Installer"</string>
- <string name="done" msgid="3889387558374211719">"Færdig"</string>
- <string name="security_settings_desc" msgid="4984920898157282073">"Tillad dette program at:"</string>
+ <string name="done" msgid="3889387558374211719">"Udfør"</string>
+ <string name="security_settings_desc" msgid="4984920898157282073">"Tillad, at dette program:"</string>
<string name="cancel" msgid="8360346460165114585">"Annuller"</string>
<string name="unknown" msgid="4742479012767208045">"Ukendt"</string>
<string name="installing" msgid="8613631001631998372">"Installerer ..."</string>
@@ -27,12 +27,12 @@
<string name="install_failed" msgid="6644311739017660989">"Programmet er ikke installeret"</string>
<string name="install_failed_msg" msgid="5282789300118241924">"<xliff:g id="APP_NAME">%1$s</xliff:g> kunne ikke installeres på denne telefon."</string>
<string name="launch" msgid="4826921505917605463">"Åbn"</string>
- <string name="unknown_apps_dlg_title" msgid="2855558586206583032">"Installer blokeret"</string>
+ <string name="unknown_apps_dlg_title" msgid="2855558586206583032">"Installationen er blokeret"</string>
<string name="unknown_apps_dlg_text" msgid="5022078090329832537">"Din telefon er af sikkerhedsgrunde indstillet til at blokere installation af programmer, der ikke er anskaffet på Android Marked."</string>
<string name="ok" msgid="3468756155452870475">"OK"</string>
<string name="settings" msgid="6743583734099755409">"Indstillinger"</string>
<string name="manage_applications" msgid="2704331021611806557">"Administ. programmer"</string>
- <string name="dlg_app_replacement_title" msgid="3438730820395482641">"Erstat program"</string>
+ <string name="dlg_app_replacement_title" msgid="3438730820395482641">"Erstat programmet"</string>
<string name="dlg_app_replacement_statement" msgid="1175452362814803850">"Det program, du installerer, erstatter et andet program."\n\n"Alle tidligere brugerdata gemmes."</string>
<string name="dlg_sys_app_replacement_statement" msgid="1047598434568470723">"Dette er et systemprogram. Ønsker du stadig at erstatte det?"\n\n"Alle tidligere brugerdata gemmes."</string>
<string name="out_of_space_dlg_title" msgid="7843674437613797326">"Der er ikke mere plads"</string>
@@ -45,7 +45,7 @@
<string name="uninstall_application_text" msgid="9107842143723765782">"Dette program fjernes fra din telefon."</string>
<string name="uninstall_update_text" msgid="6695211142526505726">"Programopdateringen afinstalleres. Du kan stadig bruge programmets fabriksversion."</string>
<string name="uninstalling" msgid="5556217435895938250">"Afinstallerer ..."</string>
- <string name="uninstall_done" msgid="8730655660697216076">"Afinstallation afsluttet!"</string>
+ <string name="uninstall_done" msgid="8730655660697216076">"Afinstallationen er afsluttet!"</string>
<string name="uninstall_failed" msgid="5725854598594371845">"Afinstallationen mislykkedes"</string>
<string name="uninstall_failed_msg" msgid="5480019148754200912">"<xliff:g id="APP_NAME">%1$s</xliff:g> kunne ikke afinstalleres!"</string>
<string name="Parse_error_dlg_title" msgid="6784222986864864223">"Parsingfejl"</string>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml
index 197c3843..bcb09177 100644
--- a/res/values-ru/strings.xml
+++ b/res/values-ru/strings.xml
@@ -28,7 +28,7 @@
<string name="install_failed_msg" msgid="5282789300118241924">"Установить приложение <xliff:g id="APP_NAME">%1$s</xliff:g> на этом телефоне не удалось."</string>
<string name="launch" msgid="4826921505917605463">"Открыть"</string>
<string name="unknown_apps_dlg_title" msgid="2855558586206583032">"Установка заблокирована"</string>
- <string name="unknown_apps_dlg_text" msgid="5022078090329832537">"Из соображений безопасности на вашем телефоне заблокирована установка приложений, источником которых не является Android-маркет."</string>
+ <string name="unknown_apps_dlg_text" msgid="5022078090329832537">"Из соображений безопасности на вашем телефоне заблокирована установка приложений, источником которых не является Android Маркет."</string>
<string name="ok" msgid="3468756155452870475">"ОК"</string>
<string name="settings" msgid="6743583734099755409">"Настройки"</string>
<string name="manage_applications" msgid="2704331021611806557">"Управление приложениями"</string>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 32a0b1d7..9f11099f 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -35,7 +35,7 @@
<string name="dlg_app_replacement_title" msgid="3438730820395482641">"替换应用程序"</string>
<string name="dlg_app_replacement_statement" msgid="1175452362814803850">"您正在安装的应用程序会替换其他应用程序。"\n\n"会保存所有以前的用户数据。"</string>
<string name="dlg_sys_app_replacement_statement" msgid="1047598434568470723">"这是一个系统应用程序。您是否仍要替换它?"\n\n"之前的所有用户数据都会保存。"</string>
- <string name="out_of_space_dlg_title" msgid="7843674437613797326">"空间不足"</string>
+ <string name="out_of_space_dlg_title" msgid="7843674437613797326">"没有存储空间"</string>
<string name="out_of_space_dlg_text" msgid="5817764827778985771">"无法查看<xliff:g id="APP_NAME">%1$s</xliff:g>。请释放部分手机空间,然后重试。"</string>
<string name="dlg_ok" msgid="6944357727705699232">"确定"</string>
<string name="app_not_found_dlg_title" msgid="1510267643973600726">"找不到应用程序"</string>
diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java
index c5a3c5b5..1ecc1f1e 100755
--- a/src/com/android/packageinstaller/InstallAppProgress.java
+++ b/src/com/android/packageinstaller/InstallAppProgress.java
@@ -29,6 +29,7 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
+import android.os.FileUtils;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
@@ -38,6 +39,11 @@ import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
/**
* This activity corresponds to a download progress screen that is displayed
* when the user tries
@@ -60,6 +66,9 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
final static int FAILED = 0;
private final int INSTALL_COMPLETE = 1;
private Intent mLaunchIntent;
+ private File mTmpFile;
+ private final String TMP_FILE_NAME="tmpCopy.apk";
+
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
@@ -123,18 +132,6 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
public void initView() {
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.op_progress);
- // 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();
try {
@@ -148,6 +145,27 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
if((installFlags & PackageManager.INSTALL_REPLACE_EXISTING )!= 0) {
Log.w(TAG, "Replacing package:" + mAppInfo.packageName);
}
+ PackageUtil.initSnippetForNewApp(this, mAppInfo,
+ R.id.app_snippet, mPackageURI);
+ 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);
+
+ // Create temp file before invoking install api
+ mTmpFile = createTempPackageFile(mPackageURI.getPath());
+ if (mTmpFile == null) {
+ Message msg = mHandler.obtainMessage(INSTALL_COMPLETE);
+ msg.arg1 = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
+ mHandler.sendMessage(msg);
+ return;
+ }
+ mPackageURI = Uri.parse("file://" + mTmpFile.getPath());
String installerPackageName = getIntent().getStringExtra(
Intent.EXTRA_INSTALLER_PACKAGE_NAME);
@@ -155,13 +173,55 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
pm.installPackage(mPackageURI, observer, installFlags, installerPackageName);
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (mTmpFile != null && mTmpFile.exists()) {
+ mTmpFile.delete();
+ }
+ }
+
public void onClick(View v) {
if(v == mDoneButton) {
- Log.i(TAG, "Finished installing "+mAppInfo);
+ if (mAppInfo.packageName != null) {
+ Log.i(TAG, "Finished installing "+mAppInfo.packageName);
+ }
finish();
} else if(v == mLaunchButton) {
startActivity(mLaunchIntent);
finish();
}
}
+
+ private File createTempPackageFile(String filePath) {
+ File tmpPackageFile = getFileStreamPath(TMP_FILE_NAME);
+ if (tmpPackageFile == null) {
+ Log.w(TAG, "Failed to create temp file");
+ return null;
+ }
+ if (tmpPackageFile.exists()) {
+ tmpPackageFile.delete();
+ }
+ // Open file to make it world readable
+ FileOutputStream fos;
+ try {
+ fos = openFileOutput(TMP_FILE_NAME, MODE_WORLD_READABLE);
+ } catch (FileNotFoundException e1) {
+ Log.e(TAG, "Error opening file " + TMP_FILE_NAME);
+ return null;
+ }
+ try {
+ fos.close();
+ } catch (IOException e) {
+ Log.e(TAG, "Error opening file " + TMP_FILE_NAME);
+ return null;
+ }
+
+ File srcPackageFile = new File(filePath);
+ if (!FileUtils.copyFile(srcPackageFile, tmpPackageFile)) {
+ Log.w(TAG, "Failed to make copy of file: " + srcPackageFile);
+ return null;
+ }
+ return tmpPackageFile;
+ }
}
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index 8f681bb0..b1651943 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -19,9 +19,6 @@ package com.android.packageinstaller;
import com.android.packageinstaller.R;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -33,13 +30,11 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.DialogInterface.OnCancelListener;
import android.content.pm.ApplicationInfo;
-import android.content.pm.IPackageDataObserver;
import android.content.pm.PackageManager;
import android.content.pm.PackageParser;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
import android.os.Bundle;
-import android.os.FileUtils;
import android.os.Handler;
import android.os.Message;
import android.provider.Settings;
@@ -50,7 +45,6 @@ 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
@@ -69,7 +63,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
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
@@ -271,46 +264,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
Settings.Secure.INSTALL_NON_MARKET_APPS, 0) > 0;
}
- private File createTempPackageFile(String filePath) {
- File tmpPackageFile;
- int i = filePath.lastIndexOf("/");
- String tmpFileName;
- if(i != -1) {
- tmpFileName = filePath.substring(i+1);
- } else {
- tmpFileName = filePath;
- }
- FileOutputStream fos;
- try {
- fos=openFileOutput(tmpFileName, MODE_WORLD_READABLE);
- } catch (FileNotFoundException e1) {
- Log.e(TAG, "Error opening file "+tmpFileName);
- return null;
- }
- try {
- fos.close();
- } catch (IOException e) {
- Log.e(TAG, "Error opening file "+tmpFileName);
- return null;
- }
- tmpPackageFile=getFileStreamPath(tmpFileName);
- File srcPackageFile = new File(filePath);
- if (!FileUtils.copyFile(srcPackageFile, tmpPackageFile)) {
- return null;
- }
- return tmpPackageFile;
- }
-
private void makeTempCopyAndInstall() {
- //copy file to tmp dir
- mTmpFile = createTempPackageFile(mPackageURI.getPath());
- if(mTmpFile == null) {
- //display a dialog
- Log.e(TAG, "Error copying file locally. Failed Installation");
- showDialogInner(DLG_OUT_OF_SPACE);
- return;
- }
- mPackageURI = Uri.parse("file://"+mTmpFile.getPath());
// Check if package is already installed. display confirmation dialog if replacing pkg
try {
mAppInfo = mPm.getApplicationInfo(mPkgInfo.packageName,
@@ -356,8 +310,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
showDialogInner(DLG_UNKNOWN_APPS);
return;
}
- // Clear any other temporary files in data directory
- mPm.clearApplicationUserData(getPackageName(), null);
//compute the size of the application. just an estimate
long size;
String apkPath = mPackageURI.getPath();
@@ -367,15 +319,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
checkOutOfSpace(size);
}
- @Override
- public void onDestroy() {
- super.onDestroy();
- // Delete the temporary file if it still exists
- if (mTmpFile != null) {
- deleteFile(mTmpFile.getName());
- }
- }
-
// Generic handling when pressing back key
public void onCancel(DialogInterface dialog) {
finish();
diff --git a/src/com/android/packageinstaller/PackageUtil.java b/src/com/android/packageinstaller/PackageUtil.java
index 362c9636..5b31062c 100644
--- a/src/com/android/packageinstaller/PackageUtil.java
+++ b/src/com/android/packageinstaller/PackageUtil.java
@@ -115,25 +115,33 @@ public class PackageUtil {
int snippetId, Uri packageURI) {
View appSnippet = pContext.findViewById(snippetId);
final String archiveFilePath = packageURI.getPath();
- DisplayMetrics metrics = new DisplayMetrics();
- metrics.setToDefaults();
+ Resources pRes = pContext.getResources();
AssetManager assmgr = new AssetManager();
assmgr.addAssetPath(archiveFilePath);
- Resources res = new Resources(assmgr, metrics, null);
+ Resources res = new Resources(assmgr, pRes.getDisplayMetrics(), pRes.getConfiguration());
CharSequence label = null;
// Try to load the label from the package's resources. If an app has not explicitly
// specified any label, just use the package name.
- try {
- label = res.getText(appInfo.labelRes);
- } catch (Resources.NotFoundException e) {
- label = appInfo.packageName;
+ if (appInfo.labelRes != 0) {
+ try {
+ label = res.getText(appInfo.labelRes);
+ } catch (Resources.NotFoundException e) {
+ }
+ }
+ if (label == null) {
+ label = (appInfo.nonLocalizedLabel != null) ?
+ appInfo.nonLocalizedLabel : appInfo.packageName;
}
Drawable icon = null;
// Try to load the icon from the package's resources. If an app has not explicitly
// specified any resource, just use the default icon for now.
- try {
- icon = res.getDrawable(appInfo.icon);
- } catch (Resources.NotFoundException e) {
+ if (appInfo.icon != 0) {
+ try {
+ icon = res.getDrawable(appInfo.icon);
+ } catch (Resources.NotFoundException e) {
+ }
+ }
+ if (icon == null) {
icon = pContext.getPackageManager().getDefaultActivityIcon();
}
((ImageView)appSnippet.findViewById(R.id.app_icon)).setImageDrawable(icon);