summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/packageinstaller/InstallAppProgress.java29
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java11
-rw-r--r--src/com/android/packageinstaller/permission/model/PermissionApps.java22
-rw-r--r--src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java4
-rw-r--r--src/com/android/packageinstaller/permission/ui/SecureButtonView.java56
5 files changed, 99 insertions, 23 deletions
diff --git a/src/com/android/packageinstaller/InstallAppProgress.java b/src/com/android/packageinstaller/InstallAppProgress.java
index 38f53e53..e93c93c7 100755
--- a/src/com/android/packageinstaller/InstallAppProgress.java
+++ b/src/com/android/packageinstaller/InstallAppProgress.java
@@ -34,7 +34,6 @@ import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
-import android.graphics.drawable.LevelListDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -94,7 +93,7 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
setResult(msg.arg1 == PackageInstaller.STATUS_SUCCESS
? Activity.RESULT_OK : Activity.RESULT_FIRST_USER,
result);
- finish();
+ clearCachedApkIfNeededAndFinish();
return;
}
// Update the status text
@@ -206,6 +205,11 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
initView();
}
+ @Override
+ public void onBackPressed() {
+ clearCachedApkIfNeededAndFinish();
+ }
+
@SuppressWarnings("deprecation")
@Override
public Dialog onCreateDialog(int id, Bundle bundle) {
@@ -220,13 +224,13 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
//launch manage applications
Intent intent = new Intent("android.intent.action.MANAGE_PACKAGE_STORAGE");
startActivity(intent);
- finish();
+ clearCachedApkIfNeededAndFinish();
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.i(TAG, "Canceling installation");
- finish();
+ clearCachedApkIfNeededAndFinish();
}
})
.setOnCancelListener(this)
@@ -370,14 +374,27 @@ public class InstallAppProgress extends Activity implements View.OnClickListener
if (mAppInfo.packageName != null) {
Log.i(TAG, "Finished installing "+mAppInfo.packageName);
}
- finish();
+ clearCachedApkIfNeededAndFinish();
} else if(v == mLaunchButton) {
startActivity(mLaunchIntent);
- finish();
+ clearCachedApkIfNeededAndFinish();
}
}
public void onCancel(DialogInterface dialog) {
+ clearCachedApkIfNeededAndFinish();
+ }
+
+ private void clearCachedApkIfNeededAndFinish() {
+ // If we are installing from a content:// the apk is copied in the cache
+ // dir and passed in here. As we aren't started for a result because our
+ // caller needs to be able to forward the result, here we make sure the
+ // staging file in the cache dir is removed.
+ if ("file".equals(mPackageURI.getScheme()) && mPackageURI.getPath() != null
+ && mPackageURI.getPath().startsWith(getCacheDir().toString())) {
+ File file = new File(mPackageURI.getPath());
+ file.delete();
+ }
finish();
}
}
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index 848c7688..a059931d 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -72,7 +72,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
private static final String TAG = "PackageInstaller";
private static final int REQUEST_ENABLE_UNKNOWN_SOURCES = 1;
- private static final int REQUEST_INSTALL_PACKAGE = 2;
private static final String SCHEME_FILE = "file";
private static final String SCHEME_CONTENT = "content";
@@ -185,11 +184,13 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
msg = (mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
? R.string.install_confirm_question_update_system_no_perms
: R.string.install_confirm_question_update_no_perms;
+
+ findViewById(R.id.spacer).setVisibility(View.VISIBLE);
} else {
// This is a new application with no permissions.
msg = R.string.install_confirm_question_no_perms;
}
- tabHost.setVisibility(View.GONE);
+ tabHost.setVisibility(View.INVISIBLE);
mScrollView = null;
}
if (msg != 0) {
@@ -228,7 +229,7 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Log.i(TAG, "Finishing off activity so that user can navigate to settings manually");
- finish();
+ finishAffinity();
}})
.setPositiveButton(R.string.settings, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@@ -324,7 +325,6 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
if (request == REQUEST_ENABLE_UNKNOWN_SOURCES && result == RESULT_OK) {
initiateInstall();
}
- clearCachedApkIfNeededAndFinish();
}
private boolean isInstallRequestFromUnknownSource(Intent intent) {
@@ -684,7 +684,8 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
newIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
}
if(localLOGV) Log.i(TAG, "downloaded app uri="+mPackageURI);
- startActivityForResult(newIntent, REQUEST_INSTALL_PACKAGE);
+ startActivity(newIntent);
+ finish();
}
private void clearCachedApkIfNeededAndFinish() {
diff --git a/src/com/android/packageinstaller/permission/model/PermissionApps.java b/src/com/android/packageinstaller/permission/model/PermissionApps.java
index 2025420e..be32f2ac 100644
--- a/src/com/android/packageinstaller/permission/model/PermissionApps.java
+++ b/src/com/android/packageinstaller/permission/model/PermissionApps.java
@@ -196,8 +196,18 @@ public class PermissionApps {
String label = mSkipUi ? app.packageName
: app.applicationInfo.loadLabel(mPm).toString();
- PermissionApp permApp = new PermissionApp(app.packageName,
- group, label, getBadgedIcon(app.applicationInfo),
+
+ Drawable icon = null;
+ if (!mSkipUi) {
+ UserHandle userHandle = new UserHandle(
+ UserHandle.getUserId(group.getApp().applicationInfo.uid));
+
+ icon = mPm.getUserBadgedIcon(
+ mPm.loadUnbadgedItemIcon(app.applicationInfo, app.applicationInfo),
+ userHandle);
+ }
+
+ PermissionApp permApp = new PermissionApp(app.packageName, group, label, icon,
app.applicationInfo);
permApps.add(permApp);
@@ -251,14 +261,6 @@ public class PermissionApps {
return null;
}
- private Drawable getBadgedIcon(ApplicationInfo appInfo) {
- if (mSkipUi) {
- return null;
- }
- Drawable unbadged = appInfo.loadUnbadgedIcon(mPm);
- return mPm.getUserBadgedIcon(unbadged, Process.myUserHandle());
- }
-
private void loadGroupInfo() {
PackageItemInfo info;
try {
diff --git a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
index 78d33d23..787f1533 100644
--- a/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
+++ b/src/com/android/packageinstaller/permission/ui/GrantPermissionsActivity.java
@@ -237,8 +237,8 @@ public class GrantPermissionsActivity extends OverlayTouchActivity
// Set the permission message as the title so it can be announced.
setTitle(message);
// Color the app name.
- int appLabelStart = message.toString().indexOf(appLabel.toString(), 0);
- int appLabelLength = appLabel.length();
+ int appLabelStart = message.toString().indexOf(" " + appLabel.toString() + " ", 0);
+ int appLabelLength = appLabel.length() + 1;
message.setSpan(new StyleSpan(Typeface.BOLD), appLabelStart,
appLabelStart + appLabelLength, 0);
diff --git a/src/com/android/packageinstaller/permission/ui/SecureButtonView.java b/src/com/android/packageinstaller/permission/ui/SecureButtonView.java
new file mode 100644
index 00000000..624744e5
--- /dev/null
+++ b/src/com/android/packageinstaller/permission/ui/SecureButtonView.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.packageinstaller.permission.ui;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.Button;
+
+/**
+ * Extension of Button that uses the hidden MotionEvent flag for partially obscured windows to
+ * prevent tapjacking attacks.
+ */
+public class SecureButtonView extends Button {
+
+ public SecureButtonView(Context context) {
+ this(context, null);
+ }
+
+ public SecureButtonView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public SecureButtonView(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0);
+ }
+
+ public SecureButtonView(Context context, AttributeSet attrs, int defStyleAttr,
+ int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ }
+
+ @Override
+ public boolean onFilterTouchEventForSecurity(MotionEvent event) {
+ if ((event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0
+ || (event.getFlags() & MotionEvent.FLAG_WINDOW_IS_PARTIALLY_OBSCURED) != 0) {
+ // Window is obscured, drop this touch.
+ return false;
+ }
+ return true;
+ }
+}