summaryrefslogtreecommitdiffstats
path: root/apps/Development/src/com/android/development
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2009-09-29 00:03:59 -0700
committerDianne Hackborn <hackbod@google.com>2009-09-29 00:03:59 -0700
commit5bc6141cb29913d344b4a7881956af8b5074f560 (patch)
treef1c33d50f65c526ae6d532a6eceefb1fa6ea0071 /apps/Development/src/com/android/development
parent8c77415ede684d89b738b3cf6cdaeaacd541eb87 (diff)
downloadandroid_development-5bc6141cb29913d344b4a7881956af8b5074f560.tar.gz
android_development-5bc6141cb29913d344b4a7881956af8b5074f560.tar.bz2
android_development-5bc6141cb29913d344b4a7881956af8b5074f560.zip
Add development setting for compatibility mode.
Also some cleanup here and there. Change-Id: Iebf563cf6ec2d0b1671a54bd534336e8fef4b9c0
Diffstat (limited to 'apps/Development/src/com/android/development')
-rw-r--r--apps/Development/src/com/android/development/AppPicker.java110
-rw-r--r--apps/Development/src/com/android/development/DevelopmentSettings.java32
-rw-r--r--apps/Development/src/com/android/development/PackageBrowser.java78
-rw-r--r--apps/Development/src/com/android/development/PackageSummary.java5
4 files changed, 127 insertions, 98 deletions
diff --git a/apps/Development/src/com/android/development/AppPicker.java b/apps/Development/src/com/android/development/AppPicker.java
index 693defbf9..28040c261 100644
--- a/apps/Development/src/com/android/development/AppPicker.java
+++ b/apps/Development/src/com/android/development/AppPicker.java
@@ -17,11 +17,14 @@
package com.android.development;
+import com.android.development.PackageBrowser.MyPackageInfo;
+
import android.app.ActivityManagerNative;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.os.RemoteException;
import android.provider.Settings;
@@ -29,10 +32,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.BaseAdapter;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import java.text.Collator;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -67,96 +72,67 @@ public class AppPicker extends ListActivity
@Override
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();
- if (app != null) intent.setAction(app.packageName);
+ if (app.info != null) intent.setAction(app.info.packageName);
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 {
boolean waitForDebugger = Settings.System.getInt(
getContentResolver(), Settings.System.WAIT_FOR_DEBUGGER, 0) != 0;
ActivityManagerNative.getDefault().setDebugApp(
- app != null ? app.packageName : null, waitForDebugger, true);
+ app.info != null ? app.info.packageName : null, waitForDebugger, true);
} catch (RemoteException ex) {
}
finish();
}
- private final class AppListAdapter extends BaseAdapter
- {
- public AppListAdapter(Context context)
- {
- 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);
- }
- }
+ class MyApplicationInfo {
+ ApplicationInfo info;
+ String label;
+ }
- public ApplicationInfo appForPosition(int position)
- {
- if (mList == null) {
- return null;
+ public class AppListAdapter extends ArrayAdapter<MyApplicationInfo> {
+ private List<MyApplicationInfo> mPackageInfoList = new ArrayList<MyApplicationInfo>();
+
+ 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);
}
-
- return mList.get(position);
- }
-
- public int getCount()
- {
- return mList != null ? mList.size() : 0;
- }
-
- public Object getItem(int position)
- {
- return position;
- }
-
- public long getItemId(int position)
- {
- return position;
+ Collections.sort(mPackageInfoList, sDisplayNameComparator);
+ MyApplicationInfo info = new MyApplicationInfo();
+ info.label = "(none)";
+ mPackageInfoList.add(0, info);
+ setSource(mPackageInfoList);
}
- 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);
+ @Override
+ public void bindView(View view, MyApplicationInfo info) {
+ ImageView icon = (ImageView)view.findViewById(R.id.icon);
+ TextView name = (TextView)view.findViewById(R.id.name);
+ TextView description = (TextView)view.findViewById(R.id.description);
+ name.setText(info.label);
+ if (info.info != null) {
+ icon.setImageDrawable(info.info.loadIcon(getPackageManager()));
+ description.setText(info.info.packageName);
} else {
- view = convertView;
+ icon.setImageDrawable(null);
+ description.setText("");
}
- bindView(view, mList.get(position));
- return view;
- }
-
- private final void bindView(View view, ApplicationInfo info)
- {
- 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() {
+ private final static Comparator<MyApplicationInfo> sDisplayNameComparator
+ = new Comparator<MyApplicationInfo>() {
public final int
- compare(Object a, Object b)
- {
- CharSequence sa = ((ApplicationInfo) a).packageName;
- CharSequence sb = ((ApplicationInfo) b).packageName;
-
- return collator.compare(sa, sb);
+ compare(MyApplicationInfo a, MyApplicationInfo b) {
+ return collator.compare(a.label, b.label);
}
private final Collator collator = Collator.getInstance();
diff --git a/apps/Development/src/com/android/development/DevelopmentSettings.java b/apps/Development/src/com/android/development/DevelopmentSettings.java
index 3b4848a4c..9cb6fc639 100644
--- a/apps/Development/src/com/android/development/DevelopmentSettings.java
+++ b/apps/Development/src/com/android/development/DevelopmentSettings.java
@@ -38,6 +38,7 @@ import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Spinner;
+import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;
import java.io.FileInputStream;
@@ -58,6 +59,7 @@ public class DevelopmentSettings extends Activity {
private CheckBox mShowBackgroundCB;
private CheckBox mShowSleepCB;
private CheckBox mShowXmppCB;
+ private CheckBox mCompatibilityModeCB;
private Spinner mMaxProcsSpinner;
private Spinner mWindowAnimationScaleSpinner;
private Spinner mTransitionAnimationScaleSpinner;
@@ -69,6 +71,7 @@ public class DevelopmentSettings extends Activity {
private int mProcessLimit;
private boolean mShowSleep;
private boolean mShowXmpp;
+ private boolean mCompatibilityMode;
private AnimationScaleSelectedListener mWindowAnimationScale
= new AnimationScaleSelectedListener(0);
private AnimationScaleSelectedListener mTransitionAnimationScale
@@ -106,6 +109,8 @@ public class DevelopmentSettings extends Activity {
mShowSleepCB.setOnClickListener(mShowSleepClicked);
mShowXmppCB = (CheckBox)findViewById(R.id.show_xmpp);
mShowXmppCB.setOnClickListener(mShowXmppClicked);
+ mCompatibilityModeCB = (CheckBox)findViewById(R.id.compatibility_mode);
+ mCompatibilityModeCB.setOnClickListener(mCompatibilityModeClicked);
mMaxProcsSpinner = (Spinner)findViewById(R.id.max_procs);
mMaxProcsSpinner.setOnItemSelectedListener(mMaxProcsChanged);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
@@ -168,7 +173,8 @@ public class DevelopmentSettings extends Activity {
updateSharedOptions();
updateFlingerOptions();
updateSleepOptions();
- updateXmppOptions();
+ updateXmppOptions();
+ updateCompatibilityOptions();
try {
FileInputStream in = new FileInputStream( FONT_HINTING_FILE );
@@ -235,6 +241,17 @@ public class DevelopmentSettings extends Activity {
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() {
// magic communication with surface flinger.
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() {
public void onClick(View v) {
boolean value = ((CheckBox)v).isChecked();
diff --git a/apps/Development/src/com/android/development/PackageBrowser.java b/apps/Development/src/com/android/development/PackageBrowser.java
index e4c233f7d..689183db6 100644
--- a/apps/Development/src/com/android/development/PackageBrowser.java
+++ b/apps/Development/src/com/android/development/PackageBrowser.java
@@ -31,27 +31,38 @@ import android.os.Handler;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import java.text.Collator;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
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 List<PackageInfo> mPackageInfoList = null;
+ private List<MyPackageInfo> mPackageInfoList = new ArrayList<MyPackageInfo>();
private Handler mHandler;
-
- public class PackageListAdapter extends ArrayAdapter<PackageInfo>
- {
-
- public PackageListAdapter(Context context)
- {
- super(context, android.R.layout.simple_list_item_1);
- mPackageInfoList = context.getPackageManager().getInstalledPackages(0);
+ private BroadcastReceiver mRegisteredReceiver;
+
+ public class PackageListAdapter extends ArrayAdapter<MyPackageInfo> {
+
+ public PackageListAdapter(Context context) {
+ super(context, R.layout.package_list_item);
+ List<PackageInfo> pkgs = 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) {
Collections.sort(mPackageInfoList, sDisplayNameComparator);
}
@@ -59,10 +70,13 @@ public class PackageBrowser extends ListActivity
}
@Override
- public void bindView(View view, PackageInfo info)
- {
- TextView text = (TextView)view.findViewById(android.R.id.text1);
- text.setText(info.packageName);
+ public void bindView(View view, MyPackageInfo info) {
+ ImageView icon = (ImageView)view.findViewById(R.id.icon);
+ TextView name = (TextView)view.findViewById(R.id.name);
+ 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
- compare(Object a, Object b)
- {
- CharSequence sa = ((PackageInfo) a).packageName;
- CharSequence sb = ((PackageInfo) b).packageName;
- return collator.compare(sa, sb);
+ compare(MyPackageInfo a, MyPackageInfo b) {
+ return collator.compare(a.label, b.label);
}
private final Collator collator = Collator.getInstance();
@@ -98,6 +110,14 @@ public class PackageBrowser extends ListActivity
registerIntentReceivers();
}
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (mRegisteredReceiver != null) {
+ unregisterReceiver(mRegisteredReceiver);
+ }
+ }
+
private void setupAdapter() {
mAdapter = new PackageListAdapter(this);
setListAdapter(mAdapter);
@@ -119,9 +139,9 @@ public class PackageBrowser extends ListActivity
final int curSelection = getSelectedItemPosition();
if (curSelection >= 0) {
// todo: verification dialog for package deletion
- final PackageInfo packageInfo = mAdapter.itemForPosition(curSelection);
+ final MyPackageInfo packageInfo = mAdapter.itemForPosition(curSelection);
if (packageInfo != null) {
- getPackageManager().deletePackage(packageInfo.packageName,
+ getPackageManager().deletePackage(packageInfo.info.packageName,
new IPackageDeleteObserver.Stub() {
public void packageDeleted(boolean succeeded) throws RemoteException {
if (succeeded) {
@@ -133,7 +153,7 @@ public class PackageBrowser extends ListActivity
});
// todo: verification dialog for data directory
- final String dataPath = packageInfo.applicationInfo.dataDir;
+ final String dataPath = packageInfo.info.applicationInfo.dataDir;
// todo: delete the data directory
} else {
mHandler.post(new Runnable() {
@@ -159,17 +179,17 @@ public class PackageBrowser extends ListActivity
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
filter.addDataScheme("package");
- registerReceiver(new ApplicationsIntentReceiver(), filter);
+ mRegisteredReceiver = new ApplicationsIntentReceiver();
+ registerReceiver(mRegisteredReceiver, filter);
}
@Override
- protected void onListItemClick(ListView l, View v, int position, long id)
- {
- PackageInfo info =
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ MyPackageInfo info =
mAdapter.itemForPosition(position);
if (info != null) {
Intent intent = new Intent(
- null, Uri.fromParts("package", info.packageName, null));
+ null, Uri.fromParts("package", info.info.packageName, null));
intent.setClass(this, PackageSummary.class);
startActivity(intent);
}
diff --git a/apps/Development/src/com/android/development/PackageSummary.java b/apps/Development/src/com/android/development/PackageSummary.java
index a6bbbb227..5610559e5 100644
--- a/apps/Development/src/com/android/development/PackageSummary.java
+++ b/apps/Development/src/com/android/development/PackageSummary.java
@@ -31,6 +31,7 @@ import android.content.pm.ServiceInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
@@ -90,7 +91,8 @@ public class PackageSummary extends Activity {
info = pm.getPackageInfo(mPackageName,
PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS
| PackageManager.GET_SERVICES | PackageManager.GET_PROVIDERS
- | PackageManager.GET_INSTRUMENTATION);
+ | PackageManager.GET_INSTRUMENTATION
+ | PackageManager.GET_DISABLED_COMPONENTS);
} catch (PackageManager.NameNotFoundException e) {
}
@@ -192,6 +194,7 @@ public class PackageSummary extends Activity {
ActivityInfo ai = info.receivers[i];
Button view = (Button)inflate.inflate(
R.layout.package_item, null, false);
+ Log.i("foo", "Receiver #" + i + " of " + N + ": " + ai);
setItemText(view, info, ai.name);
receivers.addView(view, lp);
}