Merge change 27318 into eclair
* changes:
Check that playlist entries refer to a row in the audio table.
diff --git a/api/current.xml b/api/current.xml
index d5f3f46..931b0d8 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"
@@ -68496,11 +68541,11 @@
visibility="public"
>
</field>
-<field name="FLASH_MODE_VIDEO_LIGHT"
+<field name="FLASH_MODE_TORCH"
type="java.lang.String"
transient="false"
volatile="false"
- value=""video-light""
+ value=""torch""
static="true"
final="true"
deprecated="not deprecated"
@@ -122805,7 +122850,7 @@
type="android.telephony.NeighboringCellInfo"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
</constructor>
@@ -122813,7 +122858,7 @@
type="android.telephony.NeighboringCellInfo"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<parameter name="rssi" type="int">
@@ -122853,6 +122898,39 @@
visibility="public"
>
</method>
+<method name="getLac"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getNetworkType"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getPsc"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getRssi"
return="int"
abstract="false"
@@ -122871,7 +122949,7 @@
synchronized="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<parameter name="cid" type="int">
@@ -122884,7 +122962,7 @@
synchronized="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<parameter name="rssi" type="int">
@@ -125204,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"
@@ -125215,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"
@@ -125226,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"
@@ -131235,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"
@@ -196727,7 +196895,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="AllocationLimitError"
@@ -196933,7 +197101,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="PotentialDeadlockError"
@@ -196960,7 +197128,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="StaleDexCacheError"
@@ -196987,7 +197155,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="TemporaryDirectory"
@@ -197030,7 +197198,7 @@
abstract="false"
static="false"
final="false"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="TouchDex"
@@ -197073,7 +197241,7 @@
abstract="false"
static="false"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<method name="dumpHprofData"
@@ -197577,7 +197745,7 @@
abstract="false"
static="false"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<method name="gcSoftReferences"
@@ -197678,7 +197846,7 @@
abstract="false"
static="false"
final="true"
- deprecated="not deprecated"
+ deprecated="deprecated"
visibility="public"
>
<constructor name="VMStack"
@@ -197745,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/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 776c923..3aaed38 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -412,10 +412,10 @@
* Set the Bluetooth scan mode of the local Bluetooth adapter.
* <p>The Bluetooth scan mode determines if the local adapter is
* connectable and/or discoverable from remote Bluetooth devices.
- * <p>For privacy reasons, it is recommended to limit the duration of time
- * that the local adapter remains in a discoverable scan mode. For example,
- * 2 minutes is a generous time to allow a remote Bluetooth device to
- * initiate and complete its discovery process.
+ * <p>For privacy reasons, discoverable mode is automatically turned off
+ * after <code>duration</code> seconds. For example, 120 seconds should be
+ * enough for a remote device to initiate and complete its discovery
+ * process.
* <p>Valid scan mode values are:
* {@link #SCAN_MODE_NONE},
* {@link #SCAN_MODE_CONNECTABLE},
@@ -427,17 +427,24 @@
* </code>instead.
*
* @param mode valid scan mode
+ * @param duration time in seconds to apply scan mode, only used for
+ * {@link #SCAN_MODE_CONNECTABLE_DISCOVERABLE}
* @return true if the scan mode was set, false otherwise
* @hide
*/
- public boolean setScanMode(int mode) {
+ public boolean setScanMode(int mode, int duration) {
try {
- return mService.setScanMode(mode);
+ return mService.setScanMode(mode, duration);
} catch (RemoteException e) {Log.e(TAG, "", e);}
return false;
}
/** @hide */
+ public boolean setScanMode(int mode) {
+ return setScanMode(mode, 120);
+ }
+
+ /** @hide */
public int getDiscoverableTimeout() {
try {
return mService.getDiscoverableTimeout();
diff --git a/core/java/android/bluetooth/IBluetooth.aidl b/core/java/android/bluetooth/IBluetooth.aidl
index 203a61d..1bc2f96 100644
--- a/core/java/android/bluetooth/IBluetooth.aidl
+++ b/core/java/android/bluetooth/IBluetooth.aidl
@@ -35,7 +35,7 @@
boolean setName(in String name);
int getScanMode();
- boolean setScanMode(int mode);
+ boolean setScanMode(int mode, int duration);
int getDiscoverableTimeout();
boolean setDiscoverableTimeout(int timeout);
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/hardware/Camera.java b/core/java/android/hardware/Camera.java
index e47ea84..a1da0e4 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -368,6 +368,9 @@
* uses auto-focus with the
* <a href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><uses-feature></a>
* manifest element.</p>
+ * <p>If the current flash mode is not
+ * {@link android.hardware.Camera.Parameters#FLASH_MODE_OFF}, flash may be
+ * fired during auto-focus depending on the driver.<p>
*
* @param cb the callback to run
*/
@@ -637,12 +640,13 @@
*/
public static final String FLASH_MODE_OFF = "off";
/**
- * Flash will be fired automatically when required. The timing is
- * decided by camera driver.
+ * Flash will be fired automatically when required. The flash may be fired
+ * during preview, auto-focus, or snapshot depending on the driver.
*/
public static final String FLASH_MODE_AUTO = "auto";
/**
- * Flash will always be fired. The timing is decided by camera driver.
+ * Flash will always be fired during snapshot. The flash may also be
+ * fired during preview or auto-focus depending on the driver.
*/
public static final String FLASH_MODE_ON = "on";
/**
@@ -650,9 +654,10 @@
*/
public static final String FLASH_MODE_RED_EYE = "red-eye";
/**
- * Constant emission of light. This can be used for video recording.
+ * Constant emission of light during preview, auto-focus and snapshot.
+ * This can also be used for video recording.
*/
- public static final String FLASH_MODE_VIDEO_LIGHT = "video-light";
+ public static final String FLASH_MODE_TORCH = "torch";
// Values for scene mode settings.
public static final String SCENE_MODE_AUTO = "auto";
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/pim/vcard/VCardComposer.java b/core/java/android/pim/vcard/VCardComposer.java
index 2404a43..e01bd3c 100644
--- a/core/java/android/pim/vcard/VCardComposer.java
+++ b/core/java/android/pim/vcard/VCardComposer.java
@@ -29,9 +29,9 @@
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.provider.ContactsContract.RawContacts;
+import android.provider.ContactsContract.CommonDataKinds.Birthday;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Im;
-import android.provider.ContactsContract.CommonDataKinds.Birthday;
import android.provider.ContactsContract.CommonDataKinds.Nickname;
import android.provider.ContactsContract.CommonDataKinds.Note;
import android.provider.ContactsContract.CommonDataKinds.Organization;
@@ -40,9 +40,6 @@
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.CommonDataKinds.StructuredPostal;
import android.provider.ContactsContract.CommonDataKinds.Website;
-import android.provider.CallLog.Calls;
-import android.provider.CallLog;
-import android.text.format.Time;
import android.text.TextUtils;
import android.text.format.Time;
import android.util.CharsetUtils;
@@ -86,6 +83,17 @@
private final static String DEFAULT_EMAIL_TYPE = Constants.ATTR_TYPE_INTERNET;
+ public static final String FAILURE_REASON_FAILED_TO_GET_DATABASE_INFO =
+ "Failed to get database information";
+
+ public static final String FAILURE_REASON_NO_ENTRY =
+ "There's no exportable in the database";
+
+ public static final String FAILURE_REASON_NOT_INITIALIZED =
+ "The vCard composer object is not correctly initialized";
+
+ public static final String NO_ERROR = "No error";
+
public static interface OneEntryHandler {
public boolean onInit(Context context);
@@ -276,7 +284,7 @@
private boolean mTerminateIsCalled;
private List<OneEntryHandler> mHandlerList;
- private String mErrorReason = "No error";
+ private String mErrorReason = NO_ERROR;
private static final Map<Integer, String> sImMap;
@@ -293,12 +301,12 @@
private boolean mIsCallLogComposer = false;
- private static final String[] CONTACTS_PROJECTION = new String[] {
- Contacts._ID,
+ private static final String[] sRawContactsProjection = new String[] {
+ RawContacts._ID,
};
/** The projection to use when querying the call log table */
- private static final String[] CALL_LOG_PROJECTION = new String[] {
+ private static final String[] sCallLogProjection = new String[] {
Calls.NUMBER, Calls.DATE, Calls.TYPE, Calls.CACHED_NAME, Calls.CACHED_NUMBER_TYPE,
Calls.CACHED_NUMBER_LABEL
};
@@ -312,17 +320,23 @@
private static final String FLAG_TIMEZONE_UTC = "Z";
public VCardComposer(Context context) {
- this(context, VCardConfig.VCARD_TYPE_DEFAULT, true);
+ this(context, VCardConfig.VCARD_TYPE_DEFAULT, true, false);
}
public VCardComposer(Context context, String vcardTypeStr,
boolean careHandlerErrors) {
this(context, VCardConfig.getVCardTypeFromString(vcardTypeStr),
- careHandlerErrors);
+ careHandlerErrors, false);
+ }
+
+ public VCardComposer(Context context, int vcardType, boolean careHandlerErrors) {
+ this(context, vcardType, careHandlerErrors, false);
}
/**
- * Construct for supporting call log entry vCard composing
+ * Construct for supporting call log entry vCard composing.
+ *
+ * @param isCallLogComposer true if this composer is for creating Call Log vCard.
*/
public VCardComposer(Context context, int vcardType, boolean careHandlerErrors,
boolean isCallLogComposer) {
@@ -359,10 +373,6 @@
}
}
- public VCardComposer(Context context, int vcardType, boolean careHandlerErrors) {
- this(context, vcardType, careHandlerErrors, false);
- }
-
/**
* This static function is to compose vCard for phone own number
*/
@@ -429,25 +439,27 @@
}
if (mIsCallLogComposer) {
- mCursor = mContentResolver.query(CallLog.Calls.CONTENT_URI, CALL_LOG_PROJECTION,
+ mCursor = mContentResolver.query(CallLog.Calls.CONTENT_URI, sCallLogProjection,
selection, selectionArgs, null);
} else {
- // TODO: thorow an appropriate exception!
- mCursor = mContentResolver.query(RawContacts.CONTENT_URI, CONTACTS_PROJECTION,
+ mCursor = mContentResolver.query(RawContacts.CONTENT_URI, sRawContactsProjection,
selection, selectionArgs, null);
}
- if (mCursor == null || !mCursor.moveToFirst()) {
- if (mCursor != null) {
- try {
- mCursor.close();
- } catch (SQLiteException e) {
- Log.e(LOG_TAG, "SQLiteException on Cursor#close(): "
- + e.getMessage());
- }
+ if (mCursor == null) {
+ mErrorReason = FAILURE_REASON_FAILED_TO_GET_DATABASE_INFO;
+ return false;
+ }
+
+ if (mCursor.getCount() == 0 || !mCursor.moveToFirst()) {
+ try {
+ mCursor.close();
+ } catch (SQLiteException e) {
+ Log.e(LOG_TAG, "SQLiteException on Cursor#close(): " + e.getMessage());
+ } finally {
mCursor = null;
+ mErrorReason = FAILURE_REASON_NO_ENTRY;
}
- mErrorReason = "Getting database information failed.";
return false;
}
@@ -462,8 +474,7 @@
public boolean createOneEntry() {
if (mCursor == null || mCursor.isAfterLast()) {
- // TODO: ditto
- mErrorReason = "Not initialized or database has some problem.";
+ mErrorReason = FAILURE_REASON_NOT_INITIALIZED;
return false;
}
String name = null;
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/Im.java b/core/java/android/provider/Im.java
index d5cc2207..d3e2820 100644
--- a/core/java/android/provider/Im.java
+++ b/core/java/android/provider/Im.java
@@ -896,12 +896,21 @@
String BODY = "body";
/**
- * The date this message is sent or received
+ * The date this message is sent or received. This represents the display date for
+ * the message.
* <P>Type: INTEGER</P>
*/
String DATE = "date";
/**
+ * The real date for this message. While 'date' can be modified by the client
+ * to account for server time skew, the real_date is the original timestamp set
+ * by the server for incoming messages.
+ * <P>Type: INTEGER</P>
+ */
+ String REAL_DATE = "real_date";
+
+ /**
* Message Type, see {@link MessageType}
* <P>Type: INTEGER</P>
*/
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e3fc72d..1cd4506 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,
@@ -2404,7 +2405,6 @@
public static final String[] SETTINGS_TO_BACKUP = {
ADB_ENABLED,
ALLOW_MOCK_LOCATION,
- INSTALL_NON_MARKET_APPS,
PARENTAL_CONTROL_ENABLED,
PARENTAL_CONTROL_REDIRECT_URL,
USB_MASS_STORAGE_ENABLED,
diff --git a/core/java/android/server/BluetoothService.java b/core/java/android/server/BluetoothService.java
index de14b5b..8b9ba84 100644
--- a/core/java/android/server/BluetoothService.java
+++ b/core/java/android/server/BluetoothService.java
@@ -78,6 +78,7 @@
private static final int MESSAGE_REGISTER_SDP_RECORDS = 1;
private static final int MESSAGE_FINISH_DISABLE = 2;
private static final int MESSAGE_UUID_INTENT = 3;
+ private static final int MESSAGE_DISCOVERABLE_TIMEOUT = 4;
// The timeout used to sent the UUIDs Intent
// This timeout should be greater than the page timeout
@@ -308,6 +309,15 @@
if (address != null)
sendUuidIntent(address);
break;
+ case MESSAGE_DISCOVERABLE_TIMEOUT:
+ int mode = msg.arg1;
+ if (isEnabled()) {
+ // TODO: Switch back to the previous scan mode
+ // This is ok for now, because we only use
+ // CONNECTABLE and CONNECTABLE_DISCOVERABLE
+ setScanMode(BluetoothAdapter.SCAN_MODE_CONNECTABLE, -1);
+ }
+ break;
}
}
};
@@ -679,23 +689,30 @@
return setPropertyInteger("DiscoverableTimeout", timeout);
}
- public synchronized boolean setScanMode(int mode) {
+ public synchronized boolean setScanMode(int mode, int duration) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS,
"Need WRITE_SECURE_SETTINGS permission");
boolean pairable = false;
boolean discoverable = false;
+
switch (mode) {
case BluetoothAdapter.SCAN_MODE_NONE:
+ mHandler.removeMessages(MESSAGE_DISCOVERABLE_TIMEOUT);
pairable = false;
discoverable = false;
break;
case BluetoothAdapter.SCAN_MODE_CONNECTABLE:
+ mHandler.removeMessages(MESSAGE_DISCOVERABLE_TIMEOUT);
pairable = true;
discoverable = false;
break;
case BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE:
+ mHandler.removeMessages(MESSAGE_DISCOVERABLE_TIMEOUT);
pairable = true;
discoverable = true;
+ Message msg = mHandler.obtainMessage(MESSAGE_DISCOVERABLE_TIMEOUT);
+ mHandler.sendMessageDelayed(msg, duration * 1000);
+ if (DBG) Log.d(TAG, "BT Discoverable for " + duration + " seconds");
break;
default:
Log.w(TAG, "Requested invalid scan mode " + mode);
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/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 6ac1f07..07034af 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -356,7 +356,10 @@
// Whether to prevent drag during touch. The initial value depends on
// mForwardTouchEvents. If WebCore wants touch events, we assume it will
// take control of touch events unless it says no for touch down event.
- private boolean mPreventDrag;
+ private static final int PREVENT_DRAG_NO = 0;
+ private static final int PREVENT_DRAG_MAYBE_YES = 1;
+ private static final int PREVENT_DRAG_YES = 2;
+ private int mPreventDrag = PREVENT_DRAG_NO;
// To keep track of whether the current drag was initiated by a WebTextView,
// so that we know not to hide the cursor
@@ -3584,9 +3587,13 @@
// update mMinZoomScale if the minimum zoom scale is not fixed
if (!mMinZoomScaleFixed) {
- mMinZoomScale = (float) getViewWidth()
+ // when change from narrow screen to wide screen, the new viewWidth
+ // can be wider than the old content width. We limit the minimum
+ // scale to 1.0f. The proper minimum scale will be calculated when
+ // the new picture shows up.
+ mMinZoomScale = Math.min(1.0f, (float) getViewWidth()
/ (mDrawHistory ? mHistoryPicture.getWidth()
- : mZoomOverviewWidth);
+ : mZoomOverviewWidth));
}
// we always force, in case our height changed, in which case we still
@@ -3682,6 +3689,7 @@
switch (action) {
case MotionEvent.ACTION_DOWN: {
+ mPreventDrag = PREVENT_DRAG_NO;
if (!mScroller.isFinished()) {
// stop the current scroll animation, but if this is
// the start of a fling, allow it to add to the current
@@ -3710,7 +3718,8 @@
}
} else {
mTouchMode = TOUCH_INIT_MODE;
- mPreventDrag = mForwardTouchEvents;
+ mPreventDrag = mForwardTouchEvents ? PREVENT_DRAG_MAYBE_YES
+ : PREVENT_DRAG_NO;
mWebViewCore.sendMessage(
EventHub.UPDATE_FRAME_CACHE_IF_LOADING);
if (mLogEvent && eventTime - mLastTouchUpTime < 1000) {
@@ -3751,11 +3760,15 @@
invalidate();
break;
}
- if (mPreventDrag || (deltaX * deltaX + deltaY * deltaY)
- < mTouchSlopSquare) {
+ if ((deltaX * deltaX + deltaY * deltaY) < mTouchSlopSquare) {
break;
}
-
+ if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
+ // track mLastTouchTime as we may need to do fling at
+ // ACTION_UP
+ mLastTouchTime = eventTime;
+ break;
+ }
if (mTouchMode == TOUCH_SHORTPRESS_MODE
|| mTouchMode == TOUCH_SHORTPRESS_START_MODE) {
mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
@@ -3884,26 +3897,46 @@
mTouchMode = TOUCH_DONE_MODE;
doDoubleTap();
break;
- case TOUCH_INIT_MODE: // tap
- mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
- if (!mPreventDrag) {
- mPrivateHandler.sendMessageDelayed(
- mPrivateHandler.obtainMessage(
- RELEASE_SINGLE_TAP),
- ViewConfiguration.getDoubleTapTimeout());
- }
- break;
- case TOUCH_SHORTPRESS_START_MODE:
- case TOUCH_SHORTPRESS_MODE:
- mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
- mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
- mTouchMode = TOUCH_DONE_MODE;
- doShortPress();
- break;
case TOUCH_SELECT_MODE:
commitCopy();
mTouchSelection = false;
break;
+ case TOUCH_INIT_MODE: // tap
+ case TOUCH_SHORTPRESS_START_MODE:
+ case TOUCH_SHORTPRESS_MODE:
+ mPrivateHandler.removeMessages(SWITCH_TO_SHORTPRESS);
+ mPrivateHandler.removeMessages(SWITCH_TO_LONGPRESS);
+ if ((deltaX * deltaX + deltaY * deltaY) > mTouchSlopSquare) {
+ Log.w(LOGTAG, "Miss a drag as we are waiting for" +
+ " WebCore's response for touch down.");
+ if (computeHorizontalScrollExtent() < computeHorizontalScrollRange()
+ || computeVerticalScrollExtent() < computeVerticalScrollRange()) {
+ // we will not rewrite drag code here, but we
+ // will try fling if it applies.
+ WebViewCore.pauseUpdate(mWebViewCore);
+ // fall through to TOUCH_DRAG_MODE
+ } else {
+ break;
+ }
+ } else {
+ if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
+ // if mPreventDrag is not confirmed, treat it as
+ // no so that it won't block tap or double tap.
+ mPreventDrag = PREVENT_DRAG_NO;
+ }
+ if (mPreventDrag == PREVENT_DRAG_NO) {
+ if (mTouchMode == TOUCH_INIT_MODE) {
+ mPrivateHandler.sendMessageDelayed(
+ mPrivateHandler.obtainMessage(
+ RELEASE_SINGLE_TAP),
+ ViewConfiguration.getDoubleTapTimeout());
+ } else {
+ mTouchMode = TOUCH_DONE_MODE;
+ doShortPress();
+ }
+ }
+ break;
+ }
case TOUCH_DRAG_MODE:
// redraw in high-quality, as we're done dragging
invalidate();
@@ -4821,6 +4854,11 @@
break;
}
case SWITCH_TO_SHORTPRESS: {
+ // if mPreventDrag is not confirmed, treat it as no so that
+ // it won't block panning the page.
+ if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
+ mPreventDrag = PREVENT_DRAG_NO;
+ }
if (mTouchMode == TOUCH_INIT_MODE) {
mTouchMode = TOUCH_SHORTPRESS_START_MODE;
updateSelection();
@@ -4830,7 +4868,7 @@
break;
}
case SWITCH_TO_LONGPRESS: {
- if (!mPreventDrag) {
+ if (mPreventDrag == PREVENT_DRAG_NO) {
mTouchMode = TOUCH_DONE_MODE;
performLongClick();
rebuildWebTextView();
@@ -4838,7 +4876,7 @@
break;
}
case RELEASE_SINGLE_TAP: {
- if (!mPreventDrag) {
+ if (mPreventDrag == PREVENT_DRAG_NO) {
mTouchMode = TOUCH_DONE_MODE;
doShortPress();
}
@@ -5064,9 +5102,14 @@
case PREVENT_TOUCH_ID:
if (msg.arg1 == MotionEvent.ACTION_DOWN) {
- mPreventDrag = msg.arg2 == 1;
- if (mPreventDrag) {
- mTouchMode = TOUCH_DONE_MODE;
+ // dont override if mPreventDrag has been set to no due
+ // to time out
+ if (mPreventDrag == PREVENT_DRAG_MAYBE_YES) {
+ mPreventDrag = msg.arg2 == 1 ? PREVENT_DRAG_YES
+ : PREVENT_DRAG_NO;
+ if (mPreventDrag == PREVENT_DRAG_YES) {
+ mTouchMode = TOUCH_DONE_MODE;
+ }
}
}
break;
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/java/com/google/android/mms/pdu/PduComposer.java b/core/java/com/google/android/mms/pdu/PduComposer.java
index 2aa5e48..8940945 100644
--- a/core/java/com/google/android/mms/pdu/PduComposer.java
+++ b/core/java/com/google/android/mms/pdu/PduComposer.java
@@ -850,8 +850,7 @@
PositionMarker ctStart = mStack.mark();
// This contentTypeIdentifier should be used for type of attachment...
- String contentType = new String(
- mPduHeader.getTextString(PduHeaders.CONTENT_TYPE));
+ String contentType = new String(mPduHeader.getTextString(PduHeaders.CONTENT_TYPE));
Integer contentTypeIdentifier = mContentTypeMap.get(contentType);
if (contentTypeIdentifier == null) {
// content type is mandatory
@@ -862,7 +861,7 @@
// content-type parameter: start
PduBody body = ((SendReq) mPdu).getBody();
- if (null == body) {
+ if (null == body || body.getPartsNum() == 0) {
// empty message
appendUintvarInteger(0);
mStack.pop();
diff --git a/core/jni/android_bluetooth_BluetoothSocket.cpp b/core/jni/android_bluetooth_BluetoothSocket.cpp
index 70d74d52..2532eff 100644
--- a/core/jni/android_bluetooth_BluetoothSocket.cpp
+++ b/core/jni/android_bluetooth_BluetoothSocket.cpp
@@ -402,7 +402,6 @@
return -1;
}
-/** jb must not be null. offset and offset+length must be within array */
static jint readNative(JNIEnv *env, jobject obj, jbyteArray jb, jint offset,
jint length) {
#ifdef HAVE_BLUETOOTH
@@ -410,10 +409,20 @@
int ret;
jbyte *b;
+ int sz;
struct asocket *s = get_socketData(env, obj);
if (!s)
return -1;
+ if (jb == NULL) {
+ jniThrowIOException(env, EINVAL);
+ return -1;
+ }
+ sz = env->GetArrayLength(jb);
+ if (offset < 0 || length < 0 || offset + length > sz) {
+ jniThrowIOException(env, EINVAL);
+ return -1;
+ }
b = env->GetByteArrayElements(jb, NULL);
if (b == NULL) {
@@ -436,7 +445,6 @@
return -1;
}
-/** jb must not be null. offset and offset+length must be within array */
static jint writeNative(JNIEnv *env, jobject obj, jbyteArray jb, jint offset,
jint length) {
#ifdef HAVE_BLUETOOTH
@@ -444,10 +452,20 @@
int ret;
jbyte *b;
+ int sz;
struct asocket *s = get_socketData(env, obj);
if (!s)
return -1;
+ if (jb == NULL) {
+ jniThrowIOException(env, EINVAL);
+ return -1;
+ }
+ sz = env->GetArrayLength(jb);
+ if (offset < 0 || length < 0 || offset + length > sz) {
+ jniThrowIOException(env, EINVAL);
+ return -1;
+ }
b = env->GetByteArrayElements(jb, NULL);
if (b == NULL) {
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 9cf5324..60a2ecb1 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -1123,10 +1123,11 @@
android:protectionLevel="signature" />
<!-- Allows applications to set a live wallpaper.
- @hide -->
+ @hide XXX Change to signature once the picker is moved to its
+ own apk as Ghod Intended. -->
<permission android:name="android.permission.SET_WALLPAPER_COMPONENT"
android:permissionGroup="android.permission-group.SYSTEM_TOOLS"
- android:protectionLevel="signature" />
+ android:protectionLevel="signatureOrSystem" />
<application android:process="system"
android:persistent="true"
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/gallery_unselected_default.9.png b/core/res/res/drawable-hdpi/gallery_unselected_default.9.png
index 855dca1..3d10b86 100644
--- a/core/res/res/drawable-hdpi/gallery_unselected_default.9.png
+++ b/core/res/res/drawable-hdpi/gallery_unselected_default.9.png
Binary files differ
diff --git a/core/res/res/drawable-hdpi/gallery_unselected_pressed.9.png b/core/res/res/drawable-hdpi/gallery_unselected_pressed.9.png
index 5ec400c..2fa7c46 100644
--- a/core/res/res/drawable-hdpi/gallery_unselected_pressed.9.png
+++ b/core/res/res/drawable-hdpi/gallery_unselected_pressed.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/core/res/res/values/config.xml b/core/res/res/values/config.xml
index cf0dfd7..907fd8f 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -126,4 +126,9 @@
<bool name="config_use_strict_phone_number_comparation">false</bool>
+ <!-- Display low battery warning when battery level dips to this value -->
+ <integer name="config_lowBatteryWarningLevel">15</integer>
+ <!-- Close low battery warning when battery level reaches this value -->
+ <integer name="config_lowBatteryCloseWarningLevel">20</integer>
+
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index eb15183..2a55d85 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -1460,8 +1460,8 @@
<string name="battery_low_subtitle">The battery is getting low:</string>
<!-- A message that appears when the battery level is getting low in a dialog. This is appened to the subtitle of the low battery alert. -->
- <string name="battery_low_percent_format">less than <xliff:g id="number">%d%%</xliff:g>
- remaining.</string>
+ <string name="battery_low_percent_format"><xliff:g id="number">%d%%</xliff:g>
+ or less remaining.</string>
<!-- When the battery is low, this is the label of the button to go to the
power usage activity to find out what drained the battery. -->
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/Element.java b/graphics/java/android/renderscript/Element.java
index 0a586c4..73d8266 100644
--- a/graphics/java/android/renderscript/Element.java
+++ b/graphics/java/android/renderscript/Element.java
@@ -70,148 +70,169 @@
}
}
- public static final Element USER_U8 = new Element();
- public static final Element USER_I8 = new Element();
- public static final Element USER_U16 = new Element();
- public static final Element USER_I16 = new Element();
- public static final Element USER_U32 = new Element();
- public static final Element USER_I32 = new Element();
- public static final Element USER_FLOAT = new Element();
-
- public static final Element A_8 = new Element();
- public static final Element RGB_565 = new Element();
- public static final Element RGB_888 = new Element();
- public static final Element RGBA_5551 = new Element();
- public static final Element RGBA_4444 = new Element();
- public static final Element RGBA_8888 = new Element();
-
- public static final Element INDEX_16 = new Element();
- public static final Element XY_F32 = new Element();
- public static final Element XYZ_F32 = new Element();
- public static final Element ST_XY_F32 = new Element();
- public static final Element ST_XYZ_F32 = new Element();
- public static final Element NORM_XYZ_F32 = new Element();
- public static final Element NORM_ST_XYZ_F32 = new Element();
-
- static void initPredefined(RenderScript rs) {
- USER_U8.mEntries = new Entry[1];
- USER_U8.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.USER, false, 8, null);
- USER_U8.init(rs);
-
- USER_I8.mEntries = new Entry[1];
- USER_I8.mEntries[0] = new Entry(DataType.SIGNED, DataKind.USER, false, 8, null);
- USER_I8.init(rs);
-
- USER_U16.mEntries = new Entry[1];
- USER_U16.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.USER, false, 16, null);
- USER_U16.init(rs);
-
- USER_I16.mEntries = new Entry[1];
- USER_I16.mEntries[0] = new Entry(DataType.SIGNED, DataKind.USER, false, 16, null);
- USER_I16.init(rs);
-
- USER_U32.mEntries = new Entry[1];
- USER_U32.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.USER, false, 32, null);
- USER_U32.init(rs);
-
- USER_I32.mEntries = new Entry[1];
- USER_I32.mEntries[0] = new Entry(DataType.SIGNED, DataKind.USER, false, 32, null);
- USER_I32.init(rs);
-
- USER_FLOAT.mEntries = new Entry[1];
- USER_FLOAT.mEntries[0] = new Entry(DataType.FLOAT, DataKind.USER, false, 32, null);
- USER_FLOAT.init(rs);
-
- A_8.mEntries = new Entry[1];
- A_8.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.ALPHA, true, 8, "a");
- A_8.init(rs);
-
- RGB_565.mEntries = new Entry[3];
- RGB_565.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 5, "r");
- RGB_565.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 6, "g");
- RGB_565.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 5, "b");
- RGB_565.init(rs);
-
- RGB_888.mEntries = new Entry[3];
- RGB_888.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 8, "r");
- RGB_888.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 8, "g");
- RGB_888.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 8, "b");
- RGB_888.init(rs);
-
- RGBA_5551.mEntries = new Entry[4];
- RGBA_5551.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 5, "r");
- RGBA_5551.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 5, "g");
- RGBA_5551.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 5, "b");
- RGBA_5551.mEntries[3] = new Entry(DataType.UNSIGNED, DataKind.ALPHA, true, 1, "a");
- RGBA_5551.init(rs);
-
- RGBA_4444.mEntries = new Entry[4];
- RGBA_4444.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 4, "r");
- RGBA_4444.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 4, "g");
- RGBA_4444.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 4, "b");
- RGBA_4444.mEntries[3] = new Entry(DataType.UNSIGNED, DataKind.ALPHA, true, 4, "a");
- RGBA_4444.init(rs);
-
- RGBA_8888.mEntries = new Entry[4];
- RGBA_8888.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 8, "r");
- RGBA_8888.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 8, "g");
- RGBA_8888.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 8, "b");
- RGBA_8888.mEntries[3] = new Entry(DataType.UNSIGNED, DataKind.ALPHA, true, 8, "a");
- RGBA_8888.init(rs);
-
- INDEX_16.mEntries = new Entry[1];
- INDEX_16.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.INDEX, false, 16, "index");
- INDEX_16.init(rs);
-
- XY_F32.mEntries = new Entry[2];
- XY_F32.mEntries[0] = new Entry(DataType.FLOAT, DataKind.X, false, 32, "x");
- XY_F32.mEntries[1] = new Entry(DataType.FLOAT, DataKind.Y, false, 32, "y");
- XY_F32.init(rs);
-
- XYZ_F32.mEntries = new Entry[3];
- XYZ_F32.mEntries[0] = new Entry(DataType.FLOAT, DataKind.X, false, 32, "x");
- XYZ_F32.mEntries[1] = new Entry(DataType.FLOAT, DataKind.Y, false, 32, "y");
- XYZ_F32.mEntries[2] = new Entry(DataType.FLOAT, DataKind.Z, false, 32, "z");
- XYZ_F32.init(rs);
-
- ST_XY_F32.mEntries = new Entry[4];
- ST_XY_F32.mEntries[0] = new Entry(DataType.FLOAT, DataKind.S, false, 32, "s");
- ST_XY_F32.mEntries[1] = new Entry(DataType.FLOAT, DataKind.T, false, 32, "t");
- ST_XY_F32.mEntries[2] = new Entry(DataType.FLOAT, DataKind.X, false, 32, "x");
- ST_XY_F32.mEntries[3] = new Entry(DataType.FLOAT, DataKind.Y, false, 32, "y");
- ST_XY_F32.init(rs);
-
- ST_XYZ_F32.mEntries = new Entry[5];
- ST_XYZ_F32.mEntries[0] = new Entry(DataType.FLOAT, DataKind.S, false, 32, "s");
- ST_XYZ_F32.mEntries[1] = new Entry(DataType.FLOAT, DataKind.T, false, 32, "t");
- ST_XYZ_F32.mEntries[2] = new Entry(DataType.FLOAT, DataKind.X, false, 32, "x");
- ST_XYZ_F32.mEntries[3] = new Entry(DataType.FLOAT, DataKind.Y, false, 32, "y");
- ST_XYZ_F32.mEntries[4] = new Entry(DataType.FLOAT, DataKind.Z, false, 32, "z");
- ST_XYZ_F32.init(rs);
-
- NORM_XYZ_F32.mEntries = new Entry[6];
- NORM_XYZ_F32.mEntries[0] = new Entry(DataType.FLOAT, DataKind.NX, false, 32, "nx");
- NORM_XYZ_F32.mEntries[1] = new Entry(DataType.FLOAT, DataKind.NY, false, 32, "ny");
- NORM_XYZ_F32.mEntries[2] = new Entry(DataType.FLOAT, DataKind.NZ, false, 32, "nz");
- NORM_XYZ_F32.mEntries[3] = new Entry(DataType.FLOAT, DataKind.X, false, 32, "x");
- NORM_XYZ_F32.mEntries[4] = new Entry(DataType.FLOAT, DataKind.Y, false, 32, "y");
- NORM_XYZ_F32.mEntries[5] = new Entry(DataType.FLOAT, DataKind.Z, false, 32, "z");
- NORM_XYZ_F32.init(rs);
-
- NORM_ST_XYZ_F32.mEntries = new Entry[8];
- NORM_ST_XYZ_F32.mEntries[0] = new Entry(DataType.FLOAT, DataKind.NX, false, 32, "nx");
- NORM_ST_XYZ_F32.mEntries[1] = new Entry(DataType.FLOAT, DataKind.NY, false, 32, "ny");
- NORM_ST_XYZ_F32.mEntries[2] = new Entry(DataType.FLOAT, DataKind.NZ, false, 32, "nz");
- NORM_ST_XYZ_F32.mEntries[3] = new Entry(DataType.FLOAT, DataKind.S, false, 32, "s");
- NORM_ST_XYZ_F32.mEntries[4] = new Entry(DataType.FLOAT, DataKind.T, false, 32, "t");
- NORM_ST_XYZ_F32.mEntries[5] = new Entry(DataType.FLOAT, DataKind.X, false, 32, "x");
- NORM_ST_XYZ_F32.mEntries[6] = new Entry(DataType.FLOAT, DataKind.Y, false, 32, "y");
- NORM_ST_XYZ_F32.mEntries[7] = new Entry(DataType.FLOAT, DataKind.Z, false, 32, "z");
- NORM_ST_XYZ_F32.init(rs);
-
- rs.nInitElements(A_8.mID, RGBA_4444.mID, RGBA_8888.mID, RGB_565.mID);
+ public static Element USER_U8(RenderScript rs) {
+ if(rs.mElement_USER_U8 == null) {
+ rs.mElement_USER_U8 = new Element(rs, 1);
+ rs.mElement_USER_U8.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.USER, false, 8, null);
+ rs.mElement_USER_U8.init();
+ }
+ return rs.mElement_USER_U8;
}
+ public static Element USER_I8(RenderScript rs) {
+ if(rs.mElement_USER_I8 == null) {
+ rs.mElement_USER_I8 = new Element(rs, 1);
+ rs.mElement_USER_I8.mEntries[0] = new Entry(DataType.SIGNED, DataKind.USER, false, 8, null);
+ rs.mElement_USER_I8.init();
+ }
+ return rs.mElement_USER_I8;
+ }
+
+ public static Element USER_U16(RenderScript rs) {
+ if(rs.mElement_USER_U16 == null) {
+ rs.mElement_USER_U16 = new Element(rs, 1);
+ rs.mElement_USER_U16.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.USER, false, 16, null);
+ rs.mElement_USER_U16.init();
+ }
+ return rs.mElement_USER_U16;
+ }
+
+ public static Element USER_I16(RenderScript rs) {
+ if(rs.mElement_USER_I16 == null) {
+ rs.mElement_USER_I16 = new Element(rs, 1);
+ rs.mElement_USER_I16.mEntries[0] = new Entry(DataType.SIGNED, DataKind.USER, false, 16, null);
+ rs.mElement_USER_I16.init();
+ }
+ return rs.mElement_USER_I16;
+ }
+
+ public static Element USER_U32(RenderScript rs) {
+ if(rs.mElement_USER_U32 == null) {
+ rs.mElement_USER_U32 = new Element(rs, 1);
+ rs.mElement_USER_U32.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.USER, false, 32, null);
+ rs.mElement_USER_U32.init();
+ }
+ return rs.mElement_USER_U32;
+ }
+
+ public static Element USER_I32(RenderScript rs) {
+ if(rs.mElement_USER_I32 == null) {
+ rs.mElement_USER_I32 = new Element(rs, 1);
+ rs.mElement_USER_I32.mEntries[0] = new Entry(DataType.SIGNED, DataKind.USER, false, 32, null);
+ rs.mElement_USER_I32.init();
+ }
+ return rs.mElement_USER_I32;
+ }
+
+ public static Element USER_F32(RenderScript rs) {
+ if(rs.mElement_USER_FLOAT == null) {
+ rs.mElement_USER_FLOAT = new Element(rs, 1);
+ rs.mElement_USER_FLOAT.mEntries[0] = new Entry(DataType.FLOAT, DataKind.USER, false, 32, null);
+ rs.mElement_USER_FLOAT.init();
+ }
+ return rs.mElement_USER_FLOAT;
+ }
+
+ public static Element A_8(RenderScript rs) {
+ if(rs.mElement_A_8 == null) {
+ rs.mElement_A_8 = new Element(rs, 1);
+ rs.mElement_A_8.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.ALPHA, true, 8, "a");
+ rs.mElement_A_8.init();
+ }
+ return rs.mElement_A_8;
+ }
+
+ public static Element RGB_565(RenderScript rs) {
+ if(rs.mElement_RGB_565 == null) {
+ rs.mElement_RGB_565 = new Element(rs, 3);
+ rs.mElement_RGB_565.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 5, "r");
+ rs.mElement_RGB_565.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 6, "g");
+ rs.mElement_RGB_565.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 5, "b");
+ rs.mElement_RGB_565.init();
+ }
+ return rs.mElement_RGB_565;
+ }
+
+ public static Element RGB_888(RenderScript rs) {
+ if(rs.mElement_RGB_888 == null) {
+ rs.mElement_RGB_888 = new Element(rs, 3);
+ rs.mElement_RGB_888.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 8, "r");
+ rs.mElement_RGB_888.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 8, "g");
+ rs.mElement_RGB_888.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 8, "b");
+ rs.mElement_RGB_888.init();
+ }
+ return rs.mElement_RGB_888;
+ }
+
+ public static Element RGBA_5551(RenderScript rs) {
+ if(rs.mElement_RGBA_5551 == null) {
+ rs.mElement_RGBA_5551 = new Element(rs, 4);
+ rs.mElement_RGBA_5551.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 5, "r");
+ rs.mElement_RGBA_5551.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 5, "g");
+ rs.mElement_RGBA_5551.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 5, "b");
+ rs.mElement_RGBA_5551.mEntries[3] = new Entry(DataType.UNSIGNED, DataKind.ALPHA, true, 1, "a");
+ rs.mElement_RGBA_5551.init();
+ }
+ return rs.mElement_RGBA_5551;
+ }
+
+ public static Element RGBA_4444(RenderScript rs) {
+ if(rs.mElement_RGBA_4444 == null) {
+ rs.mElement_RGBA_4444 = new Element(rs, 4);
+ rs.mElement_RGBA_4444.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 4, "r");
+ rs.mElement_RGBA_4444.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 4, "g");
+ rs.mElement_RGBA_4444.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 4, "b");
+ rs.mElement_RGBA_4444.mEntries[3] = new Entry(DataType.UNSIGNED, DataKind.ALPHA, true, 4, "a");
+ rs.mElement_RGBA_4444.init();
+ }
+ return rs.mElement_RGBA_4444;
+ }
+
+ public static Element RGBA_8888(RenderScript rs) {
+ if(rs.mElement_RGBA_8888 == null) {
+ rs.mElement_RGBA_8888 = new Element(rs, 4);
+ rs.mElement_RGBA_8888.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.RED, true, 8, "r");
+ rs.mElement_RGBA_8888.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.GREEN, true, 8, "g");
+ rs.mElement_RGBA_8888.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.BLUE, true, 8, "b");
+ rs.mElement_RGBA_8888.mEntries[3] = new Entry(DataType.UNSIGNED, DataKind.ALPHA, true, 8, "a");
+ rs.mElement_RGBA_8888.init();
+ }
+ return rs.mElement_RGBA_8888;
+ }
+
+ public static Element INDEX_16(RenderScript rs) {
+ if(rs.mElement_INDEX_16 == null) {
+ rs.mElement_INDEX_16 = new Element(rs, 1);
+ rs.mElement_INDEX_16.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.INDEX, false, 16, "index");
+ rs.mElement_INDEX_16.init();
+ }
+ return rs.mElement_INDEX_16;
+ }
+
+ public static Element XY_F32(RenderScript rs) {
+ if(rs.mElement_XY_F32 == null) {
+ rs.mElement_XY_F32 = new Element(rs, 2);
+ rs.mElement_XY_F32.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.X, false, 32, "x");
+ rs.mElement_XY_F32.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.Y, false, 32, "y");
+ rs.mElement_XY_F32.init();
+ }
+ return rs.mElement_XY_F32;
+ }
+
+ public static Element XYZ_F32(RenderScript rs) {
+ if(rs.mElement_XYZ_F32 == null) {
+ rs.mElement_XYZ_F32 = new Element(rs, 3);
+ rs.mElement_XYZ_F32.mEntries[0] = new Entry(DataType.UNSIGNED, DataKind.X, false, 32, "x");
+ rs.mElement_XYZ_F32.mEntries[1] = new Entry(DataType.UNSIGNED, DataKind.Y, false, 32, "y");
+ rs.mElement_XYZ_F32.mEntries[2] = new Entry(DataType.UNSIGNED, DataKind.Z, false, 32, "z");
+ rs.mElement_XYZ_F32.init();
+ }
+ return rs.mElement_XYZ_F32;
+ }
+
+ static void initPredefined(RenderScript rs) {
+ rs.nInitElements(A_8(rs).mID, RGBA_4444(rs).mID, RGBA_8888(rs).mID, RGB_565(rs).mID);
+ }
public enum DataType {
FLOAT (0),
@@ -252,10 +273,10 @@
}
}
- Element() {
- super(null);
- mID = 0;
+ Element(RenderScript rs, int count) {
+ super(rs);
mSize = 0;
+ mEntries = new Entry[count];
}
public void destroy() throws IllegalStateException {
@@ -300,8 +321,7 @@
e.mSize = (bits + 7) >> 3;
}
- void init(RenderScript rs) {
- mRS = rs;
+ void init() {
internalCreate(mRS, this);
}
@@ -463,10 +483,9 @@
}
public Element create() {
- Element e = new Element();
- e.mEntries = new Entry[mEntryCount];
+ Element e = new Element(mRS, mEntryCount);
java.lang.System.arraycopy(mEntries, 0, e.mEntries, 0, mEntryCount);
- e.init(mRS);
+ e.init();
return e;
}
}
diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java
index 2a11bfb..ddb23ac 100644
--- a/graphics/java/android/renderscript/ProgramVertex.java
+++ b/graphics/java/android/renderscript/ProgramVertex.java
@@ -110,7 +110,7 @@
mProjection = new Matrix();
mTexture = new Matrix();
- mAlloc = Allocation.createSized(rs, Element.USER_FLOAT, 48);
+ mAlloc = Allocation.createSized(rs, Element.USER_F32(rs), 48);
mAlloc.subData1D(MODELVIEW_OFFSET, 16, mModel.mMat);
mAlloc.subData1D(PROJECTION_OFFSET, 16, mProjection.mMat);
mAlloc.subData1D(TEXTURE_OFFSET, 16, mTexture.mMat);
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..6b0b696 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -191,7 +191,25 @@
@SuppressWarnings({"FieldCanBeLocal"})
private Surface mSurface;
- private static boolean mElementsInitialized = false;
+
+ Element mElement_USER_U8;
+ Element mElement_USER_I8;
+ Element mElement_USER_U16;
+ Element mElement_USER_I16;
+ Element mElement_USER_U32;
+ Element mElement_USER_I32;
+ Element mElement_USER_FLOAT;
+
+ Element mElement_A_8;
+ Element mElement_RGB_565;
+ Element mElement_RGB_888;
+ Element mElement_RGBA_5551;
+ Element mElement_RGBA_4444;
+ Element mElement_RGBA_8888;
+
+ Element mElement_INDEX_16;
+ Element mElement_XY_F32;
+ Element mElement_XYZ_F32;
///////////////////////////////////////////////////////////////////////////////////
//
@@ -203,12 +221,7 @@
nDeviceSetConfig(mDev, 0, 1);
}
mContext = nContextCreate(mDev, mSurface, 0, useDepth);
-
- // TODO: This should be protected by a lock
- if(!mElementsInitialized) {
- Element.initPredefined(this);
- mElementsInitialized = true;
- }
+ Element.initPredefined(this);
}
public void destroy() {
@@ -219,6 +232,10 @@
mDev = 0;
}
+ boolean isAlive() {
+ return mContext != 0;
+ }
+
void pause() {
nContextPause();
}
diff --git a/graphics/java/android/renderscript/SimpleMesh.java b/graphics/java/android/renderscript/SimpleMesh.java
index dc74c61..987ec44 100644
--- a/graphics/java/android/renderscript/SimpleMesh.java
+++ b/graphics/java/android/renderscript/SimpleMesh.java
@@ -296,7 +296,7 @@
Builder smb = new Builder(mRS);
smb.addVertexType(mElement, mVtxCount / floatCount);
- smb.setIndexType(Element.INDEX_16, mIndexCount);
+ smb.setIndexType(Element.INDEX_16(mRS), mIndexCount);
smb.setPrimitive(Primitive.TRIANGLE);
SimpleMesh sm = smb.create();
diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java
index df60990..ad4cf6b 100644
--- a/graphics/java/android/renderscript/Type.java
+++ b/graphics/java/android/renderscript/Type.java
@@ -162,12 +162,19 @@
}
public Builder(RenderScript rs, Element e) {
+ if(e.mID == 0) {
+ throw new IllegalArgumentException("Invalid element.");
+ }
+
mRS = rs;
mEntries = new Entry[4];
mElement = e;
}
public void add(Dimension d, int value) {
+ if(value < 1) {
+ throw new IllegalArgumentException("Values of less than 1 for Dimensions are not valid.");
+ }
if(mEntries.length >= mEntryCount) {
Entry[] en = new Entry[mEntryCount + 8];
System.arraycopy(mEntries, 0, en, 0, mEntries.length);
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/Film/src/com/android/film/FilmRS.java b/libs/rs/java/Film/src/com/android/film/FilmRS.java
index cee827b..b5b6723 100644
--- a/libs/rs/java/Film/src/com/android/film/FilmRS.java
+++ b/libs/rs/java/Film/src/com/android/film/FilmRS.java
@@ -152,9 +152,9 @@
mBufferIDs = new int[13];
mImages = new Allocation[13];
mAllocIDs = Allocation.createSized(mRS,
- Element.USER_FLOAT, mBufferIDs.length);
+ Element.USER_F32(mRS), mBufferIDs.length);
- Element ie = Element.RGB_565;
+ Element ie = Element.RGB_565(mRS);
mImages[0] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p01, ie, true);
mImages[1] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p02, ie, true);
mImages[2] = Allocation.createFromBitmapResourceBoxed(mRS, mRes, R.drawable.p03, ie, true);
@@ -195,7 +195,7 @@
{
mBufferState = new int[10];
mAllocState = Allocation.createSized(mRS,
- Element.USER_FLOAT, mBufferState.length);
+ Element.USER_F32(mRS), mBufferState.length);
mBufferState[STATE_LAST_FOCUS] = -1;
mAllocState.data(mBufferState);
}
@@ -238,12 +238,12 @@
mAllocOffsets = Allocation.createSized(mRS,
- Element.USER_I32, mFSM.mTriangleOffsets.length);
+ Element.USER_I32(mRS), mFSM.mTriangleOffsets.length);
mAllocOffsets.data(mFSM.mTriangleOffsets);
mScriptStrip.bindAllocation(mAllocOffsets, 4);
mAllocOffsetsTex = Allocation.createSized(mRS,
- Element.USER_FLOAT, mFSM.mTriangleOffsetsTex.length);
+ Element.USER_F32(mRS), mFSM.mTriangleOffsetsTex.length);
mAllocOffsetsTex.data(mFSM.mTriangleOffsetsTex);
mScriptStrip.bindAllocation(mAllocOffsetsTex, 5);
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/java/Rollo/src/com/android/rollo/RolloRS.java b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
index ba74b58..ff89bc3 100644
--- a/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
+++ b/libs/rs/java/Rollo/src/com/android/rollo/RolloRS.java
@@ -182,7 +182,7 @@
mAllocScratchBuf = new int[32];
mAllocScratch = Allocation.createSized(mRS,
- Element.USER_I32, mAllocScratchBuf.length);
+ Element.USER_I32(mRS), mAllocScratchBuf.length);
mAllocScratch.data(mAllocScratchBuf);
Log.e("rs", "Done loading named");
@@ -193,14 +193,14 @@
mIcons = new Allocation[29];
mAllocIconIDBuf = new int[mIcons.length];
mAllocIconID = Allocation.createSized(mRS,
- Element.USER_I32, mAllocIconIDBuf.length);
+ Element.USER_I32(mRS), mAllocIconIDBuf.length);
mLabels = new Allocation[29];
mAllocLabelIDBuf = new int[mLabels.length];
mAllocLabelID = Allocation.createSized(mRS,
- Element.USER_I32, mLabels.length);
+ Element.USER_I32(mRS), mLabels.length);
- Element ie8888 = Element.RGBA_8888;
+ Element ie8888 = Element.RGBA_8888(mRS);
mIcons[0] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.browser, ie8888, true);
mIcons[1] = Allocation.createFromBitmapResource(mRS, mRes, R.raw.market, ie8888, true);
@@ -284,7 +284,7 @@
p.setTextSize(20);
p.setColor(0xffffffff);
c.drawText(t, 2, 26, p);
- return Allocation.createFromBitmap(mRS, b, Element.RGBA_8888, true);
+ return Allocation.createFromBitmap(mRS, b, Element.RGBA_8888(mRS), true);
}
@@ -298,7 +298,7 @@
mAllocStateBuf = new int[] {0, 0, 0, 8, 0, 0, -1, 0, mAllocIconIDBuf.length, 0, 0};
mAllocState = Allocation.createSized(mRS,
- Element.USER_I32, mAllocStateBuf.length);
+ Element.USER_I32(mRS), mAllocStateBuf.length);
mScript.bindAllocation(mAllocState, 0);
mScript.bindAllocation(mAllocIconID, 1);
mScript.bindAllocation(mAllocScratch, 2);
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..8ac9c26 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);
@@ -139,6 +141,7 @@
if (size != sizeBytes) {
LOGE("Allocation::subData called with mismatched size expected %i, got %i", size, sizeBytes);
+ mType->dumpLOGV("type info");
return;
}
memcpy(ptr, data, size);
@@ -186,14 +189,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 +374,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..de074c8 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;
@@ -98,4 +102,9 @@
return 0;
}
+void Component::dumpLOGV(const char *prefix) const
+{
+ ObjectBase::dumpLOGV(prefix);
+ LOGV("%s component: %i %i %i %i", prefix, mType, mKind, mIsNormalized, mBits);
+}
diff --git a/libs/rs/rsComponent.h b/libs/rs/rsComponent.h
index 5856524..5366cc4 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;}
@@ -56,6 +56,7 @@
const char * getCType() const;
const char * getComponentName() const {return mName.string();}
+ virtual void dumpLOGV(const char *prefix) const;
protected:
@@ -66,7 +67,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..67e4f14 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;
}
@@ -51,6 +55,8 @@
rsAssert(!mComponents[idx].get());
rsAssert(idx < mComponentCount);
mComponents[idx].set(c);
+
+// Fixme: This should probably not be here
c->incUserRef();
}
@@ -175,6 +181,17 @@
}
+void Element::dumpLOGV(const char *prefix) const
+{
+ ObjectBase::dumpLOGV(prefix);
+ LOGV("%s Element: components %i, size %i", prefix, mComponentCount, getSizeBytes());
+ for (uint32_t ct = 0; ct < mComponentCount; ct++) {
+ char buf[1024];
+ sprintf(buf, "%s component %i: ", prefix, ct);
+ mComponents[ct]->dumpLOGV(buf);
+ }
+}
+
ElementState::ElementState()
{
}
@@ -197,7 +214,11 @@
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),
+
+ rsAssert(bits > 0);
+
+ Component *c = new Component(rsc,
+ static_cast<Component::DataKind>(dk),
static_cast<Component::DataType>(dt),
isNormalized,
bits,
@@ -208,7 +229,9 @@
RsElement rsi_ElementCreate(Context *rsc)
{
ElementState * sec = &rsc->mStateElement;
- Element *se = new Element(sec->mComponentBuildList.size());
+ Element *se = new Element(rsc, sec->mComponentBuildList.size());
+
+ rsAssert(se->getComponentCount() > 0);
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..b41c552 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();
@@ -51,6 +51,9 @@
uint32_t getComponentCount() const {return mComponentCount;}
Component * getComponent(uint32_t idx) const {return mComponents[idx].get();}
+
+ void dumpLOGV(const char *prefix) const;
+
protected:
// deallocate any components that are part of this element.
void clear();
@@ -59,7 +62,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..0008ea4 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::dumpLOGV(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) {
+ dumpLOGV("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->dumpLOGV(" ");
+ o = o->mNext;
+ }
+ }
+}
+
diff --git a/libs/rs/rsObjectBase.h b/libs/rs/rsObjectBase.h
index d1e6baa..dc85ac7 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);
+
+ virtual void dumpLOGV(const char *prefix) 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..ddaa2f0 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));
@@ -300,6 +302,16 @@
}
+void Type::dumpLOGV(const char *prefix) const
+{
+ char buf[1024];
+ ObjectBase::dumpLOGV(prefix);
+ LOGV("%s Type: x=%i y=%i z=%i mip=%i face=%i", prefix, mDimX, mDimY, mDimZ, mDimLOD, mFaces);
+ sprintf(buf, "%s element: ", prefix);
+ mElement->dumpLOGV(buf);
+}
+
+
//////////////////////////////////////////////////
//
namespace android {
@@ -363,7 +375,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 +384,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..2c43405 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);
@@ -69,6 +69,7 @@
void enableGLVertexBuffer() const;
+ void dumpLOGV(const char *prefix) const;
protected:
struct LOD {
@@ -139,12 +140,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/surfaceflinger/BufferAllocator.cpp b/libs/surfaceflinger/BufferAllocator.cpp
index 19867a5..caf9bec 100644
--- a/libs/surfaceflinger/BufferAllocator.cpp
+++ b/libs/surfaceflinger/BufferAllocator.cpp
@@ -102,6 +102,10 @@
rec.vaddr = 0;
rec.size = h * stride[0] * bytesPerPixel(format);
list.add(*handle, rec);
+ } else {
+ String8 s;
+ dump(s);
+ LOGD("%s", s.string());
}
return err;
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/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index a5a8cc9..872b2bc 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -1743,7 +1743,7 @@
if (Res_GETPACKAGE(resID)+1 == 0) {
LOGW("No package identifier when getting name for resource number 0x%08x", resID);
} else {
- LOGW("Resources don't contain pacakge for resource number 0x%08x", resID);
+ LOGW("Resources don't contain package for resource number 0x%08x", resID);
}
return false;
}
@@ -1793,7 +1793,7 @@
if (Res_GETPACKAGE(resID)+1 == 0) {
LOGW("No package identifier when getting name for resource number 0x%08x", resID);
} else {
- LOGW("Resources don't contain pacakge for resource number 0x%08x", resID);
+ LOGW("Resources don't contain package for resource number 0x%08x", resID);
}
return BAD_INDEX;
}
diff --git a/media/java/android/media/MiniThumbFile.java b/media/java/android/media/MiniThumbFile.java
index c607218..def0288 100644
--- a/media/java/android/media/MiniThumbFile.java
+++ b/media/java/android/media/MiniThumbFile.java
@@ -215,7 +215,6 @@
r.write(data);
r.seek(pos);
r.writeByte(1); // we have data in this slot
- mChannel.force(true);
}
} catch (IOException ex) {
Log.e(TAG, "couldn't save mini thumbnail data for "
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/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java
index cb917db..15290c1 100644
--- a/services/java/com/android/server/BackupManagerService.java
+++ b/services/java/com/android/server/BackupManagerService.java
@@ -637,6 +637,9 @@
IBackupTransport transport = getTransport(mCurrentTransport);
if (transport == null) {
Log.v(TAG, "Backup requested but no transport available");
+ synchronized (mQueueLock) {
+ mBackupOrRestoreInProgress = false;
+ }
mWakelock.release();
break;
}
@@ -671,6 +674,9 @@
(new PerformBackupThread(transport, queue, oldJournal)).start();
} else {
Log.v(TAG, "Backup requested but nothing pending");
+ synchronized (mQueueLock) {
+ mBackupOrRestoreInProgress = false;
+ }
mWakelock.release();
}
}
@@ -1686,6 +1692,9 @@
}
// Last but not least, release the cpu
+ synchronized (mQueueLock) {
+ mBackupOrRestoreInProgress = false;
+ }
mWakelock.release();
}
}
diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java
index 53edf31..bb36936 100644
--- a/services/java/com/android/server/BatteryService.java
+++ b/services/java/com/android/server/BatteryService.java
@@ -90,9 +90,6 @@
// This should probably be exposed in the API, though it's not critical
private static final int BATTERY_PLUGGED_NONE = 0;
- private static final int BATTERY_LEVEL_CLOSE_WARNING = 20;
- private static final int BATTERY_LEVEL_WARNING = 15;
-
private final Context mContext;
private final IBatteryStats mBatteryStats;
@@ -114,7 +111,10 @@
private int mLastBatteryVoltage;
private int mLastBatteryTemperature;
private boolean mLastBatteryLevelCritical;
-
+
+ private int mLowBatteryWarningLevel;
+ private int mLowBatteryCloseWarningLevel;
+
private int mPlugType;
private int mLastPlugType = -1; // Extra state so we can detect first run
@@ -127,6 +127,11 @@
mContext = context;
mBatteryStats = BatteryStatsService.getService();
+ mLowBatteryWarningLevel = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_lowBatteryWarningLevel);
+ mLowBatteryCloseWarningLevel = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_lowBatteryCloseWarningLevel);
+
mUEventObserver.startObserving("SUBSYSTEM=power_supply");
// set initial status
@@ -271,13 +276,15 @@
final boolean oldPlugged = mLastPlugType != BATTERY_PLUGGED_NONE;
/* The ACTION_BATTERY_LOW broadcast is sent in these situations:
- * - is just un-plugged (previously was plugged) and battery level is under WARNING, or
- * - is not plugged and battery level crosses the WARNING boundary (becomes < 15).
+ * - is just un-plugged (previously was plugged) and battery level is
+ * less than or equal to WARNING, or
+ * - is not plugged and battery level falls to WARNING boundary
+ * (becomes <= mLowBatteryWarningLevel).
*/
final boolean sendBatteryLow = !plugged
&& mBatteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN
- && mBatteryLevel < BATTERY_LEVEL_WARNING
- && (oldPlugged || mLastBatteryLevel >= BATTERY_LEVEL_WARNING);
+ && mBatteryLevel <= mLowBatteryWarningLevel
+ && (oldPlugged || mLastBatteryLevel > mLowBatteryWarningLevel);
sendIntent();
@@ -299,7 +306,7 @@
mSentLowBatteryBroadcast = true;
statusIntent.setAction(Intent.ACTION_BATTERY_LOW);
mContext.sendBroadcast(statusIntent);
- } else if (mSentLowBatteryBroadcast && mLastBatteryLevel >= BATTERY_LEVEL_CLOSE_WARNING) {
+ } else if (mSentLowBatteryBroadcast && mLastBatteryLevel >= mLowBatteryCloseWarningLevel) {
mSentLowBatteryBroadcast = false;
statusIntent.setAction(Intent.ACTION_BATTERY_OKAY);
mContext.sendBroadcast(statusIntent);
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..228d25e 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;
@@ -4174,7 +4174,7 @@
final int N = mWindows.size();
for (int i=0; i<N; i++) {
WindowState w = (WindowState)mWindows.get(i);
- if (w.isVisibleLw() && !w.isDisplayedLw()) {
+ if (w.isVisibleLw() && !w.isDrawnLw()) {
return;
}
}
@@ -7664,6 +7664,16 @@
|| mAnimating);
}
+ /**
+ * Returns true if the window has a surface that it has drawn a
+ * complete UI in to.
+ */
+ public boolean isDrawnLw() {
+ final AppWindowToken atoken = mAppToken;
+ return mSurface != null && !mDestroying
+ && !mDrawPending && !mCommitDrawPending;
+ }
+
public boolean fillsScreenLw(int screenWidth, int screenHeight,
boolean shownFrame, boolean onlyOpaque) {
if (mSurface == null) {
@@ -8268,10 +8278,10 @@
continue;
}
if (DEBUG_VISIBILITY) {
- Log.v(TAG, "Win " + win + ": isDisplayed="
- + win.isDisplayedLw()
+ Log.v(TAG, "Win " + win + ": isDrawn="
+ + win.isDrawnLw()
+ ", isAnimating=" + win.isAnimating());
- if (!win.isDisplayedLw()) {
+ if (!win.isDrawnLw()) {
Log.v(TAG, "Not displayed: s=" + win.mSurface
+ " pv=" + win.mPolicyVisibility
+ " dp=" + win.mDrawPending
@@ -8284,7 +8294,7 @@
}
}
numInteresting++;
- if (win.isDisplayedLw()) {
+ if (win.isDrawnLw()) {
if (!win.isAnimating()) {
numVisible++;
}
@@ -9007,7 +9017,6 @@
|| !win.mRelayoutCalled
|| win.mRootToken.hidden
|| (atoken != null && atoken.hiddenRequested)
- || !win.mPolicyVisibility
|| win.mAttachedHidden
|| win.mExiting || win.mDestroying;
@@ -9217,10 +9226,10 @@
== WindowManager.LayoutParams.TYPE_BASE_APPLICATION)
&& !w.mExiting && !w.mDestroying) {
if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) {
- Log.v(TAG, "Eval win " + w + ": isDisplayed="
- + w.isDisplayedLw()
+ Log.v(TAG, "Eval win " + w + ": isDrawn="
+ + w.isDrawnLw()
+ ", isAnimating=" + w.isAnimating());
- if (!w.isDisplayedLw()) {
+ if (!w.isDrawnLw()) {
Log.v(TAG, "Not displayed: s=" + w.mSurface
+ " pv=" + w.mPolicyVisibility
+ " dp=" + w.mDrawPending
@@ -9233,7 +9242,7 @@
if (w != atoken.startingWindow) {
if (!atoken.freezingScreen || !w.mAppFreezing) {
atoken.numInterestingWindows++;
- if (w.isDisplayedLw()) {
+ if (w.isDrawnLw()) {
atoken.numDrawnWindows++;
if (DEBUG_VISIBILITY || DEBUG_ORIENTATION) Log.v(TAG,
"tokenMayBeDrawn: " + atoken
@@ -9242,7 +9251,7 @@
tokenMayBeDrawn = true;
}
}
- } else if (w.isDisplayedLw()) {
+ } else if (w.isDrawnLw()) {
atoken.startingDisplayed = true;
}
}
@@ -9327,7 +9336,6 @@
transit = WindowManagerPolicy.TRANSIT_UNSET;
}
mNextAppTransition = WindowManagerPolicy.TRANSIT_UNSET;
- mNextAppTransitionPackage = null;
mAppTransitionReady = false;
mAppTransitionRunning = true;
mAppTransitionTimeout = false;
@@ -9484,6 +9492,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/StatusBarPolicy.java b/services/java/com/android/server/status/StatusBarPolicy.java
index da64e54..6570bcd 100644
--- a/services/java/com/android/server/status/StatusBarPolicy.java
+++ b/services/java/com/android/server/status/StatusBarPolicy.java
@@ -670,11 +670,9 @@
private void showLowBatteryWarning() {
closeLastBatteryView();
- /* Show exact battery level.
- * Add 1 because the text says "less than X%".
- */
+ // Show exact battery level.
CharSequence levelText = mContext.getString(
- com.android.internal.R.string.battery_low_percent_format, mBatteryLevel + 1);
+ com.android.internal.R.string.battery_low_percent_format, mBatteryLevel);
if (mBatteryLevelTextView != null) {
mBatteryLevelTextView.setText(levelText);
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/NeighboringCellInfo.java b/telephony/java/android/telephony/NeighboringCellInfo.java
index f492abd..d698169 100644
--- a/telephony/java/android/telephony/NeighboringCellInfo.java
+++ b/telephony/java/android/telephony/NeighboringCellInfo.java
@@ -18,6 +18,15 @@
import android.os.Parcel;
import android.os.Parcelable;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSDPA;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSUPA;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSPA;
+
+
/**
* Represents the neighboring cell information, including
@@ -34,19 +43,53 @@
*/
static final public int UNKNOWN_CID = -1;
+ /**
+ * In GSM, mRssi is the Received RSSI;
+ * In UMTS, mRssi is the Level index of CPICH Received Signal Code Power
+ */
private int mRssi;
+ /**
+ * CID in 16 bits format in GSM. Return UNKNOWN_CID in UMTS and CMDA.
+ */
private int mCid;
+ /**
+ * LAC in 16 bits format in GSM. Return UNKNOWN_CID in UMTS and CMDA.
+ */
+ private int mLac;
+ /**
+ * Primary Scrambling Code in 9 bits format in UMTS
+ * Return UNKNOWN_CID in GSM and CMDA.
+ */
+ private int mPsc;
+ /**
+ * Radio network type, value is one of following
+ * TelephonyManager.NETWORK_TYPE_XXXXXX.
+ */
+ private int mNetworkType;
/**
+ * @deprecated
* Empty constructor. Initializes the RSSI and CID.
+ *
+ * NeighboringCellInfo is one time shot for the neighboring cells based on
+ * the radio network type at that moment. Its constructor needs radio network
+ * type.
*/
public NeighboringCellInfo() {
mRssi = UNKNOWN_RSSI;
+ mLac = UNKNOWN_CID;
mCid = UNKNOWN_CID;
+ mPsc = UNKNOWN_CID;
+ mNetworkType = NETWORK_TYPE_UNKNOWN;
}
/**
+ * @deprecated
* Initialize the object from rssi and cid.
+ *
+ * NeighboringCellInfo is one time shot for the neighboring cells based on
+ * the radio network type at that moment. Its constructor needs radio network
+ * type.
*/
public NeighboringCellInfo(int rssi, int cid) {
mRssi = rssi;
@@ -54,40 +97,148 @@
}
/**
+ * @hide
+ * Initialize the object from rssi, location string, and radioType
+ * radioType is one of following
+ * {@link TelephonyManager#NETWORK_TYPE_GPRS TelephonyManager.NETWORK_TYPE_GPRS},
+ * {@link TelephonyManager#NETWORK_TYPE_EDGE TelephonyManager.NETWORK_TYPE_EDGE},
+ * {@link TelephonyManager#NETWORK_TYPE_UMTS TelephonyManager.NETWORK_TYPE_UMTS},
+ * {@link TelephonyManager#NETWORK_TYPE_HSDPA TelephonyManager.NETWORK_TYPE_HSDPA},
+ * {@link TelephonyManager#NETWORK_TYPE_HSUPA TelephonyManager.NETWORK_TYPE_HSUPA},
+ * and {@link TelephonyManager#NETWORK_TYPE_HSPA TelephonyManager.NETWORK_TYPE_HSPA}.
+ */
+ public NeighboringCellInfo(int rssi, String location, int radioType) {
+ // set default value
+ mRssi = rssi;
+ mNetworkType = NETWORK_TYPE_UNKNOWN;
+ mPsc = UNKNOWN_CID;
+ mLac = UNKNOWN_CID;
+ mCid = UNKNOWN_CID;
+
+
+ // pad location string with leading "0"
+ int l = location.length();
+ if (l > 8) return;
+ if (l < 8) {
+ for (int i = 0; i < (8-l); i++) {
+ location = "0" + location;
+ }
+ }
+
+ try {// set LAC/CID or PSC based on radioType
+ switch (radioType) {
+ case NETWORK_TYPE_GPRS:
+ case NETWORK_TYPE_EDGE:
+ mNetworkType = radioType;
+ mLac = Integer.valueOf(location.substring(0, 4), 16);
+ mCid = Integer.valueOf(location.substring(4), 16);
+ break;
+ case NETWORK_TYPE_UMTS:
+ case NETWORK_TYPE_HSDPA:
+ case NETWORK_TYPE_HSUPA:
+ case NETWORK_TYPE_HSPA:
+ mNetworkType = radioType;
+ mPsc = Integer.valueOf(location, 16);
+ break;
+ }
+ } catch (NumberFormatException e) {
+ // parsing location error
+ mPsc = UNKNOWN_CID;
+ mLac = UNKNOWN_CID;
+ mCid = UNKNOWN_CID;
+ mNetworkType = NETWORK_TYPE_UNKNOWN;
+ }
+ }
+
+ /**
* Initialize the object from a parcel.
*/
public NeighboringCellInfo(Parcel in) {
mRssi = in.readInt();
+ mLac = in.readInt();
mCid = in.readInt();
+ mPsc = in.readInt();
+ mNetworkType = in.readInt();
}
/**
- * @return received signal strength in "asu", ranging from 0 - 31,
- * or UNKNOWN_RSSI if unknown
+ * @return received signal strength or UNKNOWN_RSSI if unknown
*
- * For GSM, dBm = -113 + 2*asu,
+ * For GSM, it is in "asu" ranging from 0 to 31 (dBm = -113 + 2*asu)
* 0 means "-113 dBm or less" and 31 means "-51 dBm or greater"
+ * For UMTS, it is the Level index of CPICH RSCP defined in TS 25.125
*/
public int getRssi() {
return mRssi;
}
/**
- * @return cell id, UNKNOWN_CID if unknown, 0xffffffff max legal value
+ * @return LAC in GSM, 0xffff max legal value
+ * UNKNOWN_CID if in UMTS or CMDA or unknown
+ */
+ public int getLac() {
+ return mLac;
+ }
+
+ /**
+ * @return cell id in GSM, 0xffff max legal value
+ * UNKNOWN_CID if in UMTS or CDMA or unknown
*/
public int getCid() {
return mCid;
}
/**
+ * @return Primary Scrambling Code in 9 bits format in UMTS, 0x1ff max value
+ * UNKNOWN_CID if in GSM or CMDA or unknown
+ */
+ public int getPsc() {
+ return mPsc;
+ }
+
+ /**
+ * @return Radio network type while neighboring cell location is stored.
+ *
+ * Return {@link TelephonyManager#NETWORK_TYPE_UNKNOWN TelephonyManager.NETWORK_TYPE_UNKNOWN}
+ * means that the location information is unavailable.
+ *
+ * Return {@link TelephonyManager#NETWORK_TYPE_GPRS TelephonyManager.NETWORK_TYPE_GPRS} or
+ * {@link TelephonyManager#NETWORK_TYPE_EDGE TelephonyManager.NETWORK_TYPE_EDGE}
+ * means that Neighboring Cell information is stored for GSM network, in
+ * which {@link NeighboringCellInfo#getLac NeighboringCellInfo.getLac} and
+ * {@link NeighboringCellInfo#getCid NeighboringCellInfo.getCid} should be
+ * called to access location.
+ *
+ * Return {@link TelephonyManager#NETWORK_TYPE_UMTS TelephonyManager.NETWORK_TYPE_UMTS},
+ * {@link TelephonyManager#NETWORK_TYPE_HSDPA TelephonyManager.NETWORK_TYPE_HSDPA},
+ * {@link TelephonyManager#NETWORK_TYPE_HSUPA TelephonyManager.NETWORK_TYPE_HSUPA},
+ * or {@link TelephonyManager#NETWORK_TYPE_HSPA TelephonyManager.NETWORK_TYPE_HSPA}
+ * means that Neighboring Cell information is stored for UMTS network, in
+ * which {@link NeighboringCellInfo#getPsc NeighboringCellInfo.getPsc}
+ * should be called to access location.
+ */
+ public int getNetworkType() {
+ return mNetworkType;
+ }
+ /**
+ * @deprecated
* Set the cell id.
+ *
+ * NeighboringCellInfo is a one time shot for the neighboring cells based on
+ * the radio network type at that moment. It shouldn't be changed after
+ * creation.
*/
public void setCid(int cid) {
mCid = cid;
}
/**
+ * @deprecated
* Set the signal strength of the cell.
+ *
+ * NeighboringCellInfo is a one time shot for the neighboring cells based on
+ * the radio network type at that moment. It shouldn't be changed after
+ * creation.
*/
public void setRssi(int rssi) {
mRssi = rssi;
@@ -95,8 +246,20 @@
@Override
public String toString() {
- return "["+ ((mCid == UNKNOWN_CID) ? "/" : Integer.toHexString(mCid))
- + " at " + ((mRssi == UNKNOWN_RSSI)? "/" : mRssi) + "]";
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("[");
+ if (mPsc != UNKNOWN_CID) {
+ sb.append(Integer.toHexString(mPsc))
+ .append("@").append(((mRssi == UNKNOWN_RSSI)? "-" : mRssi));
+ } else if(mLac != UNKNOWN_CID && mCid != UNKNOWN_CID) {
+ sb.append(Integer.toHexString(mLac))
+ .append(Integer.toHexString(mCid))
+ .append("@").append(((mRssi == UNKNOWN_RSSI)? "-" : mRssi));
+ }
+ sb.append("]");
+
+ return sb.toString();
}
public int describeContents() {
@@ -105,7 +268,10 @@
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mRssi);
+ dest.writeInt(mLac);
dest.writeInt(mCid);
+ dest.writeInt(mPsc);
+ dest.writeInt(mNetworkType);
}
public static final Parcelable.Creator<NeighboringCellInfo> CREATOR
@@ -118,6 +284,4 @@
return new NeighboringCellInfo[size];
}
};
-}
-
-
+}
\ No newline at end of file
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 6664b08..a53b157 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -254,13 +254,13 @@
* (@link android.Manifest.permission#ACCESS_COARSE_UPDATES}
*/
public List<NeighboringCellInfo> getNeighboringCellInfo() {
- try {
- return getITelephony().getNeighboringCellInfo();
- } catch (RemoteException ex) {
- return null;
- } catch (NullPointerException ex) {
- return null;
- }
+ try {
+ return getITelephony().getNeighboringCellInfo();
+ } catch (RemoteException ex) {
+ return null;
+ } catch (NullPointerException ex) {
+ return null;
+ }
}
/** No phone radio. */
@@ -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/telephony/java/com/android/internal/telephony/RIL.java b/telephony/java/com/android/internal/telephony/RIL.java
index d1b446b..f3b59a8 100644
--- a/telephony/java/com/android/internal/telephony/RIL.java
+++ b/telephony/java/com/android/internal/telephony/RIL.java
@@ -17,6 +17,14 @@
package com.android.internal.telephony;
import static com.android.internal.telephony.RILConstants.*;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSDPA;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSUPA;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_HSPA;
+
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -30,6 +38,7 @@
import android.os.Message;
import android.os.Parcel;
import android.os.PowerManager;
+import android.os.SystemProperties;
import android.os.PowerManager.WakeLock;
import android.telephony.NeighboringCellInfo;
import android.telephony.PhoneNumberUtils;
@@ -2876,21 +2885,44 @@
private Object
responseCellList(Parcel p) {
- int num;
+ int num, rssi;
+ String location;
ArrayList<NeighboringCellInfo> response;
NeighboringCellInfo cell;
num = p.readInt();
- response = new ArrayList<NeighboringCellInfo>(num);
+ response = new ArrayList<NeighboringCellInfo>();
- for (int i = 0 ; i < num ; i++) {
- int rssi = p.readInt();
- int cid = Integer.valueOf(p.readString(), 16);
- cell = new NeighboringCellInfo(rssi, cid);
- response.add(cell);
+ // Determine the radio access type
+ String radioString = SystemProperties.get(
+ TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, "unknown");
+ int radioType;
+ if (radioString.equals("GPRS")) {
+ radioType = NETWORK_TYPE_GPRS;
+ } else if (radioString.equals("EDGE")) {
+ radioType = NETWORK_TYPE_EDGE;
+ } else if (radioString.equals("UMTS")) {
+ radioType = NETWORK_TYPE_UMTS;
+ } else if (radioString.equals("HSDPA")) {
+ radioType = NETWORK_TYPE_HSDPA;
+ } else if (radioString.equals("HSUPA")) {
+ radioType = NETWORK_TYPE_HSUPA;
+ } else if (radioString.equals("HSPA")) {
+ radioType = NETWORK_TYPE_HSPA;
+ } else {
+ radioType = NETWORK_TYPE_UNKNOWN;
}
- return response;
+ // Interpret the location based on radio access type
+ if (radioType != NETWORK_TYPE_UNKNOWN) {
+ for (int i = 0 ; i < num ; i++) {
+ rssi = p.readInt();
+ location = p.readString();
+ cell = new NeighboringCellInfo(rssi, location, radioType);
+ response.add(cell);
+ }
+ }
+ return response;
}
private Object responseGmsBroadcastConfig(Parcel p) {
diff --git a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
index ffaa1cd..93b48a9 100644
--- a/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/cdma/CdmaDataConnectionTracker.java
@@ -246,8 +246,7 @@
@Override
protected boolean isApnTypeActive(String type) {
return (isApnTypeAvailable(type) &&
- mCdmaPhone.mSST.getCurrentCdmaDataConnectionState() ==
- ServiceState.STATE_IN_SERVICE);
+ (state == State.CONNECTED || state == State.INITING));
}
@Override
@@ -261,8 +260,7 @@
}
protected String[] getActiveApnTypes() {
- if (mCdmaPhone.mSST.getCurrentCdmaDataConnectionState() ==
- ServiceState.STATE_IN_SERVICE) {
+ if (state == State.CONNECTED || state == State.INITING) {
return mSupportedApnTypes.clone();
}
return new String[0];
@@ -626,6 +624,15 @@
}
/**
+ * @override com.android.intenral.telephony.DataConnectionTracker
+ */
+ @Override
+ protected void onEnableNewApn() {
+ // for cdma we only use this when default data is enabled..
+ onTrySetupData(Phone.REASON_DATA_ENABLED);
+ }
+
+ /**
* @override com.android.internal.telephony.DataConnectionTracker
*/
protected boolean onTrySetupData(String reason) {
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/AndroidTests/src/com/android/unit_tests/NeighboringCellInfoTest.java b/tests/AndroidTests/src/com/android/unit_tests/NeighboringCellInfoTest.java
index 2bdf1dd..7252aa9 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/NeighboringCellInfoTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/NeighboringCellInfoTest.java
@@ -15,41 +15,65 @@
*/
package com.android.unit_tests;
+import android.os.Parcel;
import android.test.AndroidTestCase;
import android.telephony.NeighboringCellInfo;
import android.test. suitebuilder.annotation.SmallTest;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_UNKNOWN;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS;
+import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS;
+
public class NeighboringCellInfoTest extends AndroidTestCase {
@SmallTest
public void testConstructor() {
- NeighboringCellInfo empty = new NeighboringCellInfo();
- assertEquals(NeighboringCellInfo.UNKNOWN_RSSI, empty.getRssi());
- assertEquals(NeighboringCellInfo.UNKNOWN_CID, empty.getCid());
-
int rssi = 31;
- int cid = 0xffffffff;
- NeighboringCellInfo max = new NeighboringCellInfo(rssi, cid);
- assertEquals(rssi, max.getRssi());
- assertEquals(cid, max.getCid());
- }
+ NeighboringCellInfo nc;
- @SmallTest
- public void testGetAndSet() {
- int rssi = 16;
- int cid = 0x12345678;
- NeighboringCellInfo nc = new NeighboringCellInfo();
- nc.setRssi(rssi);
- nc.setCid(cid);
+ nc = new NeighboringCellInfo(rssi, "FFFFFFF", NETWORK_TYPE_EDGE);
+ assertEquals(NETWORK_TYPE_EDGE, nc.getNetworkType());
assertEquals(rssi, nc.getRssi());
- assertEquals(cid, nc.getCid());
+ assertEquals(0xfff, nc.getLac());
+ assertEquals(0xffff, nc.getCid());
+ assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc());
+
+ nc = new NeighboringCellInfo(rssi, "1FF", NETWORK_TYPE_UMTS);
+ assertEquals(NETWORK_TYPE_UMTS, nc.getNetworkType());
+ assertEquals(rssi, nc.getRssi());
+ assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getCid());
+ assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getLac());
+ assertEquals(0x1ff, nc.getPsc());
+
+ nc = new NeighboringCellInfo(rssi, "1FF", NETWORK_TYPE_UNKNOWN);
+ assertEquals(NETWORK_TYPE_UNKNOWN, nc.getNetworkType());
+ assertEquals(rssi, nc.getRssi());
+ assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getCid());
+ assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getLac());
+ assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc());
}
@SmallTest
- public void testToString() {
- NeighboringCellInfo empty = new NeighboringCellInfo();
- assertEquals("[/ at /]", empty.toString());
+ public void testParcel() {
+ int rssi = 20;
- NeighboringCellInfo nc = new NeighboringCellInfo(16, 0x12345678);
- assertEquals("[12345678 at 16]", nc.toString());
- }
+ NeighboringCellInfo nc = new NeighboringCellInfo(rssi, "12345678", NETWORK_TYPE_GPRS);
+ assertEquals(NETWORK_TYPE_GPRS, nc.getNetworkType());
+ assertEquals(rssi, nc.getRssi());
+ assertEquals(0x1234, nc.getLac());
+ assertEquals(0x5678, nc.getCid());
+ assertEquals(NeighboringCellInfo.UNKNOWN_CID, nc.getPsc());
+
+ Parcel p = Parcel.obtain();
+ p.setDataPosition(0);
+ nc.writeToParcel(p, 0);
+
+ p.setDataPosition(0);
+ NeighboringCellInfo nw = new NeighboringCellInfo(p);
+ assertEquals(NETWORK_TYPE_GPRS, nw.getNetworkType());
+ assertEquals(rssi, nw.getRssi());
+ assertEquals(0x1234, nw.getLac());
+ assertEquals(0x5678, nw.getCid());
+ assertEquals(NeighboringCellInfo.UNKNOWN_CID, nw.getPsc());
+ }
}
diff --git a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
index 861e37b..32763b3 100644
--- a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
+++ b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
@@ -21,7 +21,7 @@
super(PKG_NAME, PowerTestActivity.class);
}
- public void testPageLoad() throws Throwable {
+ public void testPageLoadStaticNYTimes() throws Throwable {
Instrumentation mInst = getInstrumentation();
PowerTestActivity act = getActivity();
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());
}
}
}