summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-06-01 12:47:03 -0700
committerDianne Hackborn <hackbod@google.com>2012-06-01 12:47:03 -0700
commit7ff6e568611af22ee38d2669c5c913d3a8824d41 (patch)
tree720188f3909d8231d5a4cd8d0adafa4aebfe02ff
parent7bfa6560f10776e362bf0586f68f7d888d413a60 (diff)
downloadandroid_packages_apps_PackageInstaller-7ff6e568611af22ee38d2669c5c913d3a8824d41.tar.gz
android_packages_apps_PackageInstaller-7ff6e568611af22ee38d2669c5c913d3a8824d41.tar.bz2
android_packages_apps_PackageInstaller-7ff6e568611af22ee38d2669c5c913d3a8824d41.zip
Survey says: NIET!
Bug: 6593206 Change-Id: Ib8ec410e9af258b507706f2a162e8e7482f93f6a
-rw-r--r--Android.mk2
-rw-r--r--res/layout/install_confirm.xml71
-rw-r--r--src/com/android/packageinstaller/PackageInstallerActivity.java227
3 files changed, 76 insertions, 224 deletions
diff --git a/Android.mk b/Android.mk
index 0612cfe3..f286016d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -5,7 +5,7 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
+#LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
LOCAL_PACKAGE_NAME := PackageInstaller
LOCAL_CERTIFICATE := platform
diff --git a/res/layout/install_confirm.xml b/res/layout/install_confirm.xml
index 753a24b6..0eb8ba6b 100644
--- a/res/layout/install_confirm.xml
+++ b/res/layout/install_confirm.xml
@@ -25,7 +25,9 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:paddingLeft="8dip"
+ android:paddingRight="8dip">
<TextView
android:id="@+id/install_confirm_question"
@@ -34,50 +36,38 @@
android:text="@string/install_confirm_question"
android:textAppearance="?android:attr/textAppearanceMedium"
style="@style/padded"
- android:paddingTop="12dip" />
+ android:paddingTop="12dip"
+ android:paddingBottom="16dip"/>
- <TabHost
- android:id="@android:id/tabhost"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1">
-
- <LinearLayout
- android:orientation="vertical"
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="wrap_content"
+ android:fillViewport="true"
+ android:layout_weight="1">
- <HorizontalScrollView
+ <!-- Security settings description. -->
+ <LinearLayout
+ android:id="@+id/permissions_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@*android:drawable/tab_unselected_holo"
- android:fillViewport="true"
- android:scrollbars="none">
- <FrameLayout android:layout_width="match_parent"
- android:layout_height="wrap_content">
- <TabWidget
- android:id="@android:id/tabs"
- android:orientation="horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center" />
- </FrameLayout>
- </HorizontalScrollView>
-
- <FrameLayout
- android:id="@android:id/tabcontent"
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_weight="0"/>
-
- <android.support.v4.view.ViewPager
- android:id="@+id/pager"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"/>
-
+ android:layout_marginRight="?android:attr/scrollbarSize"
+ style="@style/padded"
+ android:orientation="vertical">
+ <TextView
+ android:id="@+id/security_settings_desc"
+ android:text="@string/security_settings_desc"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ />
+ <LinearLayout
+ android:id="@+id/security_settings_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1.0"
+ android:orientation="vertical"/>
</LinearLayout>
- </TabHost>
+ </ScrollView>
<!-- OK confirm and cancel buttons. -->
<LinearLayout
@@ -85,7 +75,8 @@
android:layout_height="wrap_content"
android:orientation="vertical"
android:divider="?android:attr/dividerHorizontal"
- android:showDividers="beginning">
+ android:showDividers="beginning"
+ android:paddingTop="16dip">
<LinearLayout
style="?android:attr/buttonBarStyle"
diff --git a/src/com/android/packageinstaller/PackageInstallerActivity.java b/src/com/android/packageinstaller/PackageInstallerActivity.java
index 3c5566e9..99631035 100644
--- a/src/com/android/packageinstaller/PackageInstallerActivity.java
+++ b/src/com/android/packageinstaller/PackageInstallerActivity.java
@@ -32,8 +32,6 @@ import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
-import android.support.v4.view.PagerAdapter;
-import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -41,6 +39,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AppSecurityPermissions;
import android.widget.Button;
+import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TabHost;
import android.widget.TabWidget;
@@ -80,192 +79,27 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
// Dialog identifiers used in showDialog
private static final int DLG_BASE = 0;
- private static final int DLG_UNKNOWN_APPS = DLG_BASE + 1;
- private static final int DLG_PACKAGE_ERROR = DLG_BASE + 2;
- private static final int DLG_OUT_OF_SPACE = DLG_BASE + 3;
- private static final int DLG_INSTALL_ERROR = DLG_BASE + 4;
- private static final int DLG_ALLOW_SOURCE = DLG_BASE + 5;
-
- /**
- * This is a helper class that implements the management of tabs and all
- * details of connecting a ViewPager with associated TabHost. It relies on a
- * trick. Normally a tab host has a simple API for supplying a View or
- * Intent that each tab will show. This is not sufficient for switching
- * between pages. So instead we make the content part of the tab host
- * 0dp high (it is not shown) and the TabsAdapter supplies its own dummy
- * view to show as the tab content. It listens to changes in tabs, and takes
- * care of switch to the correct paged in the ViewPager whenever the selected
- * tab changes.
- */
- public static class TabsAdapter extends PagerAdapter
- implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener {
- private final Context mContext;
- private final TabHost mTabHost;
- private final ViewPager mViewPager;
- private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>();
- private final Rect mTempRect = new Rect();
-
- static final class TabInfo {
- private final String tag;
- private final View view;
-
- TabInfo(String _tag, View _view) {
- tag = _tag;
- view = _view;
- }
- }
-
- static class DummyTabFactory implements TabHost.TabContentFactory {
- private final Context mContext;
-
- public DummyTabFactory(Context context) {
- mContext = context;
- }
-
- @Override
- public View createTabContent(String tag) {
- View v = new View(mContext);
- v.setMinimumWidth(0);
- v.setMinimumHeight(0);
- return v;
- }
- }
-
- public TabsAdapter(Activity activity, TabHost tabHost, ViewPager pager) {
- mContext = activity;
- mTabHost = tabHost;
- mViewPager = pager;
- mTabHost.setOnTabChangedListener(this);
- mViewPager.setAdapter(this);
- mViewPager.setOnPageChangeListener(this);
- }
-
- public void addTab(TabHost.TabSpec tabSpec, View view) {
- tabSpec.setContent(new DummyTabFactory(mContext));
- String tag = tabSpec.getTag();
-
- TabInfo info = new TabInfo(tag, view);
- mTabs.add(info);
- mTabHost.addTab(tabSpec);
- notifyDataSetChanged();
- }
-
- @Override
- public int getCount() {
- return mTabs.size();
- }
-
- @Override
- public Object instantiateItem(ViewGroup container, int position) {
- View view = mTabs.get(position).view;
- container.addView(view);
- return view;
- }
-
- @Override
- public void destroyItem(ViewGroup container, int position, Object object) {
- container.removeView((View)object);
- }
-
- @Override
- public boolean isViewFromObject(View view, Object object) {
- return view == object;
- }
-
- @Override
- public void onTabChanged(String tabId) {
- int position = mTabHost.getCurrentTab();
- mViewPager.setCurrentItem(position);
- }
-
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- }
-
- @Override
- public void onPageSelected(int position) {
- // Unfortunately when TabHost changes the current tab, it kindly
- // also takes care of putting focus on it when not in touch mode.
- // The jerk.
- // This hack tries to prevent this from pulling focus out of our
- // ViewPager.
- TabWidget widget = mTabHost.getTabWidget();
- int oldFocusability = widget.getDescendantFocusability();
- widget.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
- mTabHost.setCurrentTab(position);
- widget.setDescendantFocusability(oldFocusability);
-
- // Scroll the current tab into visibility if needed.
- View tab = widget.getChildTabViewAt(position);
- mTempRect.set(tab.getLeft(), tab.getTop(), tab.getRight(), tab.getBottom());
- widget.requestRectangleOnScreen(mTempRect, false);
-
- // Make sure the scrollbars are visible for a moment after selection
- final View contentView = mTabs.get(position).view;
- if (contentView instanceof CaffeinatedScrollView) {
- ((CaffeinatedScrollView) contentView).awakenScrollBars();
- }
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
- }
- }
+ private static final int DLG_REPLACE_APP = DLG_BASE + 1;
+ private static final int DLG_UNKNOWN_APPS = DLG_BASE + 2;
+ private static final int DLG_PACKAGE_ERROR = DLG_BASE + 3;
+ private static final int DLG_OUT_OF_SPACE = DLG_BASE + 4;
+ private static final int DLG_INSTALL_ERROR = DLG_BASE + 5;
+ private static final int DLG_ALLOW_SOURCE = DLG_BASE + 6;
private void startInstallConfirm() {
- TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
- tabHost.setup();
- ViewPager viewPager = (ViewPager)findViewById(R.id.pager);
- TabsAdapter adapter = new TabsAdapter(this, tabHost, viewPager);
-
+ LinearLayout permsSection = (LinearLayout) mInstallConfirm.findViewById(R.id.permissions_section);
+ LinearLayout securityList = (LinearLayout) permsSection.findViewById(
+ R.id.security_settings_list);
boolean permVisible = false;
- int msg = 0;
- if (mPkgInfo != null) {
- AppSecurityPermissions perms = new AppSecurityPermissions(this, mPkgInfo);
- if (mAppInfo != null) {
- permVisible = true;
- msg = (mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0
- ? R.string.install_confirm_question_update_system
- : R.string.install_confirm_question_update;
- ScrollView scrollView = new CaffeinatedScrollView(this);
- scrollView.setFillViewport(true);
- if (perms.getPermissionCount(AppSecurityPermissions.WHICH_NEW) > 0) {
- scrollView.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_NEW));
- } else {
- LayoutInflater inflater = (LayoutInflater)getSystemService(
- Context.LAYOUT_INFLATER_SERVICE);
- TextView label = (TextView)inflater.inflate(R.layout.label, null);
- label.setText(R.string.no_new_perms);
- scrollView.addView(label);
- }
- adapter.addTab(tabHost.newTabSpec("new").setIndicator(
- getText(R.string.newPerms)), scrollView);
- }
- if (perms.getPermissionCount(AppSecurityPermissions.WHICH_PERSONAL) > 0) {
- permVisible = true;
- ScrollView scrollView = new CaffeinatedScrollView(this);
- scrollView.setFillViewport(true);
- scrollView.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_PERSONAL));
- adapter.addTab(tabHost.newTabSpec("personal").setIndicator(
- getText(R.string.privacyPerms)), scrollView);
- }
- if (perms.getPermissionCount(AppSecurityPermissions.WHICH_DEVICE) > 0) {
+ if(mPkgInfo != null) {
+ AppSecurityPermissions asp = new AppSecurityPermissions(this, mPkgInfo);
+ if(asp.getPermissionCount() > 0) {
permVisible = true;
- ScrollView scrollView = new CaffeinatedScrollView(this);
- scrollView.setFillViewport(true);
- scrollView.addView(perms.getPermissionsView(AppSecurityPermissions.WHICH_DEVICE));
- adapter.addTab(tabHost.newTabSpec("device").setIndicator(
- getText(R.string.devicePerms)), scrollView);
+ securityList.addView(asp.getPermissionsView());
}
}
- if (!permVisible) {
- if (msg == 0) {
- msg = R.string.install_confirm_question_no_perms;
- }
- tabHost.setVisibility(View.INVISIBLE);
- }
- if (msg != 0) {
- ((TextView)findViewById(R.id.install_confirm_question)).setText(msg);
+ if(!permVisible){
+ permsSection.setVisibility(View.INVISIBLE);
}
mInstallConfirm.setVisibility(View.VISIBLE);
mOk = (Button)findViewById(R.id.ok_button);
@@ -283,6 +117,27 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
@Override
public Dialog onCreateDialog(int id, Bundle bundle) {
switch (id) {
+ case DLG_REPLACE_APP:
+ int msgId = R.string.dlg_app_replacement_statement;
+ // Customized text for system apps
+ if ((mAppInfo != null) && (mAppInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
+ msgId = R.string.dlg_sys_app_replacement_statement;
+ }
+ return new AlertDialog.Builder(this)
+ .setTitle(R.string.dlg_app_replacement_title)
+ .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ startInstallConfirm();
+ }})
+ .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ Log.i(TAG, "Canceling installation");
+ setResult(RESULT_CANCELED);
+ finish();
+ }})
+ .setMessage(msgId)
+ .setOnCancelListener(this)
+ .create();
case DLG_UNKNOWN_APPS:
return new AlertDialog.Builder(this)
.setTitle(R.string.unknown_apps_dlg_title)
@@ -406,7 +261,13 @@ public class PackageInstallerActivity extends Activity implements OnCancelListen
} catch (NameNotFoundException e) {
mAppInfo = null;
}
- startInstallConfirm();
+ if (mAppInfo == null || getIntent().getBooleanExtra(Intent.EXTRA_ALLOW_REPLACE, false)) {
+ startInstallConfirm();
+ } else {
+ if(localLOGV) Log.i(TAG, "Replacing existing package:"+
+ mPkgInfo.applicationInfo.packageName);
+ showDialogInner(DLG_REPLACE_APP);
+ }
}
void setPmResult(int pmResult) {