diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-04-16 19:41:14 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2012-04-16 20:42:03 -0700 |
commit | 79da2eaa800f889be5e5f5bd91121c2ecb55ce14 (patch) | |
tree | 27f9e4b158afdee8d1a143a154396634c87e12ef | |
parent | 250b43aeacc2edf80965a1b837b64daa50208f1d (diff) | |
download | packages_apps_packageinstaller-79da2eaa800f889be5e5f5bd91121c2ecb55ce14.zip packages_apps_packageinstaller-79da2eaa800f889be5e5f5bd91121c2ecb55ce14.tar.gz packages_apps_packageinstaller-79da2eaa800f889be5e5f5bd91121c2ecb55ce14.tar.bz2 |
Stop advertising content://-style Uri support.
Internally using PackageParser, which needs raw files. Tried making
local copy of incoming files, but ran into 6347522. Instead, stop
advertising support for content://-style Uris.
Bug: 6343461
Change-Id: Ia57ffa56876f38db359e618d9a2c1116c71f56f2
-rw-r--r-- | AndroidManifest.xml | 1 | ||||
-rwxr-xr-x | src/com/android/packageinstaller/InstallAppProgress.java | 18 | ||||
-rw-r--r-- | src/com/android/packageinstaller/PackageInstallerActivity.java | 22 | ||||
-rw-r--r-- | src/com/android/packageinstaller/PackageUtil.java | 40 |
4 files changed, 48 insertions, 33 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 02f9983..cde090d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -20,7 +20,6 @@ <action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.INSTALL_PACKAGE" /> <category android:name="android.intent.category.DEFAULT" /> - <data android:scheme="content" /> <data android:scheme="file" /> <data android:mimeType="application/vnd.android.package-archive" /> </intent-filter> diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java index a1c0795..bb6fda2 100755 --- a/src/com/android/packageinstaller/InstallAppProgress.java +++ b/src/com/android/packageinstaller/InstallAppProgress.java @@ -16,20 +16,18 @@ */ package com.android.packageinstaller; -import com.android.packageinstaller.R; - import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; -import android.content.Intent; import android.content.DialogInterface.OnCancelListener; +import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageInstallObserver; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.ResolveInfo; import android.graphics.drawable.LevelListDrawable; import android.net.Uri; import android.os.Bundle; @@ -41,6 +39,7 @@ import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; +import java.io.File; import java.util.List; /** @@ -161,6 +160,12 @@ public class InstallAppProgress extends Activity implements View.OnClickListener Intent intent = getIntent(); mAppInfo = intent.getParcelableExtra(PackageUtil.INTENT_ATTR_APPLICATION_INFO); mPackageURI = intent.getData(); + + final String scheme = mPackageURI.getScheme(); + if (!"file".equals(scheme)) { + throw new IllegalArgumentException("unexpected scheme " + scheme); + } + initView(); } @@ -220,8 +225,9 @@ public class InstallAppProgress extends Activity implements View.OnClickListener if((installFlags & PackageManager.INSTALL_REPLACE_EXISTING )!= 0) { Log.w(TAG, "Replacing package:" + mAppInfo.packageName); } - PackageUtil.AppSnippet as = PackageUtil.getAppSnippet(this, mAppInfo, - mPackageURI); + + final File sourceFile = new File(mPackageURI.getPath()); + PackageUtil.AppSnippet as = PackageUtil.getAppSnippet(this, mAppInfo, sourceFile); mLabel = as.label; PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet); mStatusTextView = (TextView)findViewById(R.id.center_text); diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java index d459160..ab9bb5a 100644 --- a/src/com/android/packageinstaller/PackageInstallerActivity.java +++ b/src/com/android/packageinstaller/PackageInstallerActivity.java @@ -38,6 +38,8 @@ import android.widget.AppSecurityPermissions; import android.widget.Button; import android.widget.LinearLayout; +import java.io.File; + /* * This activity is launched when a new application is installed via side loading * The package is first parsed and the user is notified of parse errors via a dialog. @@ -270,14 +272,22 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); - //get intent information + + // get intent information final Intent intent = getIntent(); mPackageURI = intent.getData(); mPm = getPackageManager(); - mPkgInfo = PackageUtil.getPackageInfo(mPackageURI); - + + final String scheme = mPackageURI.getScheme(); + if (!"file".equals(scheme)) { + throw new IllegalArgumentException("unexpected scheme " + scheme); + } + + final File sourceFile = new File(mPackageURI.getPath()); + mPkgInfo = PackageUtil.getPackageInfo(sourceFile); + // Check for parse errors - if(mPkgInfo == null) { + if (mPkgInfo == null) { Log.w(TAG, "Parse error when parsing manifest. Discontinuing installation"); showDialogInner(DLG_PACKAGE_ERROR); setPmResult(PackageManager.INSTALL_FAILED_INVALID_APK); @@ -288,8 +298,8 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen setContentView(R.layout.install_start); mInstallConfirm = findViewById(R.id.install_confirm_panel); mInstallConfirm.setVisibility(View.INVISIBLE); - PackageUtil.AppSnippet as = PackageUtil.getAppSnippet(this, - mPkgInfo.applicationInfo, mPackageURI); + final PackageUtil.AppSnippet as = PackageUtil.getAppSnippet( + this, mPkgInfo.applicationInfo, sourceFile); PackageUtil.initSnippetForNewApp(this, as, R.id.app_snippet); // Deal with install source. diff --git a/src/com/android/packageinstaller/PackageUtil.java b/src/com/android/packageinstaller/PackageUtil.java index 1f6a9dc..8681bfc 100644 --- a/src/com/android/packageinstaller/PackageUtil.java +++ b/src/com/android/packageinstaller/PackageUtil.java @@ -14,10 +14,10 @@ ** See the License for the specific language governing permissions and ** limitations under the License. */ + package com.android.packageinstaller; import android.app.Activity; -import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -25,7 +25,6 @@ import android.content.pm.PackageParser; import android.content.res.AssetManager; import android.content.res.Resources; import android.graphics.drawable.Drawable; -import android.net.Uri; import android.util.DisplayMetrics; import android.view.View; import android.widget.ImageView; @@ -45,30 +44,30 @@ public class PackageUtil { public static final String INTENT_ATTR_PERMISSIONS_LIST=PREFIX+"PermissionsList"; //intent attribute strings related to uninstall public static final String INTENT_ATTR_PACKAGE_NAME=PREFIX+"PackageName"; - - /* - * Utility method to get application information for a given packageURI + + /** + * Utility method to get application information for a given {@link File} */ - public static ApplicationInfo getApplicationInfo(Uri packageURI) { - final String archiveFilePath = packageURI.getPath(); + public static ApplicationInfo getApplicationInfo(File sourcePath) { + final String archiveFilePath = sourcePath.getAbsolutePath(); PackageParser packageParser = new PackageParser(archiveFilePath); File sourceFile = new File(archiveFilePath); DisplayMetrics metrics = new DisplayMetrics(); metrics.setToDefaults(); - PackageParser.Package pkg = packageParser.parsePackage(sourceFile, archiveFilePath, metrics, 0); + PackageParser.Package pkg = packageParser.parsePackage( + sourceFile, archiveFilePath, metrics, 0); if (pkg == null) { return null; } return pkg.applicationInfo; } - - /* - * Utility method to get package information for a given packageURI + + /** + * Utility method to get package information for a given {@link File} */ - public static PackageParser.Package getPackageInfo(Uri packageURI) { - final String archiveFilePath = packageURI.getPath(); + public static PackageParser.Package getPackageInfo(File sourceFile) { + final String archiveFilePath = sourceFile.getAbsolutePath(); PackageParser packageParser = new PackageParser(archiveFilePath); - File sourceFile = new File(archiveFilePath); DisplayMetrics metrics = new DisplayMetrics(); metrics.setToDefaults(); PackageParser.Package pkg = packageParser.parsePackage(sourceFile, @@ -84,7 +83,7 @@ public class PackageUtil { return snippetView; } - /* + /** * Utility method to display a snippet of an installed application. * The content view should have been set on context before invoking this method. * appSnippet view should include R.id.app_icon and R.id.app_name @@ -103,7 +102,7 @@ public class PackageUtil { appInfo.loadIcon(pm)); } - /* + /** * Utility method to display application snippet of a new package. * The content view should have been set on context before invoking this method. * appSnippet view should include R.id.app_icon and R.id.app_name @@ -142,16 +141,17 @@ public class PackageUtil { this.icon = icon; } } - /* + + /** * Utility method to load application label * * @param pContext context of package that can load the resources * @param appInfo ApplicationInfo object of package whose resources are to be loaded * @param snippetId view id of app snippet view */ - public static AppSnippet getAppSnippet(Activity pContext, ApplicationInfo appInfo, - Uri packageURI) { - final String archiveFilePath = packageURI.getPath(); + public static AppSnippet getAppSnippet( + Activity pContext, ApplicationInfo appInfo, File sourceFile) { + final String archiveFilePath = sourceFile.getAbsolutePath(); Resources pRes = pContext.getResources(); AssetManager assmgr = new AssetManager(); assmgr.addAssetPath(archiveFilePath); |