Merge change 27154 into eclair
* changes:
When change from narrow screen to wide screen, we will leave the mMinZoomScale to 1.0
diff --git a/api/current.xml b/api/current.xml
index 37fb3a8..b430e2c 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -23166,6 +23166,21 @@
<parameter name="id" type="int">
</parameter>
</method>
+<method name="cancel"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="tag" type="java.lang.String">
+</parameter>
+<parameter name="id" type="int">
+</parameter>
+</method>
<method name="cancelAll"
return="void"
abstract="false"
@@ -23192,6 +23207,23 @@
<parameter name="notification" type="android.app.Notification">
</parameter>
</method>
+<method name="notify"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="tag" type="java.lang.String">
+</parameter>
+<parameter name="id" type="int">
+</parameter>
+<parameter name="notification" type="android.app.Notification">
+</parameter>
+</method>
</class>
<class name="PendingIntent"
extends="java.lang.Object"
@@ -41594,6 +41626,19 @@
<parameter name="appInfo" type="android.content.pm.ApplicationInfo">
</parameter>
</method>
+<method name="hasSystemFeature"
+ return="boolean"
+ abstract="true"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="name" type="java.lang.String">
+</parameter>
+</method>
<method name="isSafeMode"
return="boolean"
abstract="true"
@@ -125237,6 +125282,28 @@
visibility="public"
>
</field>
+<field name="NETWORK_TYPE_1xRTT"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="7"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="NETWORK_TYPE_CDMA"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="4"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="NETWORK_TYPE_EDGE"
type="int"
transient="false"
@@ -125248,6 +125315,28 @@
visibility="public"
>
</field>
+<field name="NETWORK_TYPE_EVDO_0"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="5"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="NETWORK_TYPE_EVDO_A"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="6"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="NETWORK_TYPE_GPRS"
type="int"
transient="false"
@@ -125259,6 +125348,39 @@
visibility="public"
>
</field>
+<field name="NETWORK_TYPE_HSDPA"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="8"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="NETWORK_TYPE_HSPA"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="10"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
+<field name="NETWORK_TYPE_HSUPA"
+ type="int"
+ transient="false"
+ volatile="false"
+ value="9"
+ static="true"
+ final="true"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</field>
<field name="NETWORK_TYPE_UMTS"
type="int"
transient="false"
@@ -131268,6 +131390,19 @@
<parameter name="appInfo" type="android.content.pm.ApplicationInfo">
</parameter>
</method>
+<method name="hasSystemFeature"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="name" type="java.lang.String">
+</parameter>
+</method>
<method name="isSafeMode"
return="boolean"
abstract="false"
@@ -196760,7 +196895,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="AllocationLimitError"
@@ -196966,7 +197101,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="PotentialDeadlockError"
@@ -196993,7 +197128,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="StaleDexCacheError"
@@ -197020,7 +197155,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="TemporaryDirectory"
@@ -197063,7 +197198,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="TouchDex"
@@ -197106,7 +197241,7 @@
abstract="false"
static="false"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<method name="dumpHprofData"
@@ -197610,7 +197745,7 @@
abstract="false"
static="false"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<method name="gcSoftReferences"
@@ -197711,7 +197846,7 @@
abstract="false"
static="false"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="VMStack"
@@ -197778,7 +197913,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<method name="fork"
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 7adaf57..79eb310b 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -18,6 +18,7 @@
import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
+import android.content.pm.FeatureInfo;
import android.content.pm.IPackageDeleteObserver;
import android.content.pm.IPackageInstallObserver;
import android.content.pm.IPackageManager;
@@ -34,6 +35,8 @@
import android.os.ServiceManager;
import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -42,21 +45,21 @@
public final class Pm {
IPackageManager mPm;
-
+
private WeakHashMap<String, Resources> mResourceCache
= new WeakHashMap<String, Resources>();
-
+
private String[] mArgs;
private int mNextArg;
private String mCurArgData;
-
- private static final String PM_NOT_RUNNING_ERR =
+
+ private static final String PM_NOT_RUNNING_ERR =
"Error: Could not access the Package Manager. Is the system running?";
-
+
public static void main(String[] args) {
new Pm().run(args);
}
-
+
public void run(String[] args) {
boolean validCommand = false;
if (args.length < 1) {
@@ -73,37 +76,37 @@
mArgs = args;
String op = args[0];
mNextArg = 1;
-
+
if ("list".equals(op)) {
runList();
return;
}
-
+
if ("path".equals(op)) {
runPath();
return;
}
-
+
if ("install".equals(op)) {
runInstall();
return;
}
-
+
if ("uninstall".equals(op)) {
runUninstall();
return;
}
-
+
if ("enable".equals(op)) {
runSetEnabledSetting(PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
return;
}
-
+
if ("disable".equals(op)) {
runSetEnabledSetting(PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
return;
}
-
+
try {
if (args.length == 1) {
if (args[0].equalsIgnoreCase("-l")) {
@@ -128,13 +131,14 @@
}
}
}
-
+
/**
* Execute the list sub-command.
- *
+ *
* pm list [package | packages]
* pm list permission-groups
* pm list permissions
+ * pm list features
* pm list instrumentation
*/
private void runList() {
@@ -150,6 +154,8 @@
runListPermissionGroups();
} else if ("permissions".equals(type)) {
runListPermissions();
+ } else if ("features".equals(type)) {
+ runListFeatures();
} else if ("instrumentation".equals(type)) {
runListInstrumentation();
} else {
@@ -157,7 +163,7 @@
showUsage();
}
}
-
+
/**
* Lists all the installed packages.
*/
@@ -182,10 +188,10 @@
showUsage();
return;
}
-
+
try {
List<PackageInfo> packages = mPm.getInstalledPackages(0 /* all */);
-
+
int count = packages.size();
for (int p = 0 ; p < count ; p++) {
PackageInfo info = packages.get(p);
@@ -201,10 +207,48 @@
System.err.println(PM_NOT_RUNNING_ERR);
}
}
-
+
+ /**
+ * Lists all of the features supported by the current device.
+ *
+ * pm list features
+ */
+ private void runListFeatures() {
+ try {
+ List<FeatureInfo> list = new ArrayList<FeatureInfo>();
+ FeatureInfo[] rawList = mPm.getSystemAvailableFeatures();
+ for (int i=0; i<rawList.length; i++) {
+ list.add(rawList[i]);
+ }
+
+
+ // Sort by name
+ Collections.sort(list, new Comparator<FeatureInfo>() {
+ public int compare(FeatureInfo o1, FeatureInfo o2) {
+ if (o1.name == o2.name) return 0;
+ if (o1.name == null) return -1;
+ if (o2.name == null) return 1;
+ return o1.name.compareTo(o2.name);
+ }
+ });
+
+ int count = (list != null) ? list.size() : 0;
+ for (int p = 0; p < count; p++) {
+ FeatureInfo fi = list.get(p);
+ System.out.print("feature:");
+ if (fi.name != null) System.out.println(fi.name);
+ else System.out.println("reqGlEsVersion=0x"
+ + Integer.toHexString(fi.reqGlEsVersion));
+ }
+ } catch (RemoteException e) {
+ System.err.println(e.toString());
+ System.err.println(PM_NOT_RUNNING_ERR);
+ }
+ }
+
/**
* Lists all of the installed instrumentation, or all for a given package
- *
+ *
* pm list instrumentation [package] [-f]
*/
private void runListInstrumentation() {
@@ -260,14 +304,14 @@
System.err.println(PM_NOT_RUNNING_ERR);
}
}
-
+
/**
* Lists all the known permission groups.
*/
private void runListPermissionGroups() {
try {
List<PermissionGroupInfo> pgs = mPm.getAllPermissionGroups(0);
-
+
int count = pgs.size();
for (int p = 0 ; p < count ; p++) {
PermissionGroupInfo pgi = pgs.get(p);
@@ -279,7 +323,7 @@
System.err.println(PM_NOT_RUNNING_ERR);
}
}
-
+
private String loadText(PackageItemInfo pii, int res, CharSequence nonLocalized) {
if (nonLocalized != null) {
return nonLocalized.toString();
@@ -290,7 +334,7 @@
}
return null;
}
-
+
/**
* Lists all the permissions in a group.
*/
@@ -321,7 +365,7 @@
return;
}
}
-
+
String grp = nextOption();
ArrayList<String> groupList = new ArrayList<String>();
if (groups) {
@@ -334,7 +378,7 @@
} else {
groupList.add(grp);
}
-
+
if (dangerousOnly) {
System.out.println("Dangerous Permissions:");
System.out.println("");
@@ -365,7 +409,7 @@
System.err.println(PM_NOT_RUNNING_ERR);
}
}
-
+
private void doListPermissions(ArrayList<String> groupList,
boolean groups, boolean labels, boolean summary,
int startProtectionLevel, int endProtectionLevel)
@@ -385,7 +429,7 @@
pgi.nonLocalizedLabel) + ": ");
} else {
System.out.print(pgi.name + ": ");
-
+
}
} else {
System.out.println((labels ? "+ " : "")
@@ -468,13 +512,13 @@
}
}
}
-
+
if (summary) {
System.out.println("");
}
}
}
-
+
private void runPath() {
String pkg = nextArg();
if (pkg == null) {
@@ -484,7 +528,7 @@
}
displayPackageFilePath(pkg);
}
-
+
class PackageInstallObserver extends IPackageInstallObserver.Stub {
boolean finished;
int result;
@@ -497,95 +541,40 @@
}
}
}
-
+
+ /**
+ * Converts a failure code into a string by using reflection to find a matching constant
+ * in PackageManager.
+ */
private String installFailureToString(int result) {
- String s;
- switch (result) {
- case PackageManager.INSTALL_FAILED_ALREADY_EXISTS:
- s = "INSTALL_FAILED_ALREADY_EXISTS";
- break;
- case PackageManager.INSTALL_FAILED_INVALID_APK:
- s = "INSTALL_FAILED_INVALID_APK";
- break;
- case PackageManager.INSTALL_FAILED_INVALID_URI:
- s = "INSTALL_FAILED_INVALID_URI";
- break;
- case PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE:
- s = "INSTALL_FAILED_INSUFFICIENT_STORAGE";
- break;
- case PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE:
- s = "INSTALL_FAILED_DUPLICATE_PACKAGE";
- break;
- case PackageManager.INSTALL_FAILED_NO_SHARED_USER:
- s = "INSTALL_FAILED_NO_SHARED_USER";
- break;
- case PackageManager.INSTALL_FAILED_UPDATE_INCOMPATIBLE:
- s = "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
- break;
- case PackageManager.INSTALL_FAILED_SHARED_USER_INCOMPATIBLE:
- s = "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
- break;
- case PackageManager.INSTALL_FAILED_MISSING_SHARED_LIBRARY:
- s = "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
- break;
- case PackageManager.INSTALL_FAILED_DEXOPT:
- s = "INSTALL_FAILED_DEXOPT";
- break;
- case PackageManager.INSTALL_FAILED_OLDER_SDK:
- s = "INSTALL_FAILED_OLDER_SDK";
- break;
- case PackageManager.INSTALL_FAILED_CONFLICTING_PROVIDER:
- s = "INSTALL_FAILED_CONFLICTING_PROVIDER";
- break;
- case PackageManager.INSTALL_FAILED_NEWER_SDK:
- s = "INSTALL_FAILED_NEWER_SDK";
- break;
- case PackageManager.INSTALL_FAILED_TEST_ONLY:
- s = "INSTALL_FAILED_TEST_ONLY";
- break;
- case PackageManager.INSTALL_FAILED_CPU_ABI_INCOMPATIBLE:
- s = "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
- break;
- case PackageManager.INSTALL_FAILED_MISSING_FEATURE:
- s = "INSTALL_FAILED_MISSING_FEATURE";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_NOT_APK:
- s = "INSTALL_PARSE_FAILED_NOT_APK";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_BAD_MANIFEST:
- s = "INSTALL_PARSE_FAILED_BAD_MANIFEST";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION:
- s = "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_NO_CERTIFICATES:
- s = "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES:
- s = "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING:
- s = "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME:
- s = "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID:
- s = "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED:
- s = "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
- break;
- case PackageManager.INSTALL_PARSE_FAILED_MANIFEST_EMPTY:
- s = "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
- break;
- default:
- s = Integer.toString(result);
- break;
+ Field[] fields = PackageManager.class.getFields();
+ for (Field f: fields) {
+ if (f.getType() == int.class) {
+ int modifiers = f.getModifiers();
+ // only look at public final static fields.
+ if (((modifiers & Modifier.FINAL) != 0) &&
+ ((modifiers & Modifier.PUBLIC) != 0) &&
+ ((modifiers & Modifier.STATIC) != 0)) {
+ String fieldName = f.getName();
+ if (fieldName.startsWith("INSTALL_FAILED_") ||
+ fieldName.startsWith("INSTALL_PARSE_FAILED_")) {
+ // get the int value and compare it to result.
+ try {
+ if (result == f.getInt(null)) {
+ return fieldName;
+ }
+ } catch (IllegalAccessException e) {
+ // this shouldn't happen since we only look for public static fields.
+ }
+ }
+ }
+ }
}
- return s;
+
+ // couldn't find a matching constant? return the value
+ return Integer.toString(result);
}
-
+
private void runInstall() {
int installFlags = 0;
String installerPackageName = null;
@@ -624,7 +613,7 @@
try {
mPm.installPackage(Uri.fromFile(new File(apkFilePath)), obs, installFlags,
installerPackageName);
-
+
synchronized (obs) {
while (!obs.finished) {
try {
@@ -645,11 +634,11 @@
System.err.println(PM_NOT_RUNNING_ERR);
}
}
-
+
class PackageDeleteObserver extends IPackageDeleteObserver.Stub {
boolean finished;
boolean result;
-
+
public void packageDeleted(boolean succeeded) {
synchronized (this) {
finished = true;
@@ -658,7 +647,7 @@
}
}
}
-
+
private void runUninstall() {
int unInstallFlags = 0;
@@ -712,7 +701,7 @@
}
return "unknown";
}
-
+
private void runSetEnabledSetting(int state) {
String pkg = nextArg();
if (pkg == null) {
@@ -760,11 +749,11 @@
System.err.println(PM_NOT_RUNNING_ERR);
}
}
-
+
private Resources getResources(PackageItemInfo pii) {
Resources res = mResourceCache.get(pii.packageName);
if (res != null) return res;
-
+
try {
ApplicationInfo ai = mPm.getApplicationInfo(pii.packageName, 0);
AssetManager am = new AssetManager();
@@ -778,7 +767,7 @@
return null;
}
}
-
+
private String nextOption() {
if (mNextArg >= mArgs.length) {
return null;
@@ -830,7 +819,8 @@
System.err.println(" pm list packages [-f]");
System.err.println(" pm list permission-groups");
System.err.println(" pm list permissions [-g] [-f] [-d] [-u] [GROUP]");
- System.err.println(" pm list instrumentation [-f] [TARGET-PACKAGE]");
+ System.err.println(" pm list instrumentation [-f] [TARGET-PACKAGE]");
+ System.err.println(" pm list features");
System.err.println(" pm path PACKAGE");
System.err.println(" pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] PATH");
System.err.println(" pm uninstall [-k] PACKAGE");
@@ -855,6 +845,8 @@
System.err.println("or only those that target a specified package. Options:");
System.err.println(" -f: see their associated file.");
System.err.println("");
+ System.err.println("The list features command prints all features of the system.");
+ System.err.println("");
System.err.println("The path command prints the path to the .apk of a package.");
System.err.println("");
System.err.println("The install command installs a package to the system. Options:");
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 2bb8480..9095ec9 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -3020,9 +3020,9 @@
* or {@link #finish} to specify an explicit transition animation to
* perform next.
* @param enterAnim A resource ID of the animation resource to use for
- * the incoming activity.
+ * the incoming activity. Use 0 for no animation.
* @param exitAnim A resource ID of the animation resource to use for
- * the outgoing activity.
+ * the outgoing activity. Use 0 for no animation.
*/
public void overridePendingTransition(int enterAnim, int exitAnim) {
try {
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 65d6eb9..76a133b 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -2951,8 +2951,8 @@
// The window is now visible if it has been added, we are not
// simply finishing, and we are not starting another activity.
- if (!r.activity.mFinished && r.activity.mDecor != null
- && !r.hideForNow) {
+ if (!r.activity.mFinished && !a.mStartedActivity
+ && r.activity.mDecor != null && !r.hideForNow) {
if (r.newConfig != null) {
performConfigurationChanged(r.activity, r.newConfig);
r.newConfig = null;
@@ -2966,9 +2966,11 @@
l.softInputMode = (l.softInputMode
& (~WindowManager.LayoutParams.SOFT_INPUT_IS_FORWARD_NAVIGATION))
| forwardBit;
- ViewManager wm = a.getWindowManager();
- View decor = r.window.getDecorView();
- wm.updateViewLayout(decor, l);
+ if (r.activity.mVisibleFromClient) {
+ ViewManager wm = a.getWindowManager();
+ View decor = r.window.getDecorView();
+ wm.updateViewLayout(decor, l);
+ }
}
r.activity.mVisibleFromServer = true;
mNumVisibleActivities++;
diff --git a/core/java/android/app/ApplicationContext.java b/core/java/android/app/ApplicationContext.java
index 8896015..0582e34 100644
--- a/core/java/android/app/ApplicationContext.java
+++ b/core/java/android/app/ApplicationContext.java
@@ -1686,6 +1686,15 @@
}
@Override
+ public boolean hasSystemFeature(String name) {
+ try {
+ return mPM.hasSystemFeature(name);
+ } catch (RemoteException e) {
+ throw new RuntimeException("Package manager has died", e);
+ }
+ }
+
+ @Override
public int checkPermission(String permName, String pkgName) {
try {
return mPM.checkPermission(permName, pkgName);
diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl
index c1035b6..4d5238c 100644
--- a/core/java/android/app/INotificationManager.aidl
+++ b/core/java/android/app/INotificationManager.aidl
@@ -24,11 +24,15 @@
/** {@hide} */
interface INotificationManager
{
+ /** @deprecated use {@link #enqueueNotificationWithTag} instead */
void enqueueNotification(String pkg, int id, in Notification notification, inout int[] idReceived);
+ /** @deprecated use {@link #cancelNotificationWithTag} instead */
void cancelNotification(String pkg, int id);
void cancelAllNotifications(String pkg);
void enqueueToast(String pkg, ITransientNotification callback, int duration);
void cancelToast(String pkg, ITransientNotification callback);
+ void enqueueNotificationWithTag(String pkg, String tag, int id, in Notification notification, inout int[] idReceived);
+ void cancelNotificationWithTag(String pkg, String tag, int id);
}
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index 7b51fdf..6fe12fc 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -87,12 +87,27 @@
*/
public void notify(int id, Notification notification)
{
+ notify(null, id, notification);
+ }
+
+ /**
+ * Persistent notification on the status bar,
+ *
+ * @param tag An string identifier for this notification unique within your
+ * application.
+ * @param notification A {@link Notification} object describing how to
+ * notify the user, other than the view you're providing. Must not be null.
+ * @return the id of the notification that is associated with the string identifier that
+ * can be used to cancel the notification
+ */
+ public void notify(String tag, int id, Notification notification)
+ {
int[] idOut = new int[1];
INotificationManager service = getService();
String pkg = mContext.getPackageName();
if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")");
try {
- service.enqueueNotification(pkg, id, notification, idOut);
+ service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut);
if (id != idOut[0]) {
Log.w(TAG, "notify: id corrupted: sent " + id + ", got back " + idOut[0]);
}
@@ -107,11 +122,21 @@
*/
public void cancel(int id)
{
+ cancel(null, id);
+ }
+
+ /**
+ * Cancel a previously shown notification. If it's transient, the view
+ * will be hidden. If it's persistent, it will be removed from the status
+ * bar.
+ */
+ public void cancel(String tag, int id)
+ {
INotificationManager service = getService();
String pkg = mContext.getPackageName();
if (localLOGV) Log.v(TAG, pkg + ": cancel(" + id + ")");
try {
- service.cancelNotification(pkg, id);
+ service.cancelNotificationWithTag(pkg, tag, id);
} catch (RemoteException e) {
}
}
diff --git a/core/java/android/content/SyncManager.java b/core/java/android/content/SyncManager.java
index 1c61324d..6181a07 100644
--- a/core/java/android/content/SyncManager.java
+++ b/core/java/android/content/SyncManager.java
@@ -2092,6 +2092,7 @@
clickIntent.setClassName("com.android.providers.subscribedfeeds",
"com.android.settings.SyncActivityTooManyDeletes");
clickIntent.putExtra("account", account);
+ clickIntent.putExtra("authority", authority);
clickIntent.putExtra("provider", authorityName.toString());
clickIntent.putExtra("numDeletes", numDeletes);
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index c322951..fc6538f 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -283,6 +283,8 @@
*/
FeatureInfo[] getSystemAvailableFeatures();
+ boolean hasSystemFeature(String name);
+
void enterSafeMode();
boolean isSafeMode();
void systemReady();
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 825eb85..cd48dcb 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -995,11 +995,19 @@
*
* @return An array of FeatureInfo classes describing the features
* that are available on the system, or null if there are none(!!).
- *
*/
public abstract FeatureInfo[] getSystemAvailableFeatures();
/**
+ * Check whether the given feature name is one of the available
+ * features as returned by {@link #getSystemAvailableFeatures()}.
+ *
+ * @return Returns true if the devices supports the feature, else
+ * false.
+ */
+ public abstract boolean hasSystemFeature(String name);
+
+ /**
* Determine the best action to perform for a given Intent. This is how
* {@link Intent#resolveActivity} finds an activity if a class has not
* been explicitly specified.
diff --git a/core/java/android/net/MobileDataStateTracker.java b/core/java/android/net/MobileDataStateTracker.java
index d8db4c1..709766b 100644
--- a/core/java/android/net/MobileDataStateTracker.java
+++ b/core/java/android/net/MobileDataStateTracker.java
@@ -157,7 +157,8 @@
// if we're not enabled but the APN Type is supported by this connection
// we should record the interface name if one's provided. If the user
// turns on this network we will need the interfacename but won't get
- // a fresh connected message - TODO fix this..
+ // a fresh connected message - TODO fix this when we get per-APN
+ // notifications
if (state == Phone.DataState.CONNECTED) {
if (DBG) Log.d(TAG, "replacing old mInterfaceName (" +
mInterfaceName + ") with " +
@@ -186,10 +187,13 @@
if (mInterfaceName != null) {
NetworkUtils.resetConnections(mInterfaceName);
}
- if (DBG) Log.d(TAG, "clearing mInterfaceName for "+ mApnType +
- " as it DISCONNECTED");
- mInterfaceName = null;
- mDefaultGatewayAddr = 0;
+ // can't do this here - ConnectivityService needs it to clear stuff
+ // it's ok though - just leave it to be refreshed next time
+ // we connect.
+ //if (DBG) Log.d(TAG, "clearing mInterfaceName for "+ mApnType +
+ // " as it DISCONNECTED");
+ //mInterfaceName = null;
+ //mDefaultGatewayAddr = 0;
break;
case CONNECTING:
setDetailedState(DetailedState.CONNECTING, reason, apnName);
@@ -310,6 +314,11 @@
*/
@Override
public boolean teardown() {
+ // since we won't get a notification currently (TODO - per APN notifications)
+ // we won't get a disconnect message until all APN's on the current connection's
+ // APN list are disabled. That means privateRoutes for DNS and such will remain on -
+ // not a problem since that's all shared with whatever other APN is still on, but
+ // ugly.
setTeardownRequested(true);
return (setEnableApn(mApnType, false) != Phone.APN_REQUEST_FAILED);
}
@@ -321,6 +330,7 @@
setTeardownRequested(false);
switch (setEnableApn(mApnType, true)) {
case Phone.APN_ALREADY_ACTIVE:
+ // TODO - remove this when we get per-apn notifications
mEnabled = true;
// need to set self to CONNECTING so the below message is handled.
mMobileDataState = Phone.DataState.CONNECTING;
diff --git a/core/java/android/net/NetworkStateTracker.java b/core/java/android/net/NetworkStateTracker.java
index 54529ae..d3e4ea5 100644
--- a/core/java/android/net/NetworkStateTracker.java
+++ b/core/java/android/net/NetworkStateTracker.java
@@ -124,11 +124,12 @@
public void addPrivateDnsRoutes() {
if (DBG) Log.d(TAG, "addPrivateDnsRoutes for " + this +
- "(" + mInterfaceName + ")");
+ "(" + mInterfaceName + ") - mPrivateDnsRouteSet = "+mPrivateDnsRouteSet);
if (mInterfaceName != null && !mPrivateDnsRouteSet) {
for (String addrString : getNameServers()) {
int addr = NetworkUtils.lookupHost(addrString);
- if (addr != -1) {
+ if (addr != -1 && addr != 0) {
+ if (DBG) Log.d(TAG, " adding "+addrString+" ("+addr+")");
NetworkUtils.addHostRoute(mInterfaceName, addr);
}
}
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index b4778fe..b9f78a1 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -146,6 +146,9 @@
* <li> The {@link android.app.Activity} class will now execute back
* key presses on the key up instead of key down, to be able to detect
* canceled presses from virtual keys.
+ * <li> The {@link android.widget.TabWidget} class will use a new color scheme
+ * for tabs. In the new scheme, the foreground tab has a medium gray background
+ * the background tabs have a dark gray background.
* </ul>
*/
public static final int ECLAIR = CUR_DEVELOPMENT;
diff --git a/core/java/android/provider/ContactsContract.java b/core/java/android/provider/ContactsContract.java
index e32d3ad..cd03869 100644
--- a/core/java/android/provider/ContactsContract.java
+++ b/core/java/android/provider/ContactsContract.java
@@ -434,29 +434,6 @@
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/contact";
/**
- * An optional query parameter added to {@link Groups#CONTENT_URI} or
- * {@link Settings#CONTENT_URI} signaling that any update of
- * {@link Contacts#STARRED} should not be triggered based on
- * {@link Groups#GROUP_VISIBLE} or {@link Settings#UNGROUPED_VISIBLE}
- * during the current update. Callers should follow-up with a separate
- * update using {@link #FORCE_STARRED_UPDATE} to ensure that
- * {@link Contacts#STARRED} remains consistent.
- *
- * @hide
- */
- public static final String DELAY_STARRED_UPDATE = "delay_update";
-
- /**
- * An optional query parameter added to {@link Groups#CONTENT_URI} or
- * {@link Settings#CONTENT_URI} signaling that a full update of
- * {@link Contacts#STARRED} should be triggered. This is usually only
- * needed after using {@link #DELAY_STARRED_UPDATE}.
- *
- * @hide
- */
- public static final String FORCE_STARRED_UPDATE = "force_update";
-
- /**
* A sub-directory of a single contact that contains all of the constituent raw contact
* {@link Data} rows.
*/
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e3fc72d..2b6313d 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1416,6 +1416,7 @@
DIM_SCREEN,
SCREEN_OFF_TIMEOUT,
SCREEN_BRIGHTNESS,
+ SCREEN_BRIGHTNESS_MODE,
VIBRATE_ON,
NOTIFICATIONS_USE_RING_VOLUME,
MODE_RINGER,
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index b2f0c60..ca907af 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -1104,13 +1104,13 @@
final int NS = mNumSamples;
final int NI = NP*NS;
final int ND = NI * NUM_SAMPLE_DATA;
- if (data.length <= ND) {
+ if (data.length < (ND+(NP*NUM_SAMPLE_DATA))) {
final int NEW_ND = ND + (NP * (BASE_AVAIL_SAMPLES * NUM_SAMPLE_DATA));
float[] newData = new float[NEW_ND];
System.arraycopy(data, 0, newData, 0, ND);
mDataSamples = data = newData;
}
- if (times.length <= NS) {
+ if (times.length < (NS+1)) {
final int NEW_NS = NS + BASE_AVAIL_SAMPLES;
long[] newHistoryTimes = new long[NEW_NS];
System.arraycopy(times, 0, newHistoryTimes, 0, NS);
diff --git a/core/java/android/widget/TabHost.java b/core/java/android/widget/TabHost.java
index ee3b91e..31920e7 100644
--- a/core/java/android/widget/TabHost.java
+++ b/core/java/android/widget/TabHost.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -28,11 +29,12 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
-import com.android.internal.R;
import java.util.ArrayList;
import java.util.List;
+import com.android.internal.R;
+
/**
* Container for a tabbed window view. This object holds two children: a set of tab labels that the
* user clicks to select a specific tab, and a FrameLayout object that displays the contents of that
@@ -497,17 +499,22 @@
}
public View createIndicatorView() {
+ final Context context = getContext();
LayoutInflater inflater =
- (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
mTabWidget, // tab widget is the parent
false); // no inflate params
- // TODO: Move this to xml when bug 2068024 is resolved.
- tabIndicator.getBackground().setDither(true);
final TextView tv = (TextView) tabIndicator.findViewById(R.id.title);
tv.setText(mLabel);
+ if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
+ // Donut apps get old color scheme
+ tabIndicator.setBackgroundResource(R.drawable.tab_indicator_v4);
+ tv.setTextColor(context.getResources().getColorStateList(R.color.tab_indicator_text_v4));
+ }
+
return tabIndicator;
}
}
@@ -526,13 +533,12 @@
}
public View createIndicatorView() {
+ final Context context = getContext();
LayoutInflater inflater =
- (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View tabIndicator = inflater.inflate(R.layout.tab_indicator,
mTabWidget, // tab widget is the parent
false); // no inflate params
- // TODO: Move this to xml when bug 2068024 is resolved.
- tabIndicator.getBackground().setDither(true);
final TextView tv = (TextView) tabIndicator.findViewById(R.id.title);
tv.setText(mLabel);
@@ -540,6 +546,12 @@
final ImageView iconView = (ImageView) tabIndicator.findViewById(R.id.icon);
iconView.setImageDrawable(mIcon);
+ if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
+ // Donut apps get old color scheme
+ tabIndicator.setBackgroundResource(R.drawable.tab_indicator_v4);
+ tv.setTextColor(context.getResources().getColorStateList(R.color.tab_indicator_text_v4));
+ }
+
return tabIndicator;
}
}
diff --git a/core/java/android/widget/TabWidget.java b/core/java/android/widget/TabWidget.java
index 889f37f..2ba6268 100644
--- a/core/java/android/widget/TabWidget.java
+++ b/core/java/android/widget/TabWidget.java
@@ -16,11 +16,15 @@
package android.widget;
+import com.android.internal.R;
+
import android.content.Context;
+import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
@@ -94,10 +98,24 @@
setOrientation(LinearLayout.HORIZONTAL);
mGroupFlags |= FLAG_USE_CHILD_DRAWING_ORDER;
- mBottomLeftStrip = mContext.getResources().getDrawable(
- com.android.internal.R.drawable.tab_bottom_left);
- mBottomRightStrip = mContext.getResources().getDrawable(
- com.android.internal.R.drawable.tab_bottom_right);
+ final Context context = mContext;
+ final Resources resources = context.getResources();
+
+ if (context.getApplicationInfo().targetSdkVersion <= Build.VERSION_CODES.DONUT) {
+ // Donut apps get old color scheme
+ mBottomLeftStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_left_v4);
+ mBottomRightStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_right_v4);
+ } else {
+ // Use modern color scheme for Eclair and beyond
+ mBottomLeftStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_left);
+ mBottomRightStrip = resources.getDrawable(
+ com.android.internal.R.drawable.tab_bottom_right);
+ }
+
+
// Deal with focus, as we don't want the focus to go by default
// to a tab other than the current tab
setFocusable(true);
diff --git a/core/java/com/android/internal/widget/ContactHeaderWidget.java b/core/java/com/android/internal/widget/ContactHeaderWidget.java
index 35d637d..86ee3dbc7 100644
--- a/core/java/com/android/internal/widget/ContactHeaderWidget.java
+++ b/core/java/com/android/internal/widget/ContactHeaderWidget.java
@@ -16,13 +16,14 @@
package com.android.internal.widget;
+import com.android.internal.R;
+
import android.Manifest;
import android.content.AsyncQueryHandler;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
-import android.content.Intent;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -31,13 +32,13 @@
import android.os.SystemClock;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
-import android.provider.ContactsContract.Intents;
import android.provider.ContactsContract.PhoneLookup;
import android.provider.ContactsContract.Presence;
import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Photo;
-import android.provider.SocialContract.Activities;
+import android.text.TextUtils;
+import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -47,8 +48,6 @@
import android.widget.ImageView;
import android.widget.TextView;
-import com.android.internal.R;
-
/**
* Header used across system for displaying a title bar with contact info. You
* can bind specific values on the header, or use helper methods like
@@ -57,8 +56,7 @@
* The parent must request the {@link Manifest.permission#READ_CONTACTS}
* permission to access contact data.
*/
-public class ContactHeaderWidget extends FrameLayout implements View.OnClickListener,
- View.OnLongClickListener {
+public class ContactHeaderWidget extends FrameLayout implements View.OnClickListener {
private static final String TAG = "ContactHeaderWidget";
@@ -69,6 +67,7 @@
private FasttrackBadgeWidget mPhotoView;
private ImageView mPresenceView;
private TextView mStatusView;
+ private TextView mStatusDateView;
private int mNoPhotoResource;
private QueryHandler mQueryHandler;
@@ -82,37 +81,36 @@
* Interface for callbacks invoked when the user interacts with a header.
*/
public interface ContactHeaderListener {
- public void onPhotoLongClick(View view);
- public void onDisplayNameLongClick(View view);
+ public void onPhotoClick(View view);
+ public void onDisplayNameClick(View view);
}
private ContactHeaderListener mListener;
- //Projection used for the summary info in the header.
- protected static final String[] HEADER_PROJECTION = new String[] {
- Contacts.DISPLAY_NAME,
- Contacts.STARRED,
- Contacts.PHOTO_ID,
- Contacts.PRESENCE_STATUS,
- Contacts._ID,
- Contacts.LOOKUP_KEY,
- };
- protected static final int HEADER_DISPLAY_NAME_COLUMN_INDEX = 0;
- //TODO: We need to figure out how we're going to get the phonetic name.
- //static final int HEADER_PHONETIC_NAME_COLUMN_INDEX
- protected static final int HEADER_STARRED_COLUMN_INDEX = 1;
- protected static final int HEADER_PHOTO_ID_COLUMN_INDEX = 2;
- protected static final int HEADER_PRESENCE_STATUS_COLUMN_INDEX = 3;
- protected static final int HEADER_CONTACT_ID_COLUMN_INDEX = 4;
- protected static final int HEADER_LOOKUP_KEY_COLUMN_INDEX = 5;
- //Projection used for finding the most recent social status.
- protected static final String[] SOCIAL_PROJECTION = new String[] {
- Activities.TITLE,
- Activities.PUBLISHED,
- };
- protected static final int SOCIAL_TITLE_COLUMN_INDEX = 0;
- protected static final int SOCIAL_PUBLISHED_COLUMN_INDEX = 1;
+ private interface ContactQuery {
+ //Projection used for the summary info in the header.
+ String[] COLUMNS = new String[] {
+ Contacts._ID,
+ Contacts.LOOKUP_KEY,
+ Contacts.PHOTO_ID,
+ Contacts.DISPLAY_NAME,
+ Contacts.STARRED,
+ Contacts.PRESENCE_STATUS,
+ Contacts.PRESENCE_CUSTOM_STATUS,
+ Contacts.PRESENCE_CUSTOM_STATUS_TIMESTAMP,
+ };
+ int _ID = 0;
+ int LOOKUP_KEY = 1;
+ int PHOTO_ID = 2;
+ int DISPLAY_NAME = 3;
+ //TODO: We need to figure out how we're going to get the phonetic name.
+ //static final int HEADER_PHONETIC_NAME_COLUMN_INDEX
+ int STARRED = 4;
+ int PRESENCE_STATUS = 5;
+ int PRESENCE_CUSTOM_STATUS = 6;
+ int PRESENCE_CUSTOM_STATUS_TIMESTAMP = 7;
+ }
//Projection used for looking up contact id from phone number
protected static final String[] PHONE_LOOKUP_PROJECTION = new String[] {
@@ -136,10 +134,8 @@
protected static final int CONTACT_LOOKUP_ID_COLUMN_INDEX = 0;
private static final int TOKEN_CONTACT_INFO = 0;
- private static final int TOKEN_SOCIAL = 1;
- private static final int TOKEN_PHONE_LOOKUP = 2;
- private static final int TOKEN_EMAIL_LOOKUP = 3;
- private static final int TOKEN_LOOKUP_CONTACT_FOR_SOCIAL_QUERY = 4;
+ private static final int TOKEN_PHONE_LOOKUP = 1;
+ private static final int TOKEN_EMAIL_LOOKUP = 2;
public ContactHeaderWidget(Context context) {
this(context, null);
@@ -159,7 +155,6 @@
inflater.inflate(R.layout.contact_header, this);
mDisplayNameView = (TextView) findViewById(R.id.name);
- mDisplayNameView.setOnLongClickListener(this);
mAggregateBadge = findViewById(R.id.aggregate_badge);
mAggregateBadge.setVisibility(View.GONE);
@@ -169,11 +164,11 @@
mStarredView.setOnClickListener(this);
mPhotoView = (FasttrackBadgeWidget) findViewById(R.id.photo);
- mPhotoView.setOnLongClickListener(this);
mPresenceView = (ImageView) findViewById(R.id.presence);
mStatusView = (TextView)findViewById(R.id.status);
+ mStatusDateView = (TextView)findViewById(R.id.status_date);
// Set the photo with a random "no contact" image
long now = SystemClock.elapsedRealtime();
@@ -192,6 +187,11 @@
mQueryHandler = new QueryHandler(mContentResolver);
}
+ public void enableClickListeners() {
+ mDisplayNameView.setOnClickListener(this);
+ mPhotoView.setOnClickListener(this);
+ }
+
/**
* Set the given {@link ContactHeaderListener} to handle header events.
*/
@@ -199,28 +199,15 @@
mListener = listener;
}
- /** {@inheritDoc} */
- public boolean onLongClick(View v) {
- switch (v.getId()) {
- case R.id.photo:
- performPhotoLongClick();
- return true;
- case R.id.name:
- performDisplayNameLongClick();
- return true;
- }
- return false;
- }
-
- private void performPhotoLongClick() {
+ private void performPhotoClick() {
if (mListener != null) {
- mListener.onPhotoLongClick(mPhotoView);
+ mListener.onPhotoClick(mPhotoView);
}
}
- private void performDisplayNameLongClick() {
+ private void performDisplayNameClick() {
if (mListener != null) {
- mListener.onDisplayNameLongClick(mDisplayNameView);
+ mListener.onDisplayNameClick(mDisplayNameView);
}
}
@@ -239,11 +226,6 @@
invalidate();
break;
}
- case TOKEN_SOCIAL: {
- bindSocial(cursor);
- invalidate();
- break;
- }
case TOKEN_PHONE_LOOKUP: {
if (cursor != null && cursor.moveToFirst()) {
long contactId = cursor.getLong(PHONE_LOOKUP_CONTACT_ID_COLUMN_INDEX);
@@ -270,13 +252,6 @@
}
break;
}
- case TOKEN_LOOKUP_CONTACT_FOR_SOCIAL_QUERY: {
- if (cursor != null && cursor.moveToFirst()) {
- long contactId = cursor.getLong(CONTACT_LOOKUP_ID_COLUMN_INDEX);
- startSocialQuery(ContentUris.withAppendedId(
- Activities.CONTENT_CONTACT_STATUS_URI, contactId));
- }
- }
}
} finally {
if (cursor != null) {
@@ -319,8 +294,17 @@
* Manually set the contact uri
*/
public void setContactUri(Uri uri) {
+ setContactUri(uri, true);
+ }
+
+ /**
+ * Manually set the contact uri
+ */
+ public void setContactUri(Uri uri, boolean sendToFastrack) {
mContactUri = uri;
- mPhotoView.assignContactUri(uri);
+ if (sendToFastrack) {
+ mPhotoView.assignContactUri(uri);
+ }
}
/**
@@ -346,7 +330,12 @@
* Manually set the social snippet text to display in the header.
*/
public void setSocialSnippet(CharSequence snippet) {
- mStatusView.setText(snippet);
+ if (snippet == null) {
+ mStatusView.setVisibility(View.GONE);
+ } else {
+ mStatusView.setText(snippet);
+ mStatusView.setVisibility(View.VISIBLE);
+ }
}
/**
@@ -366,11 +355,6 @@
*/
public void bindFromContactLookupUri(Uri contactLookupUri) {
mContactUri = contactLookupUri;
-
- // Query for the contactId so we can do the social query.
- mQueryHandler.startQuery(TOKEN_LOOKUP_CONTACT_FOR_SOCIAL_QUERY, null, contactLookupUri,
- CONTACT_LOOKUP_PROJECTION, null, null, null);
-
startContactQuery(contactLookupUri);
}
@@ -385,8 +369,6 @@
long contactId = ContentUris.parseId(contactUri);
startContactQuery(contactUri);
- startSocialQuery(ContentUris.withAppendedId(
- Activities.CONTENT_CONTACT_STATUS_URI, contactId));
}
/**
@@ -417,13 +399,8 @@
PHONE_LOOKUP_PROJECTION, null, null, null);
}
- private void startSocialQuery(Uri contactSocial) {
- mQueryHandler.startQuery(TOKEN_SOCIAL, null, contactSocial, SOCIAL_PROJECTION, null, null,
- null);
- }
-
private void startContactQuery(Uri contactUri) {
- mQueryHandler.startQuery(TOKEN_CONTACT_INFO, null, contactUri, HEADER_PROJECTION,
+ mQueryHandler.startQuery(TOKEN_CONTACT_INFO, null, contactUri, ContactQuery.COLUMNS,
null, null, null);
}
@@ -434,17 +411,17 @@
if (c == null || !c.moveToFirst()) return;
// TODO: Bring back phonetic name
- final String displayName = c.getString(HEADER_DISPLAY_NAME_COLUMN_INDEX);
- final long contactId = c.getLong(HEADER_CONTACT_ID_COLUMN_INDEX);
- final String lookupKey = c.getString(HEADER_LOOKUP_KEY_COLUMN_INDEX);
+ final String displayName = c.getString(ContactQuery.DISPLAY_NAME);
+ final long contactId = c.getLong(ContactQuery._ID);
+ final String lookupKey = c.getString(ContactQuery.LOOKUP_KEY);
final String phoneticName = null;
this.setDisplayName(displayName, null);
- final boolean starred = c.getInt(HEADER_STARRED_COLUMN_INDEX) != 0;
+ final boolean starred = c.getInt(ContactQuery.STARRED) != 0;
mStarredView.setChecked(starred);
//Set the photo
- Bitmap photoBitmap = loadContactPhoto(c.getLong(HEADER_PHOTO_ID_COLUMN_INDEX), null);
+ Bitmap photoBitmap = loadContactPhoto(c.getLong(ContactQuery.PHOTO_ID), null);
if (photoBitmap == null) {
photoBitmap = loadPlaceholderPhoto(null);
}
@@ -452,43 +429,62 @@
mPhotoView.assignContactUri(Contacts.getLookupUri(contactId, lookupKey));
//Set the presence status
- int presence = c.getInt(HEADER_PRESENCE_STATUS_COLUMN_INDEX);
- mPresenceView.setImageResource(Presence.getPresenceIconResourceId(presence));
- }
+ if (!c.isNull(ContactQuery.PRESENCE_STATUS)) {
+ int presence = c.getInt(ContactQuery.PRESENCE_STATUS);
+ mPresenceView.setImageResource(Presence.getPresenceIconResourceId(presence));
+ mPresenceView.setVisibility(View.VISIBLE);
+ } else {
+ mPresenceView.setVisibility(View.GONE);
+ }
- /**
- * Bind the social data provided by the given {@link Cursor}.
- */
- protected void bindSocial(Cursor c) {
- if (c == null || !c.moveToFirst()) return;
- final String status = c.getString(SOCIAL_TITLE_COLUMN_INDEX);
- this.setSocialSnippet(status);
+ //Set the status update
+ String status = c.getString(ContactQuery.PRESENCE_CUSTOM_STATUS);
+ if (!TextUtils.isEmpty(status)) {
+ mStatusView.setText(status);
+ mStatusView.setVisibility(View.VISIBLE);
+
+ if (!c.isNull(ContactQuery.PRESENCE_CUSTOM_STATUS_TIMESTAMP)) {
+ long date = c.getLong(ContactQuery.PRESENCE_CUSTOM_STATUS_TIMESTAMP);
+
+ // Set the date/time field by mixing relative and absolute
+ // times.
+ int flags = DateUtils.FORMAT_ABBREV_RELATIVE;
+
+ mStatusDateView.setText(DateUtils.getRelativeTimeSpanString(date, System
+ .currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags));
+ mStatusDateView.setVisibility(View.VISIBLE);
+ } else {
+ mStatusDateView.setVisibility(View.GONE);
+ }
+ } else {
+ mStatusView.setVisibility(View.GONE);
+ mStatusDateView.setVisibility(View.GONE);
+ }
+
+ // TODO add support for status update source, e.g. "via Google Talk"
}
public void onClick(View view) {
- // Make sure there is a contact
- if (mContactUri == null) {
- return;
+ switch (view.getId()) {
+ case R.id.star: {
+ // Toggle "starred" state
+ // Make sure there is a contact
+ if (mContactUri != null) {
+ final ContentValues values = new ContentValues(1);
+ values.put(Contacts.STARRED, mStarredView.isChecked());
+ mContentResolver.update(mContactUri, values, null, null);
+ }
+ break;
+ }
+ case R.id.photo: {
+ performPhotoClick();
+ break;
+ }
+ case R.id.name: {
+ performDisplayNameClick();
+ break;
+ }
}
-
- if (view.getId() == R.id.star) {
- // Toggle "starred" state
- final ContentValues values = new ContentValues(1);
- values.put(Contacts.STARRED, mStarredView.isChecked());
- mContentResolver.update(mContactUri, values, null, null);
- }
- }
-
- private Rect getTargetRect(View anchor) {
- final int[] location = new int[2];
- anchor.getLocationOnScreen(location);
-
- final Rect rect = new Rect();
- rect.left = location[0];
- rect.top = location[1];
- rect.right = rect.left + anchor.getWidth();
- rect.bottom = rect.top + anchor.getHeight();
- return rect;
}
private Bitmap loadContactPhoto(long photoId, BitmapFactory.Options options) {
diff --git a/core/java/com/android/internal/widget/RotarySelector.java b/core/java/com/android/internal/widget/RotarySelector.java
index 42cbd07..8939346 100644
--- a/core/java/com/android/internal/widget/RotarySelector.java
+++ b/core/java/com/android/internal/widget/RotarySelector.java
@@ -56,10 +56,10 @@
// UI elements
private Bitmap mBackground;
- private Drawable mDimple;
+ private Bitmap mDimple;
- private Drawable mLeftHandleIcon;
- private Drawable mRightHandleIcon;
+ private Bitmap mLeftHandleIcon;
+ private Bitmap mRightHandleIcon;
private Bitmap mArrowShortLeftAndRight;
private Bitmap mArrowLongLeft; // Long arrow starting on the left, pointing clockwise
@@ -177,7 +177,7 @@
// Assets (all are BitmapDrawables).
mBackground = getBitmapFor(R.drawable.jog_dial_bg);
- mDimple = r.getDrawable(R.drawable.jog_dial_dimple);
+ mDimple = getBitmapFor(R.drawable.jog_dial_dimple);
mArrowLongLeft = getBitmapFor(R.drawable.jog_dial_arrow_long_left_green);
mArrowLongRight = getBitmapFor(R.drawable.jog_dial_arrow_long_right_red);
@@ -187,7 +187,7 @@
mEdgeTriggerThresh = (int) (mDensity * EDGE_TRIGGER_DIP);
- mDimpleWidth = mDimple.getIntrinsicWidth();
+ mDimpleWidth = mDimple.getWidth();
mBackgroundWidth = mBackground.getWidth();
mBackgroundHeight = mBackground.getHeight();
@@ -239,20 +239,9 @@
* @param resId the resource ID.
*/
public void setLeftHandleResource(int resId) {
- Drawable d = null;
if (resId != 0) {
- d = getResources().getDrawable(resId);
+ mLeftHandleIcon = getBitmapFor(resId);
}
- setLeftHandleDrawable(d);
- }
-
- /**
- * Sets the left handle icon to a given Drawable.
- *
- * @param d the Drawable to use as the icon, or null to remove the icon.
- */
- public void setLeftHandleDrawable(Drawable d) {
- mLeftHandleIcon = d;
invalidate();
}
@@ -265,23 +254,13 @@
* @param resId the resource ID.
*/
public void setRightHandleResource(int resId) {
- Drawable d = null;
if (resId != 0) {
- d = getResources().getDrawable(resId);
+ mRightHandleIcon = getBitmapFor(resId);
}
- setRightHandleDrawable(d);
- }
-
- /**
- * Sets the right handle icon to a given Drawable.
- *
- * @param d the Drawable to use as the icon, or null to remove the icon.
- */
- public void setRightHandleDrawable(Drawable d) {
- mRightHandleIcon = d;
invalidate();
}
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int length = isHoriz() ?
@@ -699,18 +678,15 @@
}
/**
- * Sets the bounds of the specified Drawable so that it's centered
- * on the point (x,y), then draws it onto the specified canvas.
+ * Draw the bitmap so that it's centered
+ * on the point (x,y), then draws it using specified canvas.
* TODO: is there already a utility method somewhere for this?
*/
- private static void drawCentered(Drawable d, Canvas c, int x, int y) {
- int w = d.getIntrinsicWidth();
- int h = d.getIntrinsicHeight();
+ private void drawCentered(Bitmap d, Canvas c, int x, int y) {
+ int w = d.getWidth();
+ int h = d.getHeight();
- // if (DBG) log("--> drawCentered: " + x + " , " + y + "; intrinsic " + w + " x " + h);
- d.setBounds(x - (w / 2), y - (h / 2),
- x + (w / 2), y + (h / 2));
- d.draw(c);
+ c.drawBitmap(d, x - (w / 2), y - (h / 2), mPaint);
}
diff --git a/core/res/res/color/tab_indicator_text_v4.xml b/core/res/res/color/tab_indicator_text_v4.xml
new file mode 100644
index 0000000..4f4e394
--- /dev/null
+++ b/core/res/res/color/tab_indicator_text_v4.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_selected="true" android:color="#808080"/>
+ <item android:color="#FFFFFF"/> <!-- not selected -->
+</selector>
diff --git a/core/res/res/drawable-hdpi/fasttrack_badge_small.9.png b/core/res/res/drawable-hdpi/fasttrack_badge_small_unpressed.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/fasttrack_badge_small.9.png
rename to core/res/res/drawable-hdpi/fasttrack_badge_small_unpressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/fasttrack_badge.9.png b/core/res/res/drawable-hdpi/fasttrack_badge_unpressed.9.png
similarity index 100%
rename from core/res/res/drawable-hdpi/fasttrack_badge.9.png
rename to core/res/res/drawable-hdpi/fasttrack_badge_unpressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/tab_selected_bar_left_v4.9.png b/core/res/res/drawable-hdpi/tab_selected_bar_left_v4.9.png
new file mode 100644
index 0000000..e7a07255
--- /dev/null
+++ b/core/res/res/drawable-hdpi/tab_selected_bar_left_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/tab_selected_bar_right_v4.9.png b/core/res/res/drawable-hdpi/tab_selected_bar_right_v4.9.png
new file mode 100644
index 0000000..e7a07255
--- /dev/null
+++ b/core/res/res/drawable-hdpi/tab_selected_bar_right_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/tab_selected_v4.9.png b/core/res/res/drawable-hdpi/tab_selected_v4.9.png
new file mode 100644
index 0000000..77d0f344
--- /dev/null
+++ b/core/res/res/drawable-hdpi/tab_selected_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/tab_unselected_v4.9.png b/core/res/res/drawable-hdpi/tab_unselected_v4.9.png
new file mode 100644
index 0000000..43b1ee5
--- /dev/null
+++ b/core/res/res/drawable-hdpi/tab_unselected_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/fasttrack_badge_small.9.png b/core/res/res/drawable-mdpi/fasttrack_badge_small_unpressed.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/fasttrack_badge_small.9.png
rename to core/res/res/drawable-mdpi/fasttrack_badge_small_unpressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/fasttrack_badge.9.png b/core/res/res/drawable-mdpi/fasttrack_badge_unpressed.9.png
similarity index 100%
rename from core/res/res/drawable-mdpi/fasttrack_badge.9.png
rename to core/res/res/drawable-mdpi/fasttrack_badge_unpressed.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/tab_selected_bar_left_v4.9.png b/core/res/res/drawable-mdpi/tab_selected_bar_left_v4.9.png
new file mode 100644
index 0000000..d14c02b
--- /dev/null
+++ b/core/res/res/drawable-mdpi/tab_selected_bar_left_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/tab_selected_bar_right_v4.9.png b/core/res/res/drawable-mdpi/tab_selected_bar_right_v4.9.png
new file mode 100644
index 0000000..d14c02b
--- /dev/null
+++ b/core/res/res/drawable-mdpi/tab_selected_bar_right_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/tab_selected_v4.9.png b/core/res/res/drawable-mdpi/tab_selected_v4.9.png
new file mode 100644
index 0000000..52cc34e
--- /dev/null
+++ b/core/res/res/drawable-mdpi/tab_selected_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable-mdpi/tab_unselected_v4.9.png b/core/res/res/drawable-mdpi/tab_unselected_v4.9.png
new file mode 100644
index 0000000..7d0859a
--- /dev/null
+++ b/core/res/res/drawable-mdpi/tab_unselected_v4.9.png
Binary files differ
diff --git a/core/res/res/drawable/fasttrack_badge.xml b/core/res/res/drawable/fasttrack_badge.xml
index 89c63a1..c6c9a93 100644
--- a/core/res/res/drawable/fasttrack_badge.xml
+++ b/core/res/res/drawable/fasttrack_badge.xml
@@ -19,7 +19,7 @@
android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
- android:drawable="@drawable/fasttrack_badge" />
+ android:drawable="@drawable/fasttrack_badge_unpressed" />
<item
android:state_pressed="true"
diff --git a/core/res/res/drawable/fasttrack_badge_small.xml b/core/res/res/drawable/fasttrack_badge_small.xml
index 269e936..c8837e4 100644
--- a/core/res/res/drawable/fasttrack_badge_small.xml
+++ b/core/res/res/drawable/fasttrack_badge_small.xml
@@ -19,7 +19,7 @@
android:state_focused="false"
android:state_selected="false"
android:state_pressed="false"
- android:drawable="@drawable/fasttrack_badge_small" />
+ android:drawable="@drawable/fasttrack_badge_small_unpressed" />
<item
android:state_pressed="true"
diff --git a/core/res/res/drawable/tab_bottom_left_v4.xml b/core/res/res/drawable/tab_bottom_left_v4.xml
new file mode 100644
index 0000000..0aee288
--- /dev/null
+++ b/core/res/res/drawable/tab_bottom_left_v4.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true" android:drawable="@drawable/tab_press_bar_left"/>
+ <item android:state_focused="false" android:drawable="@drawable/tab_selected_bar_left_v4"/>
+ <item android:state_focused="true" android:drawable="@drawable/tab_focus_bar_left"/>
+</selector>
diff --git a/core/res/res/drawable/tab_bottom_right_v4.xml b/core/res/res/drawable/tab_bottom_right_v4.xml
new file mode 100644
index 0000000..64227dd
--- /dev/null
+++ b/core/res/res/drawable/tab_bottom_right_v4.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:state_pressed="true" android:drawable="@drawable/tab_press_bar_right"/>
+ <item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/tab_selected_bar_right_v4"/>
+ <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/tab_focus_bar_right"/>
+</selector>
diff --git a/core/res/res/drawable/tab_indicator_v4.xml b/core/res/res/drawable/tab_indicator_v4.xml
new file mode 100644
index 0000000..b1e3c9c
--- /dev/null
+++ b/core/res/res/drawable/tab_indicator_v4.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <!-- Non focused states -->
+ <item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_v4" />
+ <item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_v4" />
+
+ <!-- Focused states -->
+ <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_focus" />
+ <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_focus" />
+
+ <!-- Pressed -->
+ <item android:state_pressed="true" android:drawable="@drawable/tab_press" />
+</selector>
diff --git a/core/res/res/layout-ja/contact_header_name.xml b/core/res/res/layout-ja/contact_header_name.xml
index 9dceeb6..faf1b87 100644
--- a/core/res/res/layout-ja/contact_header_name.xml
+++ b/core/res/res/layout-ja/contact_header_name.xml
@@ -4,9 +4,9 @@
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.
@@ -20,11 +20,11 @@
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
- android:layout_height="wrap_content">
+ android:layout_height="fill_parent">
<TextView android:id="@+id/name"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
android:singleLine="true"
android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceMedium"
diff --git a/core/res/res/layout/contact_header.xml b/core/res/res/layout/contact_header.xml
index d19bb04..2dbc311 100644
--- a/core/res/res/layout/contact_header.xml
+++ b/core/res/res/layout/contact_header.xml
@@ -4,9 +4,9 @@
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.
@@ -17,26 +17,25 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/banner"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
+ android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="@drawable/title_bar_medium"
- android:paddingRight="5dip"
- android:gravity="center_vertical">
-
+ android:paddingRight="5dip">
+
<android.widget.FasttrackBadgeWidget android:id="@+id/photo"
android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
+ android:layout_gravity="center_vertical"
android:layout_marginRight="10dip"
android:layout_marginLeft="10dip"
style="@*android:style/Widget.FasttrackBadgeWidget.WindowSmall" />
/>
-
+
<LinearLayout
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:layout_marginTop="5dip"
- android:orientation="vertical">
+ android:orientation="vertical"
+ android:layout_gravity="center_vertical" >
<LinearLayout
android:layout_width="fill_parent"
@@ -59,25 +58,36 @@
<TextView android:id="@+id/status"
android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:layout_marginTop="-4dip"
+ />
+
+ <TextView android:id="@+id/status_date"
+ android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:textAppearance="?android:attr/textAppearanceSmall"
- android:maxLines="2"
- android:ellipsize="end"/>
-
+ android:textSize="12sp"
+ android:layout_marginTop="-2dip"
+ />
</LinearLayout>
<ImageView
android:id="@+id/presence"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
android:paddingLeft="3dip"
android:paddingRight="6dip"/>
-
+
<CheckBox
android:id="@+id/star"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
android:visibility="gone"
style="?android:attr/starStyle" />
diff --git a/core/res/res/layout/contact_header_name.xml b/core/res/res/layout/contact_header_name.xml
index 9a56fb4..a763c22 100644
--- a/core/res/res/layout/contact_header_name.xml
+++ b/core/res/res/layout/contact_header_name.xml
@@ -4,9 +4,9 @@
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.
@@ -23,4 +23,5 @@
android:textStyle="bold"
android:singleLine="true"
android:ellipsize="end"
+ android:layout_gravity="center_vertical"
/>
diff --git a/data/etc/android.hardware.touchscreen.multitouch.xml b/data/etc/android.hardware.touchscreen.multitouch.xml
new file mode 100644
index 0000000..3d2399a
--- /dev/null
+++ b/data/etc/android.hardware.touchscreen.multitouch.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 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.
+-->
+
+<!-- This is the standard set of features for a touchscreen that supports
+ multitouch. -->
+<permissions>
+ <feature name="android.hardware.touchscreen.multitouch" />
+</permissions>
diff --git a/data/etc/required_hardware.xml b/data/etc/required_hardware.xml
index 896a148..05e7f8a 100644
--- a/data/etc/required_hardware.xml
+++ b/data/etc/required_hardware.xml
@@ -22,4 +22,5 @@
<feature name="android.hardware.sensor.accelerometer" />
<feature name="android.hardware.bluetooth" />
<feature name="android.hardware.wifi" />
+ <feature name="android.hardware.touchscreen" />
</permissions>
diff --git a/docs/html/guide/appendix/api-levels.jd b/docs/html/guide/appendix/api-levels.jd
index acf6899..3158192 100644
--- a/docs/html/guide/appendix/api-levels.jd
+++ b/docs/html/guide/appendix/api-levels.jd
@@ -7,17 +7,18 @@
<h2>In this document</h2>
<ol>
<li><a href="intro">What is API Level?</a></li>
- <li><a href="#uses">Uses of API Level</a></li>
+ <li><a href="#uses">Uses of API Level in Android</a></li>
<li><a href="#considerations">Development Considerations</a>
<ol>
<li><a href="#fc">Application forward compatibility</a></li>
<li><a href="#bc">Application backward compatibility</a></li>
- <li><a href="#platform">Selecting a platform version for compiling</a></li>
+ <li><a href="#platform">Selecting a platform version and API Level</a></li>
<li><a href="#apilevel">Declaring a minimum API Level</a></li>
<li><a href="#testing">Testing against higher API Levels</a></li>
</ol>
</li>
- <li><a href="#filtering">Filtering the documentation</a></li>
+ <li><a href="#provisional">Using a Provisional API Level</a></li>
+ <li><a href="#filtering">Filtering the Reference Documentation by API Level</a></li>
</ol>
<h2>See also</h2>
@@ -285,6 +286,27 @@
a list of platform versions and their API Levels. </p>
+<h2 id="provisional">Using a Provisional API Level</h2>
+
+<p>During an "Early Look" SDK release, the APIs may not be final, so the API Level integer
+will not be specified. You must instead use a provisional API Level in your application
+manifest in order to build applications against the Early Look platform. In this case,
+the provisional API Level is not an integer, but a string matching the codename of the
+unreleased platform version (for example, "Eclair"). The provisional API Level will be specified
+in the Early Look SDK release notes and is case-sensitive.</p>
+
+<p>The use of a provisional API Level is designed to protect developers
+and device users from inadvertently publishing or installing applications based on the
+Early Look framework API, which may not run properly on actual devices running the final
+system image.</p>
+
+<p>The provisional API Level will only be valid while using the Early Look SDK to run
+applications in the emulator. An application using the provisional API Level can never be
+installed on an Android device. When the final SDK is released, you must replace any
+instances of the provisional API Level in your application manifest with the final
+API Level integer.</p>
+
+
<h2 id="filtering">Filtering the Reference Documentation by API Level</h2>
<p>Reference documentation pages on the Android Developers site offer a "Filter
diff --git a/docs/html/sdk/RELEASENOTES.jd b/docs/html/sdk/RELEASENOTES.jd
index 0dcafd3..c2aa454 100644
--- a/docs/html/sdk/RELEASENOTES.jd
+++ b/docs/html/sdk/RELEASENOTES.jd
@@ -54,7 +54,7 @@
<p>If you're installing the Android SDK for the first time, please see
the instructions in <a
-href="{@docRoot}sdk/1.5_r1/installing.html">Installing the SDK</a>.
+href="{@docRoot}sdk/1.6_r1/installing.html">Installing the SDK</a>.
<h3>ADT Plugin for Eclipse</h3>
@@ -71,7 +71,7 @@
<p>The new version of ADT is downloadable from the usual remote update site or
is separately downloadable as a .zip archive. For instructions on how to
-download the plugin, please see <a href="upgrading.html#UpdateAdt">Upgrading
+download the plugin, please see <a href="{@docRoot}sdk/1.6_r1/upgrading.html#UpdateAdt">Upgrading
Your Eclipse Plugin</a>. </p>
<h3>Android SDK and AVD Manager</h3>
diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java
index c25f16a..c626d5d 100644
--- a/graphics/java/android/renderscript/BaseObj.java
+++ b/graphics/java/android/renderscript/BaseObj.java
@@ -60,9 +60,10 @@
protected void finalize() throws Throwable
{
if (!mDestroyed) {
- if(mID != 0) {
+ if(mID != 0 && mRS.isAlive()) {
mRS.nObjDestroyOOB(mID);
}
+ mRS = null;
mID = 0;
mDestroyed = true;
Log.v(RenderScript.LOG_TAG,
diff --git a/graphics/java/android/renderscript/RSSurfaceView.java b/graphics/java/android/renderscript/RSSurfaceView.java
index 63994ab..53466cc 100644
--- a/graphics/java/android/renderscript/RSSurfaceView.java
+++ b/graphics/java/android/renderscript/RSSurfaceView.java
@@ -45,7 +45,7 @@
public RSSurfaceView(Context context) {
super(context);
init();
- Log.v(RenderScript.LOG_TAG, "RSSurfaceView");
+ //Log.v(RenderScript.LOG_TAG, "RSSurfaceView");
}
/**
@@ -55,7 +55,7 @@
public RSSurfaceView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
- Log.v(RenderScript.LOG_TAG, "RSSurfaceView");
+ //Log.v(RenderScript.LOG_TAG, "RSSurfaceView");
}
private void init() {
@@ -80,7 +80,7 @@
*/
public void surfaceDestroyed(SurfaceHolder holder) {
// Surface will be destroyed when we return
- Log.v(RenderScript.LOG_TAG, "surfaceDestroyed");
+ //Log.v(RenderScript.LOG_TAG, "surfaceDestroyed");
}
/**
@@ -88,7 +88,7 @@
* not normally called or subclassed by clients of RSSurfaceView.
*/
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
- Log.v(RenderScript.LOG_TAG, "surfaceChanged");
+ //Log.v(RenderScript.LOG_TAG, "surfaceChanged");
}
/**
@@ -101,7 +101,7 @@
if(mRS != null) {
mRS.pause();
}
- Log.v(RenderScript.LOG_TAG, "onPause");
+ //Log.v(RenderScript.LOG_TAG, "onPause");
}
/**
@@ -115,7 +115,7 @@
if(mRS != null) {
mRS.resume();
}
- Log.v(RenderScript.LOG_TAG, "onResume");
+ //Log.v(RenderScript.LOG_TAG, "onResume");
}
/**
@@ -125,7 +125,7 @@
* @param r the runnable to be run on the GL rendering thread.
*/
public void queueEvent(Runnable r) {
- Log.v(RenderScript.LOG_TAG, "queueEvent");
+ //Log.v(RenderScript.LOG_TAG, "queueEvent");
}
/**
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index f815f52..ed61691 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -219,6 +219,10 @@
mDev = 0;
}
+ boolean isAlive() {
+ return mContext != 0;
+ }
+
void pause() {
nContextPause();
}
diff --git a/include/ui/CameraParameters.h b/include/ui/CameraParameters.h
index 9ca1806..9c3d4f0 100644
--- a/include/ui/CameraParameters.h
+++ b/include/ui/CameraParameters.h
@@ -69,11 +69,203 @@
void dump() const;
status_t dump(int fd, const Vector<String16>& args) const;
+ // Parameter keys to communicate between camera application and driver.
+ // The access (read/write, read only, or write only) is viewed from the
+ // perspective of applications, not driver.
+
+ // Preview frame size in pixels (width x height).
+ // Example value: "480x320". Read/Write.
+ static const char KEY_PREVIEW_SIZE[];
+ // Supported preview frame sizes in pixels.
+ // Example value: "800x600,480x320". Read only.
+ static const char KEY_SUPPORTED_PREVIEW_SIZES[];
+ // The image format for preview frames.
+ // Example value: "yuv420sp" or PIXEL_FORMAT_XXX constants. Read/write.
+ static const char KEY_PREVIEW_FORMAT[];
+ // Supported image formats for preview frames.
+ // Example value: "yuv420sp,yuv422i-yuyv". Read only.
+ static const char KEY_SUPPORTED_PREVIEW_FORMATS[];
+ // Number of preview frames per second.
+ // Example value: "15". Read/write.
+ static const char KEY_PREVIEW_FRAME_RATE[];
+ // Supported number of preview frames per second.
+ // Example value: "24,15,10". Read.
+ static const char KEY_SUPPORTED_PREVIEW_FRAME_RATES[];
+ // The dimensions for captured pictures in pixels (width x height).
+ // Example value: "1024x768". Read/write.
+ static const char KEY_PICTURE_SIZE[];
+ // Supported dimensions for captured pictures in pixels.
+ // Example value: "2048x1536,1024x768". Read only.
+ static const char KEY_SUPPORTED_PICTURE_SIZES[];
+ // The image format for captured pictures.
+ // Example value: "jpeg" or PIXEL_FORMAT_XXX constants. Read/write.
+ static const char KEY_PICTURE_FORMAT[];
+ // Supported image formats for captured pictures.
+ // Example value: "jpeg,rgb565". Read only.
+ static const char KEY_SUPPORTED_PICTURE_FORMATS[];
+ // The width (in pixels) of EXIF thumbnail in Jpeg picture.
+ // Example value: "512". Read/write.
+ static const char KEY_JPEG_THUMBNAIL_WIDTH[];
+ // The height (in pixels) of EXIF thumbnail in Jpeg picture.
+ // Example value: "384". Read/write.
+ static const char KEY_JPEG_THUMBNAIL_HEIGHT[];
+ // Supported EXIF thumbnail sizes (width x height).
+ // Example value: "512x384,320x240". Read only.
+ static const char KEY_SUPPORTED_THUMBNAIL_SIZES[];
+ // The quality of the EXIF thumbnail in Jpeg picture. The range is 1 to 100,
+ // with 100 being the best.
+ // Example value: "90". Read/write.
+ static const char KEY_JPEG_THUMBNAIL_QUALITY[];
+ // Jpeg quality of captured picture. The range is 1 to 100, with 100 being
+ // the best.
+ // Example value: "90". Read/write.
+ static const char KEY_JPEG_QUALITY[];
+ // The orientation of the device in degrees. For example, suppose the
+ // natural position of the device is landscape. If the user takes a picture
+ // in landscape mode in 2048x1536 resolution, the rotation will be set to
+ // "0". If the user rotates the phone 90 degrees clockwise, the rotation
+ // should be set to "90".
+ // The camera driver can set orientation in the EXIF header without rotating
+ // the picture. Or the driver can rotate the picture and the EXIF thumbnail.
+ // If the Jpeg picture is rotated, the orientation in the EXIF header should
+ // be missing or 1 (row #0 is top and column #0 is left side). The driver
+ // should not set default value for this parameter.
+ // Example value: "0" or "90" or "180" or "270". Write only.
+ static const char KEY_ROTATION[];
+ // GPS latitude coordinate. This will be stored in JPEG EXIF header.
+ // Example value: "25.032146". Write only.
+ static const char KEY_GPS_LATITUDE[];
+ // GPS longitude coordinate. This will be stored in JPEG EXIF header.
+ // Example value: "121.564448". Write only.
+ static const char KEY_GPS_LONGITUDE[];
+ // GPS altitude. This will be stored in JPEG EXIF header.
+ // Example value: "21.0". Write only.
+ static const char KEY_GPS_ALTITUDE[];
+ // GPS timestamp (UTC in seconds since January 1, 1970). This should be
+ // stored in JPEG EXIF header.
+ // Example value: "1251192757". Write only.
+ static const char KEY_GPS_TIMESTAMP[];
+ // Current white balance setting.
+ // Example value: "auto" or WHITE_BALANCE_XXX constants. Read/write.
+ static const char KEY_WHITE_BALANCE[];
+ // Supported white balance settings.
+ // Example value: "auto,incandescent,daylight". Read only.
+ static const char KEY_SUPPORTED_WHITE_BALANCE[];
+ // Current color effect setting.
+ // Example value: "none" or EFFECT_XXX constants. Read/write.
+ static const char KEY_EFFECT[];
+ // Supported color effect settings.
+ // Example value: "none,mono,sepia". Read only.
+ static const char KEY_SUPPORTED_EFFECTS[];
+ // Current antibanding setting.
+ // Example value: "auto" or ANTIBANDING_XXX constants. Read/write.
+ static const char KEY_ANTIBANDING[];
+ // Supported antibanding settings.
+ // Example value: "auto,50hz,60hz,off". Read only.
+ static const char KEY_SUPPORTED_ANTIBANDING[];
+ // Current scene mode.
+ // Example value: "auto" or SCENE_MODE_XXX constants. Read/write.
+ static const char KEY_SCENE_MODE[];
+ // Supported scene mode settings.
+ // Example value: "auto,night,fireworks". Read only.
+ static const char KEY_SUPPORTED_SCENE_MODES[];
+ // Current flash mode.
+ // Example value: "auto" or FLASH_MODE_XXX constants. Read/write.
+ static const char KEY_FLASH_MODE[];
+ // Supported flash modes.
+ // Example value: "auto,on,off". Read only.
+ static const char KEY_SUPPORTED_FLASH_MODES[];
+ // Current focus mode. If the camera does not support auto-focus, the value
+ // should be FOCUS_MODE_FIXED. If the focus mode is not FOCUS_MODE_FIXED or
+ // or FOCUS_MODE_INFINITY, applications should call
+ // CameraHardwareInterface.autoFocus to start the focus.
+ // Example value: "auto" or FOCUS_MODE_XXX constants. Read/write.
+ static const char KEY_FOCUS_MODE[];
+ // Supported focus modes.
+ // Example value: "auto,macro,fixed". Read only.
+ static const char KEY_SUPPORTED_FOCUS_MODES[];
+
+ // Values for white balance settings.
+ static const char WHITE_BALANCE_AUTO[];
+ static const char WHITE_BALANCE_INCANDESCENT[];
+ static const char WHITE_BALANCE_FLUORESCENT[];
+ static const char WHITE_BALANCE_WARM_FLUORESCENT[];
+ static const char WHITE_BALANCE_DAYLIGHT[];
+ static const char WHITE_BALANCE_CLOUDY_DAYLIGHT[];
+ static const char WHITE_BALANCE_TWILIGHT[];
+ static const char WHITE_BALANCE_SHADE[];
+
+ // Values for effect settings.
+ static const char EFFECT_NONE[];
+ static const char EFFECT_MONO[];
+ static const char EFFECT_NEGATIVE[];
+ static const char EFFECT_SOLARIZE[];
+ static const char EFFECT_SEPIA[];
+ static const char EFFECT_POSTERIZE[];
+ static const char EFFECT_WHITEBOARD[];
+ static const char EFFECT_BLACKBOARD[];
+ static const char EFFECT_AQUA[];
+
+ // Values for antibanding settings.
+ static const char ANTIBANDING_AUTO[];
+ static const char ANTIBANDING_50HZ[];
+ static const char ANTIBANDING_60HZ[];
+ static const char ANTIBANDING_OFF[];
+
+ // Values for flash mode settings.
+ // Flash will not be fired.
+ static const char FLASH_MODE_OFF[];
+ // Flash will be fired automatically when required. The timing is decided by
+ // camera driver.
+ static const char FLASH_MODE_AUTO[];
+ // Flash will always be fired. The timing is decided by camera driver.
+ static const char FLASH_MODE_ON[];
+ // Flash will be fired in red-eye reduction mode.
+ static const char FLASH_MODE_RED_EYE[];
+ // Constant emission of light. This can be used for video recording.
+ static const char FLASH_MODE_VIDEO_LIGHT[];
+
+ // Values for scene mode settings.
+ static const char SCENE_MODE_AUTO[];
+ static const char SCENE_MODE_ACTION[];
+ static const char SCENE_MODE_PORTRAIT[];
+ static const char SCENE_MODE_LANDSCAPE[];
+ static const char SCENE_MODE_NIGHT[];
+ static const char SCENE_MODE_NIGHT_PORTRAIT[];
+ static const char SCENE_MODE_THEATRE[];
+ static const char SCENE_MODE_BEACH[];
+ static const char SCENE_MODE_SNOW[];
+ static const char SCENE_MODE_SUNSET[];
+ static const char SCENE_MODE_STEADYPHOTO[];
+ static const char SCENE_MODE_FIREWORKS[];
+ static const char SCENE_MODE_SPORTS[];
+ static const char SCENE_MODE_PARTY[];
+ static const char SCENE_MODE_CANDLELIGHT[];
+
+ // Formats for setPreviewFormat and setPictureFormat.
+ static const char PIXEL_FORMAT_YUV422SP[];
+ static const char PIXEL_FORMAT_YUV420SP[]; // NV21
+ static const char PIXEL_FORMAT_YUV422I[]; // YUY2
+ static const char PIXEL_FORMAT_RGB565[];
+ static const char PIXEL_FORMAT_JPEG[];
+
+ // Values for focus mode settings.
+ // Auto-focus mode.
+ static const char FOCUS_MODE_AUTO[];
+ // Focus is set at infinity. Applications should not call
+ // CameraHardwareInterface.autoFocus in this mode.
+ static const char FOCUS_MODE_INFINITY[];
+ static const char FOCUS_MODE_MACRO[];
+ // Focus is fixed. The camera is always in this mode if the focus is not
+ // adjustable. If the camera has auto-focus, this mode can fix the
+ // focus, which is usually at hyperfocal distance. Applications should
+ // not call CameraHardwareInterface.autoFocus in this mode.
+ static const char FOCUS_MODE_FIXED[];
+
private:
DefaultKeyedVector<String8,String8> mMap;
};
-
}; // namespace android
#endif
diff --git a/libs/rs/java/Fountain/res/raw/fountain.c b/libs/rs/java/Fountain/res/raw/fountain.c
index 57e10cf..86f0f99 100644
--- a/libs/rs/java/Fountain/res/raw/fountain.c
+++ b/libs/rs/java/Fountain/res/raw/fountain.c
@@ -31,10 +31,11 @@
np->b = b;
np->a = 0xf0;
newPart++;
+ np++;
if (newPart >= count) {
newPart = 0;
+ np = &p[newPart];
}
- np++;
}
}
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/Fountain.java b/libs/rs/java/Fountain/src/com/android/fountain/Fountain.java
index 58c78fa..9ae3e67 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/Fountain.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/Fountain.java
@@ -62,6 +62,8 @@
@Override
protected void onResume() {
+ Log.e("rs", "onResume");
+
// Ideally a game should implement onResume() and onPause()
// to take appropriate action when the activity looses focus
super.onResume();
@@ -70,12 +72,16 @@
@Override
protected void onPause() {
+ Log.e("rs", "onPause");
+
// Ideally a game should implement onResume() and onPause()
// to take appropriate action when the activity looses focus
super.onPause();
mView.onPause();
- Runtime.getRuntime().exit(0);
+
+
+ //Runtime.getRuntime().exit(0);
}
diff --git a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
index 1b07f98..cda005e 100644
--- a/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
+++ b/libs/rs/java/Fountain/src/com/android/fountain/FountainView.java
@@ -42,21 +42,34 @@
public FountainView(Context context) {
super(context);
-
//setFocusable(true);
}
private RenderScript mRS;
private FountainRS mRender;
+ private void destroyRS() {
+ if(mRS != null) {
+ mRS = null;
+ destroyRenderScript();
+ }
+ java.lang.System.gc();
+ }
+
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
super.surfaceChanged(holder, format, w, h);
-
+ destroyRS();
mRS = createRenderScript(false, true);
mRender = new FountainRS();
mRender.init(mRS, getResources(), w, h);
}
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ // Surface will be destroyed when we return
+ destroyRS();
+ }
+
+
@Override
public boolean onTouchEvent(MotionEvent ev)
diff --git a/libs/rs/rsAdapter.cpp b/libs/rs/rsAdapter.cpp
index d20e910..0d31fac 100644
--- a/libs/rs/rsAdapter.cpp
+++ b/libs/rs/rsAdapter.cpp
@@ -21,13 +21,17 @@
using namespace android::renderscript;
-Adapter1D::Adapter1D()
+Adapter1D::Adapter1D(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
reset();
}
-Adapter1D::Adapter1D(Allocation *a)
+Adapter1D::Adapter1D(Context *rsc, Allocation *a) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
reset();
setAllocation(a);
}
@@ -71,7 +75,7 @@
RsAdapter1D rsi_Adapter1DCreate(Context *rsc)
{
- Adapter1D *a = new Adapter1D();
+ Adapter1D *a = new Adapter1D(rsc);
a->incUserRef();
return a;
}
@@ -125,13 +129,17 @@
//////////////////////////
-Adapter2D::Adapter2D()
+Adapter2D::Adapter2D(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
reset();
}
-Adapter2D::Adapter2D(Allocation *a)
+Adapter2D::Adapter2D(Context *rsc, Allocation *a) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
reset();
setAllocation(a);
}
@@ -184,7 +192,7 @@
RsAdapter2D rsi_Adapter2DCreate(Context *rsc)
{
- Adapter2D *a = new Adapter2D();
+ Adapter2D *a = new Adapter2D(rsc);
a->incUserRef();
return a;
}
diff --git a/libs/rs/rsAdapter.h b/libs/rs/rsAdapter.h
index 865535e..cb2872e 100644
--- a/libs/rs/rsAdapter.h
+++ b/libs/rs/rsAdapter.h
@@ -23,15 +23,15 @@
namespace android {
namespace renderscript {
-
+
class Adapter1D : public ObjectBase
{
public:
// By policy this allocation will hold a pointer to the type
// but will not destroy it on destruction.
- Adapter1D();
- Adapter1D(Allocation *);
+ Adapter1D(Context *);
+ Adapter1D(Context *, Allocation *);
void reset();
void * getElement(uint32_t x);
@@ -64,8 +64,8 @@
public:
// By policy this allocation will hold a pointer to the type
// but will not destroy it on destruction.
- Adapter2D();
- Adapter2D(Allocation *);
+ Adapter2D(Context *);
+ Adapter2D(Context *, Allocation *);
void reset();
void * getElement(uint32_t x, uint32_t y) const;
@@ -79,8 +79,8 @@
inline void setFace(uint32_t face) {mFace = face;}
//void setArray(uint32_t num, uint32_t value);
- void data(const void *data);
- void subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data);
+ void data(const void *data);
+ void subData(uint32_t xoff, uint32_t yoff, uint32_t w, uint32_t h, const void *data);
protected:
ObjectBaseRef<Allocation> mAllocation;
diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp
index cb82624..8ee6e5a 100644
--- a/libs/rs/rsAllocation.cpp
+++ b/libs/rs/rsAllocation.cpp
@@ -22,8 +22,10 @@
using namespace android;
using namespace android::renderscript;
-Allocation::Allocation(const Type *type)
+Allocation::Allocation(Context *rsc, const Type *type) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mPtr = NULL;
mCpuWrite = false;
@@ -90,7 +92,7 @@
}
glBindTexture(GL_TEXTURE_2D, mTextureID);
- Adapter2D adapt(this);
+ Adapter2D adapt(getContext(), this);
for(uint32_t lod = 0; (lod + lodOffset) < mType->getLODCount(); lod++) {
adapt.setLOD(lod+lodOffset);
@@ -186,14 +188,14 @@
{
const Type * type = static_cast<const Type *>(vtype);
- Allocation * alloc = new Allocation(type);
+ Allocation * alloc = new Allocation(rsc, type);
alloc->incUserRef();
return alloc;
}
RsAllocation rsi_AllocationCreateSized(Context *rsc, RsElement e, size_t count)
{
- Type * type = new Type();
+ Type * type = new Type(rsc);
type->setDimX(count);
type->setElement(static_cast<Element *>(e));
type->compute();
@@ -371,8 +373,8 @@
cvt(texAlloc->getPtr(), data, w * h);
if (genMips) {
- Adapter2D adapt(texAlloc);
- Adapter2D adapt2(texAlloc);
+ Adapter2D adapt(rsc, texAlloc);
+ Adapter2D adapt2(rsc, texAlloc);
for(uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) {
adapt.setLOD(lod);
adapt2.setLOD(lod + 1);
diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h
index 1f58ec5..1b83267 100644
--- a/libs/rs/rsAllocation.h
+++ b/libs/rs/rsAllocation.h
@@ -33,7 +33,7 @@
public:
// By policy this allocation will hold a pointer to the type
// but will not destroy it on destruction.
- Allocation(const Type *);
+ Allocation(Context *rsc, const Type *);
virtual ~Allocation();
void setCpuWritable(bool);
diff --git a/libs/rs/rsComponent.cpp b/libs/rs/rsComponent.cpp
index 4a043f3..42e2e4f 100644
--- a/libs/rs/rsComponent.cpp
+++ b/libs/rs/rsComponent.cpp
@@ -21,18 +21,22 @@
using namespace android::renderscript;
-Component::Component()
+Component::Component(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mType = FLOAT;
mKind = USER;
mIsNormalized = false;
mBits = 0;
}
-Component::Component(
+Component::Component(Context *rsc,
DataKind dk, DataType dt,
- bool isNormalized, uint32_t bits, const char * name)
+ bool isNormalized, uint32_t bits, const char * name) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mType = dt;
mKind = dk;
mIsNormalized = isNormalized;
diff --git a/libs/rs/rsComponent.h b/libs/rs/rsComponent.h
index 5856524..290cd57 100644
--- a/libs/rs/rsComponent.h
+++ b/libs/rs/rsComponent.h
@@ -44,7 +44,7 @@
};
- Component(DataKind dk, DataType dt, bool isNorm, uint32_t bits, const char *);
+ Component(Context *rsc, DataKind dk, DataType dt, bool isNorm, uint32_t bits, const char *);
virtual ~Component();
DataType getType() const {return mType;}
@@ -66,7 +66,7 @@
String8 mName;
private:
- Component();
+ Component(Context *rsc);
};
diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp
index 2fe762c..70add92 100644
--- a/libs/rs/rsContext.cpp
+++ b/libs/rs/rsContext.cpp
@@ -28,8 +28,6 @@
using namespace android;
using namespace android::renderscript;
-bool g_logTimes = -1;
-
pthread_key_t Context::gThreadTLSKey = 0;
void Context::initEGL()
@@ -117,7 +115,7 @@
bool Context::runRootScript()
{
- if (this->logTimes) {
+ if (props.mLogTimes) {
timerSet(RS_TIMER_CLEAR_SWAP);
}
rsAssert(mRootScript->mEnviroment.mIsRoot);
@@ -140,7 +138,7 @@
glClear(GL_COLOR_BUFFER_BIT);
}
- if (this->logTimes) {
+ if (this->props.mLogTimes) {
timerSet(RS_TIMER_SCRIPT);
}
bool ret = runScript(mRootScript.get(), 0);
@@ -208,10 +206,10 @@
mVertex->setupGL(this, &mStateVertex);
}
-static bool get_log_times()
+static bool getProp(const char *str)
{
char buf[PROPERTY_VALUE_MAX];
- property_get("debug.rs.profile", buf, "0");
+ property_get(str, buf, "0");
return 0 != strcmp(buf, "0");
}
@@ -219,7 +217,9 @@
{
Context *rsc = static_cast<Context *>(vrsc);
- rsc->logTimes = get_log_times();
+ rsc->props.mLogTimes = getProp("debug.rs.profile");
+ rsc->props.mLogScripts = getProp("debug.rs.script");
+ rsc->props.mLogObjects = getProp("debug.rs.objects");
rsc->initEGL();
@@ -252,11 +252,11 @@
if (mDraw) {
mDraw = rsc->runRootScript() && !rsc->mPaused;
- if (rsc->logTimes) {
+ if (rsc->props.mLogTimes) {
rsc->timerSet(RS_TIMER_CLEAR_SWAP);
}
eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface);
- if (rsc->logTimes) {
+ if (rsc->props.mLogTimes) {
rsc->timerFrame();
rsc->timerSet(RS_TIMER_INTERNAL);
rsc->timerPrint();
@@ -269,6 +269,17 @@
}
LOGV("RS Thread exiting");
+ rsc->mRaster.clear();
+ rsc->mFragment.clear();
+ rsc->mVertex.clear();
+ rsc->mFragmentStore.clear();
+ rsc->mRootScript.clear();
+ rsc->mStateRaster.deinit(rsc);
+ rsc->mStateVertex.deinit(rsc);
+ rsc->mStateFragment.deinit(rsc);
+ rsc->mStateFragmentStore.deinit(rsc);
+ ObjectBase::zeroAllUserRef(rsc);
+
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
eglSwapBuffers(rsc->mEGL.mDisplay, rsc->mEGL.mSurface);
@@ -286,6 +297,7 @@
mExit = false;
mUseDepth = useDepth;
mPaused = false;
+ mObjHead = NULL;
int status;
pthread_attr_t threadAttr;
diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h
index 0a886cd..cef421d 100644
--- a/libs/rs/rsContext.h
+++ b/libs/rs/rsContext.h
@@ -143,7 +143,13 @@
bool checkVersion1_1() const {return (mGL.mMajorVersion > 1) || (mGL.mMinorVersion >= 1); }
bool checkVersion2_0() const {return mGL.mMajorVersion >= 2; }
- bool logTimes;
+ struct {
+ bool mLogTimes;
+ bool mLogScripts;
+ bool mLogObjects;
+ } props;
+
+ mutable const ObjectBase * mObjHead;
protected:
Device *mDev;
diff --git a/libs/rs/rsElement.cpp b/libs/rs/rsElement.cpp
index b5267b3..a00fb52 100644
--- a/libs/rs/rsElement.cpp
+++ b/libs/rs/rsElement.cpp
@@ -22,14 +22,18 @@
using namespace android::renderscript;
-Element::Element()
+Element::Element(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mComponents = NULL;
mComponentCount = 0;
}
-Element::Element(uint32_t count)
+Element::Element(Context *rsc, uint32_t count) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mComponents = new ObjectBaseRef<Component> [count];
mComponentCount = count;
}
@@ -197,7 +201,8 @@
void rsi_ElementAdd(Context *rsc, RsDataKind dk, RsDataType dt, bool isNormalized, size_t bits, const char *name)
{
ElementState * sec = &rsc->mStateElement;
- Component *c = new Component(static_cast<Component::DataKind>(dk),
+ Component *c = new Component(rsc,
+ static_cast<Component::DataKind>(dk),
static_cast<Component::DataType>(dt),
isNormalized,
bits,
@@ -208,7 +213,7 @@
RsElement rsi_ElementCreate(Context *rsc)
{
ElementState * sec = &rsc->mStateElement;
- Element *se = new Element(sec->mComponentBuildList.size());
+ Element *se = new Element(rsc, sec->mComponentBuildList.size());
for (size_t ct = 0; ct < se->getComponentCount(); ct++) {
se->setComponent(ct, sec->mComponentBuildList[ct]);
diff --git a/libs/rs/rsElement.h b/libs/rs/rsElement.h
index 7b5a83d..82da441 100644
--- a/libs/rs/rsElement.h
+++ b/libs/rs/rsElement.h
@@ -28,7 +28,7 @@
class Element : public ObjectBase
{
public:
- Element(uint32_t count);
+ Element(Context *, uint32_t count);
~Element();
@@ -59,7 +59,7 @@
ObjectBaseRef<Component> * mComponents;
//uint32_t *mOffsetTable;
- Element();
+ Element(Context *);
};
diff --git a/libs/rs/rsFileA3D.cpp b/libs/rs/rsFileA3D.cpp
index 347ef23..c566665 100644
--- a/libs/rs/rsFileA3D.cpp
+++ b/libs/rs/rsFileA3D.cpp
@@ -242,7 +242,7 @@
void FileA3D::processChunk_Mesh(Context *rsc, IO *io, A3DIndexEntry *ie)
{
- Mesh * m = new Mesh;
+ Mesh * m = new Mesh(rsc);
m->mPrimitivesCount = io->loadU32();
m->mPrimitives = new Mesh::Primitive_t *[m->mPrimitivesCount];
diff --git a/libs/rs/rsLight.cpp b/libs/rs/rsLight.cpp
index ad06c1f..6f2cf3e 100644
--- a/libs/rs/rsLight.cpp
+++ b/libs/rs/rsLight.cpp
@@ -22,8 +22,10 @@
using namespace android::renderscript;
-Light::Light(bool isLocal, bool isMono)
+Light::Light(Context *rsc, bool isLocal, bool isMono) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mIsLocal = isLocal;
mIsMono = isMono;
@@ -104,7 +106,7 @@
RsLight rsi_LightCreate(Context *rsc)
{
- Light *l = new Light(rsc->mStateLight.mIsLocal,
+ Light *l = new Light(rsc, rsc->mStateLight.mIsLocal,
rsc->mStateLight.mIsMono);
l->incUserRef();
return l;
diff --git a/libs/rs/rsLight.h b/libs/rs/rsLight.h
index b0c3386..d8796e6 100644
--- a/libs/rs/rsLight.h
+++ b/libs/rs/rsLight.h
@@ -29,7 +29,7 @@
class Light : public ObjectBase
{
public:
- Light(bool isLocal, bool isMono);
+ Light(Context *, bool isLocal, bool isMono);
virtual ~Light();
// Values, mutable after creation.
diff --git a/libs/rs/rsLocklessFifo.cpp b/libs/rs/rsLocklessFifo.cpp
index f4f5d40..b0540a6 100644
--- a/libs/rs/rsLocklessFifo.cpp
+++ b/libs/rs/rsLocklessFifo.cpp
@@ -131,6 +131,12 @@
mSignalToWorker.wait();
}
+ if (mInShutdown) {
+ *command = 0;
+ *bytesData = 0;
+ return 0;
+ }
+
*command = reinterpret_cast<const uint16_t *>(mGet)[0];
*bytesData = reinterpret_cast<const uint16_t *>(mGet)[1];
if (*command) {
diff --git a/libs/rs/rsMesh.cpp b/libs/rs/rsMesh.cpp
index aeb52ed..d595b4e 100644
--- a/libs/rs/rsMesh.cpp
+++ b/libs/rs/rsMesh.cpp
@@ -22,8 +22,10 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
-Mesh::Mesh()
+Mesh::Mesh(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mVerticies = NULL;
mVerticiesCount = 0;
mPrimitives = NULL;
diff --git a/libs/rs/rsMesh.h b/libs/rs/rsMesh.h
index be207a3..5201abd 100644
--- a/libs/rs/rsMesh.h
+++ b/libs/rs/rsMesh.h
@@ -29,7 +29,7 @@
class Mesh : public ObjectBase
{
public:
- Mesh();
+ Mesh(Context *);
~Mesh();
struct Verticies_t
@@ -42,7 +42,7 @@
size_t mOffsetCoord;
size_t mOffsetTex;
size_t mOffsetNorm;
-
+
size_t mSizeCoord;
size_t mSizeTex;
size_t mSizeNorm;
diff --git a/libs/rs/rsObjectBase.cpp b/libs/rs/rsObjectBase.cpp
index 7e7afab..720e8fc 100644
--- a/libs/rs/rsObjectBase.cpp
+++ b/libs/rs/rsObjectBase.cpp
@@ -15,22 +15,52 @@
*/
#include "rsObjectBase.h"
+#include "rsContext.h"
using namespace android;
using namespace android::renderscript;
-ObjectBase::ObjectBase()
+ObjectBase::ObjectBase(Context *rsc)
{
mUserRefCount = 0;
mSysRefCount = 0;
mName = NULL;
+ mRSC = NULL;
+ mNext = NULL;
+ mPrev = NULL;
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
+ setContext(rsc);
}
ObjectBase::~ObjectBase()
{
- //LOGV("~ObjectBase %p ref %i", this, mRefCount);
+ //LOGV("~ObjectBase %p ref %i,%i", this, mUserRefCount, mSysRefCount);
rsAssert(!mUserRefCount);
rsAssert(!mSysRefCount);
+ remove();
+}
+
+void ObjectBase::dumpObj(const char *op) const
+{
+ if (mName) {
+ LOGV("%s RSobj %p, name %s, refs %i,%i from %s,%i links %p,%p,%p",
+ op, this, mName, mUserRefCount, mSysRefCount, mAllocFile, mAllocLine, mNext, mPrev, mRSC);
+ } else {
+ LOGV("%s RSobj %p, no-name, refs %i,%i from %s,%i links %p,%p,%p",
+ op, this, mUserRefCount, mSysRefCount, mAllocFile, mAllocLine, mNext, mPrev, mRSC);
+ }
+}
+
+void ObjectBase::setContext(Context *rsc)
+{
+ if (mRSC) {
+ remove();
+ }
+ mRSC = rsc;
+ if (rsc) {
+ add();
+ }
}
void ObjectBase::incUserRef() const
@@ -45,34 +75,39 @@
//LOGV("ObjectBase %p inc ref %i", this, mRefCount);
}
-void ObjectBase::decUserRef() const
+bool ObjectBase::checkDelete() const
+{
+ if (!(mSysRefCount | mUserRefCount)) {
+ if (mRSC && mRSC->props.mLogObjects) {
+ dumpObj("checkDelete");
+ }
+ delete this;
+ return true;
+ }
+ return false;
+}
+
+bool ObjectBase::decUserRef() const
{
rsAssert(mUserRefCount > 0);
mUserRefCount --;
- //LOGV("ObjectBase %p dec ref %i", this, mRefCount);
- if (!(mSysRefCount | mUserRefCount)) {
- if (mName) {
- LOGV("Deleting RS object %p, name %s", this, mName);
- } else {
- LOGV("Deleting RS object %p, no name", this);
- }
- delete this;
- }
+ //dumpObj("decUserRef");
+ return checkDelete();
}
-void ObjectBase::decSysRef() const
+bool ObjectBase::zeroUserRef() const
+{
+ mUserRefCount = 0;
+ //dumpObj("zeroUserRef");
+ return checkDelete();
+}
+
+bool ObjectBase::decSysRef() const
{
rsAssert(mSysRefCount > 0);
mSysRefCount --;
- //LOGV("ObjectBase %p dec ref %i", this, mRefCount);
- if (!(mSysRefCount | mUserRefCount)) {
- if (mName) {
- LOGV("Deleting RS object %p, name %s", this, mName);
- } else {
- LOGV("Deleting RS object %p, no name", this);
- }
- delete this;
- }
+ //dumpObj("decSysRef");
+ return checkDelete();
}
void ObjectBase::setName(const char *name)
@@ -96,3 +131,66 @@
}
}
+void ObjectBase::add() const
+{
+ rsAssert(!mNext);
+ rsAssert(!mPrev);
+ //LOGV("calling add rsc %p", mRSC);
+ mNext = mRSC->mObjHead;
+ if (mRSC->mObjHead) {
+ mRSC->mObjHead->mPrev = this;
+ }
+ mRSC->mObjHead = this;
+}
+
+void ObjectBase::remove() const
+{
+ //LOGV("calling remove rsc %p", mRSC);
+ if (!mRSC) {
+ rsAssert(!mPrev);
+ rsAssert(!mNext);
+ return;
+ }
+ if (mRSC->mObjHead == this) {
+ mRSC->mObjHead = mNext;
+ }
+ if (mPrev) {
+ mPrev->mNext = mNext;
+ }
+ if (mNext) {
+ mNext->mPrev = mPrev;
+ }
+ mPrev = NULL;
+ mNext = NULL;
+}
+
+void ObjectBase::zeroAllUserRef(Context *rsc)
+{
+ if (rsc->props.mLogObjects) {
+ LOGV("Forcing release of all outstanding user refs.");
+ }
+
+ // This operation can be slow, only to be called during context cleanup.
+ const ObjectBase * o = rsc->mObjHead;
+ while (o) {
+ //LOGE("o %p", o);
+ if (o->zeroUserRef()) {
+ // deleted the object and possibly others, restart from head.
+ o = rsc->mObjHead;
+ //LOGE("o head %p", o);
+ } else {
+ o = o->mNext;
+ //LOGE("o next %p", o);
+ }
+ }
+
+ if (rsc->props.mLogObjects) {
+ LOGV("Objects remaining.");
+ o = rsc->mObjHead;
+ while (o) {
+ o->dumpObj(" ");
+ o = o->mNext;
+ }
+ }
+}
+
diff --git a/libs/rs/rsObjectBase.h b/libs/rs/rsObjectBase.h
index d1e6baa..ea5e37cc 100644
--- a/libs/rs/rsObjectBase.h
+++ b/libs/rs/rsObjectBase.h
@@ -23,18 +23,21 @@
namespace android {
namespace renderscript {
+class Context;
+
// An element is a group of Components that occupies one cell in a structure.
class ObjectBase
{
public:
- ObjectBase();
+ ObjectBase(Context *rsc);
virtual ~ObjectBase();
void incSysRef() const;
- void decSysRef() const;
+ bool decSysRef() const;
void incUserRef() const;
- void decUserRef() const;
+ bool decUserRef() const;
+ bool zeroUserRef() const;
const char * getName() const {
return mName;
@@ -42,12 +45,30 @@
void setName(const char *);
void setName(const char *, uint32_t len);
+ Context * getContext() const {return mRSC;}
+ void setContext(Context *);
+
+ static void zeroAllUserRef(Context *rsc);
+
+ void dumpObj(const char *op) const;
+
+protected:
+ const char *mAllocFile;
+ uint32_t mAllocLine;
+
private:
+ void add() const;
+ void remove() const;
+
+ bool checkDelete() const;
+
char * mName;
+ Context *mRSC;
mutable int32_t mSysRefCount;
mutable int32_t mUserRefCount;
-
+ mutable const ObjectBase * mPrev;
+ mutable const ObjectBase * mNext;
};
template<class T>
diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp
index 18eacfb..5f2a609 100644
--- a/libs/rs/rsProgram.cpp
+++ b/libs/rs/rsProgram.cpp
@@ -21,12 +21,13 @@
using namespace android::renderscript;
-Program::Program(Element *in, Element *out)
+Program::Program(Context *rsc, Element *in, Element *out) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
+
mElementIn.set(in);
mElementOut.set(out);
-
-
}
Program::~Program()
diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h
index bb3d9ac..26b78dd 100644
--- a/libs/rs/rsProgram.h
+++ b/libs/rs/rsProgram.h
@@ -29,7 +29,7 @@
class Program : public ObjectBase
{
public:
- Program(Element *in, Element *out);
+ Program(Context *, Element *in, Element *out);
virtual ~Program();
void bindAllocation(Allocation *);
diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp
index 6cf64a4..708a0e0 100644
--- a/libs/rs/rsProgramFragment.cpp
+++ b/libs/rs/rsProgramFragment.cpp
@@ -24,9 +24,11 @@
using namespace android::renderscript;
-ProgramFragment::ProgramFragment(Element *in, Element *out, bool pointSpriteEnable) :
- Program(in, out)
+ProgramFragment::ProgramFragment(Context *rsc, Element *in, Element *out, bool pointSpriteEnable) :
+ Program(rsc, in, out)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
for (uint32_t ct=0; ct < MAX_TEXTURE; ct++) {
mEnvModes[ct] = RS_TEX_ENV_MODE_REPLACE;
mTextureDimensions[ct] = 2;
@@ -186,10 +188,16 @@
void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h)
{
- ProgramFragment *pf = new ProgramFragment(NULL, NULL, false);
+ ProgramFragment *pf = new ProgramFragment(rsc, NULL, NULL, false);
mDefault.set(pf);
}
+void ProgramFragmentState::deinit(Context *rsc)
+{
+ mDefault.clear();
+ mLast.clear();
+}
+
namespace android {
namespace renderscript {
@@ -197,7 +205,7 @@
void rsi_ProgramFragmentBegin(Context * rsc, RsElement in, RsElement out, bool pointSpriteEnable)
{
delete rsc->mStateFragment.mPF;
- rsc->mStateFragment.mPF = new ProgramFragment((Element *)in, (Element *)out, pointSpriteEnable);
+ rsc->mStateFragment.mPF = new ProgramFragment(rsc, (Element *)in, (Element *)out, pointSpriteEnable);
}
void rsi_ProgramFragmentBindTexture(Context *rsc, RsProgramFragment vpf, uint32_t slot, RsAllocation a)
diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h
index 51117eb..e26c6e8 100644
--- a/libs/rs/rsProgramFragment.h
+++ b/libs/rs/rsProgramFragment.h
@@ -32,7 +32,7 @@
- ProgramFragment(Element *in, Element *out, bool pointSpriteEnable);
+ ProgramFragment(Context *, Element *in, Element *out, bool pointSpriteEnable);
virtual ~ProgramFragment();
virtual void setupGL(const Context *, ProgramFragmentState *);
@@ -75,6 +75,7 @@
ProgramFragment *mPF;
void init(Context *rsc, int32_t w, int32_t h);
+ void deinit(Context *rsc);
ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE];
ObjectBaseRef<ProgramFragment> mDefault;
diff --git a/libs/rs/rsProgramFragmentStore.cpp b/libs/rs/rsProgramFragmentStore.cpp
index 3179484..de33d9c 100644
--- a/libs/rs/rsProgramFragmentStore.cpp
+++ b/libs/rs/rsProgramFragmentStore.cpp
@@ -24,9 +24,11 @@
using namespace android::renderscript;
-ProgramFragmentStore::ProgramFragmentStore(Element *in, Element *out) :
- Program(in, out)
+ProgramFragmentStore::ProgramFragmentStore(Context *rsc, Element *in, Element *out) :
+ Program(rsc, in, out)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mDitherEnable = true;
mBlendEnable = false;
mColorRWriteEnable = true;
@@ -213,10 +215,16 @@
void ProgramFragmentStoreState::init(Context *rsc, int32_t w, int32_t h)
{
- ProgramFragmentStore *pfs = new ProgramFragmentStore(NULL, NULL);
+ ProgramFragmentStore *pfs = new ProgramFragmentStore(rsc, NULL, NULL);
mDefault.set(pfs);
}
+void ProgramFragmentStoreState::deinit(Context *rsc)
+{
+ mDefault.clear();
+ mLast.clear();
+}
+
namespace android {
namespace renderscript {
@@ -224,7 +232,7 @@
void rsi_ProgramFragmentStoreBegin(Context * rsc, RsElement in, RsElement out)
{
delete rsc->mStateFragmentStore.mPFS;
- rsc->mStateFragmentStore.mPFS = new ProgramFragmentStore((Element *)in, (Element *)out);
+ rsc->mStateFragmentStore.mPFS = new ProgramFragmentStore(rsc, (Element *)in, (Element *)out);
}
diff --git a/libs/rs/rsProgramFragmentStore.h b/libs/rs/rsProgramFragmentStore.h
index e646e03..a344387 100644
--- a/libs/rs/rsProgramFragmentStore.h
+++ b/libs/rs/rsProgramFragmentStore.h
@@ -28,7 +28,7 @@
class ProgramFragmentStore : public Program
{
public:
- ProgramFragmentStore(Element *in, Element *out);
+ ProgramFragmentStore(Context *, Element *in, Element *out);
virtual ~ProgramFragmentStore();
virtual void setupGL(const Context *, ProgramFragmentStoreState *);
@@ -65,6 +65,7 @@
ProgramFragmentStoreState();
~ProgramFragmentStoreState();
void init(Context *rsc, int32_t w, int32_t h);
+ void deinit(Context *rsc);
ObjectBaseRef<ProgramFragmentStore> mDefault;
ObjectBaseRef<ProgramFragmentStore> mLast;
diff --git a/libs/rs/rsProgramRaster.cpp b/libs/rs/rsProgramRaster.cpp
index b968fe1..fcf6824 100644
--- a/libs/rs/rsProgramRaster.cpp
+++ b/libs/rs/rsProgramRaster.cpp
@@ -24,13 +24,16 @@
using namespace android::renderscript;
-ProgramRaster::ProgramRaster(Element *in,
+ProgramRaster::ProgramRaster(Context *rsc,
+ Element *in,
Element *out,
bool pointSmooth,
bool lineSmooth,
bool pointSprite) :
- Program(in, out)
+ Program(rsc, in, out)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mPointSmooth = pointSmooth;
mLineSmooth = lineSmooth;
mPointSprite = pointSprite;
@@ -95,10 +98,16 @@
void ProgramRasterState::init(Context *rsc, int32_t w, int32_t h)
{
- ProgramRaster *pr = new ProgramRaster(NULL, NULL, false, false, false);
+ ProgramRaster *pr = new ProgramRaster(rsc, NULL, NULL, false, false, false);
mDefault.set(pr);
}
+void ProgramRasterState::deinit(Context *rsc)
+{
+ mDefault.clear();
+ mLast.clear();
+}
+
namespace android {
namespace renderscript {
@@ -108,7 +117,8 @@
bool lineSmooth,
bool pointSprite)
{
- ProgramRaster *pr = new ProgramRaster(static_cast<Element *>(in),
+ ProgramRaster *pr = new ProgramRaster(rsc,
+ static_cast<Element *>(in),
static_cast<Element *>(out),
pointSmooth,
lineSmooth,
diff --git a/libs/rs/rsProgramRaster.h b/libs/rs/rsProgramRaster.h
index 5984868..a6d5ba8 100644
--- a/libs/rs/rsProgramRaster.h
+++ b/libs/rs/rsProgramRaster.h
@@ -28,7 +28,8 @@
class ProgramRaster : public Program
{
public:
- ProgramRaster(Element *in,
+ ProgramRaster(Context *rsc,
+ Element *in,
Element *out,
bool pointSmooth,
bool lineSmooth,
@@ -57,6 +58,7 @@
ProgramRasterState();
~ProgramRasterState();
void init(Context *rsc, int32_t w, int32_t h);
+ void deinit(Context *rsc);
ObjectBaseRef<ProgramRaster> mDefault;
ObjectBaseRef<ProgramRaster> mLast;
diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp
index dda56d7..9bfa602 100644
--- a/libs/rs/rsProgramVertex.cpp
+++ b/libs/rs/rsProgramVertex.cpp
@@ -24,9 +24,11 @@
using namespace android::renderscript;
-ProgramVertex::ProgramVertex(Element *in, Element *out) :
- Program(in, out)
+ProgramVertex::ProgramVertex(Context *rsc, Element *in, Element *out) :
+ Program(rsc, in, out)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mTextureMatrixEnable = false;
mLightCount = 0;
}
@@ -139,10 +141,10 @@
rsi_TypeBegin(rsc, e);
rsi_TypeAdd(rsc, RS_DIMENSION_X, 48);
- mAllocType = rsi_TypeCreate(rsc);
+ mAllocType.set((Type *)rsi_TypeCreate(rsc));
- ProgramVertex *pv = new ProgramVertex(NULL, NULL);
- Allocation *alloc = (Allocation *)rsi_AllocationCreateTyped(rsc, mAllocType);
+ ProgramVertex *pv = new ProgramVertex(rsc, NULL, NULL);
+ Allocation *alloc = (Allocation *)rsi_AllocationCreateTyped(rsc, mAllocType.get());
mDefaultAlloc.set(alloc);
mDefault.set(pv);
@@ -156,6 +158,16 @@
alloc->subData(RS_PROGRAM_VERTEX_MODELVIEW_OFFSET, 16, &m.m[0], 16*4);
}
+void ProgramVertexState::deinit(Context *rsc)
+{
+ mDefaultAlloc.clear();
+ mDefault.clear();
+ mAllocType.clear();
+ mLast.clear();
+ delete mPV;
+ mPV = NULL;
+}
+
namespace android {
namespace renderscript {
@@ -163,7 +175,7 @@
void rsi_ProgramVertexBegin(Context *rsc, RsElement in, RsElement out)
{
delete rsc->mStateVertex.mPV;
- rsc->mStateVertex.mPV = new ProgramVertex((Element *)in, (Element *)out);
+ rsc->mStateVertex.mPV = new ProgramVertex(rsc, (Element *)in, (Element *)out);
}
RsProgramVertex rsi_ProgramVertexCreate(Context *rsc)
diff --git a/libs/rs/rsProgramVertex.h b/libs/rs/rsProgramVertex.h
index 32d147c..e198f23 100644
--- a/libs/rs/rsProgramVertex.h
+++ b/libs/rs/rsProgramVertex.h
@@ -30,7 +30,7 @@
public:
const static uint32_t MAX_LIGHTS = 8;
- ProgramVertex(Element *in, Element *out);
+ ProgramVertex(Context *, Element *in, Element *out);
virtual ~ProgramVertex();
virtual void setupGL(const Context *rsc, ProgramVertexState *state);
@@ -59,12 +59,13 @@
~ProgramVertexState();
void init(Context *rsc, int32_t w, int32_t h);
+ void deinit(Context *rsc);
ObjectBaseRef<ProgramVertex> mDefault;
ObjectBaseRef<ProgramVertex> mLast;
ObjectBaseRef<Allocation> mDefaultAlloc;
- RsType mAllocType;
+ ObjectBaseRef<Type> mAllocType;
ProgramVertex *mPV;
diff --git a/libs/rs/rsSampler.cpp b/libs/rs/rsSampler.cpp
index 3f56faa..b793750 100644
--- a/libs/rs/rsSampler.cpp
+++ b/libs/rs/rsSampler.cpp
@@ -25,18 +25,23 @@
using namespace android::renderscript;
-Sampler::Sampler()
+Sampler::Sampler(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
// Should not get called.
rsAssert(0);
}
-Sampler::Sampler(RsSamplerValue magFilter,
+Sampler::Sampler(Context *rsc,
+ RsSamplerValue magFilter,
RsSamplerValue minFilter,
RsSamplerValue wrapS,
RsSamplerValue wrapT,
- RsSamplerValue wrapR)
+ RsSamplerValue wrapR) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mMagFilter = magFilter;
mMinFilter = minFilter;
mWrapS = wrapS;
@@ -138,7 +143,8 @@
SamplerState * ss = &rsc->mStateSampler;
- Sampler * s = new Sampler(ss->mMagFilter,
+ Sampler * s = new Sampler(rsc,
+ ss->mMagFilter,
ss->mMinFilter,
ss->mWrapS,
ss->mWrapT,
diff --git a/libs/rs/rsSampler.h b/libs/rs/rsSampler.h
index 4b504f6..ccf9b4d 100644
--- a/libs/rs/rsSampler.h
+++ b/libs/rs/rsSampler.h
@@ -31,7 +31,8 @@
class Sampler : public ObjectBase
{
public:
- Sampler(RsSamplerValue magFilter,
+ Sampler(Context *,
+ RsSamplerValue magFilter,
RsSamplerValue minFilter,
RsSamplerValue wrapS,
RsSamplerValue wrapT,
@@ -55,12 +56,12 @@
int32_t mBoundSlot;
private:
- Sampler();
+ Sampler(Context *);
};
-class SamplerState
+class SamplerState
{
public:
diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp
index 76fed3b..cb1436b 100644
--- a/libs/rs/rsScript.cpp
+++ b/libs/rs/rsScript.cpp
@@ -19,8 +19,10 @@
using namespace android;
using namespace android::renderscript;
-Script::Script()
+Script::Script(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
memset(&mEnviroment, 0, sizeof(mEnviroment));
mEnviroment.mClearColor[0] = 0;
mEnviroment.mClearColor[1] = 0;
diff --git a/libs/rs/rsScript.h b/libs/rs/rsScript.h
index 97cb67a..0067fc8 100644
--- a/libs/rs/rsScript.h
+++ b/libs/rs/rsScript.h
@@ -36,7 +36,7 @@
public:
typedef void (* InvokeFunc_t)(void);
- Script();
+ Script(Context *);
virtual ~Script();
diff --git a/libs/rs/rsScriptC.cpp b/libs/rs/rsScriptC.cpp
index 22d42ac..e63ed24 100644
--- a/libs/rs/rsScriptC.cpp
+++ b/libs/rs/rsScriptC.cpp
@@ -33,8 +33,10 @@
ScriptC * sc = (ScriptC *) tls->mScript
-ScriptC::ScriptC()
+ScriptC::ScriptC(Context *rsc) : Script(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mAccScript = NULL;
memset(&mProgram, 0, sizeof(mProgram));
}
@@ -106,7 +108,7 @@
}
delete mScript;
- mScript = new ScriptC();
+ mScript = new ScriptC(NULL);
mInt32Defines.clear();
mFloatDefines.clear();
@@ -130,8 +132,8 @@
rsc->appendNameDefines(&tmp);
appendDecls(&tmp);
rsc->appendVarDefines(&tmp);
- appendVarDefines(&tmp);
- appendTypes(&tmp);
+ appendVarDefines(rsc, &tmp);
+ appendTypes(rsc, &tmp);
tmp.append("#line 1\n");
const char* scriptSource[] = {tmp.string(), s->mEnviroment.mScriptText};
@@ -260,11 +262,13 @@
s->append("}");
}
-void ScriptCState::appendVarDefines(String8 *str)
+void ScriptCState::appendVarDefines(const Context *rsc, String8 *str)
{
char buf[256];
- LOGD("appendVarDefines mInt32Defines.size()=%d mFloatDefines.size()=%d\n",
- mInt32Defines.size(), mFloatDefines.size());
+ if (rsc->props.mLogScripts) {
+ LOGD("appendVarDefines mInt32Defines.size()=%d mFloatDefines.size()=%d\n",
+ mInt32Defines.size(), mFloatDefines.size());
+ }
for (size_t ct=0; ct < mInt32Defines.size(); ct++) {
str->append("#define ");
str->append(mInt32Defines.keyAt(ct));
@@ -283,7 +287,7 @@
-void ScriptCState::appendTypes(String8 *str)
+void ScriptCState::appendTypes(const Context *rsc, String8 *str)
{
char buf[256];
String8 tmp;
@@ -308,7 +312,9 @@
s.append("_t struct struct_");
s.append(e->getName());
s.append("\n\n");
- LOGD(s);
+ if (rsc->props.mLogScripts) {
+ LOGV(s);
+ }
str->append(s);
}
@@ -321,7 +327,9 @@
tmp.append(c->getComponentName());
sprintf(buf, " %i\n", ct2);
tmp.append(buf);
- LOGD(tmp);
+ if (rsc->props.mLogScripts) {
+ LOGV(tmp);
+ }
str->append(tmp);
}
}
@@ -351,7 +359,9 @@
}
s.append(mSlotNames[ct]);
s.append(";\n");
- LOGD(s);
+ if (rsc->props.mLogScripts) {
+ LOGV(s);
+ }
str->append(s);
}
}
@@ -391,6 +401,7 @@
ss->runCompiler(rsc, s);
s->incUserRef();
+ s->setContext(rsc);
for (int ct=0; ct < MAX_SCRIPT_BANKS; ct++) {
s->mTypes[ct].set(ss->mConstantBufferTypes[ct].get());
s->mSlotNames[ct] = ss->mSlotNames[ct];
diff --git a/libs/rs/rsScriptC.h b/libs/rs/rsScriptC.h
index 16eb8de..ae124b4 100644
--- a/libs/rs/rsScriptC.h
+++ b/libs/rs/rsScriptC.h
@@ -37,7 +37,7 @@
typedef int (*RunScript_t)(uint32_t launchIndex);
typedef void (*VoidFunc_t)();
- ScriptC();
+ ScriptC(Context *);
virtual ~ScriptC();
struct Program_t {
@@ -77,8 +77,8 @@
void clear();
void runCompiler(Context *rsc, ScriptC *s);
- void appendVarDefines(String8 *str);
- void appendTypes(String8 *str);
+ void appendVarDefines(const Context *rsc, String8 *str);
+ void appendTypes(const Context *rsc, String8 *str);
struct SymbolTable_t {
const char * mName;
diff --git a/libs/rs/rsSimpleMesh.cpp b/libs/rs/rsSimpleMesh.cpp
index 447bcee..b082fd7 100644
--- a/libs/rs/rsSimpleMesh.cpp
+++ b/libs/rs/rsSimpleMesh.cpp
@@ -22,12 +22,16 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
-SimpleMesh::SimpleMesh()
+SimpleMesh::SimpleMesh(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
}
SimpleMesh::~SimpleMesh()
{
+ delete[] mVertexTypes;
+ delete[] mVertexBuffers;
}
void SimpleMesh::render() const
@@ -104,7 +108,7 @@
RsSimpleMesh rsi_SimpleMeshCreate(Context *rsc, RsType prim, RsType idx, RsType *vtx, uint32_t vtxCount, uint32_t primType)
{
- SimpleMesh *sm = new SimpleMesh();
+ SimpleMesh *sm = new SimpleMesh(rsc);
sm->incUserRef();
sm->mIndexType.set((const Type *)idx);
diff --git a/libs/rs/rsSimpleMesh.h b/libs/rs/rsSimpleMesh.h
index dc5e19c..1e5c908 100644
--- a/libs/rs/rsSimpleMesh.h
+++ b/libs/rs/rsSimpleMesh.h
@@ -29,7 +29,7 @@
class SimpleMesh : public ObjectBase
{
public:
- SimpleMesh();
+ SimpleMesh(Context *);
~SimpleMesh();
ObjectBaseRef<const Type> mIndexType;
diff --git a/libs/rs/rsThreadIO.cpp b/libs/rs/rsThreadIO.cpp
index 4072f06..4d3d73a 100644
--- a/libs/rs/rsThreadIO.cpp
+++ b/libs/rs/rsThreadIO.cpp
@@ -42,11 +42,15 @@
uint32_t cmdID = 0;
uint32_t cmdSize = 0;
ret = true;
- if (con->logTimes) {
+ if (con->props.mLogTimes) {
con->timerSet(Context::RS_TIMER_IDLE);
}
const void * data = mToCore.get(&cmdID, &cmdSize);
- if (con->logTimes) {
+ if (!cmdSize) {
+ // exception occured, probably shutdown.
+ return false;
+ }
+ if (con->props.mLogTimes) {
con->timerSet(Context::RS_TIMER_INTERNAL);
}
waitForCommand = false;
diff --git a/libs/rs/rsType.cpp b/libs/rs/rsType.cpp
index 1838fa6..5ce9ca2 100644
--- a/libs/rs/rsType.cpp
+++ b/libs/rs/rsType.cpp
@@ -20,8 +20,10 @@
using namespace android;
using namespace android::renderscript;
-Type::Type()
+Type::Type(Context *rsc) : ObjectBase(rsc)
{
+ mAllocFile = __FILE__;
+ mAllocLine = __LINE__;
mLODs = 0;
mLODCount = 0;
memset(&mGL, 0, sizeof(mGL));
@@ -363,7 +365,7 @@
{
TypeState * stc = &rsc->mStateType;
- Type * st = new Type();
+ Type * st = new Type(rsc);
st->incUserRef();
st->setDimX(stc->mX);
st->setDimY(stc->mY);
@@ -372,6 +374,7 @@
st->setDimLOD(stc->mLOD);
st->setDimFaces(stc->mFaces);
st->compute();
+ stc->mElement.clear();
return st;
}
diff --git a/libs/rs/rsType.h b/libs/rs/rsType.h
index 6c39a4c..116f1c7 100644
--- a/libs/rs/rsType.h
+++ b/libs/rs/rsType.h
@@ -27,7 +27,7 @@
class Type : public ObjectBase
{
public:
- Type();
+ Type(Context *);
virtual ~Type();
Type * createTex2D(const Element *, size_t w, size_t h, bool mip);
@@ -139,12 +139,6 @@
uint32_t mLOD;
bool mFaces;
ObjectBaseRef<const Element> mElement;
-
- ObjectBaseRef<const Type> mIndexType;
- ObjectBaseRef<const Type> mPrimitiveType;
- ObjectBaseRef<const Type> *mVertexTypes;
-
-
};
diff --git a/libs/ui/CameraParameters.cpp b/libs/ui/CameraParameters.cpp
index 6c25836..9200a97 100644
--- a/libs/ui/CameraParameters.cpp
+++ b/libs/ui/CameraParameters.cpp
@@ -2,16 +2,16 @@
**
** Copyright 2008, 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
+** 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
+** 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
+** 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.
*/
@@ -23,6 +23,103 @@
#include <ui/CameraParameters.h>
namespace android {
+// Parameter keys to communicate between camera application and driver.
+const char CameraParameters::KEY_PREVIEW_SIZE[] = "preview-size";
+const char CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES[] = "preview-size-values";
+const char CameraParameters::KEY_PREVIEW_FORMAT[] = "preview-format";
+const char CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS[] = "preview-format-values";
+const char CameraParameters::KEY_PREVIEW_FRAME_RATE[] = "preview-frame-rate";
+const char CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES[] = "preview-frame-rate-values";
+const char CameraParameters::KEY_PICTURE_SIZE[] = "picture-size";
+const char CameraParameters::KEY_SUPPORTED_PICTURE_SIZES[] = "picture-size-values";
+const char CameraParameters::KEY_PICTURE_FORMAT[] = "picture-format";
+const char CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS[] = "picture-format-values";
+const char CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH[] = "jpeg-thumbnail-width";
+const char CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT[] = "jpeg-thumbnail-height";
+const char CameraParameters::KEY_SUPPORTED_THUMBNAIL_SIZES[] = "jpeg-thumbnail-size-values";
+const char CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY[] = "jpeg-thumbnail-quality";
+const char CameraParameters::KEY_JPEG_QUALITY[] = "jpeg-quality";
+const char CameraParameters::KEY_ROTATION[] = "rotation";
+const char CameraParameters::KEY_GPS_LATITUDE[] = "gps-latitude";
+const char CameraParameters::KEY_GPS_LONGITUDE[] = "gps-longitude";
+const char CameraParameters::KEY_GPS_ALTITUDE[] = "gps-altitude";
+const char CameraParameters::KEY_GPS_TIMESTAMP[] = "gps-timestamp";
+const char CameraParameters::KEY_WHITE_BALANCE[] = "whitebalance";
+const char CameraParameters::KEY_SUPPORTED_WHITE_BALANCE[] = "whitebalance-values";
+const char CameraParameters::KEY_EFFECT[] = "effect";
+const char CameraParameters::KEY_SUPPORTED_EFFECTS[] = "effect-values";
+const char CameraParameters::KEY_ANTIBANDING[] = "antibanding";
+const char CameraParameters::KEY_SUPPORTED_ANTIBANDING[] = "antibanding-values";
+const char CameraParameters::KEY_SCENE_MODE[] = "scene-mode";
+const char CameraParameters::KEY_SUPPORTED_SCENE_MODES[] = "scene-mode-values";
+const char CameraParameters::KEY_FLASH_MODE[] = "flash-mode";
+const char CameraParameters::KEY_SUPPORTED_FLASH_MODES[] = "flash-mode-values";
+const char CameraParameters::KEY_FOCUS_MODE[] = "focus-mode";
+const char CameraParameters::KEY_SUPPORTED_FOCUS_MODES[] = "focus-mode-values";
+
+// Values for white balance settings.
+const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";
+const char CameraParameters::WHITE_BALANCE_INCANDESCENT[] = "incandescent";
+const char CameraParameters::WHITE_BALANCE_FLUORESCENT[] = "fluorescent";
+const char CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT[] = "warm-fluorescent";
+const char CameraParameters::WHITE_BALANCE_DAYLIGHT[] = "daylight";
+const char CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT[] = "cloudy-daylight";
+const char CameraParameters::WHITE_BALANCE_TWILIGHT[] = "twilight";
+const char CameraParameters::WHITE_BALANCE_SHADE[] = "shade";
+
+// Values for effect settings.
+const char CameraParameters::EFFECT_NONE[] = "none";
+const char CameraParameters::EFFECT_MONO[] = "mono";
+const char CameraParameters::EFFECT_NEGATIVE[] = "negative";
+const char CameraParameters::EFFECT_SOLARIZE[] = "solarize";
+const char CameraParameters::EFFECT_SEPIA[] = "sepia";
+const char CameraParameters::EFFECT_POSTERIZE[] = "posterize";
+const char CameraParameters::EFFECT_WHITEBOARD[] = "whiteboard";
+const char CameraParameters::EFFECT_BLACKBOARD[] = "blackboard";
+const char CameraParameters::EFFECT_AQUA[] = "aqua";
+
+// Values for antibanding settings.
+const char CameraParameters::ANTIBANDING_AUTO[] = "auto";
+const char CameraParameters::ANTIBANDING_50HZ[] = "50hz";
+const char CameraParameters::ANTIBANDING_60HZ[] = "60hz";
+const char CameraParameters::ANTIBANDING_OFF[] = "off";
+
+// Values for flash mode settings.
+const char CameraParameters::FLASH_MODE_OFF[] = "off";
+const char CameraParameters::FLASH_MODE_AUTO[] = "auto";
+const char CameraParameters::FLASH_MODE_ON[] = "on";
+const char CameraParameters::FLASH_MODE_RED_EYE[] = "red-eye";
+const char CameraParameters::FLASH_MODE_VIDEO_LIGHT[] = "video-light";
+
+// Values for scene mode settings.
+const char CameraParameters::SCENE_MODE_AUTO[] = "auto";
+const char CameraParameters::SCENE_MODE_ACTION[] = "action";
+const char CameraParameters::SCENE_MODE_PORTRAIT[] = "portrait";
+const char CameraParameters::SCENE_MODE_LANDSCAPE[] = "landscape";
+const char CameraParameters::SCENE_MODE_NIGHT[] = "night";
+const char CameraParameters::SCENE_MODE_NIGHT_PORTRAIT[] = "night-portrait";
+const char CameraParameters::SCENE_MODE_THEATRE[] = "theatre";
+const char CameraParameters::SCENE_MODE_BEACH[] = "beach";
+const char CameraParameters::SCENE_MODE_SNOW[] = "snow";
+const char CameraParameters::SCENE_MODE_SUNSET[] = "sunset";
+const char CameraParameters::SCENE_MODE_STEADYPHOTO[] = "steadyphoto";
+const char CameraParameters::SCENE_MODE_FIREWORKS[] = "fireworks";
+const char CameraParameters::SCENE_MODE_SPORTS[] = "sports";
+const char CameraParameters::SCENE_MODE_PARTY[] = "party";
+const char CameraParameters::SCENE_MODE_CANDLELIGHT[] = "candlelight";
+
+// Formats for setPreviewFormat and setPictureFormat.
+const char CameraParameters::PIXEL_FORMAT_YUV422SP[] = "yuv422sp";
+const char CameraParameters::PIXEL_FORMAT_YUV420SP[] = "yuv420sp";
+const char CameraParameters::PIXEL_FORMAT_YUV422I[] = "yuv422i-yuyv";
+const char CameraParameters::PIXEL_FORMAT_RGB565[] = "rgb565";
+const char CameraParameters::PIXEL_FORMAT_JPEG[] = "jpeg";
+
+// Values for focus mode settings.
+const char CameraParameters::FOCUS_MODE_AUTO[] = "auto";
+const char CameraParameters::FOCUS_MODE_INFINITY[] = "infinity";
+const char CameraParameters::FOCUS_MODE_MACRO[] = "macro";
+const char CameraParameters::FOCUS_MODE_FIXED[] = "fixed";
static const char* portrait = "portrait";
static const char* landscape = "landscape";
@@ -91,7 +188,7 @@
void CameraParameters::set(const char *key, const char *value)
{
- // XXX i think i can do this with strspn()
+ // XXX i think i can do this with strspn()
if (strchr(key, '=') || strchr(key, ';')) {
//XXX LOGE("Key \"%s\"contains invalid character (= or ;)", key);
return;
@@ -150,7 +247,7 @@
{
char str[32];
sprintf(str, "%dx%d", width, height);
- set("preview-size", str);
+ set(KEY_PREVIEW_SIZE, str);
}
void CameraParameters::getPreviewSize(int *width, int *height) const
@@ -159,7 +256,7 @@
*height = -1;
// Get the current string, if it doesn't exist, leave the -1x-1
- const char *p = get("preview-size");
+ const char *p = get(KEY_PREVIEW_SIZE);
if (p == 0)
return;
@@ -172,17 +269,17 @@
void CameraParameters::setPreviewFrameRate(int fps)
{
- set("preview-frame-rate", fps);
+ set(KEY_PREVIEW_FRAME_RATE, fps);
}
int CameraParameters::getPreviewFrameRate() const
{
- return getInt("preview-frame-rate");
+ return getInt(KEY_PREVIEW_FRAME_RATE);
}
void CameraParameters::setPreviewFormat(const char *format)
{
- set("preview-format", format);
+ set(KEY_PREVIEW_FORMAT, format);
}
int CameraParameters::getOrientation() const
@@ -196,22 +293,22 @@
void CameraParameters::setOrientation(int orientation)
{
if (orientation == CAMERA_ORIENTATION_PORTRAIT) {
- set("preview-format", portrait);
+ set("orientation", portrait);
} else {
- set("preview-format", landscape);
+ set("orientation", landscape);
}
}
const char *CameraParameters::getPreviewFormat() const
{
- return get("preview-format");
+ return get(KEY_PREVIEW_FORMAT);
}
void CameraParameters::setPictureSize(int width, int height)
{
char str[32];
sprintf(str, "%dx%d", width, height);
- set("picture-size", str);
+ set(KEY_PICTURE_SIZE, str);
}
void CameraParameters::getPictureSize(int *width, int *height) const
@@ -220,7 +317,7 @@
*height = -1;
// Get the current string, if it doesn't exist, leave the -1x-1
- const char *p = get("picture-size");
+ const char *p = get(KEY_PICTURE_SIZE);
if (p == 0)
return;
@@ -233,12 +330,12 @@
void CameraParameters::setPictureFormat(const char *format)
{
- set("picture-format", format);
+ set(KEY_PICTURE_FORMAT, format);
}
const char *CameraParameters::getPictureFormat() const
{
- return get("picture-format");
+ return get(KEY_PICTURE_FORMAT);
}
void CameraParameters::dump() const
diff --git a/media/java/android/media/MediaFile.java b/media/java/android/media/MediaFile.java
index 03ffc67..8180a7c 100644
--- a/media/java/android/media/MediaFile.java
+++ b/media/java/android/media/MediaFile.java
@@ -17,6 +17,7 @@
package android.media;
import android.content.ContentValues;
+import android.os.SystemProperties;
import android.provider.MediaStore.Audio;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.Video;
@@ -103,7 +104,9 @@
addFileType("WAV", FILE_TYPE_WAV, "audio/x-wav");
addFileType("AMR", FILE_TYPE_AMR, "audio/amr");
addFileType("AWB", FILE_TYPE_AWB, "audio/amr-wb");
- addFileType("WMA", FILE_TYPE_WMA, "audio/x-ms-wma");
+ if (SystemProperties.getInt("ro.media.dec.aud.wma.enabled", 0) != 0) {
+ addFileType("WMA", FILE_TYPE_WMA, "audio/x-ms-wma");
+ }
addFileType("OGG", FILE_TYPE_OGG, "application/ogg");
addFileType("OGA", FILE_TYPE_OGG, "application/ogg");
addFileType("AAC", FILE_TYPE_AAC, "audio/aac");
@@ -123,8 +126,10 @@
addFileType("3GPP", FILE_TYPE_3GPP, "video/3gpp");
addFileType("3G2", FILE_TYPE_3GPP2, "video/3gpp2");
addFileType("3GPP2", FILE_TYPE_3GPP2, "video/3gpp2");
- addFileType("WMV", FILE_TYPE_WMV, "video/x-ms-wmv");
- addFileType("ASF", FILE_TYPE_ASF, "video/x-ms-asf");
+ if (SystemProperties.getInt("ro.media.dec.vid.wmv.enabled", 0) != 0) {
+ addFileType("WMV", FILE_TYPE_WMV, "video/x-ms-wmv");
+ addFileType("ASF", FILE_TYPE_ASF, "video/x-ms-asf");
+ }
addFileType("JPG", FILE_TYPE_JPEG, "image/jpeg");
addFileType("JPEG", FILE_TYPE_JPEG, "image/jpeg");
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaProfileReader.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaProfileReader.java
index 53afb1d..717f7ba 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaProfileReader.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/MediaProfileReader.java
@@ -58,19 +58,21 @@
public static void createVideoProfileTable() {
// push all the property into one big table
String encoderType = getVideoCodecProperty();
- String encoder[] = encoderType.split(",");
- for (int i = 0; i < encoder.length; i++) {
- for (int j = 0; j < VIDEO_ENCODER_PROPERTY.length; j++) {
- String propertyName = MEDIA_ENC_VID + encoder[i] + VIDEO_ENCODER_PROPERTY[j];
- String prop = SystemProperties.get(propertyName);
- //push to the table
- String propRange[] = prop.split(",");
- OUTPUT_FORMAT_TABLE.put((encoder[i] + VIDEO_ENCODER_PROPERTY[j] + "_low"),
- Integer.parseInt(propRange[0]));
- OUTPUT_FORMAT_TABLE.put((encoder[i] + VIDEO_ENCODER_PROPERTY[j] + "_high"),
- Integer.parseInt(propRange[1]));
- }
+ if (encoderType.length() != 0) {
+ String encoder[] = encoderType.split(",");
+ for (int i = 0; i < encoder.length; i++) {
+ for (int j = 0; j < VIDEO_ENCODER_PROPERTY.length; j++) {
+ String propertyName = MEDIA_ENC_VID + encoder[i] + VIDEO_ENCODER_PROPERTY[j];
+ String prop = SystemProperties.get(propertyName);
+ // push to the table
+ String propRange[] = prop.split(",");
+ OUTPUT_FORMAT_TABLE.put((encoder[i] + VIDEO_ENCODER_PROPERTY[j] + "_low"),
+ Integer.parseInt(propRange[0]));
+ OUTPUT_FORMAT_TABLE.put((encoder[i] + VIDEO_ENCODER_PROPERTY[j] + "_high"),
+ Integer.parseInt(propRange[1]));
+ }
+ }
}
}
@@ -78,18 +80,19 @@
// push all the property into one big table
String audioType = getAudioCodecProperty();
String encoder[] = audioType.split(",");
- for (int i = 0; i < encoder.length; i++) {
- for (int j = 0; j < AUDIO_ENCODER_PROPERTY.length; j++) {
- String propertyName = MEDIA_AUD_VID + encoder[i] + AUDIO_ENCODER_PROPERTY[j];
- String prop = SystemProperties.get(propertyName);
- //push to the table
- String propRange[] = prop.split(",");
- OUTPUT_FORMAT_TABLE.put((encoder[i] + AUDIO_ENCODER_PROPERTY[j] + "_low"),
- Integer.parseInt(propRange[0]));
- OUTPUT_FORMAT_TABLE.put((encoder[i] + AUDIO_ENCODER_PROPERTY[j] + "_high"),
- Integer.parseInt(propRange[1]));
+ if (audioType.length() != 0) {
+ for (int i = 0; i < encoder.length; i++) {
+ for (int j = 0; j < AUDIO_ENCODER_PROPERTY.length; j++) {
+ String propertyName = MEDIA_AUD_VID + encoder[i] + AUDIO_ENCODER_PROPERTY[j];
+ String prop = SystemProperties.get(propertyName);
+ // push to the table
+ String propRange[] = prop.split(",");
+ OUTPUT_FORMAT_TABLE.put((encoder[i] + AUDIO_ENCODER_PROPERTY[j] + "_low"),
+ Integer.parseInt(propRange[0]));
+ OUTPUT_FORMAT_TABLE.put((encoder[i] + AUDIO_ENCODER_PROPERTY[j] + "_high"),
+ Integer.parseInt(propRange[1]));
+ }
}
-
}
}
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
index 690eff6..fdc5970 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/MediaRecorderTest.java
@@ -434,15 +434,15 @@
boolean recordSuccess = false;
String deviceType = MediaProfileReader.getDeviceType();
Log.v(TAG, "deviceType = " + deviceType);
- if (deviceType.compareTo("voles") == 0) {
- // Test cases are device specified
- MediaProfileReader.createVideoProfileTable();
- MediaProfileReader.createAudioProfileTable();
- MediaProfileReader.createEncoderTable();
- String encoderType = MediaProfileReader.getVideoCodecProperty();
- String encoder[] = encoderType.split(",");
- String audioType = MediaProfileReader.getAudioCodecProperty();
+ // Test cases are device specified
+ MediaProfileReader.createVideoProfileTable();
+ MediaProfileReader.createAudioProfileTable();
+ MediaProfileReader.createEncoderTable();
+ String encoderType = MediaProfileReader.getVideoCodecProperty();
+ String audioType = MediaProfileReader.getAudioCodecProperty();
+ if ((encoderType.length() != 0) || (audioType.length() != 0)) {
String audio[] = audioType.split(",");
+ String encoder[] = encoderType.split(",");
for (int k = 0; k < 2; k++) {
for (int i = 0; i < encoder.length; i++) {
for (int j = 0; j < audio.length; j++) {
@@ -451,18 +451,18 @@
} else {
recordSuccess = recordVideoWithPara(encoder[i], audio[j], "low");
}
- if (!recordSuccess){
+ if (!recordSuccess) {
Log.v(TAG, "testDeviceSpecificCodec failed");
Log.v(TAG, "Encoder = " + encoder[i] + "Audio Encoder = " + audio[j]);
noOfFailure++;
}
- //assertTrue((encoder[i] + audio[j]), recordSuccess);
+ // assertTrue((encoder[i] + audio[j]), recordSuccess);
}
}
}
- }
- if (noOfFailure != 0){
- assertTrue("testDeviceSpecificCodec", false);
+ if (noOfFailure != 0) {
+ assertTrue("testDeviceSpecificCodec", false);
+ }
}
}
}
diff --git a/opengl/java/android/opengl/GLSurfaceView.java b/opengl/java/android/opengl/GLSurfaceView.java
index 3662a4f..695d0616 100644
--- a/opengl/java/android/opengl/GLSurfaceView.java
+++ b/opengl/java/android/opengl/GLSurfaceView.java
@@ -829,6 +829,9 @@
* OpenGL context is a somewhat heavy object.
*/
mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
+ if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
+ throw new RuntimeException("createContext failed");
+ }
mEglSurface = null;
}
@@ -842,7 +845,7 @@
* The window size has changed, so we need to create a new
* surface.
*/
- if (mEglSurface != null) {
+ if (mEglSurface != null && mEglSurface != EGL10.EGL_NO_SURFACE) {
/*
* Unbind and destroy the old EGL surface, if
@@ -859,12 +862,17 @@
mEglSurface = mEGLWindowSurfaceFactory.createWindowSurface(mEgl,
mEglDisplay, mEglConfig, holder);
+ if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) {
+ throw new RuntimeException("createWindowSurface failed");
+ }
+
/*
* Before we can issue GL commands, we need to make sure
* the context is current and bound to a surface.
*/
- mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface,
- mEglContext);
+ if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
+ throw new RuntimeException("eglMakeCurrent failed.");
+ }
GL gl = mEglContext.getGL();
if (mGLWrapper != null) {
@@ -902,7 +910,7 @@
}
public void destroySurface() {
- if (mEglSurface != null) {
+ if (mEglSurface != null && mEglSurface != EGL10.EGL_NO_SURFACE) {
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_CONTEXT);
diff --git a/opengl/libs/Android.mk b/opengl/libs/Android.mk
index 9578452..d6c7114 100644
--- a/opengl/libs/Android.mk
+++ b/opengl/libs/Android.mk
@@ -32,6 +32,10 @@
LOCAL_CFLAGS += -DADRENO130=1
endif
+ifeq ($(TARGET_BOARD_PLATFORM),qsd8k)
+LOCAL_CFLAGS += -DADRENO130=1
+endif
+
include $(BUILD_SHARED_LIBRARY)
installed_libEGL := $(LOCAL_INSTALLED_MODULE)
diff --git a/opengl/tests/gl2_basic/gl2_basic.cpp b/opengl/tests/gl2_basic/gl2_basic.cpp
index ba9a717..9345de5 100644
--- a/opengl/tests/gl2_basic/gl2_basic.cpp
+++ b/opengl/tests/gl2_basic/gl2_basic.cpp
@@ -44,17 +44,6 @@
fprintf(stderr, "GL %s = %s\n", name, v);
}
-static const char* eglErrorToString[] = {
- "EGL_SUCCESS", // 0x3000 12288
- "EGL_NOT_INITIALIZED",
- "EGL_BAD_ACCESS", // 0x3002 12290
- "EGL_BAD_ALLOC", "EGL_BAD_ATTRIBUTE",
- "EGL_BAD_CONFIG",
- "EGL_BAD_CONTEXT", // 0x3006 12294
- "EGL_BAD_CURRENT_SURFACE", "EGL_BAD_DISPLAY", "EGL_BAD_MATCH",
- "EGL_BAD_NATIVE_PIXMAP", "EGL_BAD_NATIVE_WINDOW", "EGL_BAD_PARAMETER", // 0x300c 12300
- "EGL_BAD_SURFACE" };
-
static void checkEglError(const char* op, EGLBoolean returnVal = EGL_TRUE) {
if (returnVal != EGL_TRUE) {
fprintf(stderr, "%s() returned %d\n", op, returnVal);
@@ -62,11 +51,7 @@
for (EGLint error = eglGetError(); error != EGL_SUCCESS; error
= eglGetError()) {
- const char* errorString = "unknown";
- if (error >= EGL_SUCCESS && error <= EGL_BAD_SURFACE) {
- errorString = eglErrorToString[error - EGL_SUCCESS];
- }
- fprintf(stderr, "after %s() eglError %s (0x%x)\n", op, errorString,
+ fprintf(stderr, "after %s() eglError %s (0x%x)\n", op, EGLUtils::strerror(error),
error);
}
}
@@ -190,22 +175,33 @@
checkGlError("glDrawArrays");
}
+#if 0
+
+void PrintEGLConfig(EGLDisplay dpy, EGLConfig config) {
+ int attrib[] = {EGL_RED_SIZE, EGL_GREEN_SIZE, EGL_BLUE_SIZE, EGL_ALPHA_SIZE,
+ EGL_DEPTH_SIZE, EGL_SURFACE_TYPE, EGL_RENDERABLE_TYPE
+ };
+ for(size_t i = 0; i < sizeof(attrib)/sizeof(attrib[0]); i++) {
+ int value = 0;
+ int a = attrib[i];
+ if (eglGetConfigAttrib(dpy, config, a, &value)) {
+ printf(" 0x%04x: %d", a, value);
+ }
+ }
+ printf("\n");
+}
+
+#endif
+
int main(int argc, char** argv) {
EGLBoolean returnValue;
- EGLConfig configs[2];
- EGLint config_count;
+ EGLConfig myConfig = {0};
EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
- EGLint s_configAttribs[] = { EGL_BUFFER_SIZE, EGL_DONT_CARE, EGL_RED_SIZE,
- 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, EGL_DEPTH_SIZE, 8,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE };
-
- EGLint s_configAttribs2[] =
- {
- EGL_DEPTH_SIZE, 16,
- EGL_NONE
- };
-
+ EGLint s_configAttribs[] = {
+ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT|EGL_WINDOW_BIT,
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL_NONE };
EGLint majorVersion;
EGLint minorVersion;
EGLContext context;
@@ -214,9 +210,6 @@
EGLDisplay dpy;
- EGLNativeWindowType window = 0;
- window = android_createDisplaySurface();
-
checkEglError("<init>");
dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
checkEglError("eglGetDisplay");
@@ -233,43 +226,31 @@
return 0;
}
- returnValue = eglGetConfigs(dpy, configs, 2, &config_count);
- checkEglError("eglGetConfigs", returnValue);
- fprintf(stderr, "Config count: %d\n", config_count);
- for (int i = 0; i < config_count; i++) {
- fprintf(stderr, "%d: 0x%08x\n", i, (unsigned int) configs[i]);
+ EGLNativeWindowType window = android_createDisplaySurface();
+ returnValue = EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &myConfig);
+ if (returnValue) {
+ printf("EGLUtils::selectConfigForNativeWindow() returned %d", returnValue);
+ return 0;
}
-#if 0
- EGLConfig config;
- EGLUtils::selectConfigForNativeWindow(dpy, s_configAttribs, window, &config);
- checkEglError("EGLUtils::selectConfigForNativeWindow");
-#else
- int chooseConfigResult = eglChooseConfig(dpy, s_configAttribs2, configs, 2,
- &config_count);
- checkEglError("eglChooseConfig", chooseConfigResult);
- if (chooseConfigResult != EGL_TRUE) {
- printf("eglChooseConfig failed\n");
- return 0;
- }
-#endif
-
- surface = eglCreateWindowSurface(dpy, configs[0], window, NULL);
+ surface = eglCreateWindowSurface(dpy, myConfig, window, NULL);
checkEglError("eglCreateWindowSurface");
if (surface == EGL_NO_SURFACE) {
printf("gelCreateWindowSurface failed.\n");
return 0;
}
- EGLint gl2_0Attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
- context = eglCreateContext(dpy, configs[0], EGL_NO_CONTEXT, context_attribs);
+ context = eglCreateContext(dpy, myConfig, EGL_NO_CONTEXT, context_attribs);
checkEglError("eglCreateContext");
if (context == EGL_NO_CONTEXT) {
printf("eglCreateContext failed\n");
return 0;
}
- eglMakeCurrent(dpy, surface, surface, context);
- checkEglError("eglMakeCurrent");
+ returnValue = eglMakeCurrent(dpy, surface, surface, context);
+ checkEglError("eglMakeCurrent", returnValue);
+ if (returnValue != EGL_TRUE) {
+ return 0;
+ }
eglQuerySurface(dpy, surface, EGL_WIDTH, &w);
checkEglError("eglQuerySurface");
eglQuerySurface(dpy, surface, EGL_HEIGHT, &h);
diff --git a/opengl/tests/gl2_jni/Android.mk b/opengl/tests/gl2_jni/Android.mk
index ff15814..81247df 100644
--- a/opengl/tests/gl2_jni/Android.mk
+++ b/opengl/tests/gl2_jni/Android.mk
@@ -44,8 +44,6 @@
LOCAL_MODULE := libgl2jni
-LOCAL_ARM_MODE := arm
-
LOCAL_PRELINK_MODULE := false
include $(BUILD_SHARED_LIBRARY)
diff --git a/opengl/tests/gl2_jni/jni/gl_code.cpp b/opengl/tests/gl2_jni/jni/gl_code.cpp
index 146d52a..c2fabe6 100644
--- a/opengl/tests/gl2_jni/jni/gl_code.cpp
+++ b/opengl/tests/gl2_jni/jni/gl_code.cpp
@@ -3,12 +3,12 @@
#include <nativehelper/jni.h>
#define LOG_TAG "GL2JNI gl_code.cpp"
#include <utils/Log.h>
-
+
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
-#include <stdio.h>
+#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -23,7 +23,7 @@
LOGI("after %s() glError (0x%x)\n", op, error);
}
}
-
+
static const char gVertexShader[] = "attribute vec4 vPosition;\n"
"void main() {\n"
" gl_Position = vPosition;\n"
@@ -151,15 +151,15 @@
extern "C" {
JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_init(JNIEnv * env, jobject obj, jint width, jint height);
JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_step(JNIEnv * env, jobject obj);
-};
-
-JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_init(JNIEnv * env, jobject obj, jint width, jint height)
-{
- setupGraphics(width, height);
-}
+};
-JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_step(JNIEnv * env, jobject obj)
-{
- renderFrame();
-}
+JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_init(JNIEnv * env, jobject obj, jint width, jint height)
+{
+ setupGraphics(width, height);
+}
+
+JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_step(JNIEnv * env, jobject obj)
+{
+ renderFrame();
+}
diff --git a/opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java b/opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java
index baa10af..2dae090 100644
--- a/opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java
+++ b/opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java
@@ -44,6 +44,7 @@
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.opengles.GL10;
+
/**
* An implementation of SurfaceView that uses the dedicated surface for
* displaying an OpenGL animation. This allows the animation to run in a
@@ -67,13 +68,14 @@
private void init() {
setEGLContextFactory(new ContextFactory());
- // setEGLConfigChooser(new ConfigChooser());
+ setEGLConfigChooser(new ConfigChooser());
setRenderer(new Renderer());
}
private static class ContextFactory implements GLSurfaceView.EGLContextFactory {
private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
+ Log.w(TAG, "creating OpenGL ES 2.0 context");
checkEglError("Before eglCreateContext", egl);
int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
@@ -83,7 +85,7 @@
public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
egl.eglDestroyContext(display, context);
- }
+ }
}
private static void checkEglError(String prompt, EGL10 egl) {
@@ -95,11 +97,13 @@
private static class ConfigChooser implements GLSurfaceView.EGLConfigChooser {
private static int EGL_OPENGL_ES2_BIT = 4;
- private static int[] s_configAttribs2 =
+ private static int[] s_configAttribs2 =
{
- EGL10.EGL_DEPTH_SIZE, 16,
- // EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
- EGL10.EGL_NONE
+ EGL10.EGL_RED_SIZE, 4,
+ EGL10.EGL_GREEN_SIZE, 4,
+ EGL10.EGL_BLUE_SIZE, 4,
+ EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+ EGL10.EGL_NONE
};
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
@@ -108,6 +112,7 @@
int numConfigs = num_config[0];
+ Log.w(TAG, String.format("Found %d configurations", numConfigs));
if (numConfigs <= 0) {
throw new IllegalArgumentException("No configs match configSpec");
}
diff --git a/packages/SettingsProvider/res/values/defaults.xml b/packages/SettingsProvider/res/values/defaults.xml
index db1b5f1..fbfe755 100644
--- a/packages/SettingsProvider/res/values/defaults.xml
+++ b/packages/SettingsProvider/res/values/defaults.xml
@@ -30,6 +30,7 @@
<bool name="def_screen_brightness_automatic_mode">false</bool>
<fraction name="def_window_animation_scale">100%</fraction>
<fraction name="def_window_transition_scale">100%</fraction>
+ <bool name="def_haptic_feedback">true</bool>
<bool name="def_bluetooth_on">false</bool>
<bool name="def_install_non_market_apps">false</bool>
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index c561078..e25c648 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -71,7 +71,7 @@
// database gets upgraded properly. At a minimum, please confirm that 'upgradeVersion'
// is properly propagated through your change. Not doing so will result in a loss of user
// settings.
- private static final int DATABASE_VERSION = 41;
+ private static final int DATABASE_VERSION = 42;
private Context mContext;
@@ -502,6 +502,25 @@
upgradeVersion = 41;
}
+ if (upgradeVersion == 41) {
+ /*
+ * Initialize newly public haptic feedback setting
+ */
+ db.beginTransaction();
+ try {
+ db.execSQL("DELETE FROM system WHERE name='"
+ + Settings.System.HAPTIC_FEEDBACK_ENABLED + "'");
+ SQLiteStatement stmt = db.compileStatement("INSERT INTO system(name,value)"
+ + " VALUES(?,?);");
+ loadDefaultHapticSettings(stmt);
+ stmt.close();
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ upgradeVersion = 42;
+ }
+
if (upgradeVersion != currentVersion) {
Log.w(TAG, "Got stuck trying to upgrade from version " + upgradeVersion
+ ", must wipe the settings provider");
@@ -746,6 +765,8 @@
loadBooleanSetting(stmt, Settings.System.ACCELEROMETER_ROTATION,
R.bool.def_accelerometer_rotation);
+ loadDefaultHapticSettings(stmt);
+
stmt.close();
}
@@ -756,6 +777,11 @@
R.fraction.def_window_transition_scale, 1);
}
+ private void loadDefaultHapticSettings(SQLiteStatement stmt) {
+ loadBooleanSetting(stmt, Settings.System.HAPTIC_FEEDBACK_ENABLED,
+ R.bool.def_haptic_feedback);
+ }
+
private void loadSecureSettings(SQLiteDatabase db) {
SQLiteStatement stmt = db.compileStatement("INSERT OR IGNORE INTO secure(name,value)"
+ " VALUES(?,?);");
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
index 77da8f1..3b91a38 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
@@ -40,16 +40,23 @@
private Context mContext;
private AudioManager mAudioManager;
private IContentService mContentService;
+ private IPowerManager mPowerManager;
private static final String[] PROVIDERS = { "gmail-ls", "calendar", "contacts" };
private boolean mSilent;
private boolean mVibrate;
+ private boolean mHasAutoBrightness;
public SettingsHelper(Context context) {
mContext = context;
mAudioManager = (AudioManager) context
.getSystemService(Context.AUDIO_SERVICE);
mContentService = ContentResolver.getContentService();
+ mPowerManager = IPowerManager.Stub.asInterface(
+ ServiceManager.getService("power"));
+
+ mHasAutoBrightness = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_automatic_brightness_available);
}
/**
@@ -64,6 +71,18 @@
public boolean restoreValue(String name, String value) {
if (Settings.System.SCREEN_BRIGHTNESS.equals(name)) {
setBrightness(Integer.parseInt(value));
+ } else if (Settings.System.SCREEN_BRIGHTNESS_MODE.equals(name)) {
+ if (mHasAutoBrightness) {
+ // When setting auto-brightness, must reset the brightness afterwards
+ try {
+ int curBrightness = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.SCREEN_BRIGHTNESS);
+ setAutoBrightness(Integer.parseInt(value) != 0);
+ setBrightness(curBrightness);
+ } catch (Settings.SettingNotFoundException e) {
+ // no brightness setting at all? weird. skip this then.
+ }
+ }
} else if (Settings.System.SOUND_EFFECTS_ENABLED.equals(name)) {
setSoundEffects(Integer.parseInt(value) == 1);
} else if (Settings.Secure.LOCATION_PROVIDERS_ALLOWED.equals(name)) {
@@ -73,6 +92,16 @@
return true;
}
+ private void setAutoBrightness(boolean value) {
+ if (mPowerManager != null) {
+ try {
+ mPowerManager.setAutoBrightness(value);
+ } catch (RemoteException e) {
+ // unable to reach the power manager; skip
+ }
+ }
+ }
+
private void setGpsLocation(String value) {
final String GPS = LocationManager.GPS_PROVIDER;
boolean enabled =
diff --git a/services/java/com/android/server/NotificationManagerService.java b/services/java/com/android/server/NotificationManagerService.java
index 696ef31..ff23a13 100755
--- a/services/java/com/android/server/NotificationManagerService.java
+++ b/services/java/com/android/server/NotificationManagerService.java
@@ -30,7 +30,6 @@
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
-import android.content.ContentQueryMap;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -103,7 +102,8 @@
private boolean mAdbNotificationShown = false;
private Notification mAdbNotification;
- private ArrayList<NotificationRecord> mNotificationList;
+ private final ArrayList<NotificationRecord> mNotificationList =
+ new ArrayList<NotificationRecord>();
private ArrayList<ToastRecord> mToastQueue;
@@ -152,20 +152,22 @@
private static final class NotificationRecord
{
- String pkg;
- int id;
+ final String pkg;
+ final String tag;
+ final int id;
ITransientNotification callback;
int duration;
- Notification notification;
+ final Notification notification;
IBinder statusBarKey;
- NotificationRecord(String pkg, int id, Notification notification)
+ NotificationRecord(String pkg, String tag, int id, Notification notification)
{
this.pkg = pkg;
+ this.tag = tag;
this.id = id;
this.notification = notification;
}
-
+
void dump(PrintWriter pw, String prefix, Context baseContext) {
pw.println(prefix + this);
pw.println(prefix + " icon=0x" + Integer.toHexString(notification.icon)
@@ -189,7 +191,8 @@
return "NotificationRecord{"
+ Integer.toHexString(System.identityHashCode(this))
+ " pkg=" + pkg
- + " id=" + Integer.toHexString(id) + "}";
+ + " id=" + Integer.toHexString(id)
+ + " tag=" + tag + "}";
}
}
@@ -258,8 +261,8 @@
cancelAll();
}
- public void onNotificationClick(String pkg, int id) {
- cancelNotification(pkg, id, Notification.FLAG_AUTO_CANCEL,
+ public void onNotificationClick(String pkg, String tag, int id) {
+ cancelNotification(pkg, tag, id, Notification.FLAG_AUTO_CANCEL,
Notification.FLAG_FOREGROUND_SERVICE);
}
@@ -369,7 +372,6 @@
mSound = new AsyncPlayer(TAG);
mSound.setUsesWakeLock(context);
mToastQueue = new ArrayList<ToastRecord>();
- mNotificationList = new ArrayList<NotificationRecord>();
mHandler = new WorkerHandler();
mStatusBarService = statusBar;
statusBar.setNotificationCallbacks(mNotificationCallbacks);
@@ -583,6 +585,12 @@
// ============================================================================
public void enqueueNotification(String pkg, int id, Notification notification, int[] idOut)
{
+ enqueueNotificationWithTag(pkg, null /* tag */, id, notification, idOut);
+ }
+
+ public void enqueueNotificationWithTag(String pkg, String tag, int id,
+ Notification notification, int[] idOut)
+ {
checkIncomingCall(pkg);
// This conditional is a dirty hack to limit the logging done on
@@ -608,10 +616,10 @@
}
synchronized (mNotificationList) {
- NotificationRecord r = new NotificationRecord(pkg, id, notification);
+ NotificationRecord r = new NotificationRecord(pkg, tag, id, notification);
NotificationRecord old = null;
- int index = indexOfNotificationLocked(pkg, id);
+ int index = indexOfNotificationLocked(pkg, tag, id);
if (index < 0) {
mNotificationList.add(r);
} else {
@@ -645,17 +653,18 @@
}
NotificationData n = new NotificationData();
- n.id = id;
- n.pkg = pkg;
- n.when = notification.when;
- n.tickerText = truncatedTicker;
- n.ongoingEvent = (notification.flags & Notification.FLAG_ONGOING_EVENT) != 0;
- if (!n.ongoingEvent && (notification.flags & Notification.FLAG_NO_CLEAR) == 0) {
- n.clearable = true;
- }
- n.contentView = notification.contentView;
- n.contentIntent = notification.contentIntent;
- n.deleteIntent = notification.deleteIntent;
+ n.pkg = pkg;
+ n.tag = tag;
+ n.id = id;
+ n.when = notification.when;
+ n.tickerText = truncatedTicker;
+ n.ongoingEvent = (notification.flags & Notification.FLAG_ONGOING_EVENT) != 0;
+ if (!n.ongoingEvent && (notification.flags & Notification.FLAG_NO_CLEAR) == 0) {
+ n.clearable = true;
+ }
+ n.contentView = notification.contentView;
+ n.contentIntent = notification.contentIntent;
+ n.deleteIntent = notification.deleteIntent;
if (old != null && old.statusBarKey != null) {
r.statusBarKey = old.statusBarKey;
long identity = Binder.clearCallingIdentity();
@@ -828,16 +837,14 @@
* Cancels a notification ONLY if it has all of the {@code mustHaveFlags}
* and none of the {@code mustNotHaveFlags}.
*/
- private void cancelNotification(String pkg, int id, int mustHaveFlags,
+ private void cancelNotification(String pkg, String tag, int id, int mustHaveFlags,
int mustNotHaveFlags) {
EventLog.writeEvent(EVENT_LOG_CANCEL, pkg, id, mustHaveFlags);
synchronized (mNotificationList) {
- NotificationRecord r = null;
-
- int index = indexOfNotificationLocked(pkg, id);
+ int index = indexOfNotificationLocked(pkg, tag, id);
if (index >= 0) {
- r = mNotificationList.get(index);
+ NotificationRecord r = mNotificationList.get(index);
if ((r.notification.flags & mustHaveFlags) != mustHaveFlags) {
return;
@@ -888,9 +895,13 @@
public void cancelNotification(String pkg, int id) {
+ cancelNotificationWithTag(pkg, null /* tag */, id);
+ }
+
+ public void cancelNotificationWithTag(String pkg, String tag, int id) {
checkIncomingCall(pkg);
// Don't allow client applications to cancel foreground service notis.
- cancelNotification(pkg, id, 0,
+ cancelNotification(pkg, tag, id, 0,
Binder.getCallingUid() == Process.SYSTEM_UID
? 0 : Notification.FLAG_FOREGROUND_SERVICE);
}
@@ -999,12 +1010,21 @@
}
// lock on mNotificationList
- private int indexOfNotificationLocked(String pkg, int id)
+ private int indexOfNotificationLocked(String pkg, String tag, int id)
{
ArrayList<NotificationRecord> list = mNotificationList;
final int len = list.size();
for (int i=0; i<len; i++) {
NotificationRecord r = list.get(i);
+ if (tag == null) {
+ if (r.tag != null) {
+ continue;
+ }
+ } else {
+ if (!tag.equals(r.tag)) {
+ continue;
+ }
+ }
if (r.id == id && r.pkg.equals(pkg)) {
return i;
}
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 323a11f..867f215 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -1103,6 +1103,12 @@
return null;
}
+ public boolean hasSystemFeature(String name) {
+ synchronized (mPackages) {
+ return mAvailableFeatures.containsKey(name);
+ }
+ }
+
public int checkPermission(String permName, String pkgName) {
synchronized (mPackages) {
PackageParser.Package p = mPackages.get(pkgName);
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 78a82dd..8ebbc93 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -3122,7 +3122,7 @@
public void overridePendingAppTransition(String packageName,
int enterAnim, int exitAnim) {
- if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET){
+ if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
mNextAppTransitionPackage = packageName;
mNextAppTransitionEnter = enterAnim;
mNextAppTransitionExit = exitAnim;
@@ -9327,7 +9327,6 @@
transit = WindowManagerPolicy.TRANSIT_UNSET;
}
mNextAppTransition = WindowManagerPolicy.TRANSIT_UNSET;
- mNextAppTransitionPackage = null;
mAppTransitionReady = false;
mAppTransitionRunning = true;
mAppTransitionTimeout = false;
@@ -9484,6 +9483,8 @@
wtoken.allDrawn = true;
}
+ mNextAppTransitionPackage = null;
+
mOpeningApps.clear();
mClosingApps.clear();
diff --git a/services/java/com/android/server/status/NotificationData.java b/services/java/com/android/server/status/NotificationData.java
index 63a7d70..0a3411a1 100644
--- a/services/java/com/android/server/status/NotificationData.java
+++ b/services/java/com/android/server/status/NotificationData.java
@@ -5,6 +5,7 @@
public class NotificationData {
public String pkg;
+ public String tag;
public int id;
public CharSequence tickerText;
@@ -17,9 +18,6 @@
public PendingIntent deleteIntent;
- public NotificationData() {
- }
-
public String toString() {
return "NotificationData(package=" + pkg + " tickerText=" + tickerText
+ " ongoingEvent=" + ongoingEvent + " contentIntent=" + contentIntent
diff --git a/services/java/com/android/server/status/StatusBarService.java b/services/java/com/android/server/status/StatusBarService.java
index 83552dd..9929498 100644
--- a/services/java/com/android/server/status/StatusBarService.java
+++ b/services/java/com/android/server/status/StatusBarService.java
@@ -126,7 +126,7 @@
public interface NotificationCallbacks {
void onSetDisabled(int status);
void onClearAll();
- void onNotificationClick(String pkg, int id);
+ void onNotificationClick(String pkg, String tag, int id);
void onPanelRevealed();
}
@@ -833,7 +833,7 @@
content.setOnFocusChangeListener(mFocusChangeListener);
PendingIntent contentIntent = n.contentIntent;
if (contentIntent != null) {
- content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.id));
+ content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.tag, n.id));
}
View child = null;
@@ -896,7 +896,7 @@
com.android.internal.R.id.content);
PendingIntent contentIntent = n.contentIntent;
if (contentIntent != null) {
- content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.id));
+ content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.tag, n.id));
}
}
catch (RuntimeException e) {
@@ -1248,11 +1248,13 @@
private class Launcher implements View.OnClickListener {
private PendingIntent mIntent;
private String mPkg;
+ private String mTag;
private int mId;
- Launcher(PendingIntent intent, String pkg, int id) {
+ Launcher(PendingIntent intent, String pkg, String tag, int id) {
mIntent = intent;
mPkg = pkg;
+ mTag = tag;
mId = id;
}
@@ -1267,7 +1269,7 @@
}
try {
mIntent.send();
- mNotificationCallbacks.onNotificationClick(mPkg, mId);
+ mNotificationCallbacks.onNotificationClick(mPkg, mTag, mId);
} catch (PendingIntent.CanceledException e) {
// the stack trace isn't very helpful here. Just log the exception message.
Log.w(TAG, "Sending contentIntent failed: " + e);
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index fb96b2a..a53b157 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -373,24 +373,18 @@
/** Current network is UMTS */
public static final int NETWORK_TYPE_UMTS = 3;
/** Current network is CDMA: Either IS95A or IS95B*/
- /** @hide */
public static final int NETWORK_TYPE_CDMA = 4;
- /** Current network is EVDO revision 0 or revision A*/
- /** @hide */
+ /** Current network is EVDO revision 0*/
public static final int NETWORK_TYPE_EVDO_0 = 5;
- /** @hide */
+ /** Current network is EVDO revision A*/
public static final int NETWORK_TYPE_EVDO_A = 6;
/** Current network is 1xRTT*/
- /** @hide */
public static final int NETWORK_TYPE_1xRTT = 7;
/** Current network is HSDPA */
- /** @hide */
public static final int NETWORK_TYPE_HSDPA = 8;
/** Current network is HSUPA */
- /** @hide */
public static final int NETWORK_TYPE_HSUPA = 9;
/** Current network is HSPA */
- /** @hide */
public static final int NETWORK_TYPE_HSPA = 10;
/**
diff --git a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
index 5581a24..1f0e5a5 100644
--- a/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/DataConnectionTracker.java
@@ -425,26 +425,28 @@
* will be sent by the ConnectivityManager when a connection to
* the APN has been established.
*/
- public int enableApnType(String type) {
+ public synchronized int enableApnType(String type) {
int id = apnTypeToId(type);
if (id == APN_INVALID_ID) {
return Phone.APN_REQUEST_FAILED;
}
- // If already active, return
if(DBG) Log.d(LOG_TAG, "enableApnType("+type+"), isApnTypeActive = "
+ isApnTypeActive(type) + " and state = " + state);
- if (isApnTypeActive(type)) {
- if (state == State.INITING) return Phone.APN_REQUEST_STARTED;
- else if (state == State.CONNECTED) return Phone.APN_ALREADY_ACTIVE;
- }
-
if (!isApnTypeAvailable(type)) {
return Phone.APN_TYPE_NOT_AVAILABLE;
}
+ // just because it's active doesn't mean we had it explicitly requested before
+ // (a broad default may handle many types). make sure we mark it enabled
+ // so if the default is disabled we keep the connection for others
setEnabled(id, true);
+
+ if (isApnTypeActive(type)) {
+ if (state == State.INITING) return Phone.APN_REQUEST_STARTED;
+ else if (state == State.CONNECTED) return Phone.APN_ALREADY_ACTIVE;
+ }
return Phone.APN_REQUEST_STARTED;
}
@@ -490,20 +492,21 @@
protected synchronized void onEnableApn(int apnId, int enabled) {
if (DBG) {
- Log.d(LOG_TAG, "got EVENT_APN_ENABLE_REQUEST with apnType = " + apnId +
- " and enable = " + enabled);
- Log.d(LOG_TAG, "dataEnabled[apnId] = " + dataEnabled[apnId] +
- ", enabledCount = " + enabledCount);
+ Log.d(LOG_TAG, "EVENT_APN_ENABLE_REQUEST " + apnId + ", " + enabled);
+ Log.d(LOG_TAG, " dataEnabled = " + dataEnabled[apnId] +
+ ", enabledCount = " + enabledCount +
+ ", isApnTypeActive = " + isApnTypeActive(apnIdToType(apnId)));
}
if (enabled == APN_ENABLED) {
if (!dataEnabled[apnId]) {
- mRequestedApnType = apnIdToType(apnId);
- onEnableNewApn();
-
dataEnabled[apnId] = true;
enabledCount++;
}
- onTrySetupData(null);
+ String type = apnIdToType(apnId);
+ if (!isApnTypeActive(type)) {
+ mRequestedApnType = type;
+ onEnableNewApn();
+ }
} else {
// disable
if (dataEnabled[apnId]) {
@@ -511,7 +514,8 @@
enabledCount--;
if (enabledCount == 0) {
onCleanUpConnection(true, Phone.REASON_DATA_DISABLED);
- } else if (dataEnabled[APN_DEFAULT_ID] == true) {
+ } else if (dataEnabled[APN_DEFAULT_ID] == true &&
+ !isApnTypeActive(Phone.APN_TYPE_DEFAULT)) {
mRequestedApnType = Phone.APN_TYPE_DEFAULT;
onEnableNewApn();
}
diff --git a/test-runner/android/test/mock/MockPackageManager.java b/test-runner/android/test/mock/MockPackageManager.java
index beb9044..2f313af 100644
--- a/test-runner/android/test/mock/MockPackageManager.java
+++ b/test-runner/android/test/mock/MockPackageManager.java
@@ -430,6 +430,11 @@
}
@Override
+ public boolean hasSystemFeature(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
public boolean isSafeMode() {
throw new UnsupportedOperationException();
}
diff --git a/tests/CoreTests/android/core/PipedStreamTest.java b/tests/CoreTests/android/core/PipedStreamTest.java
index 564b337..d98bc10 100644
--- a/tests/CoreTests/android/core/PipedStreamTest.java
+++ b/tests/CoreTests/android/core/PipedStreamTest.java
@@ -117,7 +117,7 @@
for (; ;) {
try {
reader.join(60 * 1000);
- writer.join(1 * 1000);
+ writer.join(1000);
break;
} catch (InterruptedException ex) {
}
@@ -166,11 +166,11 @@
int readInt = (((int) readBytes[0] & 0xff) << 24)
| (((int) readBytes[1] & 0xff) << 16)
| (((int) readBytes[2] & 0xff) << 8)
- | (((int) readBytes[3] & 0xff) << 0);
+ | (((int) readBytes[3] & 0xff));
- assertEquals(readInt, fib.next());
- assertEquals(0, readBytes[4]);
+ assertEquals("Error at " + countRead, fib.next(), readInt);
+ assertEquals("Error at " + countRead, 0, readBytes[4]);
countRead++;
}
}
@@ -189,7 +189,7 @@
writeBytes[0] = (byte) (toWrite >> 24);
writeBytes[1] = (byte) (toWrite >> 16);
writeBytes[2] = (byte) (toWrite >> 8);
- writeBytes[3] = (byte) (toWrite >> 0);
+ writeBytes[3] = (byte) (toWrite);
writeBytes[4] = 0;
out.write(writeBytes, 0, writeBytes.length);
}
@@ -203,37 +203,35 @@
for (; ;) {
try {
reader.join(60 * 1000);
- writer.join(1 * 1000);
+ writer.join(1000);
break;
} catch (InterruptedException ex) {
}
}
- assertEquals(2000, reader.countRead);
-
- if (writer.exception != null) {
- throw new Exception(writer.exception);
- }
if (reader.exception != null) {
throw new Exception(reader.exception);
}
+ if (writer.exception != null) {
+ throw new Exception(writer.exception);
+ }
+
+ assertEquals(2000, reader.countRead);
}
@SmallTest
public void testC() throws Exception {
final PipedInputStream in = new PipedInputStream();
final PipedOutputStream out = new PipedOutputStream(in);
+ final byte readBytes[] = new byte[1024 * 2];
assertEquals(0, in.available());
TestThread reader, writer;
reader = new TestThread() {
- Fibonacci fib = new Fibonacci();
-
@Override
public void runTest() throws Exception {
- byte readBytes[] = new byte[1024 * 2];
int ret;
for (; ;) {
@@ -246,17 +244,6 @@
}
nread += ret;
}
-
- assertEquals(nread, readBytes.length);
-
- for (int i = 0; i < (readBytes.length - 4); i += 4) {
- int readInt = (((int) readBytes[i + 0] & 0xff) << 24)
- | (((int) readBytes[i + 1] & 0xff) << 16)
- | (((int) readBytes[i + 2] & 0xff) << 8)
- | (((int) readBytes[i + 3] & 0xff) << 0);
-
- assertEquals(readInt, fib.next());
- }
}
}
};
@@ -271,10 +258,10 @@
byte writeBytes[] = new byte[1024 * 2];
for (int i = 0; i < (writeBytes.length - 4); i += 4) {
int toWrite = fib.next();
- writeBytes[i + 0] = (byte) (toWrite >> 24);
+ writeBytes[i ] = (byte) (toWrite >> 24);
writeBytes[i + 1] = (byte) (toWrite >> 16);
writeBytes[i + 2] = (byte) (toWrite >> 8);
- writeBytes[i + 3] = (byte) (toWrite >> 0);
+ writeBytes[i + 3] = (byte) (toWrite);
}
out.write(writeBytes, 0, writeBytes.length);
out.close();
@@ -287,17 +274,27 @@
for (; ;) {
try {
reader.join(60 * 1000);
- writer.join(1 * 100);
+ writer.join(1000);
break;
} catch (InterruptedException ex) {
}
}
+ if (reader.exception != null) {
+ throw new Exception(reader.exception);
+ }
if (writer.exception != null) {
throw new Exception(writer.exception);
}
- if (reader.exception != null) {
- throw new Exception(reader.exception);
+
+ Fibonacci fib = new Fibonacci();
+ for (int i = 0; i < (readBytes.length - 4); i += 4) {
+ int readInt = (((int) readBytes[i] & 0xff) << 24)
+ | (((int) readBytes[i + 1] & 0xff) << 16)
+ | (((int) readBytes[i + 2] & 0xff) << 8)
+ | (((int) readBytes[i + 3] & 0xff));
+
+ assertEquals("Error at " + i, readInt, fib.next());
}
}
}