Add development setting for compatibility mode.
Also some cleanup here and there. Change-Id: Iebf563cf6ec2d0b1671a54bd534336e8fef4b9c0
This commit is contained in:
@@ -68,10 +68,17 @@
|
|||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:text="@string/development_settings_show_updates_text" />
|
android:text="@string/development_settings_show_updates_text" />
|
||||||
|
|
||||||
|
<CheckBox android:id="@+id/compatibility_mode"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/show_updates"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:text="@string/development_settings_compatibility_mode_text" />
|
||||||
|
|
||||||
<Spinner android:id="@+id/max_procs"
|
<Spinner android:id="@+id/max_procs"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/show_updates"
|
android:layout_below="@id/compatibility_mode"
|
||||||
android:layout_alignParentLeft="true" />
|
android:layout_alignParentLeft="true" />
|
||||||
|
|
||||||
<View android:id="@+id/separator2"
|
<View android:id="@+id/separator2"
|
||||||
|
|||||||
68
apps/Development/res/layout/package_list_item.xml
Normal file
68
apps/Development/res/layout/package_list_item.xml
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
/*
|
||||||
|
** Copyright 2009, 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.
|
||||||
|
*/
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="fill" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingRight="6dip"
|
||||||
|
android:paddingLeft="6dip"
|
||||||
|
android:gravity="center_vertical" >
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/icon"
|
||||||
|
android:layout_width="@android:dimen/app_icon_size"
|
||||||
|
android:layout_height="@android:dimen/app_icon_size"
|
||||||
|
android:layout_marginLeft="5dip"
|
||||||
|
android:layout_marginRight="11dip"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:scaleType="fitCenter"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
<TextView android:id="@+id/name"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:layout_marginBottom="2dip" />
|
||||||
|
<TextView android:id="@+id/description"
|
||||||
|
android:layout_marginTop="-4dip"
|
||||||
|
android:layout_gravity="center_vertical|left"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingRight="4dip"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
@@ -77,6 +77,9 @@
|
|||||||
<string name="development_settings_always_finish_text">Immediately destroy activities</string>
|
<string name="development_settings_always_finish_text">Immediately destroy activities</string>
|
||||||
<string name="development_settings_show_load_text">Show running processes</string>
|
<string name="development_settings_show_load_text">Show running processes</string>
|
||||||
<string name="development_settings_show_updates_text">Show screen updates</string>
|
<string name="development_settings_show_updates_text">Show screen updates</string>
|
||||||
|
<string name="development_settings_compatibility_mode_text">Disable compatibility mode</string>
|
||||||
|
<string name="development_settings_compatibility_mode_toast">Reboot required for
|
||||||
|
change to take effect.</string>
|
||||||
<string name="development_settings_enable_gl_text">Enable OpenGL ES (reboot needed)</string>
|
<string name="development_settings_enable_gl_text">Enable OpenGL ES (reboot needed)</string>
|
||||||
<string name="development_settings_allow_mock_location_text">Allow mock locations for testing</string>
|
<string name="development_settings_allow_mock_location_text">Allow mock locations for testing</string>
|
||||||
<string name="development_settings_wait_for_debugger_text">Wait for debugger</string>
|
<string name="development_settings_wait_for_debugger_text">Wait for debugger</string>
|
||||||
|
|||||||
@@ -17,11 +17,14 @@
|
|||||||
|
|
||||||
package com.android.development;
|
package com.android.development;
|
||||||
|
|
||||||
|
import com.android.development.PackageBrowser.MyPackageInfo;
|
||||||
|
|
||||||
import android.app.ActivityManagerNative;
|
import android.app.ActivityManagerNative;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -29,10 +32,12 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -67,96 +72,67 @@ public class AppPicker extends ListActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id)
|
protected void onListItemClick(ListView l, View v, int position, long id)
|
||||||
{
|
{
|
||||||
ApplicationInfo app = mAdapter.appForPosition(position);
|
MyApplicationInfo app = mAdapter.itemForPosition(position);
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
if (app != null) intent.setAction(app.packageName);
|
if (app.info != null) intent.setAction(app.info.packageName);
|
||||||
setResult(RESULT_OK, intent);
|
setResult(RESULT_OK, intent);
|
||||||
|
|
||||||
/* This is a temporary fix for 824637 while it is blocked by 805226. When 805226 is resolved, please remove this. */
|
|
||||||
try {
|
try {
|
||||||
boolean waitForDebugger = Settings.System.getInt(
|
boolean waitForDebugger = Settings.System.getInt(
|
||||||
getContentResolver(), Settings.System.WAIT_FOR_DEBUGGER, 0) != 0;
|
getContentResolver(), Settings.System.WAIT_FOR_DEBUGGER, 0) != 0;
|
||||||
ActivityManagerNative.getDefault().setDebugApp(
|
ActivityManagerNative.getDefault().setDebugApp(
|
||||||
app != null ? app.packageName : null, waitForDebugger, true);
|
app.info != null ? app.info.packageName : null, waitForDebugger, true);
|
||||||
} catch (RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final class AppListAdapter extends BaseAdapter
|
class MyApplicationInfo {
|
||||||
{
|
ApplicationInfo info;
|
||||||
public AppListAdapter(Context context)
|
String label;
|
||||||
{
|
|
||||||
mContext = context;
|
|
||||||
mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
||||||
|
|
||||||
mList = context.getPackageManager().getInstalledApplications(0);
|
|
||||||
if (mList != null) {
|
|
||||||
Collections.sort(mList, sDisplayNameComparator);
|
|
||||||
mList.add(0, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationInfo appForPosition(int position)
|
public class AppListAdapter extends ArrayAdapter<MyApplicationInfo> {
|
||||||
{
|
private List<MyApplicationInfo> mPackageInfoList = new ArrayList<MyApplicationInfo>();
|
||||||
if (mList == null) {
|
|
||||||
return null;
|
public AppListAdapter(Context context) {
|
||||||
|
super(context, R.layout.package_list_item);
|
||||||
|
List<ApplicationInfo> pkgs = context.getPackageManager().getInstalledApplications(0);
|
||||||
|
for (int i=0; i<pkgs.size(); i++) {
|
||||||
|
MyApplicationInfo info = new MyApplicationInfo();
|
||||||
|
info.info = pkgs.get(i);
|
||||||
|
info.label = info.info.loadLabel(getPackageManager()).toString();
|
||||||
|
mPackageInfoList.add(info);
|
||||||
|
}
|
||||||
|
Collections.sort(mPackageInfoList, sDisplayNameComparator);
|
||||||
|
MyApplicationInfo info = new MyApplicationInfo();
|
||||||
|
info.label = "(none)";
|
||||||
|
mPackageInfoList.add(0, info);
|
||||||
|
setSource(mPackageInfoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mList.get(position);
|
@Override
|
||||||
}
|
public void bindView(View view, MyApplicationInfo info) {
|
||||||
|
ImageView icon = (ImageView)view.findViewById(R.id.icon);
|
||||||
public int getCount()
|
TextView name = (TextView)view.findViewById(R.id.name);
|
||||||
{
|
TextView description = (TextView)view.findViewById(R.id.description);
|
||||||
return mList != null ? mList.size() : 0;
|
name.setText(info.label);
|
||||||
}
|
if (info.info != null) {
|
||||||
|
icon.setImageDrawable(info.info.loadIcon(getPackageManager()));
|
||||||
public Object getItem(int position)
|
description.setText(info.info.packageName);
|
||||||
{
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getItemId(int position)
|
|
||||||
{
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent)
|
|
||||||
{
|
|
||||||
View view;
|
|
||||||
if (convertView == null) {
|
|
||||||
view = mInflater.inflate(
|
|
||||||
android.R.layout.simple_list_item_1, parent, false);
|
|
||||||
} else {
|
} else {
|
||||||
view = convertView;
|
icon.setImageDrawable(null);
|
||||||
|
description.setText("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bindView(view, mList.get(position));
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void bindView(View view, ApplicationInfo info)
|
private final static Comparator<MyApplicationInfo> sDisplayNameComparator
|
||||||
{
|
= new Comparator<MyApplicationInfo>() {
|
||||||
TextView text = (TextView)view.findViewById(android.R.id.text1);
|
|
||||||
|
|
||||||
text.setText(info != null ? info.packageName : "(none)");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected final Context mContext;
|
|
||||||
protected final LayoutInflater mInflater;
|
|
||||||
|
|
||||||
protected List<ApplicationInfo> mList;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static Comparator sDisplayNameComparator = new Comparator() {
|
|
||||||
public final int
|
public final int
|
||||||
compare(Object a, Object b)
|
compare(MyApplicationInfo a, MyApplicationInfo b) {
|
||||||
{
|
return collator.compare(a.label, b.label);
|
||||||
CharSequence sa = ((ApplicationInfo) a).packageName;
|
|
||||||
CharSequence sb = ((ApplicationInfo) b).packageName;
|
|
||||||
|
|
||||||
return collator.compare(sa, sb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Collator collator = Collator.getInstance();
|
private final Collator collator = Collator.getInstance();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import android.widget.Button;
|
|||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.Toast;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -58,6 +59,7 @@ public class DevelopmentSettings extends Activity {
|
|||||||
private CheckBox mShowBackgroundCB;
|
private CheckBox mShowBackgroundCB;
|
||||||
private CheckBox mShowSleepCB;
|
private CheckBox mShowSleepCB;
|
||||||
private CheckBox mShowXmppCB;
|
private CheckBox mShowXmppCB;
|
||||||
|
private CheckBox mCompatibilityModeCB;
|
||||||
private Spinner mMaxProcsSpinner;
|
private Spinner mMaxProcsSpinner;
|
||||||
private Spinner mWindowAnimationScaleSpinner;
|
private Spinner mWindowAnimationScaleSpinner;
|
||||||
private Spinner mTransitionAnimationScaleSpinner;
|
private Spinner mTransitionAnimationScaleSpinner;
|
||||||
@@ -69,6 +71,7 @@ public class DevelopmentSettings extends Activity {
|
|||||||
private int mProcessLimit;
|
private int mProcessLimit;
|
||||||
private boolean mShowSleep;
|
private boolean mShowSleep;
|
||||||
private boolean mShowXmpp;
|
private boolean mShowXmpp;
|
||||||
|
private boolean mCompatibilityMode;
|
||||||
private AnimationScaleSelectedListener mWindowAnimationScale
|
private AnimationScaleSelectedListener mWindowAnimationScale
|
||||||
= new AnimationScaleSelectedListener(0);
|
= new AnimationScaleSelectedListener(0);
|
||||||
private AnimationScaleSelectedListener mTransitionAnimationScale
|
private AnimationScaleSelectedListener mTransitionAnimationScale
|
||||||
@@ -106,6 +109,8 @@ public class DevelopmentSettings extends Activity {
|
|||||||
mShowSleepCB.setOnClickListener(mShowSleepClicked);
|
mShowSleepCB.setOnClickListener(mShowSleepClicked);
|
||||||
mShowXmppCB = (CheckBox)findViewById(R.id.show_xmpp);
|
mShowXmppCB = (CheckBox)findViewById(R.id.show_xmpp);
|
||||||
mShowXmppCB.setOnClickListener(mShowXmppClicked);
|
mShowXmppCB.setOnClickListener(mShowXmppClicked);
|
||||||
|
mCompatibilityModeCB = (CheckBox)findViewById(R.id.compatibility_mode);
|
||||||
|
mCompatibilityModeCB.setOnClickListener(mCompatibilityModeClicked);
|
||||||
mMaxProcsSpinner = (Spinner)findViewById(R.id.max_procs);
|
mMaxProcsSpinner = (Spinner)findViewById(R.id.max_procs);
|
||||||
mMaxProcsSpinner.setOnItemSelectedListener(mMaxProcsChanged);
|
mMaxProcsSpinner.setOnItemSelectedListener(mMaxProcsChanged);
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
|
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
|
||||||
@@ -169,6 +174,7 @@ public class DevelopmentSettings extends Activity {
|
|||||||
updateFlingerOptions();
|
updateFlingerOptions();
|
||||||
updateSleepOptions();
|
updateSleepOptions();
|
||||||
updateXmppOptions();
|
updateXmppOptions();
|
||||||
|
updateCompatibilityOptions();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
FileInputStream in = new FileInputStream( FONT_HINTING_FILE );
|
FileInputStream in = new FileInputStream( FONT_HINTING_FILE );
|
||||||
@@ -235,6 +241,17 @@ public class DevelopmentSettings extends Activity {
|
|||||||
Settings.System.SHOW_PROCESSES, 0) != 0);
|
Settings.System.SHOW_PROCESSES, 0) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writeCompatibilityOptions() {
|
||||||
|
Settings.System.putInt(getContentResolver(),
|
||||||
|
Settings.System.COMPATIBILITY_MODE, mCompatibilityMode ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCompatibilityOptions() {
|
||||||
|
mCompatibilityMode = Settings.System.getInt(
|
||||||
|
getContentResolver(), Settings.System.COMPATIBILITY_MODE, 1) == 0;
|
||||||
|
mCompatibilityModeCB.setChecked(mCompatibilityMode);
|
||||||
|
}
|
||||||
|
|
||||||
private void updateFlingerOptions() {
|
private void updateFlingerOptions() {
|
||||||
// magic communication with surface flinger.
|
// magic communication with surface flinger.
|
||||||
try {
|
try {
|
||||||
@@ -332,6 +349,19 @@ public class DevelopmentSettings extends Activity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private View.OnClickListener mCompatibilityModeClicked =
|
||||||
|
new View.OnClickListener() {
|
||||||
|
public void onClick(View v) {
|
||||||
|
mCompatibilityMode = ((CheckBox)v).isChecked();
|
||||||
|
writeCompatibilityOptions();
|
||||||
|
updateCompatibilityOptions();
|
||||||
|
Toast toast = Toast.makeText(DevelopmentSettings.this,
|
||||||
|
R.string.development_settings_compatibility_mode_toast,
|
||||||
|
Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private View.OnClickListener mShowLoadClicked = new View.OnClickListener() {
|
private View.OnClickListener mShowLoadClicked = new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean value = ((CheckBox)v).isChecked();
|
boolean value = ((CheckBox)v).isChecked();
|
||||||
|
|||||||
@@ -31,27 +31,38 @@ import android.os.Handler;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PackageBrowser extends ListActivity
|
public class PackageBrowser extends ListActivity {
|
||||||
{
|
static class MyPackageInfo {
|
||||||
|
PackageInfo info;
|
||||||
|
String label;
|
||||||
|
}
|
||||||
|
|
||||||
private PackageListAdapter mAdapter;
|
private PackageListAdapter mAdapter;
|
||||||
private List<PackageInfo> mPackageInfoList = null;
|
private List<MyPackageInfo> mPackageInfoList = new ArrayList<MyPackageInfo>();
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
|
private BroadcastReceiver mRegisteredReceiver;
|
||||||
|
|
||||||
public class PackageListAdapter extends ArrayAdapter<PackageInfo>
|
public class PackageListAdapter extends ArrayAdapter<MyPackageInfo> {
|
||||||
{
|
|
||||||
|
|
||||||
public PackageListAdapter(Context context)
|
public PackageListAdapter(Context context) {
|
||||||
{
|
super(context, R.layout.package_list_item);
|
||||||
super(context, android.R.layout.simple_list_item_1);
|
List<PackageInfo> pkgs = context.getPackageManager().getInstalledPackages(0);
|
||||||
mPackageInfoList = context.getPackageManager().getInstalledPackages(0);
|
for (int i=0; i<pkgs.size(); i++) {
|
||||||
|
MyPackageInfo info = new MyPackageInfo();
|
||||||
|
info.info = pkgs.get(i);
|
||||||
|
info.label = info.info.applicationInfo.loadLabel(getPackageManager()).toString();
|
||||||
|
mPackageInfoList.add(info);
|
||||||
|
}
|
||||||
if (mPackageInfoList != null) {
|
if (mPackageInfoList != null) {
|
||||||
Collections.sort(mPackageInfoList, sDisplayNameComparator);
|
Collections.sort(mPackageInfoList, sDisplayNameComparator);
|
||||||
}
|
}
|
||||||
@@ -59,10 +70,13 @@ public class PackageBrowser extends ListActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindView(View view, PackageInfo info)
|
public void bindView(View view, MyPackageInfo info) {
|
||||||
{
|
ImageView icon = (ImageView)view.findViewById(R.id.icon);
|
||||||
TextView text = (TextView)view.findViewById(android.R.id.text1);
|
TextView name = (TextView)view.findViewById(R.id.name);
|
||||||
text.setText(info.packageName);
|
TextView description = (TextView)view.findViewById(R.id.description);
|
||||||
|
icon.setImageDrawable(info.info.applicationInfo.loadIcon(getPackageManager()));
|
||||||
|
name.setText(info.label);
|
||||||
|
description.setText(info.info.packageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,13 +92,11 @@ public class PackageBrowser extends ListActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static Comparator sDisplayNameComparator = new Comparator() {
|
private final static Comparator<MyPackageInfo> sDisplayNameComparator
|
||||||
|
= new Comparator<MyPackageInfo>() {
|
||||||
public final int
|
public final int
|
||||||
compare(Object a, Object b)
|
compare(MyPackageInfo a, MyPackageInfo b) {
|
||||||
{
|
return collator.compare(a.label, b.label);
|
||||||
CharSequence sa = ((PackageInfo) a).packageName;
|
|
||||||
CharSequence sb = ((PackageInfo) b).packageName;
|
|
||||||
return collator.compare(sa, sb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Collator collator = Collator.getInstance();
|
private final Collator collator = Collator.getInstance();
|
||||||
@@ -98,6 +110,14 @@ public class PackageBrowser extends ListActivity
|
|||||||
registerIntentReceivers();
|
registerIntentReceivers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (mRegisteredReceiver != null) {
|
||||||
|
unregisterReceiver(mRegisteredReceiver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setupAdapter() {
|
private void setupAdapter() {
|
||||||
mAdapter = new PackageListAdapter(this);
|
mAdapter = new PackageListAdapter(this);
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
@@ -119,9 +139,9 @@ public class PackageBrowser extends ListActivity
|
|||||||
final int curSelection = getSelectedItemPosition();
|
final int curSelection = getSelectedItemPosition();
|
||||||
if (curSelection >= 0) {
|
if (curSelection >= 0) {
|
||||||
// todo: verification dialog for package deletion
|
// todo: verification dialog for package deletion
|
||||||
final PackageInfo packageInfo = mAdapter.itemForPosition(curSelection);
|
final MyPackageInfo packageInfo = mAdapter.itemForPosition(curSelection);
|
||||||
if (packageInfo != null) {
|
if (packageInfo != null) {
|
||||||
getPackageManager().deletePackage(packageInfo.packageName,
|
getPackageManager().deletePackage(packageInfo.info.packageName,
|
||||||
new IPackageDeleteObserver.Stub() {
|
new IPackageDeleteObserver.Stub() {
|
||||||
public void packageDeleted(boolean succeeded) throws RemoteException {
|
public void packageDeleted(boolean succeeded) throws RemoteException {
|
||||||
if (succeeded) {
|
if (succeeded) {
|
||||||
@@ -133,7 +153,7 @@ public class PackageBrowser extends ListActivity
|
|||||||
});
|
});
|
||||||
|
|
||||||
// todo: verification dialog for data directory
|
// todo: verification dialog for data directory
|
||||||
final String dataPath = packageInfo.applicationInfo.dataDir;
|
final String dataPath = packageInfo.info.applicationInfo.dataDir;
|
||||||
// todo: delete the data directory
|
// todo: delete the data directory
|
||||||
} else {
|
} else {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@@ -159,17 +179,17 @@ public class PackageBrowser extends ListActivity
|
|||||||
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||||
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
||||||
filter.addDataScheme("package");
|
filter.addDataScheme("package");
|
||||||
registerReceiver(new ApplicationsIntentReceiver(), filter);
|
mRegisteredReceiver = new ApplicationsIntentReceiver();
|
||||||
|
registerReceiver(mRegisteredReceiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id)
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
{
|
MyPackageInfo info =
|
||||||
PackageInfo info =
|
|
||||||
mAdapter.itemForPosition(position);
|
mAdapter.itemForPosition(position);
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
Intent intent = new Intent(
|
Intent intent = new Intent(
|
||||||
null, Uri.fromParts("package", info.packageName, null));
|
null, Uri.fromParts("package", info.info.packageName, null));
|
||||||
intent.setClass(this, PackageSummary.class);
|
intent.setClass(this, PackageSummary.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import android.content.pm.ServiceInfo;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
@@ -90,7 +91,8 @@ public class PackageSummary extends Activity {
|
|||||||
info = pm.getPackageInfo(mPackageName,
|
info = pm.getPackageInfo(mPackageName,
|
||||||
PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS
|
PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS
|
||||||
| PackageManager.GET_SERVICES | PackageManager.GET_PROVIDERS
|
| PackageManager.GET_SERVICES | PackageManager.GET_PROVIDERS
|
||||||
| PackageManager.GET_INSTRUMENTATION);
|
| PackageManager.GET_INSTRUMENTATION
|
||||||
|
| PackageManager.GET_DISABLED_COMPONENTS);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +194,7 @@ public class PackageSummary extends Activity {
|
|||||||
ActivityInfo ai = info.receivers[i];
|
ActivityInfo ai = info.receivers[i];
|
||||||
Button view = (Button)inflate.inflate(
|
Button view = (Button)inflate.inflate(
|
||||||
R.layout.package_item, null, false);
|
R.layout.package_item, null, false);
|
||||||
|
Log.i("foo", "Receiver #" + i + " of " + N + ": " + ai);
|
||||||
setItemText(view, info, ai.name);
|
setItemText(view, info, ai.name);
|
||||||
receivers.addView(view, lp);
|
receivers.addView(view, lp);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user