summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-04-16 19:41:14 -0700
committerJeff Sharkey <jsharkey@android.com>2012-04-16 20:42:03 -0700
commit79da2eaa800f889be5e5f5bd91121c2ecb55ce14 (patch)
tree27f9e4b158afdee8d1a143a154396634c87e12ef /src
parent250b43aeacc2edf80965a1b837b64daa50208f1d (diff)
downloadandroid_packages_apps_PackageInstaller-79da2eaa800f889be5e5f5bd91121c2ecb55ce14.tar.gz
android_packages_apps_PackageInstaller-79da2eaa800f889be5e5f5bd91121c2ecb55ce14.tar.bz2
android_packages_apps_PackageInstaller-79da2eaa800f889be5e5f5bd91121c2ecb55ce14.zip
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
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppProgress.java18
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java22
-rw-r--r--src/com/android/packageinstaller/PackageUtil.java40
3 files changed, 48 insertions, 32 deletions
diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java
index a1c07952..bb6fda2f 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 d4591601..ab9bb5a3 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 1f6a9dcd..8681bfc7 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);