From 9629a925eded634556b444d6d11985894dfb9f6a Mon Sep 17 00:00:00 2001 From: Suchi Amalapurapu Date: Mon, 25 Jan 2010 12:40:34 -0800 Subject: Remove copying temporary file into installer's private data directory. The system process can now make a copy for itself. --- .../packageinstaller/InstallAppProgress.java | 46 ---------------------- .../packageinstaller/PackageInstallerActivity.java | 2 +- 2 files changed, 1 insertion(+), 47 deletions(-) diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java index 1ecc1f1e..96fe7a7a 100755 --- a/src/com/android/packageinstaller/InstallAppProgress.java +++ b/src/com/android/packageinstaller/InstallAppProgress.java @@ -66,8 +66,6 @@ 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) { @@ -157,15 +155,6 @@ public class InstallAppProgress extends Activity implements View.OnClickListener 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); @@ -176,9 +165,6 @@ public class InstallAppProgress extends Activity implements View.OnClickListener @Override protected void onDestroy() { super.onDestroy(); - if (mTmpFile != null && mTmpFile.exists()) { - mTmpFile.delete(); - } } public void onClick(View v) { @@ -192,36 +178,4 @@ public class InstallAppProgress extends Activity implements View.OnClickListener 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 b1651943..a945a548 100644 --- a/src/com/android/packageinstaller/PackageInstallerActivity.java +++ b/src/com/android/packageinstaller/PackageInstallerActivity.java @@ -315,7 +315,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen String apkPath = mPackageURI.getPath(); File apkFile = new File(apkPath); //TODO? DEVISE BETTER HEAURISTIC - size = 4*apkFile.length(); + size = 1*apkFile.length(); checkOutOfSpace(size); } -- cgit v1.2.3