summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Activity.java7
-rw-r--r--core/java/android/app/ActivityManager.java101
-rw-r--r--core/java/android/app/ActivityManagerNative.java181
-rw-r--r--core/java/android/app/ActivityThread.java37
-rw-r--r--core/java/android/app/ActivityView.java285
-rw-r--r--core/java/android/app/AppOpsManager.java2
-rw-r--r--core/java/android/app/ApplicationPackageManager.java33
-rw-r--r--core/java/android/app/ContextImpl.java9
-rw-r--r--core/java/android/app/Dialog.java4
-rw-r--r--core/java/android/app/Fragment.java1
-rw-r--r--core/java/android/app/FragmentManager.java5
-rw-r--r--core/java/android/app/IActivityContainer.aidl35
-rw-r--r--core/java/android/app/IActivityContainerCallback.aidl24
-rw-r--r--core/java/android/app/IActivityManager.java32
-rw-r--r--core/java/android/app/IWallpaperManager.aidl10
-rw-r--r--core/java/android/app/NativeActivity.java37
-rw-r--r--core/java/android/app/Notification.java190
-rw-r--r--core/java/android/app/SharedPreferencesImpl.java6
-rw-r--r--core/java/android/app/backup/BackupDataInput.java12
-rw-r--r--core/java/android/app/backup/BackupDataOutput.java12
-rw-r--r--core/java/android/app/backup/FileBackupHelperBase.java13
-rw-r--r--core/java/android/bluetooth/BluetoothInputDevice.java26
-rw-r--r--core/java/android/bluetooth/BluetoothSocket.java27
-rw-r--r--core/java/android/content/ContentProviderNative.java13
-rw-r--r--core/java/android/content/Context.java12
-rw-r--r--core/java/android/content/Intent.java11
-rw-r--r--core/java/android/content/pm/ApplicationInfo.java10
-rw-r--r--core/java/android/content/pm/ComponentInfo.java18
-rw-r--r--core/java/android/content/pm/PackageItemInfo.java52
-rw-r--r--core/java/android/content/pm/PackageManager.java122
-rw-r--r--core/java/android/content/pm/PackageParser.java78
-rw-r--r--core/java/android/content/res/AssetManager.java7
-rw-r--r--core/java/android/database/CursorWindow.java53
-rw-r--r--core/java/android/database/sqlite/SQLiteConnection.java66
-rw-r--r--core/java/android/database/sqlite/SQLiteDatabase.java10
-rw-r--r--core/java/android/ddm/DdmHandleProfiling.java47
-rw-r--r--core/java/android/hardware/Camera.java2
-rw-r--r--core/java/android/hardware/SystemSensorManager.java12
-rw-r--r--core/java/android/hardware/display/DisplayManager.java21
-rw-r--r--core/java/android/hardware/display/DisplayManagerInternal.java109
-rw-r--r--core/java/android/hardware/display/DisplayViewport.java77
-rw-r--r--core/java/android/hardware/hdmi/HdmiCec.java251
-rw-r--r--core/java/android/hardware/hdmi/HdmiCecClient.java125
-rw-r--r--core/java/android/hardware/hdmi/HdmiCecManager.java73
-rw-r--r--core/java/android/hardware/hdmi/HdmiCecMessage.aidl19
-rw-r--r--core/java/android/hardware/hdmi/HdmiCecMessage.java145
-rw-r--r--core/java/android/hardware/hdmi/IHdmiCecListener.aidl29
-rw-r--r--core/java/android/hardware/hdmi/IHdmiCecService.aidl40
-rw-r--r--core/java/android/hardware/input/IInputManager.aidl11
-rw-r--r--core/java/android/hardware/input/InputDeviceIdentifier.aidl19
-rw-r--r--core/java/android/hardware/input/InputDeviceIdentifier.java82
-rw-r--r--core/java/android/hardware/input/InputManager.java84
-rw-r--r--core/java/android/hardware/input/InputManagerInternal.java36
-rw-r--r--core/java/android/hardware/usb/UsbDevice.java49
-rw-r--r--core/java/android/hardware/usb/UsbDeviceConnection.java2
-rw-r--r--core/java/android/hardware/usb/UsbRequest.java2
-rw-r--r--core/java/android/inputmethodservice/IInputMethodSessionWrapper.java10
-rw-r--r--core/java/android/net/ConnectivityManager.java12
-rw-r--r--core/java/android/net/EthernetDataTracker.java2
-rw-r--r--core/java/android/net/INetworkManagementEventObserver.aidl27
-rw-r--r--core/java/android/net/LinkAddress.java207
-rw-r--r--core/java/android/net/LinkProperties.java48
-rw-r--r--core/java/android/net/NetworkIdentity.java8
-rw-r--r--core/java/android/net/NetworkPolicy.java8
-rw-r--r--core/java/android/net/NetworkStats.java6
-rw-r--r--core/java/android/net/NetworkTemplate.java13
-rw-r--r--core/java/android/net/ProxyDataTracker.java204
-rw-r--r--core/java/android/net/SSLCertificateSocketFactory.java2
-rw-r--r--core/java/android/net/arp/ArpPeer.java174
-rw-r--r--core/java/android/os/BatteryStats.java16
-rw-r--r--core/java/android/os/Binder.java8
-rw-r--r--core/java/android/os/Bundle.java2
-rw-r--r--core/java/android/os/Debug.java54
-rw-r--r--core/java/android/os/FactoryTest.java14
-rw-r--r--core/java/android/os/MemoryFile.java10
-rw-r--r--core/java/android/os/MessageQueue.java12
-rw-r--r--core/java/android/os/Parcel.java89
-rw-r--r--core/java/android/os/PowerManager.java13
-rw-r--r--core/java/android/os/PowerManagerInternal.java60
-rw-r--r--core/java/android/os/Process.java17
-rw-r--r--core/java/android/os/RecoverySystem.java64
-rw-r--r--core/java/android/os/SELinux.java12
-rw-r--r--core/java/android/os/StrictMode.java11
-rw-r--r--core/java/android/os/storage/StorageVolume.java2
-rw-r--r--core/java/android/service/dreams/DozeHardware.java77
-rw-r--r--core/java/android/service/dreams/DreamManagerInternal.java39
-rw-r--r--core/java/android/service/dreams/DreamService.java298
-rw-r--r--core/java/android/service/dreams/IDozeHardware.aidl24
-rw-r--r--core/java/android/service/dreams/IDreamManager.aidl6
-rw-r--r--core/java/android/service/dreams/IDreamService.aidl2
-rw-r--r--core/java/android/service/notification/NotificationListenerService.java11
-rw-r--r--core/java/android/speech/SpeechRecognizer.java2
-rw-r--r--core/java/android/speech/srec/MicrophoneInputStream.java12
-rw-r--r--core/java/android/speech/srec/Recognizer.java136
-rw-r--r--core/java/android/text/MeasuredText.java2
-rw-r--r--core/java/android/util/CharsetUtils.java198
-rw-r--r--core/java/android/util/TypedValue.java16
-rw-r--r--core/java/android/view/DisplayAdjustments.java6
-rw-r--r--core/java/android/view/DisplayEventReceiver.java8
-rw-r--r--core/java/android/view/GLES20Canvas.java264
-rw-r--r--core/java/android/view/GLES20DisplayList.java98
-rw-r--r--core/java/android/view/GLES20Layer.java8
-rw-r--r--core/java/android/view/GLES20RecordingCanvas.java2
-rw-r--r--core/java/android/view/GraphicBuffer.java20
-rw-r--r--core/java/android/view/HardwareCanvas.java14
-rw-r--r--core/java/android/view/HardwareRenderer.java8
-rw-r--r--core/java/android/view/InputChannel.java2
-rw-r--r--core/java/android/view/InputDevice.java90
-rw-r--r--core/java/android/view/InputEventReceiver.java10
-rw-r--r--core/java/android/view/InputEventSender.java10
-rw-r--r--core/java/android/view/InputQueue.java22
-rw-r--r--core/java/android/view/KeyCharacterMap.java24
-rw-r--r--core/java/android/view/KeyEvent.java14
-rw-r--r--core/java/android/view/MotionEvent.java80
-rw-r--r--core/java/android/view/Surface.java36
-rw-r--r--core/java/android/view/SurfaceControl.java100
-rw-r--r--core/java/android/view/TextureView.java6
-rw-r--r--core/java/android/view/VelocityTracker.java18
-rw-r--r--core/java/android/view/View.java31
-rw-r--r--core/java/android/view/ViewGroup.java9
-rw-r--r--core/java/android/view/Window.java13
-rw-r--r--core/java/android/view/WindowManagerInternal.java33
-rw-r--r--core/java/android/view/WindowManagerPolicy.java22
-rw-r--r--core/java/android/view/accessibility/AccessibilityManager.java40
-rw-r--r--core/java/android/widget/CompoundButton.java2
-rwxr-xr-x[-rw-r--r--]core/java/android/widget/CursorTreeAdapter.java2
-rw-r--r--core/java/android/widget/NumberPicker.java53
-rw-r--r--core/java/android/widget/SpellChecker.java6
-rw-r--r--core/java/android/widget/Spinner.java6
129 files changed, 4090 insertions, 1671 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index d6db8c2..ec58fb0 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -2402,6 +2402,13 @@ public class Activity extends ContextThemeWrapper
}
return false;
}
+
+ /**
+ * Called when the main window associated with the activity has been dismissed.
+ */
+ public void onWindowDismissed() {
+ finish();
+ }
/**
* Called to process key events. You can override this to intercept all
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 7ca3459..c877cd3 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -1289,106 +1289,15 @@ public class ActivityManager {
}
/**
- * Information you can retrieve about the WindowManager StackBox hierarchy.
- * @hide
- */
- public static class StackBoxInfo implements Parcelable {
- public int stackBoxId;
- public float weight;
- public boolean vertical;
- public Rect bounds;
- public StackBoxInfo[] children;
- public int stackId;
- public StackInfo stack;
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(stackBoxId);
- dest.writeFloat(weight);
- dest.writeInt(vertical ? 1 : 0);
- bounds.writeToParcel(dest, flags);
- dest.writeInt(stackId);
- if (children != null) {
- children[0].writeToParcel(dest, flags);
- children[1].writeToParcel(dest, flags);
- } else {
- stack.writeToParcel(dest, flags);
- }
- }
-
- public void readFromParcel(Parcel source) {
- stackBoxId = source.readInt();
- weight = source.readFloat();
- vertical = source.readInt() == 1;
- bounds = Rect.CREATOR.createFromParcel(source);
- stackId = source.readInt();
- if (stackId == -1) {
- children = new StackBoxInfo[2];
- children[0] = StackBoxInfo.CREATOR.createFromParcel(source);
- children[1] = StackBoxInfo.CREATOR.createFromParcel(source);
- } else {
- stack = StackInfo.CREATOR.createFromParcel(source);
- }
- }
-
- public static final Creator<StackBoxInfo> CREATOR =
- new Creator<ActivityManager.StackBoxInfo>() {
-
- @Override
- public StackBoxInfo createFromParcel(Parcel source) {
- return new StackBoxInfo(source);
- }
-
- @Override
- public StackBoxInfo[] newArray(int size) {
- return new StackBoxInfo[size];
- }
- };
-
- public StackBoxInfo() {
- }
-
- public StackBoxInfo(Parcel source) {
- readFromParcel(source);
- }
-
- public String toString(String prefix) {
- StringBuilder sb = new StringBuilder(256);
- sb.append(prefix); sb.append("Box id=" + stackBoxId); sb.append(" weight=" + weight);
- sb.append(" vertical=" + vertical); sb.append(" bounds=" + bounds.toShortString());
- sb.append("\n");
- if (children != null) {
- sb.append(prefix); sb.append("First child=\n");
- sb.append(children[0].toString(prefix + " "));
- sb.append(prefix); sb.append("Second child=\n");
- sb.append(children[1].toString(prefix + " "));
- } else {
- sb.append(prefix); sb.append("Stack=\n");
- sb.append(stack.toString(prefix + " "));
- }
- return sb.toString();
- }
-
- @Override
- public String toString() {
- return toString("");
- }
- }
-
- /**
* Information you can retrieve about an ActivityStack in the system.
* @hide
*/
public static class StackInfo implements Parcelable {
public int stackId;
- public Rect bounds;
+ public Rect bounds = new Rect();
public int[] taskIds;
public String[] taskNames;
+ public int displayId;
@Override
public int describeContents() {
@@ -1404,6 +1313,7 @@ public class ActivityManager {
dest.writeInt(bounds.bottom);
dest.writeIntArray(taskIds);
dest.writeStringArray(taskNames);
+ dest.writeInt(displayId);
}
public void readFromParcel(Parcel source) {
@@ -1412,6 +1322,7 @@ public class ActivityManager {
source.readInt(), source.readInt(), source.readInt(), source.readInt());
taskIds = source.createIntArray();
taskNames = source.createStringArray();
+ displayId = source.readInt();
}
public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() {
@@ -1435,7 +1346,9 @@ public class ActivityManager {
public String toString(String prefix) {
StringBuilder sb = new StringBuilder(256);
sb.append(prefix); sb.append("Stack id="); sb.append(stackId);
- sb.append(" bounds="); sb.append(bounds.toShortString()); sb.append("\n");
+ sb.append(" bounds="); sb.append(bounds.toShortString());
+ sb.append(" displayId="); sb.append(displayId);
+ sb.append("\n");
prefix = prefix + " ";
for (int i = 0; i < taskIds.length; ++i) {
sb.append(prefix); sb.append("taskId="); sb.append(taskIds[i]);
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 74266cc..7695ecc 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -16,7 +16,7 @@
package android.app;
-import android.app.ActivityManager.StackBoxInfo;
+import android.app.ActivityManager.StackInfo;
import android.content.ComponentName;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
@@ -31,6 +31,7 @@ import android.content.pm.ParceledListSlice;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Rect;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -611,18 +612,6 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
return true;
}
- case CREATE_STACK_TRANSACTION: {
- data.enforceInterface(IActivityManager.descriptor);
- int taskId = data.readInt();
- int relativeStackId = data.readInt();
- int position = data.readInt();
- float weight = data.readFloat();
- int res = createStack(taskId, relativeStackId, position, weight);
- reply.writeNoException();
- reply.writeInt(res);
- return true;
- }
-
case MOVE_TASK_TO_STACK_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
int taskId = data.readInt();
@@ -635,25 +624,26 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
case RESIZE_STACK_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
- int stackBoxId = data.readInt();
+ int stackId = data.readInt();
float weight = data.readFloat();
- resizeStackBox(stackBoxId, weight);
+ Rect r = Rect.CREATOR.createFromParcel(data);
+ resizeStack(stackId, r);
reply.writeNoException();
return true;
}
- case GET_STACK_BOXES_TRANSACTION: {
+ case GET_ALL_STACK_INFOS_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
- List<StackBoxInfo> list = getStackBoxes();
+ List<StackInfo> list = getAllStackInfos();
reply.writeNoException();
reply.writeTypedList(list);
return true;
}
- case GET_STACK_BOX_INFO_TRANSACTION: {
+ case GET_STACK_INFO_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
- int stackBoxId = data.readInt();
- StackBoxInfo info = getStackBoxInfo(stackBoxId);
+ int stackId = data.readInt();
+ StackInfo info = getStackInfo(stackId);
reply.writeNoException();
if (info != null) {
reply.writeInt(1);
@@ -2028,6 +2018,54 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
reply.writeNoException();
return true;
}
+
+ case CREATE_ACTIVITY_CONTAINER_TRANSACTION: {
+ data.enforceInterface(IActivityManager.descriptor);
+ IBinder parentActivityToken = data.readStrongBinder();
+ IActivityContainerCallback callback =
+ (IActivityContainerCallback) data.readStrongBinder();
+ IActivityContainer activityContainer =
+ createActivityContainer(parentActivityToken, callback);
+ reply.writeNoException();
+ if (activityContainer != null) {
+ reply.writeInt(1);
+ reply.writeStrongBinder(activityContainer.asBinder());
+ } else {
+ reply.writeInt(0);
+ }
+ return true;
+ }
+
+ case DELETE_ACTIVITY_CONTAINER_TRANSACTION: {
+ data.enforceInterface(IActivityManager.descriptor);
+ IActivityContainer activityContainer =
+ IActivityContainer.Stub.asInterface(data.readStrongBinder());
+ deleteActivityContainer(activityContainer);
+ reply.writeNoException();
+ return true;
+ }
+
+ case GET_ACTIVITY_CONTAINER_TRANSACTION: {
+ data.enforceInterface(IActivityManager.descriptor);
+ IBinder activityToken = data.readStrongBinder();
+ IActivityContainer activityContainer = getEnclosingActivityContainer(activityToken);
+ reply.writeNoException();
+ if (activityContainer != null) {
+ reply.writeInt(1);
+ reply.writeStrongBinder(activityContainer.asBinder());
+ } else {
+ reply.writeInt(0);
+ }
+ return true;
+ }
+
+ case GET_HOME_ACTIVITY_TOKEN_TRANSACTION: {
+ data.enforceInterface(IActivityManager.descriptor);
+ IBinder homeActivityToken = getHomeActivityToken();
+ reply.writeNoException();
+ reply.writeStrongBinder(homeActivityToken);
+ return true;
+ }
}
return super.onTransact(code, data, reply, flags);
@@ -2715,24 +2753,6 @@ class ActivityManagerProxy implements IActivityManager
reply.recycle();
}
@Override
- public int createStack(int taskId, int relativeStackBoxId, int position, float weight)
- throws RemoteException
- {
- Parcel data = Parcel.obtain();
- Parcel reply = Parcel.obtain();
- data.writeInterfaceToken(IActivityManager.descriptor);
- data.writeInt(taskId);
- data.writeInt(relativeStackBoxId);
- data.writeInt(position);
- data.writeFloat(weight);
- mRemote.transact(CREATE_STACK_TRANSACTION, data, reply, 0);
- reply.readException();
- int res = reply.readInt();
- data.recycle();
- reply.recycle();
- return res;
- }
- @Override
public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException
{
Parcel data = Parcel.obtain();
@@ -2747,44 +2767,44 @@ class ActivityManagerProxy implements IActivityManager
reply.recycle();
}
@Override
- public void resizeStackBox(int stackBoxId, float weight) throws RemoteException
+ public void resizeStack(int stackBoxId, Rect r) throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
data.writeInt(stackBoxId);
- data.writeFloat(weight);
+ r.writeToParcel(data, 0);
mRemote.transact(RESIZE_STACK_TRANSACTION, data, reply, IBinder.FLAG_ONEWAY);
reply.readException();
data.recycle();
reply.recycle();
}
@Override
- public List<StackBoxInfo> getStackBoxes() throws RemoteException
+ public List<StackInfo> getAllStackInfos() throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
- mRemote.transact(GET_STACK_BOXES_TRANSACTION, data, reply, 0);
+ mRemote.transact(GET_ALL_STACK_INFOS_TRANSACTION, data, reply, 0);
reply.readException();
- ArrayList<StackBoxInfo> list = reply.createTypedArrayList(StackBoxInfo.CREATOR);
+ ArrayList<StackInfo> list = reply.createTypedArrayList(StackInfo.CREATOR);
data.recycle();
reply.recycle();
return list;
}
@Override
- public StackBoxInfo getStackBoxInfo(int stackBoxId) throws RemoteException
+ public StackInfo getStackInfo(int stackId) throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInterfaceToken(IActivityManager.descriptor);
- data.writeInt(stackBoxId);
- mRemote.transact(GET_STACK_BOX_INFO_TRANSACTION, data, reply, 0);
+ data.writeInt(stackId);
+ mRemote.transact(GET_STACK_INFO_TRANSACTION, data, reply, 0);
reply.readException();
int res = reply.readInt();
- StackBoxInfo info = null;
+ StackInfo info = null;
if (res != 0) {
- info = StackBoxInfo.CREATOR.createFromParcel(reply);
+ info = StackInfo.CREATOR.createFromParcel(reply);
}
data.recycle();
reply.recycle();
@@ -4660,5 +4680,70 @@ class ActivityManagerProxy implements IActivityManager
reply.recycle();
}
+ public IActivityContainer createActivityContainer(IBinder parentActivityToken,
+ IActivityContainerCallback callback) throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ data.writeStrongBinder(parentActivityToken);
+ data.writeStrongBinder((IBinder)callback);
+ mRemote.transact(CREATE_ACTIVITY_CONTAINER_TRANSACTION, data, reply, 0);
+ reply.readException();
+ final int result = reply.readInt();
+ final IActivityContainer res;
+ if (result == 1) {
+ res = IActivityContainer.Stub.asInterface(reply.readStrongBinder());
+ } else {
+ res = null;
+ }
+ data.recycle();
+ reply.recycle();
+ return res;
+ }
+
+ public void deleteActivityContainer(IActivityContainer activityContainer)
+ throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ data.writeStrongBinder(activityContainer.asBinder());
+ mRemote.transact(DELETE_ACTIVITY_CONTAINER_TRANSACTION, data, reply, 0);
+ reply.readException();
+ data.recycle();
+ reply.recycle();
+ }
+
+ public IActivityContainer getEnclosingActivityContainer(IBinder activityToken)
+ throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ data.writeStrongBinder(activityToken);
+ mRemote.transact(GET_ACTIVITY_CONTAINER_TRANSACTION, data, reply, 0);
+ reply.readException();
+ final int result = reply.readInt();
+ final IActivityContainer res;
+ if (result == 1) {
+ res = IActivityContainer.Stub.asInterface(reply.readStrongBinder());
+ } else {
+ res = null;
+ }
+ data.recycle();
+ reply.recycle();
+ return res;
+ }
+
+ public IBinder getHomeActivityToken() throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ mRemote.transact(GET_HOME_ACTIVITY_TOKEN_TRANSACTION, data, reply, 0);
+ reply.readException();
+ IBinder res = reply.readStrongBinder();
+ data.recycle();
+ reply.recycle();
+ return res;
+ }
+
private IBinder mRemote;
}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 4825c56..b038f9e 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -93,10 +93,11 @@ import com.android.internal.os.BinderInternal;
import com.android.internal.os.RuntimeInit;
import com.android.internal.os.SamplingProfilerIntegration;
import com.android.internal.util.FastPrintWriter;
-import com.android.internal.util.Objects;
import com.android.org.conscrypt.OpenSSLSocketImpl;
import com.google.android.collect.Lists;
+import dalvik.system.VMRuntime;
+
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
@@ -109,6 +110,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.TimeZone;
import java.util.regex.Pattern;
@@ -117,6 +119,7 @@ import libcore.io.EventLogger;
import libcore.io.IoUtils;
import dalvik.system.CloseGuard;
+import dalvik.system.VMRuntime;
final class RemoteServiceException extends AndroidRuntimeException {
public RemoteServiceException(String msg) {
@@ -221,7 +224,7 @@ public final class ActivityThread {
public boolean equals(Object o) {
if (o instanceof ProviderKey) {
final ProviderKey other = (ProviderKey) o;
- return Objects.equal(authority, other.authority) && userId == other.userId;
+ return Objects.equals(authority, other.authority) && userId == other.userId;
}
return false;
}
@@ -739,6 +742,9 @@ public final class ActivityThread {
setCoreSettings(coreSettings);
+ // Tell the VMRuntime about the application.
+ VMRuntime.registerAppInfo(appInfo.dataDir, appInfo.processName);
+
AppBindData data = new AppBindData();
data.processName = processName;
data.appInfo = appInfo;
@@ -1068,8 +1074,15 @@ public final class ActivityThread {
synchronized (this) {
if (mLastProcessState != processState) {
mLastProcessState = processState;
-
- // Update Dalvik state here based on ActivityManager.PROCESS_STATE_* constants.
+ // Update Dalvik state based on ActivityManager.PROCESS_STATE_* constants.
+ final int DALVIK_PROCESS_STATE_JANK_PERCEPTIBLE = 0;
+ final int DALVIK_PROCESS_STATE_JANK_IMPERCEPTIBLE = 1;
+ int dalvikProcessState = DALVIK_PROCESS_STATE_JANK_IMPERCEPTIBLE;
+ // TODO: Tune this since things like gmail sync are important background but not jank perceptible.
+ if (processState <= ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) {
+ dalvikProcessState = DALVIK_PROCESS_STATE_JANK_PERCEPTIBLE;
+ }
+ VMRuntime.getRuntime().updateProcessState(dalvikProcessState);
if (false) {
Slog.i(TAG, "******************* PROCESS STATE CHANGED TO: " + processState
+ (fromIpc ? " (from ipc": ""));
@@ -2194,15 +2207,27 @@ public final class ActivityThread {
final Activity activity) {
ContextImpl appContext = ContextImpl.createActivityContext(this, r.packageInfo, r.token);
appContext.setOuterContext(activity);
+ Context baseContext = appContext;
+
+ final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
+ try {
+ IActivityContainer container =
+ ActivityManagerNative.getDefault().getEnclosingActivityContainer(r.token);
+ final int displayId =
+ container == null ? Display.DEFAULT_DISPLAY : container.getDisplayId();
+ if (displayId > Display.DEFAULT_DISPLAY) {
+ Display display = dm.getRealDisplay(displayId, r.token);
+ baseContext = appContext.createDisplayContext(display);
+ }
+ } catch (RemoteException e) {
+ }
// For debugging purposes, if the activity's package name contains the value of
// the "debug.use-second-display" system property as a substring, then show
// its content on a secondary display if there is one.
- Context baseContext = appContext;
String pkgName = SystemProperties.get("debug.second-display.pkg");
if (pkgName != null && !pkgName.isEmpty()
&& r.packageInfo.mPackageName.contains(pkgName)) {
- DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
for (int displayId : dm.getDisplayIds()) {
if (displayId != Display.DEFAULT_DISPLAY) {
Display display = dm.getRealDisplay(displayId, r.token);
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java
new file mode 100644
index 0000000..113f123
--- /dev/null
+++ b/core/java/android/app/ActivityView.java
@@ -0,0 +1,285 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package android.app;
+
+import android.content.Context;
+import android.content.ContextWrapper;
+import android.content.IIntentSender;
+import android.content.Intent;
+import android.content.IntentSender;
+import android.graphics.SurfaceTexture;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.AttributeSet;
+import android.util.DisplayMetrics;
+import android.util.Log;
+import android.view.InputDevice;
+import android.view.InputEvent;
+import android.view.MotionEvent;
+import android.view.Surface;
+import android.view.TextureView;
+import android.view.TextureView.SurfaceTextureListener;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+
+/** @hide */
+public class ActivityView extends ViewGroup {
+ private final String TAG = "ActivityView";
+ private final boolean DEBUG = false;
+
+ private final TextureView mTextureView;
+ private IActivityContainer mActivityContainer;
+ private Activity mActivity;
+ private int mWidth;
+ private int mHeight;
+ private Surface mSurface;
+
+ // Only one IIntentSender or Intent may be queued at a time. Most recent one wins.
+ IIntentSender mQueuedPendingIntent;
+ Intent mQueuedIntent;
+
+ public ActivityView(Context context) {
+ this(context, null);
+ }
+
+ public ActivityView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ActivityView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+
+ while (context instanceof ContextWrapper) {
+ if (context instanceof Activity) {
+ mActivity = (Activity)context;
+ break;
+ }
+ context = ((ContextWrapper)context).getBaseContext();
+ }
+ if (mActivity == null) {
+ throw new IllegalStateException("The ActivityView's Context is not an Activity.");
+ }
+
+ mTextureView = new TextureView(context);
+ mTextureView.setSurfaceTextureListener(new ActivityViewSurfaceTextureListener());
+ addView(mTextureView);
+ if (DEBUG) Log.v(TAG, "ctor()");
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int l, int t, int r, int b) {
+ mTextureView.layout(0, 0, r - l, b - t);
+ }
+
+ @Override
+ protected void onAttachedToWindow() {
+ if (DEBUG) Log.v(TAG, "onAttachedToWindow()");
+ super.onAttachedToWindow();
+ try {
+ final IBinder token = mActivity.getActivityToken();
+ mActivityContainer =
+ ActivityManagerNative.getDefault().createActivityContainer(token, null);
+ } catch (RemoteException e) {
+ throw new IllegalStateException("ActivityView: Unable to create ActivityContainer. "
+ + e);
+ }
+
+ attachToSurfaceWhenReady();
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ if (DEBUG) Log.v(TAG, "onDetachedFromWindow(): mActivityContainer=" + mActivityContainer);
+ super.onDetachedFromWindow();
+ if (mActivityContainer != null) {
+ detach();
+ try {
+ ActivityManagerNative.getDefault().deleteActivityContainer(mActivityContainer);
+ } catch (RemoteException e) {
+ }
+ mActivityContainer = null;
+ }
+ }
+
+ @Override
+ protected void onWindowVisibilityChanged(int visibility) {
+ if (DEBUG) Log.v(TAG, "onWindowVisibilityChanged(): visibility=" + visibility);
+ super.onWindowVisibilityChanged(visibility);
+ switch (visibility) {
+ case View.VISIBLE:
+ attachToSurfaceWhenReady();
+ break;
+ case View.INVISIBLE:
+ break;
+ case View.GONE:
+ break;
+ }
+ }
+
+ private boolean injectInputEvent(InputEvent event) {
+ try {
+ return mActivityContainer != null && mActivityContainer.injectEvent(event);
+ } catch (RemoteException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ return injectInputEvent(event) || super.onTouchEvent(event);
+ }
+
+ @Override
+ public boolean onGenericMotionEvent(MotionEvent event) {
+ if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) {
+ if (injectInputEvent(event)) {
+ return true;
+ }
+ }
+ return super.onGenericMotionEvent(event);
+ }
+
+ public boolean isAttachedToDisplay() {
+ return mSurface != null;
+ }
+
+ public void startActivity(Intent intent) {
+ if (DEBUG) Log.v(TAG, "startActivity(): intent=" + intent + " " +
+ (isAttachedToDisplay() ? "" : "not") + " attached");
+ if (mSurface != null) {
+ try {
+ mActivityContainer.startActivity(intent);
+ } catch (RemoteException e) {
+ throw new IllegalStateException("ActivityView: Unable to startActivity. " + e);
+ }
+ } else {
+ mQueuedIntent = intent;
+ mQueuedPendingIntent = null;
+ }
+ }
+
+ private void startActivityIntentSender(IIntentSender iIntentSender) {
+ try {
+ mActivityContainer.startActivityIntentSender(iIntentSender);
+ } catch (RemoteException e) {
+ throw new IllegalStateException(
+ "ActivityView: Unable to startActivity from IntentSender. " + e);
+ }
+ }
+
+ public void startActivity(IntentSender intentSender) {
+ if (DEBUG) Log.v(TAG, "startActivityIntentSender(): intentSender=" + intentSender + " " +
+ (isAttachedToDisplay() ? "" : "not") + " attached");
+ final IIntentSender iIntentSender = intentSender.getTarget();
+ if (mSurface != null) {
+ startActivityIntentSender(iIntentSender);
+ } else {
+ mQueuedPendingIntent = iIntentSender;
+ mQueuedIntent = null;
+ }
+ }
+
+ public void startActivity(PendingIntent pendingIntent) {
+ if (DEBUG) Log.v(TAG, "startActivityPendingIntent(): PendingIntent=" + pendingIntent + " "
+ + (isAttachedToDisplay() ? "" : "not") + " attached");
+ final IIntentSender iIntentSender = pendingIntent.getTarget();
+ if (mSurface != null) {
+ startActivityIntentSender(iIntentSender);
+ } else {
+ mQueuedPendingIntent = iIntentSender;
+ mQueuedIntent = null;
+ }
+ }
+
+ private void attachToSurfaceWhenReady() {
+ final SurfaceTexture surfaceTexture = mTextureView.getSurfaceTexture();
+ if (mActivityContainer == null || surfaceTexture == null || mSurface != null) {
+ // Either not ready to attach, or already attached.
+ return;
+ }
+
+ WindowManager wm = (WindowManager)mActivity.getSystemService(Context.WINDOW_SERVICE);
+ DisplayMetrics metrics = new DisplayMetrics();
+ wm.getDefaultDisplay().getMetrics(metrics);
+
+ mSurface = new Surface(surfaceTexture);
+ try {
+ mActivityContainer.attachToSurface(mSurface, mWidth, mHeight, metrics.densityDpi);
+ } catch (RemoteException e) {
+ mSurface.release();
+ mSurface = null;
+ throw new IllegalStateException(
+ "ActivityView: Unable to create ActivityContainer. " + e);
+ }
+
+ if (DEBUG) Log.v(TAG, "attachToSurfaceWhenReady: " + (mQueuedIntent != null ||
+ mQueuedPendingIntent != null ? "" : "no") + " queued intent");
+ if (mQueuedIntent != null) {
+ startActivity(mQueuedIntent);
+ mQueuedIntent = null;
+ } else if (mQueuedPendingIntent != null) {
+ startActivityIntentSender(mQueuedPendingIntent);
+ mQueuedPendingIntent = null;
+ }
+ }
+
+ private void detach() {
+ if (DEBUG) Log.d(TAG, "detach: attached=" + isAttachedToDisplay());
+ if (mSurface != null) {
+ try {
+ mActivityContainer.detachFromDisplay();
+ } catch (RemoteException e) {
+ }
+ mSurface.release();
+ mSurface = null;
+ }
+ }
+
+ private class ActivityViewSurfaceTextureListener implements SurfaceTextureListener {
+ @Override
+ public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
+ int height) {
+ if (DEBUG) Log.d(TAG, "onSurfaceTextureAvailable: width=" + width + " height="
+ + height);
+ mWidth = width;
+ mHeight = height;
+ if (mActivityContainer != null) {
+ attachToSurfaceWhenReady();
+ }
+ }
+
+ @Override
+ public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width,
+ int height) {
+ if (DEBUG) Log.d(TAG, "onSurfaceTextureSizeChanged: w=" + width + " h=" + height);
+ }
+
+ @Override
+ public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
+ if (DEBUG) Log.d(TAG, "onSurfaceTextureDestroyed");
+ detach();
+ return true;
+ }
+
+ @Override
+ public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
+// Log.d(TAG, "onSurfaceTextureUpdated");
+ }
+
+ }
+}
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index 286bde0..079cf7a 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -369,8 +369,8 @@ public class AppOpsManager {
android.Manifest.permission.WRITE_CALL_LOG,
android.Manifest.permission.READ_CALENDAR,
android.Manifest.permission.WRITE_CALENDAR,
- null, // no permission required for notifications
android.Manifest.permission.ACCESS_WIFI_STATE,
+ null, // no permission required for notifications
null, // neighboring cells shares the coarse location perm
android.Manifest.permission.CALL_PHONE,
android.Manifest.permission.READ_SMS,
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index b505d4f..6f53df4 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -729,6 +729,39 @@ final class ApplicationPackageManager extends PackageManager {
}
@Override
+ public Drawable getActivityBanner(ComponentName activityName)
+ throws NameNotFoundException {
+ return getActivityInfo(activityName, 0).loadBanner(this);
+ }
+
+ @Override
+ public Drawable getActivityBanner(Intent intent)
+ throws NameNotFoundException {
+ if (intent.getComponent() != null) {
+ return getActivityBanner(intent.getComponent());
+ }
+
+ ResolveInfo info = resolveActivity(
+ intent, PackageManager.MATCH_DEFAULT_ONLY);
+ if (info != null) {
+ return info.activityInfo.loadBanner(this);
+ }
+
+ throw new NameNotFoundException(intent.toUri(0));
+ }
+
+ @Override
+ public Drawable getApplicationBanner(ApplicationInfo info) {
+ return info.loadBanner(this);
+ }
+
+ @Override
+ public Drawable getApplicationBanner(String packageName)
+ throws NameNotFoundException {
+ return getApplicationBanner(getApplicationInfo(packageName, 0));
+ }
+
+ @Override
public Drawable getActivityLogo(ComponentName activityName)
throws NameNotFoundException {
return getActivityInfo(activityName, 0).loadLogo(this);
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index d9cad3b..bb46197 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -51,6 +51,8 @@ import android.hardware.ConsumerIrManager;
import android.hardware.ISerialManager;
import android.hardware.SerialManager;
import android.hardware.SystemSensorManager;
+import android.hardware.hdmi.HdmiCecManager;
+import android.hardware.hdmi.IHdmiCecService;
import android.hardware.camera2.CameraManager;
import android.hardware.display.DisplayManager;
import android.hardware.input.InputManager;
@@ -357,6 +359,13 @@ class ContextImpl extends Context {
return new BluetoothManager(ctx);
}});
+ registerService(HDMI_CEC_SERVICE, new StaticServiceFetcher() {
+ public Object createStaticService() {
+ IBinder b = ServiceManager.getService(HDMI_CEC_SERVICE);
+ return new HdmiCecManager(IHdmiCecService.Stub.asInterface(b));
+ }});
+
+
registerService(CLIPBOARD_SERVICE, new ServiceFetcher() {
public Object createService(ContextImpl ctx) {
return new ClipboardManager(ctx.getOuterContext(),
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index cda2c5f..a8277b5 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -695,6 +695,10 @@ public class Dialog implements DialogInterface, Window.Callback,
public void onDetachedFromWindow() {
}
+
+ public void onWindowDismissed() {
+ dismiss();
+ }
/**
* Called to process key events. You can override this to intercept all
diff --git a/core/java/android/app/Fragment.java b/core/java/android/app/Fragment.java
index d626e5f..af8f177 100644
--- a/core/java/android/app/Fragment.java
+++ b/core/java/android/app/Fragment.java
@@ -1402,6 +1402,7 @@ public class Fragment implements ComponentCallbacks2, OnCreateContextMenuListene
mRestored = false;
mBackStackNesting = 0;
mFragmentManager = null;
+ mChildFragmentManager = null;
mActivity = null;
mFragmentId = 0;
mContainerId = 0;
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java
index 4371907..76f9d97 100644
--- a/core/java/android/app/FragmentManager.java
+++ b/core/java/android/app/FragmentManager.java
@@ -574,12 +574,12 @@ final class FragmentManagerImpl extends FragmentManager {
return null;
}
if (index >= mActive.size()) {
- throwException(new IllegalStateException("Fragement no longer exists for key "
+ throwException(new IllegalStateException("Fragment no longer exists for key "
+ key + ": index " + index));
}
Fragment f = mActive.get(index);
if (f == null) {
- throwException(new IllegalStateException("Fragement no longer exists for key "
+ throwException(new IllegalStateException("Fragment no longer exists for key "
+ key + ": index " + index));
}
return f;
@@ -1026,6 +1026,7 @@ final class FragmentManagerImpl extends FragmentManager {
f.mActivity = null;
f.mParentFragment = null;
f.mFragmentManager = null;
+ f.mChildFragmentManager = null;
}
}
}
diff --git a/core/java/android/app/IActivityContainer.aidl b/core/java/android/app/IActivityContainer.aidl
new file mode 100644
index 0000000..5b80e06
--- /dev/null
+++ b/core/java/android/app/IActivityContainer.aidl
@@ -0,0 +1,35 @@
+/**
+ * Copyright (c) 2013, 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.
+ */
+
+package android.app;
+
+import android.app.IActivityContainerCallback;
+import android.content.Intent;
+import android.content.IIntentSender;
+import android.os.IBinder;
+import android.view.InputEvent;
+import android.view.Surface;
+
+/** @hide */
+interface IActivityContainer {
+ void attachToDisplay(int displayId);
+ void attachToSurface(in Surface surface, int width, int height, int density);
+ void detachFromDisplay();
+ int startActivity(in Intent intent);
+ int startActivityIntentSender(in IIntentSender intentSender);
+ int getDisplayId();
+ boolean injectEvent(in InputEvent event);
+}
diff --git a/core/java/android/app/IActivityContainerCallback.aidl b/core/java/android/app/IActivityContainerCallback.aidl
new file mode 100644
index 0000000..55c2001
--- /dev/null
+++ b/core/java/android/app/IActivityContainerCallback.aidl
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2013, 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.
+ */
+
+package android.app;
+
+import android.os.IBinder;
+
+/** @hide */
+interface IActivityContainerCallback {
+ oneway void onLastActivityRemoved(IBinder container);
+}
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 77c2ea0..02a6343 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -18,7 +18,7 @@ package android.app;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.RunningServiceInfo;
-import android.app.ActivityManager.StackBoxInfo;
+import android.app.ActivityManager.StackInfo;
import android.content.ComponentName;
import android.content.ContentProviderNative;
import android.content.IContentProvider;
@@ -36,6 +36,7 @@ import android.content.pm.ProviderInfo;
import android.content.pm.UserInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
import android.os.Debug;
@@ -117,12 +118,10 @@ public interface IActivityManager extends IInterface {
public void moveTaskToBack(int task) throws RemoteException;
public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) throws RemoteException;
public void moveTaskBackwards(int task) throws RemoteException;
- public int createStack(int taskId, int relativeStackBoxId, int position, float weight)
- throws RemoteException;
public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException;
- public void resizeStackBox(int stackBoxId, float weight) throws RemoteException;
- public List<StackBoxInfo> getStackBoxes() throws RemoteException;
- public StackBoxInfo getStackBoxInfo(int stackBoxId) throws RemoteException;
+ public void resizeStack(int stackId, Rect bounds) throws RemoteException;
+ public List<StackInfo> getAllStackInfos() throws RemoteException;
+ public StackInfo getStackInfo(int stackId) throws RemoteException;
public void setFocusedStack(int stackId) throws RemoteException;
public int getTaskForActivity(IBinder token, boolean onlyRoot) throws RemoteException;
/* oneway */
@@ -408,6 +407,18 @@ public interface IActivityManager extends IInterface {
public void performIdleMaintenance() throws RemoteException;
+ /** @hide */
+ public IActivityContainer createActivityContainer(IBinder parentActivityToken,
+ IActivityContainerCallback callback) throws RemoteException;
+
+ /** @hide */
+ public void deleteActivityContainer(IActivityContainer container) throws RemoteException;
+
+ public IActivityContainer getEnclosingActivityContainer(IBinder activityToken)
+ throws RemoteException;
+
+ public IBinder getHomeActivityToken() throws RemoteException;
+
/*
* Private non-Binder interfaces
*/
@@ -678,12 +689,12 @@ public interface IActivityManager extends IInterface {
int KILL_UID_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+164;
int SET_USER_IS_MONKEY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+165;
int HANG_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+166;
- int CREATE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+167;
+ int CREATE_ACTIVITY_CONTAINER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+167;
int MOVE_TASK_TO_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+168;
int RESIZE_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+169;
- int GET_STACK_BOXES_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+170;
+ int GET_ALL_STACK_INFOS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+170;
int SET_FOCUSED_STACK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+171;
- int GET_STACK_BOX_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+172;
+ int GET_STACK_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+172;
int CONVERT_FROM_TRANSLUCENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+173;
int CONVERT_TO_TRANSLUCENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+174;
int NOTIFY_ACTIVITY_DRAWN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+175;
@@ -694,4 +705,7 @@ public interface IActivityManager extends IInterface {
int RELEASE_PERSISTABLE_URI_PERMISSION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+180;
int GET_PERSISTED_URI_PERMISSIONS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+181;
int APP_NOT_RESPONDING_VIA_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+182;
+ int GET_HOME_ACTIVITY_TOKEN_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+183;
+ int GET_ACTIVITY_CONTAINER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+184;
+ int DELETE_ACTIVITY_CONTAINER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+185;
}
diff --git a/core/java/android/app/IWallpaperManager.aidl b/core/java/android/app/IWallpaperManager.aidl
index 3efd3c0..181eb63 100644
--- a/core/java/android/app/IWallpaperManager.aidl
+++ b/core/java/android/app/IWallpaperManager.aidl
@@ -71,4 +71,14 @@ interface IWallpaperManager {
* Returns the desired minimum height for the wallpaper.
*/
int getHeightHint();
+
+ /**
+ * Returns the name of the wallpaper. Private API.
+ */
+ String getName();
+
+ /**
+ * Informs the service that wallpaper settings have been restored. Private API.
+ */
+ void settingsRestored();
}
diff --git a/core/java/android/app/NativeActivity.java b/core/java/android/app/NativeActivity.java
index 4ca3747..2e05edb 100644
--- a/core/java/android/app/NativeActivity.java
+++ b/core/java/android/app/NativeActivity.java
@@ -76,7 +76,7 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,
private NativeContentView mNativeContentView;
private InputMethodManager mIMM;
- private int mNativeHandle;
+ private long mNativeHandle;
private InputQueue mCurInputQueue;
private SurfaceHolder mCurSurfaceHolder;
@@ -91,27 +91,26 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback2,
private boolean mDestroyed;
- private native int loadNativeCode(String path, String funcname, MessageQueue queue,
+ private native long loadNativeCode(String path, String funcname, MessageQueue queue,
String internalDataPath, String obbPath, String externalDataPath, int sdkVersion,
AssetManager assetMgr, byte[] savedState);
- private native void unloadNativeCode(int handle);
-
- private native void onStartNative(int handle);
- private native void onResumeNative(int handle);
- private native byte[] onSaveInstanceStateNative(int handle);
- private native void onPauseNative(int handle);
- private native void onStopNative(int handle);
- private native void onConfigurationChangedNative(int handle);
- private native void onLowMemoryNative(int handle);
- private native void onWindowFocusChangedNative(int handle, boolean focused);
- private native void onSurfaceCreatedNative(int handle, Surface surface);
- private native void onSurfaceChangedNative(int handle, Surface surface,
+ private native void unloadNativeCode(long handle);
+ private native void onStartNative(long handle);
+ private native void onResumeNative(long handle);
+ private native byte[] onSaveInstanceStateNative(long handle);
+ private native void onPauseNative(long handle);
+ private native void onStopNative(long handle);
+ private native void onConfigurationChangedNative(long handle);
+ private native void onLowMemoryNative(long handle);
+ private native void onWindowFocusChangedNative(long handle, boolean focused);
+ private native void onSurfaceCreatedNative(long handle, Surface surface);
+ private native void onSurfaceChangedNative(long handle, Surface surface,
int format, int width, int height);
- private native void onSurfaceRedrawNeededNative(int handle, Surface surface);
- private native void onSurfaceDestroyedNative(int handle);
- private native void onInputQueueCreatedNative(int handle, int queuePtr);
- private native void onInputQueueDestroyedNative(int handle, int queuePtr);
- private native void onContentRectChangedNative(int handle, int x, int y, int w, int h);
+ private native void onSurfaceRedrawNeededNative(long handle, Surface surface);
+ private native void onSurfaceDestroyedNative(long handle);
+ private native void onInputQueueCreatedNative(long handle, long queuePtr);
+ private native void onInputQueueDestroyedNative(long handle, long queuePtr);
+ private native void onContentRectChangedNative(long handle, int x, int y, int w, int h);
static class NativeContentView extends View {
NativeActivity mActivity;
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index cce6fc4..e6b5de1 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -348,6 +348,13 @@ public class Notification implements Parcelable
*/
public static final int FLAG_HIGH_PRIORITY = 0x00000080;
+ /**
+ * Bit to be bitswise-ored into the {@link #flags} field that should be
+ * set if this notification is relevant to the current device only
+ * and it is not recommended that it bridge to other devices.
+ */
+ public static final int FLAG_LOCAL_ONLY = 0x00000100;
+
public int flags;
/**
@@ -394,41 +401,82 @@ public class Notification implements Parcelable
public int priority;
/**
- * @hide
- * Notification type: incoming call (voice or video) or similar synchronous communication request.
+ * Notification category: incoming call (voice or video) or similar synchronous communication request.
*/
- public static final String KIND_CALL = "android.call";
+ public static final String CATEGORY_CALL = "call";
/**
- * @hide
- * Notification type: incoming direct message (SMS, instant message, etc.).
+ * Notification category: incoming direct message (SMS, instant message, etc.).
*/
- public static final String KIND_MESSAGE = "android.message";
+ public static final String CATEGORY_MESSAGE = "msg";
/**
- * @hide
- * Notification type: asynchronous bulk message (email).
+ * Notification category: asynchronous bulk message (email).
*/
- public static final String KIND_EMAIL = "android.email";
+ public static final String CATEGORY_EMAIL = "email";
/**
- * @hide
- * Notification type: calendar event.
+ * Notification category: calendar event.
*/
- public static final String KIND_EVENT = "android.event";
+ public static final String CATEGORY_EVENT = "event";
/**
- * @hide
- * Notification type: promotion or advertisement.
+ * Notification category: promotion or advertisement.
*/
- public static final String KIND_PROMO = "android.promo";
+ public static final String CATEGORY_PROMO = "promo";
/**
- * @hide
- * If this notification matches of one or more special types (see the <code>KIND_*</code>
- * constants), add them here, best match first.
+ * Notification category: alarm or timer.
+ */
+ public static final String CATEGORY_ALARM = "alarm";
+
+ /**
+ * Notification category: progress of a long-running background operation.
+ */
+ public static final String CATEGORY_PROGRESS = "progress";
+
+ /**
+ * Notification category: social network or sharing update.
+ */
+ public static final String CATEGORY_SOCIAL = "social";
+
+ /**
+ * Notification category: error in background operation or authentication status.
+ */
+ public static final String CATEGORY_ERROR = "err";
+
+ /**
+ * Notification category: media transport control for playback.
+ */
+ public static final String CATEGORY_TRANSPORT = "transport";
+
+ /**
+ * Notification category: system or device status update. Reserved for system use.
*/
- public String[] kind;
+ public static final String CATEGORY_SYSTEM = "sys";
+
+ /**
+ * Notification category: indication of running background service.
+ */
+ public static final String CATEGORY_SERVICE = "service";
+
+ /**
+ * Notification category: a specific, timely recommendation for a single thing.
+ * For example, a news app might want to recommend a news story it believes the user will
+ * want to read next.
+ */
+ public static final String CATEGORY_RECOMMENDATION = "recommendation";
+
+ /**
+ * Notification category: ongoing information about device or contextual status.
+ */
+ public static final String CATEGORY_STATUS = "status";
+
+ /**
+ * One of the predefined notification categories (see the <code>CATEGORY_*</code> constants)
+ * that best describes this Notification. May be used by the system for ranking and filtering.
+ */
+ public String category;
/**
* Additional semantic data to be carried around with this Notification.
@@ -561,6 +609,13 @@ public class Notification implements Parcelable
public static final String EXTRA_AS_HEADS_UP = "headsup";
/**
+ * Allow certain system-generated notifications to appear before the device is provisioned.
+ * Only available to notifications coming from the android package.
+ * @hide
+ */
+ public static final String EXTRA_ALLOW_DURING_SETUP = "android.allowDuringSetup";
+
+ /**
* Value for {@link #EXTRA_AS_HEADS_UP}.
* @hide
*/
@@ -750,7 +805,7 @@ public class Notification implements Parcelable
priority = parcel.readInt();
- kind = parcel.createStringArray(); // may set kind to null
+ category = parcel.readString();
extras = parcel.readBundle(); // may be null
@@ -815,12 +870,7 @@ public class Notification implements Parcelable
that.priority = this.priority;
- final String[] thiskind = this.kind;
- if (thiskind != null) {
- final int N = thiskind.length;
- final String[] thatkind = that.kind = new String[N];
- System.arraycopy(thiskind, 0, thatkind, 0, N);
- }
+ that.category = this.category;
if (this.extras != null) {
try {
@@ -957,7 +1007,7 @@ public class Notification implements Parcelable
parcel.writeInt(priority);
- parcel.writeStringArray(kind); // ok for null
+ parcel.writeString(category);
parcel.writeBundle(extras); // null ok
@@ -1077,16 +1127,7 @@ public class Notification implements Parcelable
sb.append(Integer.toHexString(this.defaults));
sb.append(" flags=0x");
sb.append(Integer.toHexString(this.flags));
- sb.append(" kind=[");
- if (this.kind == null) {
- sb.append("null");
- } else {
- for (int i=0; i<this.kind.length; i++) {
- if (i>0) sb.append(",");
- sb.append(this.kind[i]);
- }
- }
- sb.append("]");
+ sb.append(" category="); sb.append(this.category);
if (actions != null) {
sb.append(" ");
sb.append(actions.length);
@@ -1165,7 +1206,7 @@ public class Notification implements Parcelable
private int mProgressMax;
private int mProgress;
private boolean mProgressIndeterminate;
- private ArrayList<String> mKindList = new ArrayList<String>(1);
+ private String mCategory;
private Bundle mExtras;
private int mPriority;
private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS);
@@ -1532,6 +1573,17 @@ public class Notification implements Parcelable
}
/**
+ * Set whether or not this notification should not bridge to other devices.
+ *
+ * <p>Some notifications can be bridged to other devices for remote display.
+ * This hint can be set to recommend this notification not be bridged.
+ */
+ public Builder setLocalOnly(boolean localOnly) {
+ setFlag(FLAG_LOCAL_ONLY, localOnly);
+ return this;
+ }
+
+ /**
* Set which notification properties will be inherited from system defaults.
* <p>
* The value should be one or more of the following fields combined with
@@ -1556,24 +1608,41 @@ public class Notification implements Parcelable
}
/**
- * @hide
+ * Set the notification category.
*
- * Add a kind (category) to this notification. Optional.
+ * @see Notification#category
+ */
+ public Builder setCategory(String category) {
+ mCategory = category;
+ return this;
+ }
+
+ /**
+ * Merge additional metadata into this notification.
*
- * @see Notification#kind
+ * <p>Values within the Bundle will replace existing extras values in this Builder.
+ *
+ * @see Notification#extras
*/
- public Builder addKind(String k) {
- mKindList.add(k);
+ public Builder addExtras(Bundle bag) {
+ if (mExtras == null) {
+ mExtras = new Bundle(bag);
+ } else {
+ mExtras.putAll(bag);
+ }
return this;
}
/**
- * Add metadata to this notification.
+ * Set metadata for this notification.
*
- * A reference to the Bundle is held for the lifetime of this Builder, and the Bundle's
+ * <p>A reference to the Bundle is held for the lifetime of this Builder, and the Bundle's
* current contents are copied into the Notification each time {@link #build()} is
* called.
*
+ * <p>Replaces any existing extras values with those from the provided Bundle.
+ * Use {@link #addExtras} to merge in metadata instead.
+ *
* @see Notification#extras
*/
public Builder setExtras(Bundle bag) {
@@ -1582,6 +1651,23 @@ public class Notification implements Parcelable
}
/**
+ * Get the current metadata Bundle used by this notification Builder.
+ *
+ * <p>The returned Bundle is shared with this Builder.
+ *
+ * <p>The current contents of this Bundle are copied into the Notification each time
+ * {@link #build()} is called.
+ *
+ * @see Notification#extras
+ */
+ public Bundle getExtras() {
+ if (mExtras == null) {
+ mExtras = new Bundle();
+ }
+ return mExtras;
+ }
+
+ /**
* Add an action to this notification. Actions are typically displayed by
* the system as a button adjacent to the notification content.
* <p>
@@ -1819,12 +1905,7 @@ public class Notification implements Parcelable
if ((mDefaults & DEFAULT_LIGHTS) != 0) {
n.flags |= FLAG_SHOW_LIGHTS;
}
- if (mKindList.size() > 0) {
- n.kind = new String[mKindList.size()];
- mKindList.toArray(n.kind);
- } else {
- n.kind = null;
- }
+ n.category = mCategory;
n.priority = mPriority;
if (mActions.size() > 0) {
n.actions = new Action[mActions.size()];
@@ -1839,7 +1920,7 @@ public class Notification implements Parcelable
* this Notification object.
* @hide
*/
- public void addExtras(Bundle extras) {
+ public void populateExtras(Bundle extras) {
// Store original information used in the construction of this object
extras.putCharSequence(EXTRA_TITLE, mContentTitle);
extras.putCharSequence(EXTRA_TEXT, mContentText);
@@ -1877,7 +1958,7 @@ public class Notification implements Parcelable
n.extras = mExtras != null ? new Bundle(mExtras) : new Bundle();
- addExtras(n.extras);
+ populateExtras(n.extras);
if (mStyle != null) {
mStyle.addExtras(n.extras);
}
@@ -1900,8 +1981,7 @@ public class Notification implements Parcelable
* An object that can apply a rich notification style to a {@link Notification.Builder}
* object.
*/
- public static abstract class Style
- {
+ public static abstract class Style {
private CharSequence mBigContentTitle;
private CharSequence mSummaryText = null;
private boolean mSummaryTextSet = false;
diff --git a/core/java/android/app/SharedPreferencesImpl.java b/core/java/android/app/SharedPreferencesImpl.java
index 86fd7b9..a292ecb 100644
--- a/core/java/android/app/SharedPreferencesImpl.java
+++ b/core/java/android/app/SharedPreferencesImpl.java
@@ -421,13 +421,15 @@ final class SharedPreferencesImpl implements SharedPreferences {
for (Map.Entry<String, Object> e : mModified.entrySet()) {
String k = e.getKey();
Object v = e.getValue();
- if (v == this) { // magic value for a removal mutation
+ // "this" is the magic value for a removal mutation. In addition,
+ // setting a value to "null" for a given key is specified to be
+ // equivalent to calling remove on that key.
+ if (v == this || v == null) {
if (!mMap.containsKey(k)) {
continue;
}
mMap.remove(k);
} else {
- boolean isSame = false;
if (mMap.containsKey(k)) {
Object existingValue = mMap.get(k);
if (existingValue != null && existingValue.equals(v)) {
diff --git a/core/java/android/app/backup/BackupDataInput.java b/core/java/android/app/backup/BackupDataInput.java
index 43b920a..03205fb 100644
--- a/core/java/android/app/backup/BackupDataInput.java
+++ b/core/java/android/app/backup/BackupDataInput.java
@@ -59,7 +59,7 @@ import java.io.IOException;
* }</pre>
*/
public class BackupDataInput {
- int mBackupReader;
+ long mBackupReader;
private EntityHeader mHeader = new EntityHeader();
private boolean mHeaderReady;
@@ -185,10 +185,10 @@ public class BackupDataInput {
}
}
- private native static int ctor(FileDescriptor fd);
- private native static void dtor(int mBackupReader);
+ private native static long ctor(FileDescriptor fd);
+ private native static void dtor(long mBackupReader);
- private native int readNextHeader_native(int mBackupReader, EntityHeader entity);
- private native int readEntityData_native(int mBackupReader, byte[] data, int offset, int size);
- private native int skipEntityData_native(int mBackupReader);
+ private native int readNextHeader_native(long mBackupReader, EntityHeader entity);
+ private native int readEntityData_native(long mBackupReader, byte[] data, int offset, int size);
+ private native int skipEntityData_native(long mBackupReader);
}
diff --git a/core/java/android/app/backup/BackupDataOutput.java b/core/java/android/app/backup/BackupDataOutput.java
index 22668b6..3a070b6 100644
--- a/core/java/android/app/backup/BackupDataOutput.java
+++ b/core/java/android/app/backup/BackupDataOutput.java
@@ -62,7 +62,7 @@ import java.io.IOException;
* @see BackupAgent
*/
public class BackupDataOutput {
- int mBackupWriter;
+ long mBackupWriter;
/** @hide */
public BackupDataOutput(FileDescriptor fd) {
@@ -121,11 +121,11 @@ public class BackupDataOutput {
}
}
- private native static int ctor(FileDescriptor fd);
- private native static void dtor(int mBackupWriter);
+ private native static long ctor(FileDescriptor fd);
+ private native static void dtor(long mBackupWriter);
- private native static int writeEntityHeader_native(int mBackupWriter, String key, int dataSize);
- private native static int writeEntityData_native(int mBackupWriter, byte[] data, int size);
- private native static void setKeyPrefix_native(int mBackupWriter, String keyPrefix);
+ private native static int writeEntityHeader_native(long mBackupWriter, String key, int dataSize);
+ private native static int writeEntityData_native(long mBackupWriter, byte[] data, int size);
+ private native static void setKeyPrefix_native(long mBackupWriter, String keyPrefix);
}
diff --git a/core/java/android/app/backup/FileBackupHelperBase.java b/core/java/android/app/backup/FileBackupHelperBase.java
index 887a2e6..4ed5197 100644
--- a/core/java/android/app/backup/FileBackupHelperBase.java
+++ b/core/java/android/app/backup/FileBackupHelperBase.java
@@ -29,7 +29,7 @@ import java.io.FileDescriptor;
class FileBackupHelperBase {
private static final String TAG = "FileBackupHelperBase";
- int mPtr;
+ long mPtr;
Context mContext;
boolean mExceptionLogged;
@@ -115,14 +115,13 @@ class FileBackupHelperBase {
return false;
}
- private static native int ctor();
- private static native void dtor(int ptr);
+ private static native long ctor();
+ private static native void dtor(long ptr);
native private static int performBackup_native(FileDescriptor oldState,
- int data, FileDescriptor newState, String[] files, String[] keys);
-
- private static native int writeFile_native(int ptr, String filename, int backupReader);
- private static native int writeSnapshot_native(int ptr, FileDescriptor fd);
+ long data, FileDescriptor newState, String[] files, String[] keys);
+ private static native int writeFile_native(long ptr, String filename, long backupReader);
+ private static native int writeSnapshot_native(long ptr, FileDescriptor fd);
}
diff --git a/core/java/android/bluetooth/BluetoothInputDevice.java b/core/java/android/bluetooth/BluetoothInputDevice.java
index 844f432..c48b15d 100644
--- a/core/java/android/bluetooth/BluetoothInputDevice.java
+++ b/core/java/android/bluetooth/BluetoothInputDevice.java
@@ -76,6 +76,19 @@ public final class BluetoothInputDevice implements BluetoothProfile {
public static final String ACTION_PROTOCOL_MODE_CHANGED =
"android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED";
+ /**
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_HANDSHAKE =
+ "android.bluetooth.input.profile.action.HANDSHAKE";
+
+ /**
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_REPORT =
+ "android.bluetooth.input.profile.action.REPORT";
/**
* @hide
@@ -130,17 +143,17 @@ public final class BluetoothInputDevice implements BluetoothProfile {
/**
* @hide
*/
- public static final byte REPORT_TYPE_INPUT = 0;
+ public static final byte REPORT_TYPE_INPUT = 1;
/**
* @hide
*/
- public static final byte REPORT_TYPE_OUTPUT = 1;
+ public static final byte REPORT_TYPE_OUTPUT = 2;
/**
* @hide
*/
- public static final byte REPORT_TYPE_FEATURE = 2;
+ public static final byte REPORT_TYPE_FEATURE = 3;
/**
* @hide
@@ -180,6 +193,11 @@ public final class BluetoothInputDevice implements BluetoothProfile {
/**
* @hide
*/
+ public static final String EXTRA_STATUS = "android.bluetooth.BluetoothInputDevice.extra.STATUS";
+
+ /**
+ * @hide
+ */
public static final String EXTRA_VIRTUAL_UNPLUG_STATUS = "android.bluetooth.BluetoothInputDevice.extra.VIRTUAL_UNPLUG_STATUS";
private Context mContext;
@@ -603,7 +621,7 @@ public final class BluetoothInputDevice implements BluetoothProfile {
* @hide
*/
public boolean setReport(BluetoothDevice device, byte reportType, String report) {
- if (DBG) log("setReport(" + device + "), reportType=" + reportType + " report=" + report);
+ if (VDBG) log("setReport(" + device + "), reportType=" + reportType + " report=" + report);
if (mService != null && isEnabled() && isValidDevice(device)) {
try {
return mService.setReport(device, reportType, report);
diff --git a/core/java/android/bluetooth/BluetoothSocket.java b/core/java/android/bluetooth/BluetoothSocket.java
index d10eaea..1e75fc2 100644
--- a/core/java/android/bluetooth/BluetoothSocket.java
+++ b/core/java/android/bluetooth/BluetoothSocket.java
@@ -417,27 +417,28 @@ public final class BluetoothSocket implements Closeable {
* if an i/o error occurs.
*/
/*package*/ void flush() throws IOException {
+ if (mSocketOS == null) throw new IOException("flush is called on null OutputStream");
if (VDBG) Log.d(TAG, "flush: " + mSocketOS);
mSocketOS.flush();
}
/*package*/ int read(byte[] b, int offset, int length) throws IOException {
-
- if (VDBG) Log.d(TAG, "read in: " + mSocketIS + " len: " + length);
- int ret = mSocketIS.read(b, offset, length);
- if(ret < 0)
- throw new IOException("bt socket closed, read return: " + ret);
- if (VDBG) Log.d(TAG, "read out: " + mSocketIS + " ret: " + ret);
- return ret;
+ if (mSocketIS == null) throw new IOException("read is called on null InputStream");
+ if (VDBG) Log.d(TAG, "read in: " + mSocketIS + " len: " + length);
+ int ret = mSocketIS.read(b, offset, length);
+ if(ret < 0)
+ throw new IOException("bt socket closed, read return: " + ret);
+ if (VDBG) Log.d(TAG, "read out: " + mSocketIS + " ret: " + ret);
+ return ret;
}
/*package*/ int write(byte[] b, int offset, int length) throws IOException {
-
- if (VDBG) Log.d(TAG, "write: " + mSocketOS + " length: " + length);
- mSocketOS.write(b, offset, length);
- // There is no good way to confirm since the entire process is asynchronous anyway
- if (VDBG) Log.d(TAG, "write out: " + mSocketOS + " length: " + length);
- return length;
+ if (mSocketOS == null) throw new IOException("write is called on null OutputStream");
+ if (VDBG) Log.d(TAG, "write: " + mSocketOS + " length: " + length);
+ mSocketOS.write(b, offset, length);
+ // There is no good way to confirm since the entire process is asynchronous anyway
+ if (VDBG) Log.d(TAG, "write out: " + mSocketOS + " length: " + length);
+ return length;
}
@Override
diff --git a/core/java/android/content/ContentProviderNative.java b/core/java/android/content/ContentProviderNative.java
index bcf0b63..39286d6 100644
--- a/core/java/android/content/ContentProviderNative.java
+++ b/core/java/android/content/ContentProviderNative.java
@@ -112,17 +112,24 @@ abstract public class ContentProviderNative extends Binder implements IContentPr
Cursor cursor = query(callingPkg, url, projection, selection, selectionArgs,
sortOrder, cancellationSignal);
if (cursor != null) {
+ CursorToBulkCursorAdaptor adaptor = null;
+
try {
- CursorToBulkCursorAdaptor adaptor = new CursorToBulkCursorAdaptor(
- cursor, observer, getProviderName());
- BulkCursorDescriptor d = adaptor.getBulkCursorDescriptor();
+ adaptor = new CursorToBulkCursorAdaptor(cursor, observer,
+ getProviderName());
cursor = null;
+ BulkCursorDescriptor d = adaptor.getBulkCursorDescriptor();
+ adaptor = null;
+
reply.writeNoException();
reply.writeInt(1);
d.writeToParcel(reply, Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
} finally {
// Close cursor if an exception was thrown while constructing the adaptor.
+ if (adaptor != null) {
+ adaptor.close();
+ }
if (cursor != null) {
cursor.close();
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 2e4e209..f4b1afe 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -1974,6 +1974,8 @@ public abstract class Context {
* @see android.app.SearchManager
* @see #SENSOR_SERVICE
* @see android.hardware.SensorManager
+ * @see #HDMI_CEC_SERVICE
+ * @see android.hardware.hdmi.HdmiCecManager
* @see #STORAGE_SERVICE
* @see android.os.storage.StorageManager
* @see #VIBRATOR_SERVICE
@@ -2389,6 +2391,16 @@ public abstract class Context {
/**
* Use with {@link #getSystemService} to retrieve a
+ * {@link android.hardware.hdmi.HdmiCecManager for controlling and managing
+ * HDMI-CEC protocol.
+ *
+ * @see #getSystemService
+ * @see android.hardware.hdmi.HdmiCecManager
+ */
+ public static final String HDMI_CEC_SERVICE = "hdmi_cec";
+
+ /**
+ * Use with {@link #getSystemService} to retrieve a
* {@link android.hardware.input.InputManager} for interacting with input devices.
*
* @see #getSystemService
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 3c66b68..590ccf8 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2765,6 +2765,12 @@ public class Intent implements Parcelable, Cloneable {
@SdkConstant(SdkConstantType.INTENT_CATEGORY)
public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
/**
+ * Indicates an activity optimized for Leanback mode, and that should
+ * be displayed in the Leanback launcher.
+ */
+ @SdkConstant(SdkConstantType.INTENT_CATEGORY)
+ public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
+ /**
* Provides information about the package it is in; typically used if
* a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
* a front-door to the user without having to be shown in the all apps list.
@@ -3538,6 +3544,11 @@ public class Intent implements Parcelable, Cloneable {
* it will be finished so that the user does not return to them, but
* instead returns to whatever activity preceeded it.
*
+ * <p>When this flag is assigned to the root activity all activities up
+ * to, but not including the root activity, will be cleared. This prevents
+ * this flag from being used to finish all activities in a task and thereby
+ * ending the task.
+ *
* <p>This is useful for cases where you have a logical break in your
* application. For example, an e-mail application may have a command
* to view an attachment, which launches an image view activity to
diff --git a/core/java/android/content/pm/ApplicationInfo.java b/core/java/android/content/pm/ApplicationInfo.java
index 9c46d96..57acdff 100644
--- a/core/java/android/content/pm/ApplicationInfo.java
+++ b/core/java/android/content/pm/ApplicationInfo.java
@@ -315,6 +315,12 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
public static final int FLAG_IS_DATA_ONLY = 1<<24;
/**
+ * Value for {@link #flags}: true if the application was declared to be a game, or
+ * false if it is a non-game application.
+ */
+ public static final int FLAG_IS_GAME = 1<<25;
+
+ /**
* Value for {@link #flags}: set to {@code true} if the application
* is permitted to hold privileged permissions.
*
@@ -363,7 +369,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
* {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
* {@link #FLAG_RESIZEABLE_FOR_SCREENS},
* {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
- * {@link #FLAG_INSTALLED}.
+ * {@link #FLAG_INSTALLED}, {@link #FLAG_IS_GAME}.
*/
public int flags = 0;
@@ -474,7 +480,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
* @hide
*/
public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
-
+
public void dump(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
if (className != null) {
diff --git a/core/java/android/content/pm/ComponentInfo.java b/core/java/android/content/pm/ComponentInfo.java
index 4dbcf23..7e8f285 100644
--- a/core/java/android/content/pm/ComponentInfo.java
+++ b/core/java/android/content/pm/ComponentInfo.java
@@ -128,6 +128,17 @@ public class ComponentInfo extends PackageItemInfo {
return logo != 0 ? logo : applicationInfo.logo;
}
+ /**
+ * Return the banner resource identifier to use for this component. If the
+ * component defines a banner, that is used; else, the application banner is
+ * used.
+ *
+ * @return The banner associated with this component.
+ */
+ public final int getBannerResource() {
+ return banner != 0 ? banner : applicationInfo.banner;
+ }
+
protected void dumpFront(Printer pw, String prefix) {
super.dumpFront(pw, prefix);
pw.println(prefix + "enabled=" + enabled + " exported=" + exported
@@ -175,6 +186,13 @@ public class ComponentInfo extends PackageItemInfo {
/**
* @hide
*/
+ @Override protected Drawable loadDefaultBanner(PackageManager pm) {
+ return applicationInfo.loadBanner(pm);
+ }
+
+ /**
+ * @hide
+ */
@Override
protected Drawable loadDefaultLogo(PackageManager pm) {
return applicationInfo.loadLogo(pm);
diff --git a/core/java/android/content/pm/PackageItemInfo.java b/core/java/android/content/pm/PackageItemInfo.java
index a67326e..58f1c84 100644
--- a/core/java/android/content/pm/PackageItemInfo.java
+++ b/core/java/android/content/pm/PackageItemInfo.java
@@ -68,6 +68,12 @@ public class PackageItemInfo {
/**
* A drawable resource identifier (in the package's resources) of this
+ * component's banner. From the "banner" attribute or, if not set, 0.
+ */
+ public int banner;
+
+ /**
+ * A drawable resource identifier (in the package's resources) of this
* component's logo. Logos may be larger/wider than icons and are
* displayed by certain UI elements in place of a name or name/icon
* combination. From the "logo" attribute or, if not set, 0.
@@ -92,6 +98,7 @@ public class PackageItemInfo {
nonLocalizedLabel = orig.nonLocalizedLabel;
if (nonLocalizedLabel != null) nonLocalizedLabel = nonLocalizedLabel.toString().trim();
icon = orig.icon;
+ banner = orig.banner;
logo = orig.logo;
metaData = orig.metaData;
}
@@ -146,6 +153,27 @@ public class PackageItemInfo {
}
/**
+ * Retrieve the current graphical banner associated with this item. This
+ * will call back on the given PackageManager to load the banner from
+ * the application.
+ *
+ * @param pm A PackageManager from which the banner can be loaded; usually
+ * the PackageManager from which you originally retrieved this item.
+ *
+ * @return Returns a Drawable containing the item's banner. If the item
+ * does not have a banner, this method will return null.
+ */
+ public Drawable loadBanner(PackageManager pm) {
+ if (banner != 0) {
+ Drawable dr = pm.getDrawable(packageName, banner, getApplicationInfo());
+ if (dr != null) {
+ return dr;
+ }
+ }
+ return loadDefaultBanner(pm);
+ }
+
+ /**
* Retrieve the default graphical icon associated with this item.
*
* @param pm A PackageManager from which the icon can be loaded; usually
@@ -159,7 +187,22 @@ public class PackageItemInfo {
protected Drawable loadDefaultIcon(PackageManager pm) {
return pm.getDefaultActivityIcon();
}
-
+
+ /**
+ * Retrieve the default graphical banner associated with this item.
+ *
+ * @param pm A PackageManager from which the banner can be loaded; usually
+ * the PackageManager from which you originally retrieved this item.
+ *
+ * @return Returns a Drawable containing the item's default banner
+ * or null if no default logo is available.
+ *
+ * @hide
+ */
+ protected Drawable loadDefaultBanner(PackageManager pm) {
+ return null;
+ }
+
/**
* Retrieve the current graphical logo associated with this item. This
* will call back on the given PackageManager to load the logo from
@@ -224,10 +267,11 @@ public class PackageItemInfo {
pw.println(prefix + "name=" + name);
}
pw.println(prefix + "packageName=" + packageName);
- if (labelRes != 0 || nonLocalizedLabel != null || icon != 0) {
+ if (labelRes != 0 || nonLocalizedLabel != null || icon != 0 || banner != 0) {
pw.println(prefix + "labelRes=0x" + Integer.toHexString(labelRes)
+ " nonLocalizedLabel=" + nonLocalizedLabel
- + " icon=0x" + Integer.toHexString(icon));
+ + " icon=0x" + Integer.toHexString(icon)
+ + " banner=0x" + Integer.toHexString(banner));
}
}
@@ -243,6 +287,7 @@ public class PackageItemInfo {
dest.writeInt(icon);
dest.writeInt(logo);
dest.writeBundle(metaData);
+ dest.writeInt(banner);
}
protected PackageItemInfo(Parcel source) {
@@ -254,6 +299,7 @@ public class PackageItemInfo {
icon = source.readInt();
logo = source.readInt();
metaData = source.readBundle();
+ banner = source.readInt();
}
/**
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index c97c2b8..34a6f1d 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1225,6 +1225,26 @@ public abstract class PackageManager {
/**
* Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: The device supports leanback UI. This is
+ * typically used in a living room television experience, but is a software
+ * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
+ * feature will use resources associated with the "television" UI mode.
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_LEANBACK = "android.software.leanback";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: The device supports only leanback UI. Only
+ * applications designed for this experience should be run, though this is
+ * not enforced by the system.
+ * @hide
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and
* {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
*/
@SdkConstant(SdkConstantType.FEATURE)
@@ -1244,11 +1264,35 @@ public abstract class PackageManager {
* room television experience: displayed on a big screen, where the user
* is sitting far away from it, and the dominant form of input will be
* something like a DPAD, not through touch or mouse.
+ * @deprecated use {@link #FEATURE_LEANBACK} instead.
*/
@SdkConstant(SdkConstantType.FEATURE)
public static final String FEATURE_TELEVISION = "android.hardware.type.television";
/**
+ * Feature for {@link #getSystemAvailableFeatures} and
+ * {@link #hasSystemFeature}: This is a device dedicated to showing UI
+ * on a watch. A watch here is defined to be a device worn on the body, perhaps on
+ * the wrist. The user is very close when interacting with the device.
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_WATCH = "android.hardware.type.watch";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
+ * The device supports printing.
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_PRINTING = "android.software.print";
+
+ /**
+ * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
+ * The device can perform backup and restore operations on installed applications.
+ */
+ @SdkConstant(SdkConstantType.FEATURE)
+ public static final String FEATURE_BACKUP = "android.software.backup";
+
+ /**
* Action to external storage service to clean out removed apps.
* @hide
*/
@@ -2369,9 +2413,43 @@ public abstract class PackageManager {
throws NameNotFoundException;
/**
+ * Retrieve the banner associated with an activity. Given the full name of
+ * an activity, retrieves the information about it and calls
+ * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
+ * banner. If the activity cannot be found, NameNotFoundException is thrown.
+ *
+ * @param activityName Name of the activity whose banner is to be retrieved.
+ * @return Returns the image of the banner, or null if the activity has no
+ * banner specified.
+ * @throws NameNotFoundException Thrown if the resources for the given
+ * activity could not be loaded.
+ * @see #getActivityBanner(Intent)
+ */
+ public abstract Drawable getActivityBanner(ComponentName activityName)
+ throws NameNotFoundException;
+
+ /**
+ * Retrieve the banner associated with an Intent. If intent.getClassName()
+ * is set, this simply returns the result of
+ * getActivityBanner(intent.getClassName()). Otherwise it resolves the
+ * intent's component and returns the banner associated with the resolved
+ * component. If intent.getClassName() cannot be found or the Intent cannot
+ * be resolved to a component, NameNotFoundException is thrown.
+ *
+ * @param intent The intent for which you would like to retrieve a banner.
+ * @return Returns the image of the banner, or null if the activity has no
+ * banner specified.
+ * @throws NameNotFoundException Thrown if the resources for application
+ * matching the given intent could not be loaded.
+ * @see #getActivityBanner(ComponentName)
+ */
+ public abstract Drawable getActivityBanner(Intent intent)
+ throws NameNotFoundException;
+
+ /**
* Return the generic icon for an activity that is used when no specific
* icon is defined.
- *
+ *
* @return Drawable Image of the icon.
*/
public abstract Drawable getDefaultActivityIcon();
@@ -2409,19 +2487,43 @@ public abstract class PackageManager {
throws NameNotFoundException;
/**
- * Retrieve the logo associated with an activity. Given the full name of
- * an activity, retrieves the information about it and calls
- * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
- * If the activity cannot be found, NameNotFoundException is thrown.
- *
- * @param activityName Name of the activity whose logo is to be retrieved.
+ * Retrieve the banner associated with an application.
*
- * @return Returns the image of the logo or null if the activity has no
- * logo specified.
+ * @param info Information about application being queried.
+ * @return Returns the image of the banner or null if the application has no
+ * banner specified.
+ * @see #getApplicationBanner(String)
+ */
+ public abstract Drawable getApplicationBanner(ApplicationInfo info);
+
+ /**
+ * Retrieve the banner associated with an application. Given the name of the
+ * application's package, retrieves the information about it and calls
+ * getApplicationIcon() to return its banner. If the application cannot be
+ * found, NameNotFoundException is thrown.
*
+ * @param packageName Name of the package whose application banner is to be
+ * retrieved.
+ * @return Returns the image of the banner or null if the application has no
+ * banner specified.
* @throws NameNotFoundException Thrown if the resources for the given
- * activity could not be loaded.
+ * application could not be loaded.
+ * @see #getApplicationBanner(ApplicationInfo)
+ */
+ public abstract Drawable getApplicationBanner(String packageName)
+ throws NameNotFoundException;
+
+ /**
+ * Retrieve the logo associated with an activity. Given the full name of an
+ * activity, retrieves the information about it and calls
+ * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
+ * logo. If the activity cannot be found, NameNotFoundException is thrown.
*
+ * @param activityName Name of the activity whose logo is to be retrieved.
+ * @return Returns the image of the logo or null if the activity has no logo
+ * specified.
+ * @throws NameNotFoundException Thrown if the resources for the given
+ * activity could not be loaded.
* @see #getActivityLogo(Intent)
*/
public abstract Drawable getActivityLogo(ComponentName activityName)
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index e6da288..0ce1e44 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -58,7 +58,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
+import java.util.jar.StrictJarFile;
import java.util.zip.ZipEntry;
import com.android.internal.util.XmlUtils;
@@ -167,18 +167,20 @@ public class PackageParser {
final int labelRes;
final int iconRes;
final int logoRes;
+ final int bannerRes;
String tag;
TypedArray sa;
ParsePackageItemArgs(Package _owner, String[] _outError,
- int _nameRes, int _labelRes, int _iconRes, int _logoRes) {
+ int _nameRes, int _labelRes, int _iconRes, int _logoRes, int _bannerRes) {
owner = _owner;
outError = _outError;
nameRes = _nameRes;
labelRes = _labelRes;
iconRes = _iconRes;
logoRes = _logoRes;
+ bannerRes = _bannerRes;
}
}
@@ -190,10 +192,10 @@ public class PackageParser {
int flags;
ParseComponentArgs(Package _owner, String[] _outError,
- int _nameRes, int _labelRes, int _iconRes, int _logoRes,
+ int _nameRes, int _labelRes, int _iconRes, int _logoRes, int _bannerRes,
String[] _sepProcesses, int _processRes,
int _descriptionRes, int _enabledRes) {
- super(_owner, _outError, _nameRes, _labelRes, _iconRes, _logoRes);
+ super(_owner, _outError, _nameRes, _labelRes, _iconRes, _logoRes, _bannerRes);
sepProcesses = _sepProcesses;
processRes = _processRes;
descriptionRes = _descriptionRes;
@@ -456,7 +458,7 @@ public class PackageParser {
return pi;
}
- private Certificate[] loadCertificates(JarFile jarFile, JarEntry je,
+ private Certificate[] loadCertificates(StrictJarFile jarFile, ZipEntry je,
byte[] readBuffer) {
try {
// We must read the stream for the JarEntry to retrieve
@@ -466,13 +468,11 @@ public class PackageParser {
// not using
}
is.close();
- return je != null ? je.getCertificates() : null;
+ return je != null ? jarFile.getCertificates(je) : null;
} catch (IOException e) {
- Slog.w(TAG, "Exception reading " + je.getName() + " in "
- + jarFile.getName(), e);
+ Slog.w(TAG, "Exception reading " + je.getName() + " in " + jarFile, e);
} catch (RuntimeException e) {
- Slog.w(TAG, "Exception reading " + je.getName() + " in "
- + jarFile.getName(), e);
+ Slog.w(TAG, "Exception reading " + je.getName() + " in " + jarFile, e);
}
return null;
}
@@ -591,9 +591,9 @@ public class PackageParser {
*/
public boolean collectManifestDigest(Package pkg) {
try {
- final JarFile jarFile = new JarFile(mArchiveSourcePath);
+ final StrictJarFile jarFile = new StrictJarFile(mArchiveSourcePath);
try {
- final ZipEntry je = jarFile.getEntry(ANDROID_MANIFEST_FILENAME);
+ final ZipEntry je = jarFile.findEntry(ANDROID_MANIFEST_FILENAME);
if (je != null) {
pkg.manifestDigest = ManifestDigest.fromInputStream(jarFile.getInputStream(je));
}
@@ -624,7 +624,7 @@ public class PackageParser {
}
try {
- JarFile jarFile = new JarFile(mArchiveSourcePath);
+ StrictJarFile jarFile = new StrictJarFile(mArchiveSourcePath);
Certificate[] certs = null;
@@ -633,7 +633,7 @@ public class PackageParser {
// can trust it... we'll just use the AndroidManifest.xml
// to retrieve its signatures, not validating all of the
// files.
- JarEntry jarEntry = jarFile.getJarEntry(ANDROID_MANIFEST_FILENAME);
+ ZipEntry jarEntry = jarFile.findEntry(ANDROID_MANIFEST_FILENAME);
certs = loadCertificates(jarFile, jarEntry, readBuffer);
if (certs == null) {
Slog.e(TAG, "Package " + pkg.packageName
@@ -656,9 +656,9 @@ public class PackageParser {
}
}
} else {
- Enumeration<JarEntry> entries = jarFile.entries();
- while (entries.hasMoreElements()) {
- final JarEntry je = entries.nextElement();
+ Iterator<ZipEntry> entries = jarFile.iterator();
+ while (entries.hasNext()) {
+ final ZipEntry je = entries.next();
if (je.isDirectory()) continue;
final String name = je.getName();
@@ -744,6 +744,10 @@ public class PackageParser {
Slog.w(TAG, "Exception reading " + mArchiveSourcePath, e);
mParseError = PackageManager.INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING;
return false;
+ } catch (SecurityException e) {
+ Slog.w(TAG, "Exception reading " + mArchiveSourcePath, e);
+ mParseError = PackageManager.INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING;
+ return false;
} catch (RuntimeException e) {
Slog.w(TAG, "Exception reading " + mArchiveSourcePath, e);
mParseError = PackageManager.INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION;
@@ -1654,7 +1658,8 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestPermissionGroup_name,
com.android.internal.R.styleable.AndroidManifestPermissionGroup_label,
com.android.internal.R.styleable.AndroidManifestPermissionGroup_icon,
- com.android.internal.R.styleable.AndroidManifestPermissionGroup_logo)) {
+ com.android.internal.R.styleable.AndroidManifestPermissionGroup_logo,
+ com.android.internal.R.styleable.AndroidManifestPermissionGroup_banner)) {
sa.recycle();
mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
return null;
@@ -1697,7 +1702,8 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestPermission_name,
com.android.internal.R.styleable.AndroidManifestPermission_label,
com.android.internal.R.styleable.AndroidManifestPermission_icon,
- com.android.internal.R.styleable.AndroidManifestPermission_logo)) {
+ com.android.internal.R.styleable.AndroidManifestPermission_logo,
+ com.android.internal.R.styleable.AndroidManifestPermission_banner)) {
sa.recycle();
mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
return null;
@@ -1766,7 +1772,8 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestPermissionTree_name,
com.android.internal.R.styleable.AndroidManifestPermissionTree_label,
com.android.internal.R.styleable.AndroidManifestPermissionTree_icon,
- com.android.internal.R.styleable.AndroidManifestPermissionTree_logo)) {
+ com.android.internal.R.styleable.AndroidManifestPermissionTree_logo,
+ com.android.internal.R.styleable.AndroidManifestPermissionTree_banner)) {
sa.recycle();
mParseError = PackageManager.INSTALL_PARSE_FAILED_MANIFEST_MALFORMED;
return null;
@@ -1811,7 +1818,8 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestInstrumentation_name,
com.android.internal.R.styleable.AndroidManifestInstrumentation_label,
com.android.internal.R.styleable.AndroidManifestInstrumentation_icon,
- com.android.internal.R.styleable.AndroidManifestInstrumentation_logo);
+ com.android.internal.R.styleable.AndroidManifestInstrumentation_logo,
+ com.android.internal.R.styleable.AndroidManifestInstrumentation_banner);
mParseInstrumentationArgs.tag = "<instrumentation>";
}
@@ -1927,6 +1935,8 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestApplication_icon, 0);
ai.logo = sa.getResourceId(
com.android.internal.R.styleable.AndroidManifestApplication_logo, 0);
+ ai.banner = sa.getResourceId(
+ com.android.internal.R.styleable.AndroidManifestApplication_banner, 0);
ai.theme = sa.getResourceId(
com.android.internal.R.styleable.AndroidManifestApplication_theme, 0);
ai.descriptionRes = sa.getResourceId(
@@ -2048,6 +2058,11 @@ public class PackageParser {
ai.enabled = sa.getBoolean(
com.android.internal.R.styleable.AndroidManifestApplication_enabled, true);
+ if (sa.getBoolean(
+ com.android.internal.R.styleable.AndroidManifestApplication_isGame, false)) {
+ ai.flags |= ApplicationInfo.FLAG_IS_GAME;
+ }
+
if (false) {
if (sa.getBoolean(
com.android.internal.R.styleable.AndroidManifestApplication_cantSaveState,
@@ -2220,7 +2235,7 @@ public class PackageParser {
private boolean parsePackageItemInfo(Package owner, PackageItemInfo outInfo,
String[] outError, String tag, TypedArray sa,
- int nameRes, int labelRes, int iconRes, int logoRes) {
+ int nameRes, int labelRes, int iconRes, int logoRes, int bannerRes) {
String name = sa.getNonConfigurationString(nameRes, 0);
if (name == null) {
outError[0] = tag + " does not specify android:name";
@@ -2244,6 +2259,11 @@ public class PackageParser {
outInfo.logo = logoVal;
}
+ int bannerVal = sa.getResourceId(bannerRes, 0);
+ if (bannerVal != 0) {
+ outInfo.banner = bannerVal;
+ }
+
TypedValue v = sa.peekValue(labelRes);
if (v != null && (outInfo.labelRes=v.resourceId) == 0) {
outInfo.nonLocalizedLabel = v.coerceToString();
@@ -2267,6 +2287,7 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestActivity_label,
com.android.internal.R.styleable.AndroidManifestActivity_icon,
com.android.internal.R.styleable.AndroidManifestActivity_logo,
+ com.android.internal.R.styleable.AndroidManifestActivity_banner,
mSeparateProcesses,
com.android.internal.R.styleable.AndroidManifestActivity_process,
com.android.internal.R.styleable.AndroidManifestActivity_description,
@@ -2552,6 +2573,7 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestActivityAlias_label,
com.android.internal.R.styleable.AndroidManifestActivityAlias_icon,
com.android.internal.R.styleable.AndroidManifestActivityAlias_logo,
+ com.android.internal.R.styleable.AndroidManifestActivityAlias_banner,
mSeparateProcesses,
0,
com.android.internal.R.styleable.AndroidManifestActivityAlias_description,
@@ -2586,6 +2608,7 @@ public class PackageParser {
info.flags = target.info.flags;
info.icon = target.info.icon;
info.logo = target.info.logo;
+ info.banner = target.info.banner;
info.labelRes = target.info.labelRes;
info.nonLocalizedLabel = target.info.nonLocalizedLabel;
info.launchMode = target.info.launchMode;
@@ -2699,6 +2722,7 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestProvider_label,
com.android.internal.R.styleable.AndroidManifestProvider_icon,
com.android.internal.R.styleable.AndroidManifestProvider_logo,
+ com.android.internal.R.styleable.AndroidManifestProvider_banner,
mSeparateProcesses,
com.android.internal.R.styleable.AndroidManifestProvider_process,
com.android.internal.R.styleable.AndroidManifestProvider_description,
@@ -3005,6 +3029,7 @@ public class PackageParser {
com.android.internal.R.styleable.AndroidManifestService_label,
com.android.internal.R.styleable.AndroidManifestService_icon,
com.android.internal.R.styleable.AndroidManifestService_logo,
+ com.android.internal.R.styleable.AndroidManifestService_banner,
mSeparateProcesses,
com.android.internal.R.styleable.AndroidManifestService_process,
com.android.internal.R.styleable.AndroidManifestService_description,
@@ -3302,6 +3327,9 @@ public class PackageParser {
outInfo.logo = sa.getResourceId(
com.android.internal.R.styleable.AndroidManifestIntentFilter_logo, 0);
+ outInfo.banner = sa.getResourceId(
+ com.android.internal.R.styleable.AndroidManifestIntentFilter_banner, 0);
+
sa.recycle();
int outerDepth = parser.getDepth();
@@ -3664,6 +3692,11 @@ public class PackageParser {
outInfo.logo = logoVal;
}
+ int bannerVal = args.sa.getResourceId(args.bannerRes, 0);
+ if (bannerVal != 0) {
+ outInfo.banner = bannerVal;
+ }
+
TypedValue v = args.sa.peekValue(args.labelRes);
if (v != null && (outInfo.labelRes=v.resourceId) == 0) {
outInfo.nonLocalizedLabel = v.coerceToString();
@@ -4088,6 +4121,7 @@ public class PackageParser {
public CharSequence nonLocalizedLabel;
public int icon;
public int logo;
+ public int banner;
public int preferred;
}
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java
index fc9e486..93ce633 100644
--- a/core/java/android/content/res/AssetManager.java
+++ b/core/java/android/content/res/AssetManager.java
@@ -70,7 +70,6 @@ public final class AssetManager {
// For communication with native code.
private int mObject;
- private int mNObject; // used by the NDK
private StringBlock mStringBlocks[] = null;
@@ -540,6 +539,12 @@ public final class AssetManager {
public final int getAssetInt() {
return mAsset;
}
+ /**
+ * @hide
+ */
+ public final long getNativeAsset() {
+ return mAsset;
+ }
private AssetInputStream(int asset)
{
mAsset = asset;
diff --git a/core/java/android/database/CursorWindow.java b/core/java/android/database/CursorWindow.java
index f1f3017..197e3ff 100644
--- a/core/java/android/database/CursorWindow.java
+++ b/core/java/android/database/CursorWindow.java
@@ -27,6 +27,7 @@ import android.os.Parcelable;
import android.os.Process;
import android.util.Log;
import android.util.SparseIntArray;
+import android.util.LongSparseArray;
/**
* A buffer containing multiple cursor rows.
@@ -52,40 +53,40 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
* The native CursorWindow object pointer. (FOR INTERNAL USE ONLY)
* @hide
*/
- public int mWindowPtr;
+ public long mWindowPtr;
private int mStartPos;
private final String mName;
private final CloseGuard mCloseGuard = CloseGuard.get();
- private static native int nativeCreate(String name, int cursorWindowSize);
- private static native int nativeCreateFromParcel(Parcel parcel);
- private static native void nativeDispose(int windowPtr);
- private static native void nativeWriteToParcel(int windowPtr, Parcel parcel);
+ private static native long nativeCreate(String name, int cursorWindowSize);
+ private static native long nativeCreateFromParcel(Parcel parcel);
+ private static native void nativeDispose(long windowPtr);
+ private static native void nativeWriteToParcel(long windowPtr, Parcel parcel);
- private static native void nativeClear(int windowPtr);
+ private static native void nativeClear(long windowPtr);
- private static native int nativeGetNumRows(int windowPtr);
- private static native boolean nativeSetNumColumns(int windowPtr, int columnNum);
- private static native boolean nativeAllocRow(int windowPtr);
- private static native void nativeFreeLastRow(int windowPtr);
+ private static native int nativeGetNumRows(long windowPtr);
+ private static native boolean nativeSetNumColumns(long windowPtr, int columnNum);
+ private static native boolean nativeAllocRow(long windowPtr);
+ private static native void nativeFreeLastRow(long windowPtr);
- private static native int nativeGetType(int windowPtr, int row, int column);
- private static native byte[] nativeGetBlob(int windowPtr, int row, int column);
- private static native String nativeGetString(int windowPtr, int row, int column);
- private static native long nativeGetLong(int windowPtr, int row, int column);
- private static native double nativeGetDouble(int windowPtr, int row, int column);
- private static native void nativeCopyStringToBuffer(int windowPtr, int row, int column,
+ private static native int nativeGetType(long windowPtr, int row, int column);
+ private static native byte[] nativeGetBlob(long windowPtr, int row, int column);
+ private static native String nativeGetString(long windowPtr, int row, int column);
+ private static native long nativeGetLong(long windowPtr, int row, int column);
+ private static native double nativeGetDouble(long windowPtr, int row, int column);
+ private static native void nativeCopyStringToBuffer(long windowPtr, int row, int column,
CharArrayBuffer buffer);
- private static native boolean nativePutBlob(int windowPtr, byte[] value, int row, int column);
- private static native boolean nativePutString(int windowPtr, String value, int row, int column);
- private static native boolean nativePutLong(int windowPtr, long value, int row, int column);
- private static native boolean nativePutDouble(int windowPtr, double value, int row, int column);
- private static native boolean nativePutNull(int windowPtr, int row, int column);
+ private static native boolean nativePutBlob(long windowPtr, byte[] value, int row, int column);
+ private static native boolean nativePutString(long windowPtr, String value, int row, int column);
+ private static native boolean nativePutLong(long windowPtr, long value, int row, int column);
+ private static native boolean nativePutDouble(long windowPtr, double value, int row, int column);
+ private static native boolean nativePutNull(long windowPtr, int row, int column);
- private static native String nativeGetName(int windowPtr);
+ private static native String nativeGetName(long windowPtr);
/**
* Creates a new empty cursor window and gives it a name.
@@ -713,9 +714,9 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
dispose();
}
- private static final SparseIntArray sWindowToPidMap = new SparseIntArray();
+ private static final LongSparseArray<Integer> sWindowToPidMap = new LongSparseArray<Integer>();
- private void recordNewWindow(int pid, int window) {
+ private void recordNewWindow(int pid, long window) {
synchronized (sWindowToPidMap) {
sWindowToPidMap.put(window, pid);
if (Log.isLoggable(STATS_TAG, Log.VERBOSE)) {
@@ -724,7 +725,7 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
}
}
- private void recordClosingOfWindow(int window) {
+ private void recordClosingOfWindow(long window) {
synchronized (sWindowToPidMap) {
if (sWindowToPidMap.size() == 0) {
// this means we are not in the ContentProvider.
@@ -771,6 +772,6 @@ public class CursorWindow extends SQLiteClosable implements Parcelable {
@Override
public String toString() {
- return getName() + " {" + Integer.toHexString(mWindowPtr) + "}";
+ return getName() + " {" + Long.toHexString(mWindowPtr) + "}";
}
}
diff --git a/core/java/android/database/sqlite/SQLiteConnection.java b/core/java/android/database/sqlite/SQLiteConnection.java
index 725a1ff..24a7d33 100644
--- a/core/java/android/database/sqlite/SQLiteConnection.java
+++ b/core/java/android/database/sqlite/SQLiteConnection.java
@@ -107,7 +107,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
private final OperationLog mRecentOperations = new OperationLog();
// The native SQLiteConnection pointer. (FOR INTERNAL USE ONLY)
- private int mConnectionPtr;
+ private long mConnectionPtr;
private boolean mOnlyAllowReadOnlyOperations;
@@ -117,45 +117,45 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
// we can ensure that we detach the signal at the right time.
private int mCancellationSignalAttachCount;
- private static native int nativeOpen(String path, int openFlags, String label,
+ private static native long nativeOpen(String path, int openFlags, String label,
boolean enableTrace, boolean enableProfile);
- private static native void nativeClose(int connectionPtr);
- private static native void nativeRegisterCustomFunction(int connectionPtr,
+ private static native void nativeClose(long connectionPtr);
+ private static native void nativeRegisterCustomFunction(long connectionPtr,
SQLiteCustomFunction function);
- private static native void nativeRegisterLocalizedCollators(int connectionPtr, String locale);
- private static native int nativePrepareStatement(int connectionPtr, String sql);
- private static native void nativeFinalizeStatement(int connectionPtr, int statementPtr);
- private static native int nativeGetParameterCount(int connectionPtr, int statementPtr);
- private static native boolean nativeIsReadOnly(int connectionPtr, int statementPtr);
- private static native int nativeGetColumnCount(int connectionPtr, int statementPtr);
- private static native String nativeGetColumnName(int connectionPtr, int statementPtr,
+ private static native void nativeRegisterLocalizedCollators(long connectionPtr, String locale);
+ private static native long nativePrepareStatement(long connectionPtr, String sql);
+ private static native void nativeFinalizeStatement(long connectionPtr, long statementPtr);
+ private static native int nativeGetParameterCount(long connectionPtr, long statementPtr);
+ private static native boolean nativeIsReadOnly(long connectionPtr, long statementPtr);
+ private static native int nativeGetColumnCount(long connectionPtr, long statementPtr);
+ private static native String nativeGetColumnName(long connectionPtr, long statementPtr,
int index);
- private static native void nativeBindNull(int connectionPtr, int statementPtr,
+ private static native void nativeBindNull(long connectionPtr, long statementPtr,
int index);
- private static native void nativeBindLong(int connectionPtr, int statementPtr,
+ private static native void nativeBindLong(long connectionPtr, long statementPtr,
int index, long value);
- private static native void nativeBindDouble(int connectionPtr, int statementPtr,
+ private static native void nativeBindDouble(long connectionPtr, long statementPtr,
int index, double value);
- private static native void nativeBindString(int connectionPtr, int statementPtr,
+ private static native void nativeBindString(long connectionPtr, long statementPtr,
int index, String value);
- private static native void nativeBindBlob(int connectionPtr, int statementPtr,
+ private static native void nativeBindBlob(long connectionPtr, long statementPtr,
int index, byte[] value);
private static native void nativeResetStatementAndClearBindings(
- int connectionPtr, int statementPtr);
- private static native void nativeExecute(int connectionPtr, int statementPtr);
- private static native long nativeExecuteForLong(int connectionPtr, int statementPtr);
- private static native String nativeExecuteForString(int connectionPtr, int statementPtr);
+ long connectionPtr, long statementPtr);
+ private static native void nativeExecute(long connectionPtr, long statementPtr);
+ private static native long nativeExecuteForLong(long connectionPtr, long statementPtr);
+ private static native String nativeExecuteForString(long connectionPtr, long statementPtr);
private static native int nativeExecuteForBlobFileDescriptor(
- int connectionPtr, int statementPtr);
- private static native int nativeExecuteForChangedRowCount(int connectionPtr, int statementPtr);
+ long connectionPtr, long statementPtr);
+ private static native int nativeExecuteForChangedRowCount(long connectionPtr, long statementPtr);
private static native long nativeExecuteForLastInsertedRowId(
- int connectionPtr, int statementPtr);
+ long connectionPtr, long statementPtr);
private static native long nativeExecuteForCursorWindow(
- int connectionPtr, int statementPtr, int windowPtr,
+ long connectionPtr, long statementPtr, long windowPtr,
int startPos, int requiredPos, boolean countAllRows);
- private static native int nativeGetDbLookaside(int connectionPtr);
- private static native void nativeCancel(int connectionPtr);
- private static native void nativeResetCancel(int connectionPtr, boolean cancelable);
+ private static native int nativeGetDbLookaside(long connectionPtr);
+ private static native void nativeCancel(long connectionPtr);
+ private static native void nativeResetCancel(long connectionPtr, boolean cancelable);
private SQLiteConnection(SQLiteConnectionPool pool,
SQLiteDatabaseConfiguration configuration,
@@ -886,7 +886,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
skipCache = true;
}
- final int statementPtr = nativePrepareStatement(mConnectionPtr, sql);
+ final long statementPtr = nativePrepareStatement(mConnectionPtr, sql);
try {
final int numParameters = nativeGetParameterCount(mConnectionPtr, statementPtr);
final int type = DatabaseUtils.getSqlStatementType(sql);
@@ -987,7 +987,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
return;
}
- final int statementPtr = statement.mStatementPtr;
+ final long statementPtr = statement.mStatementPtr;
for (int i = 0; i < count; i++) {
final Object arg = bindArgs[i];
switch (DatabaseUtils.getTypeOfObject(arg)) {
@@ -1072,7 +1072,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
void dumpUnsafe(Printer printer, boolean verbose) {
printer.println("Connection #" + mConnectionId + ":");
if (verbose) {
- printer.println(" connectionPtr: 0x" + Integer.toHexString(mConnectionPtr));
+ printer.println(" connectionPtr: 0x" + Long.toHexString(mConnectionPtr));
}
printer.println(" isPrimaryConnection: " + mIsPrimaryConnection);
printer.println(" onlyAllowReadOnlyOperations: " + mOnlyAllowReadOnlyOperations);
@@ -1178,7 +1178,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
return "SQLiteConnection: " + mConfiguration.path + " (" + mConnectionId + ")";
}
- private PreparedStatement obtainPreparedStatement(String sql, int statementPtr,
+ private PreparedStatement obtainPreparedStatement(String sql, long statementPtr,
int numParameters, int type, boolean readOnly) {
PreparedStatement statement = mPreparedStatementPool;
if (statement != null) {
@@ -1225,7 +1225,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
// The native sqlite3_stmt object pointer.
// Lifetime is managed explicitly by the connection.
- public int mStatementPtr;
+ public long mStatementPtr;
// The number of parameters that the prepared statement has.
public int mNumParameters;
@@ -1271,7 +1271,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
if (statement.mInCache) { // might be false due to a race with entryRemoved
String sql = entry.getKey();
printer.println(" " + i + ": statementPtr=0x"
- + Integer.toHexString(statement.mStatementPtr)
+ + Long.toHexString(statement.mStatementPtr)
+ ", numParameters=" + statement.mNumParameters
+ ", type=" + statement.mType
+ ", readOnly=" + statement.mReadOnly
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index 60ccc61..433d5d1 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -738,14 +738,16 @@ public final class SQLiteDatabase extends SQLiteClosable {
File dir = file.getParentFile();
if (dir != null) {
final String prefix = file.getName() + "-mj";
- final FileFilter filter = new FileFilter() {
+ File[] files = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File candidate) {
return candidate.getName().startsWith(prefix);
}
- };
- for (File masterJournal : dir.listFiles(filter)) {
- deleted |= masterJournal.delete();
+ });
+ if (files != null) {
+ for (File masterJournal : files) {
+ deleted |= masterJournal.delete();
+ }
}
}
return deleted;
diff --git a/core/java/android/ddm/DdmHandleProfiling.java b/core/java/android/ddm/DdmHandleProfiling.java
index ec08393..537763d 100644
--- a/core/java/android/ddm/DdmHandleProfiling.java
+++ b/core/java/android/ddm/DdmHandleProfiling.java
@@ -37,6 +37,7 @@ public class DdmHandleProfiling extends ChunkHandler {
public static final int CHUNK_SPSS = type("SPSS");
public static final int CHUNK_SPSE = type("SPSE");
+ private static final boolean DEBUG = false;
private static DdmHandleProfiling mInstance = new DdmHandleProfiling();
@@ -72,7 +73,7 @@ public class DdmHandleProfiling extends ChunkHandler {
* Handle a chunk of data.
*/
public Chunk handleChunk(Chunk request) {
- if (false)
+ if (DEBUG)
Log.v("ddm-heap", "Handling " + name(request.type) + " chunk");
int type = request.type;
@@ -83,13 +84,13 @@ public class DdmHandleProfiling extends ChunkHandler {
} else if (type == CHUNK_MPSS) {
return handleMPSS(request);
} else if (type == CHUNK_MPSE) {
- return handleMPSE(request);
+ return handleMPSEOrSPSE(request, "Method");
} else if (type == CHUNK_MPRQ) {
return handleMPRQ(request);
} else if (type == CHUNK_SPSS) {
return handleSPSS(request);
} else if (type == CHUNK_SPSE) {
- return handleSPSE(request);
+ return handleMPSEOrSPSE(request, "Sample");
} else {
throw new RuntimeException("Unknown packet "
+ ChunkHandler.name(type));
@@ -106,7 +107,7 @@ public class DdmHandleProfiling extends ChunkHandler {
int flags = in.getInt();
int len = in.getInt();
String fileName = getString(in, len);
- if (false)
+ if (DEBUG)
Log.v("ddm-heap", "Method profiling start: filename='" + fileName
+ "', size=" + bufferSize + ", flags=" + flags);
@@ -146,7 +147,7 @@ public class DdmHandleProfiling extends ChunkHandler {
int bufferSize = in.getInt();
int flags = in.getInt();
- if (false) {
+ if (DEBUG) {
Log.v("ddm-heap", "Method prof stream start: size=" + bufferSize
+ ", flags=" + flags);
}
@@ -160,20 +161,18 @@ public class DdmHandleProfiling extends ChunkHandler {
}
/*
- * Handle a "Method Profiling w/Streaming End" request.
+ * Handle a "Method Profiling w/Streaming End" request or a
+ * "Sample Profiling w/Streaming End" request.
*/
- private Chunk handleMPSE(Chunk request) {
- byte result;
-
- if (false) {
- Log.v("ddm-heap", "Method prof stream end");
+ private Chunk handleMPSEOrSPSE(Chunk request, String type) {
+ if (DEBUG) {
+ Log.v("ddm-heap", type + " prof stream end");
}
try {
Debug.stopMethodTracing();
- result = 0;
} catch (RuntimeException re) {
- Log.w("ddm-heap", "Method prof stream end failed: "
+ Log.w("ddm-heap", type + " prof stream end failed: "
+ re.getMessage());
return createFailChunk(1, re.getMessage());
}
@@ -202,7 +201,7 @@ public class DdmHandleProfiling extends ChunkHandler {
int bufferSize = in.getInt();
int flags = in.getInt();
int interval = in.getInt();
- if (false) {
+ if (DEBUG) {
Log.v("ddm-heap", "Sample prof stream start: size=" + bufferSize
+ ", flags=" + flags + ", interval=" + interval);
}
@@ -214,25 +213,5 @@ public class DdmHandleProfiling extends ChunkHandler {
return createFailChunk(1, re.getMessage());
}
}
-
- /*
- * Handle a "Sample Profiling w/Streaming End" request.
- */
- private Chunk handleSPSE(Chunk request) {
- if (false) {
- Log.v("ddm-heap", "Sample prof stream end");
- }
-
- try {
- Debug.stopMethodTracing();
- } catch (RuntimeException re) {
- Log.w("ddm-heap", "Sample prof stream end failed: "
- + re.getMessage());
- return createFailChunk(1, re.getMessage());
- }
-
- /* VM sent the (perhaps very large) response directly */
- return null;
- }
}
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 5178901..eae4a46 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -152,7 +152,7 @@ public class Camera {
private static final int CAMERA_MSG_PREVIEW_METADATA = 0x400;
private static final int CAMERA_MSG_FOCUS_MOVE = 0x800;
- private int mNativeContext; // accessed by native methods
+ private long mNativeContext; // accessed by native methods
private EventHandler mEventHandler;
private ShutterCallback mShutterCallback;
private PictureCallback mRawImageCallback;
diff --git a/core/java/android/hardware/SystemSensorManager.java b/core/java/android/hardware/SystemSensorManager.java
index 50fdb41..8684a04 100644
--- a/core/java/android/hardware/SystemSensorManager.java
+++ b/core/java/android/hardware/SystemSensorManager.java
@@ -222,14 +222,14 @@ public class SystemSensorManager extends SensorManager {
* the queues and the listeners.
*/
private static abstract class BaseEventQueue {
- private native int nativeInitBaseEventQueue(BaseEventQueue eventQ, MessageQueue msgQ,
+ private native long nativeInitBaseEventQueue(BaseEventQueue eventQ, MessageQueue msgQ,
float[] scratch);
- private static native int nativeEnableSensor(int eventQ, int handle, int rateUs,
+ private static native int nativeEnableSensor(long eventQ, int handle, int rateUs,
int maxBatchReportLatencyUs, int reservedFlags);
- private static native int nativeDisableSensor(int eventQ, int handle);
- private static native void nativeDestroySensorEventQueue(int eventQ);
- private static native int nativeFlushSensor(int eventQ);
- private int nSensorEventQueue;
+ private static native int nativeDisableSensor(long eventQ, int handle);
+ private static native void nativeDestroySensorEventQueue(long eventQ);
+ private static native int nativeFlushSensor(long eventQ);
+ private long nSensorEventQueue;
private final SparseBooleanArray mActiveSensors = new SparseBooleanArray();
protected final SparseIntArray mSensorAccuracies = new SparseIntArray();
protected final SparseBooleanArray mFirstEvent = new SparseBooleanArray();
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java
index 093e0e9..a517bc5 100644
--- a/core/java/android/hardware/display/DisplayManager.java
+++ b/core/java/android/hardware/display/DisplayManager.java
@@ -115,6 +115,7 @@ public final class DisplayManager {
* </p>
*
* @see #createVirtualDisplay
+ * @see #VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY
*/
public static final int VIRTUAL_DISPLAY_FLAG_PUBLIC = 1 << 0;
@@ -171,6 +172,22 @@ public final class DisplayManager {
*/
public static final int VIRTUAL_DISPLAY_FLAG_SECURE = 1 << 2;
+ /**
+ * Virtual display flag: Only show this display's own content; do not mirror
+ * the content of another display.
+ *
+ * <p>
+ * This flag is used in conjunction with {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC}.
+ * Ordinarily public virtual displays will automatically mirror the content of the
+ * default display if they have no windows of their own. When this flag is
+ * specified, the virtual display will only ever show its own content and
+ * will be blanked instead if it has no windows.
+ * </p>
+ *
+ * @see #createVirtualDisplay
+ */
+ public static final int VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY = 1 << 3;
+
/** @hide */
public DisplayManager(Context context) {
mContext = context;
@@ -429,8 +446,8 @@ public final class DisplayManager {
* @param surface The surface to which the content of the virtual display should
* be rendered, must be non-null.
* @param flags A combination of virtual display flags:
- * {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC}, {@link #VIRTUAL_DISPLAY_FLAG_PRESENTATION}
- * or {@link #VIRTUAL_DISPLAY_FLAG_SECURE}.
+ * {@link #VIRTUAL_DISPLAY_FLAG_PUBLIC}, {@link #VIRTUAL_DISPLAY_FLAG_PRESENTATION},
+ * {@link #VIRTUAL_DISPLAY_FLAG_SECURE}, or {@link #VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY}.
* @return The newly created virtual display, or null if the application could
* not create the virtual display.
*
diff --git a/core/java/android/hardware/display/DisplayManagerInternal.java b/core/java/android/hardware/display/DisplayManagerInternal.java
new file mode 100644
index 0000000..8430973
--- /dev/null
+++ b/core/java/android/hardware/display/DisplayManagerInternal.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.display;
+
+import android.view.DisplayInfo;
+
+/**
+ * Display manager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+public abstract class DisplayManagerInternal {
+ /**
+ * Called by the power manager to blank all displays.
+ */
+ public abstract void blankAllDisplaysFromPowerManager();
+
+ /**
+ * Called by the power manager to unblank all displays.
+ */
+ public abstract void unblankAllDisplaysFromPowerManager();
+
+ /**
+ * Returns information about the specified logical display.
+ *
+ * @param displayId The logical display id.
+ * @return The logical display info, or null if the display does not exist. The
+ * returned object must be treated as immutable.
+ */
+ public abstract DisplayInfo getDisplayInfo(int displayId);
+
+ /**
+ * Registers a display transaction listener to provide the client a chance to
+ * update its surfaces within the same transaction as any display layout updates.
+ *
+ * @param listener The listener to register.
+ */
+ public abstract void registerDisplayTransactionListener(DisplayTransactionListener listener);
+
+ /**
+ * Unregisters a display transaction listener to provide the client a chance to
+ * update its surfaces within the same transaction as any display layout updates.
+ *
+ * @param listener The listener to unregister.
+ */
+ public abstract void unregisterDisplayTransactionListener(DisplayTransactionListener listener);
+
+ /**
+ * Overrides the display information of a particular logical display.
+ * This is used by the window manager to control the size and characteristics
+ * of the default display. It is expected to apply the requested change
+ * to the display information synchronously so that applications will immediately
+ * observe the new state.
+ *
+ * NOTE: This method must be the only entry point by which the window manager
+ * influences the logical configuration of displays.
+ *
+ * @param displayId The logical display id.
+ * @param info The new data to be stored.
+ */
+ public abstract void setDisplayInfoOverrideFromWindowManager(
+ int displayId, DisplayInfo info);
+
+ /**
+ * Called by the window manager to perform traversals while holding a
+ * surface flinger transaction.
+ */
+ public abstract void performTraversalInTransactionFromWindowManager();
+
+ /**
+ * Tells the display manager whether there is interesting unique content on the
+ * specified logical display. This is used to control automatic mirroring.
+ * <p>
+ * If the display has unique content, then the display manager arranges for it
+ * to be presented on a physical display if appropriate. Otherwise, the display manager
+ * may choose to make the physical display mirror some other logical display.
+ * </p>
+ *
+ * @param displayId The logical display id to update.
+ * @param hasContent True if the logical display has content.
+ * @param inTraversal True if called from WindowManagerService during a window traversal
+ * prior to call to performTraversalInTransactionFromWindowManager.
+ */
+ public abstract void setDisplayHasContent(int displayId, boolean hasContent,
+ boolean inTraversal);
+
+ /**
+ * Called within a Surface transaction whenever the size or orientation of a
+ * display may have changed. Provides an opportunity for the client to
+ * update the position of its surfaces as part of the same transaction.
+ */
+ public interface DisplayTransactionListener {
+ void onDisplayTransaction();
+ }
+}
diff --git a/core/java/android/hardware/display/DisplayViewport.java b/core/java/android/hardware/display/DisplayViewport.java
new file mode 100644
index 0000000..c2d498b
--- /dev/null
+++ b/core/java/android/hardware/display/DisplayViewport.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+package android.hardware.display;
+
+import android.graphics.Rect;
+
+/**
+ * Describes how the pixels of physical display device reflects the content of
+ * a logical display.
+ * <p>
+ * This information is used by the input system to translate touch input from
+ * physical display coordinates into logical display coordinates.
+ * </p>
+ *
+ * @hide Only for use within the system server.
+ */
+public final class DisplayViewport {
+ // True if this viewport is valid.
+ public boolean valid;
+
+ // The logical display id.
+ public int displayId;
+
+ // The rotation applied to the physical coordinate system.
+ public int orientation;
+
+ // The portion of the logical display that are presented on this physical display.
+ public final Rect logicalFrame = new Rect();
+
+ // The portion of the (rotated) physical display that shows the logical display contents.
+ // The relation between logical and physical frame defines how the coordinate system
+ // should be scaled or translated after rotation.
+ public final Rect physicalFrame = new Rect();
+
+ // The full width and height of the display device, rotated in the same
+ // manner as physicalFrame. This expresses the full native size of the display device.
+ // The physical frame should usually fit within this area.
+ public int deviceWidth;
+ public int deviceHeight;
+
+ public void copyFrom(DisplayViewport viewport) {
+ valid = viewport.valid;
+ displayId = viewport.displayId;
+ orientation = viewport.orientation;
+ logicalFrame.set(viewport.logicalFrame);
+ physicalFrame.set(viewport.physicalFrame);
+ deviceWidth = viewport.deviceWidth;
+ deviceHeight = viewport.deviceHeight;
+ }
+
+ // For debugging purposes.
+ @Override
+ public String toString() {
+ return "DisplayViewport{valid=" + valid
+ + ", displayId=" + displayId
+ + ", orientation=" + orientation
+ + ", logicalFrame=" + logicalFrame
+ + ", physicalFrame=" + physicalFrame
+ + ", deviceWidth=" + deviceWidth
+ + ", deviceHeight=" + deviceHeight
+ + "}";
+ }
+}
diff --git a/core/java/android/hardware/hdmi/HdmiCec.java b/core/java/android/hardware/hdmi/HdmiCec.java
new file mode 100644
index 0000000..38d9de4
--- /dev/null
+++ b/core/java/android/hardware/hdmi/HdmiCec.java
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.hdmi;
+
+/**
+ * Defines constants and utility methods related to HDMI-CEC protocol.
+ */
+public final class HdmiCec {
+
+ /** TV device type. */
+ public static final int DEVICE_TV = 0;
+
+ /** Recording device type. */
+ public static final int DEVICE_RECORDER = 1;
+
+ /** Device type reserved for future usage. */
+ public static final int DEVICE_RESERVED = 2;
+
+ /** Tuner device type. */
+ public static final int DEVICE_TUNER = 3;
+
+ /** Playback device type. */
+ public static final int DEVICE_PLAYBACK = 4;
+
+ /** Audio system device type. */
+ public static final int DEVICE_AUDIO_SYSTEM = 5;
+
+ // Value indicating the device is not an active source.
+ public static final int DEVICE_INACTIVE = -1;
+
+ /** Logical address for TV */
+ public static final int ADDR_TV = 0;
+
+ /** Logical address for recorder 1 */
+ public static final int ADDR_RECORDER_1 = 1;
+
+ /** Logical address for recorder 2 */
+ public static final int ADDR_RECORDER_2 = 2;
+
+ /** Logical address for tuner 1 */
+ public static final int ADDR_TUNER_1 = 3;
+
+ /** Logical address for playback 1 */
+ public static final int ADDR_PLAYBACK_1 = 4;
+
+ /** Logical address for audio system */
+ public static final int ADDR_AUDIO_SYSTEM = 5;
+
+ /** Logical address for tuner 2 */
+ public static final int ADDR_TUNER_2 = 6;
+
+ /** Logical address for tuner 3 */
+ public static final int ADDR_TUNER_3 = 7;
+
+ /** Logical address for playback 2 */
+ public static final int ADDR_PLAYBACK_2 = 8;
+
+ /** Logical address for recorder 3 */
+ public static final int ADDR_RECORDER_3 = 9;
+
+ /** Logical address for tuner 4 */
+ public static final int ADDR_TUNER_4 = 10;
+
+ /** Logical address for playback 3 */
+ public static final int ADDR_PLAYBACK_3 = 11;
+
+ /** Logical address reserved for future usage */
+ public static final int ADDR_RESERVED_1 = 12;
+
+ /** Logical address reserved for future usage */
+ public static final int ADDR_RESERVED_2 = 13;
+
+ /** Logical address for TV other than the one assigned with {@link #ADDR_TV} */
+ public static final int ADDR_FREE_USE = 14;
+
+ /** Logical address for devices to which address cannot be allocated */
+ public static final int ADDR_UNREGISTERED = 15;
+
+ /** Logical address used in the destination address field for broadcast messages */
+ public static final int ADDR_BROADCAST = 15;
+
+ /** Logical address used to indicate it is not initialized or invalid. */
+ public static final int ADDR_INVALID = -1;
+
+ // TODO: Complete the list of CEC messages definition.
+ public static final int MESSAGE_FEATURE_ABORT = 0x00;
+ public static final int MESSAGE_IMAGE_VIEW_ON = 0x04;
+ public static final int MESSAGE_TUNER_STEP_INCREMENT = 0x05;
+ public static final int MESSAGE_TUNER_STEP_DECREMENT = 0x06;
+ public static final int MESSAGE_TUNER_DEVICE_STATUS = 0x07;
+ public static final int MESSAGE_GIVE_TUNER_DEVICE_STATUS = 0x08;
+ public static final int MESSAGE_RECORD_ON = 0x09;
+ public static final int MESSAGE_RECORD_STATUS = 0x0A;
+ public static final int MESSAGE_RECORD_OFF = 0x0B;
+ public static final int MESSAGE_TEXT_VIEW_ON = 0x0D;
+ public static final int MESSAGE_RECORD_TV_SCREEN = 0x0F;
+ public static final int MESSAGE_GIVE_DECK_STATUS = 0x1A;
+ public static final int MESSAGE_DECK_STATUS = 0x1B;
+ public static final int MESSAGE_SET_MENU_LANGUAGE = 0x32;
+ public static final int MESSAGE_CLEAR_ANALOG_TIMER = 0x33;
+ public static final int MESSAGE_SET_ANALOG_TIMER = 0x34;
+ public static final int MESSAGE_TIMER_STATUS = 0x35;
+ public static final int MESSAGE_STANDBY = 0x36;
+ public static final int MESSAGE_PLAY = 0x41;
+ public static final int MESSAGE_DECK_CONTROL = 0x42;
+ public static final int MESSAGE_TIMER_CLEARED_STATUS = 0x043;
+ public static final int MESSAGE_USER_CONTROL_PRESSED = 0x44;
+ public static final int MESSAGE_USER_CONTROL_RELEASED = 0x45;
+ public static final int MESSAGE_GET_OSD_NAME = 0x46;
+ public static final int MESSAGE_SET_OSD_NAME = 0x47;
+ public static final int MESSAGE_SET_OSD_STRING = 0x64;
+ public static final int MESSAGE_SET_TIMER_PROGRAM_TITLE = 0x67;
+ public static final int MESSAGE_SYSTEM_AUDIO_MODE_REQUEST = 0x70;
+ public static final int MESSAGE_GIVE_AUDIO_STATUS = 0x71;
+ public static final int MESSAGE_SET_SYSTEM_AUDIO_MODE = 0x72;
+ public static final int MESSAGE_REPORT_AUDIO_STATUS = 0x7A;
+ public static final int MESSAGE_GIVE_SYSTEM_AUDIO_MODE_STATUS = 0x7D;
+ public static final int MESSAGE_SYSTEM_AUDIO_MODE_STATUS = 0x7E;
+ public static final int MESSAGE_ROUTING_CHANGE = 0x80;
+ public static final int MESSAGE_ROUTING_INFORMATION = 0x81;
+ public static final int MESSAGE_ACTIVE_SOURCE = 0x82;
+ public static final int MESSAGE_GIVE_PHYSICAL_ADDRESS = 0x83;
+ public static final int MESSAGE_REPORT_PHYSICAL_ADDRESS = 0x84;
+ public static final int MESSAGE_REQUEST_ACTIVE_SOURCE = 0x85;
+ public static final int MESSAGE_SET_STREAM_PATH = 0x86;
+ public static final int MESSAGE_DEVICE_VENDOR_ID = 0x87;
+ public static final int MESSAGE_VENDOR_COMMAND = 0x89;
+ public static final int MESSAGE_VENDOR_REMOTE_BUTTON_DOWN = 0x8A;
+ public static final int MESSAGE_VENDOR_REMOTE_BUTTON_UP = 0x8B;
+ public static final int MESSAGE_GIVE_DEVICE_VENDOR_ID = 0x8C;
+ public static final int MESSAGE_MENU_REQUEST = 0x8D;
+ public static final int MESSAGE_MENU_STATUS = 0x8E;
+ public static final int MESSAGE_GIVE_DEVICE_POWER_STATUS = 0x8F;
+ public static final int MESSAGE_REPORT_POWER_STATUS = 0x90;
+ public static final int MESSAGE_GET_MENU_LANGUAGE = 0x91;
+ public static final int MESSAGE_SELECT_ANALOG_SERVICE = 0x92;
+ public static final int MESSAGE_SELECT_DIGITAL_SERVICE = 0x93;
+ public static final int MESSAGE_SET_DIGITAL_TIMER = 0x97;
+ public static final int MESSAGE_CLEAR_DIGITAL_TIMER = 0x99;
+ public static final int MESSAGE_SET_AUDIO_RATE = 0x9A;
+ public static final int MESSAGE_INACTIVE_SOURCE = 0x9D;
+ public static final int MESSAGE_CEC_VERSION = 0x9E;
+ public static final int MESSAGE_GET_CEC_VERSION = 0x9F;
+ public static final int MESSAGE_VENDOR_COMMAND_WITH_ID = 0xA0;
+ public static final int MESSAGE_CLEAR_EXTERNAL_TIMER = 0xA1;
+ public static final int MESSAGE_SET_EXTERNAL_TIMER = 0xA2;
+ public static final int MESSAGE_ABORT = 0xFF;
+
+ private static final int[] ADDRESS_TO_TYPE = {
+ DEVICE_TV, // ADDR_TV
+ DEVICE_RECORDER, // ADDR_RECORDER_1
+ DEVICE_RECORDER, // ADDR_RECORDER_2
+ DEVICE_TUNER, // ADDR_TUNER_1
+ DEVICE_PLAYBACK, // ADDR_PLAYBACK_1
+ DEVICE_AUDIO_SYSTEM, // ADDR_AUDIO_SYSTEM
+ DEVICE_TUNER, // ADDR_TUNER_2
+ DEVICE_TUNER, // ADDR_TUNER_3
+ DEVICE_PLAYBACK, // ADDR_PLAYBACK_2
+ DEVICE_RECORDER, // ADDR_RECORDER_3
+ DEVICE_TUNER, // ADDR_TUNER_4
+ DEVICE_PLAYBACK, // ADDR_PLAYBACK_3
+ };
+
+ private static final String[] DEFAULT_NAMES = {
+ "TV",
+ "Recorder_1",
+ "Recorder_2",
+ "Tuner_1",
+ "Playback_1",
+ "AudioSystem",
+ "Tuner_2",
+ "Tuner_3",
+ "Playback_2",
+ "Recorder_3",
+ "Tuner_4",
+ "Playback_3",
+ };
+
+ private HdmiCec() { } // Prevents instantiation.
+
+ /**
+ * Check if the given type is valid. A valid type is one of the actual
+ * logical device types defined in the standard ({@link #DEVICE_TV},
+ * {@link #DEVICE_PLAYBACK}, {@link #DEVICE_TUNER}, {@link #DEVICE_RECORDER},
+ * and {@link #DEVICE_AUDIO_SYSTEM}).
+ *
+ * @param type device type
+ * @return true if the given type is valid
+ */
+ public static boolean isValidType(int type) {
+ return (DEVICE_TV <= type && type <= DEVICE_AUDIO_SYSTEM)
+ && type != DEVICE_RESERVED;
+ }
+
+ /**
+ * Check if the given logical address is valid. A logical address is valid
+ * if it is one allocated for an actual device which allows communication
+ * with other logical devices.
+ *
+ * @param address logical address
+ * @return true if the given address is valid
+ */
+ public static boolean isValidAddress(int address) {
+ // TODO: We leave out the address 'free use(14)' for now. Check this later
+ // again to make sure it is a valid address for communication.
+ return (ADDR_TV <= address && address <= ADDR_PLAYBACK_3);
+ }
+
+ /**
+ * Return the device type for the given logical address.
+ *
+ * @param address logical address
+ * @return device type for the given logical address; DEVICE_INACTIVE
+ * if the address is not valid.
+ */
+ public static int getTypeFromAddress(int address) {
+ if (isValidAddress(address)) {
+ return ADDRESS_TO_TYPE[address];
+ }
+ return DEVICE_INACTIVE;
+ }
+
+ /**
+ * Return the default device name for a logical address. This is the name
+ * by which the logical device is known to others until a name is
+ * set explicitly using HdmiCecService.setOsdName.
+ *
+ * @param address logical address
+ * @return default device name; empty string if the address is not valid
+ */
+ public static String getDefaultDeviceName(int address) {
+ if (isValidAddress(address)) {
+ return DEFAULT_NAMES[address];
+ }
+ return "";
+ }
+}
diff --git a/core/java/android/hardware/hdmi/HdmiCecClient.java b/core/java/android/hardware/hdmi/HdmiCecClient.java
new file mode 100644
index 0000000..d7f4a72
--- /dev/null
+++ b/core/java/android/hardware/hdmi/HdmiCecClient.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.hdmi;
+
+import android.os.IBinder;
+import android.os.RemoteException;
+
+import android.util.Log;
+
+/**
+ * HdmiCecClient is used to control HDMI-CEC logical device instance in the system.
+ * It is connected to actual hardware part via HdmiCecService. It provides with methods
+ * to send CEC messages to other device on the bus, and listener that allows to receive
+ * incoming messages to the device.
+ */
+public final class HdmiCecClient {
+ private static final String TAG = "HdmiCecClient";
+
+ private final IHdmiCecService mService;
+ private final IBinder mBinder;
+
+ /**
+ * Listener used by the client to get the incoming messages.
+ */
+ public static abstract class Listener {
+ /**
+ * Called when CEC message arrives. Override this method to receive the incoming
+ * CEC messages from other device on the bus.
+ *
+ * @param message {@link HdmiCecMessage} object
+ */
+ public void onMessageReceived(HdmiCecMessage message) { }
+
+ /**
+ * Called when hotplug event occurs. Override this method to receive the events.
+ *
+ * @param connected true if the cable is connected; otherwise false.
+ */
+ public void onCableStatusChanged(boolean connected) { }
+ }
+
+ // Private constructor.
+ private HdmiCecClient(IHdmiCecService service, IBinder b) {
+ mService = service;
+ mBinder = b;
+ }
+
+ // Factory method for HdmiCecClient.
+ // Declared package-private. Accessed by HdmiCecManager only.
+ static HdmiCecClient create(IHdmiCecService service, IBinder b) {
+ return new HdmiCecClient(service, b);
+ }
+
+ /**
+ * Send &lt;Active Source&gt; message.
+ */
+ public void sendActiveSource() {
+ try {
+ mService.sendActiveSource(mBinder);
+ } catch (RemoteException e) {
+ Log.e(TAG, "sendActiveSource threw exception ", e);
+ }
+ }
+
+ /**
+ * Send &lt;Inactive Source&gt; message.
+ */
+ public void sendInactiveSource() {
+ try {
+ mService.sendInactiveSource(mBinder);
+ } catch (RemoteException e) {
+ Log.e(TAG, "sendInactiveSource threw exception ", e);
+ }
+ }
+
+ /**
+ * Send &lt;TextViewOn&gt; message.
+ */
+ public void sendTextViewOn() {
+ try {
+ mService.sendTextViewOn(mBinder);
+ } catch (RemoteException e) {
+ Log.e(TAG, "sendTextViewOn threw exception ", e);
+ }
+ }
+
+ /**
+ * Send &lt;ImageViewOn&gt; message.
+ */
+ public void sendImageViewOn() {
+ try {
+ mService.sendImageViewOn(mBinder);
+ } catch (RemoteException e) {
+ Log.e(TAG, "sendImageViewOn threw exception ", e);
+ }
+ }
+
+ /**
+ * Send &lt;GiveDevicePowerStatus&gt; message.
+ *
+ * @param address logical address of the device to send the message to, such as
+ * {@link HdmiCec#ADDR_TV}.
+ */
+ public void sendGiveDevicePowerStatus(int address) {
+ try {
+ mService.sendGiveDevicePowerStatus(mBinder, address);
+ } catch (RemoteException e) {
+ Log.e(TAG, "sendGiveDevicePowerStatus threw exception ", e);
+ }
+ }
+}
diff --git a/core/java/android/hardware/hdmi/HdmiCecManager.java b/core/java/android/hardware/hdmi/HdmiCecManager.java
new file mode 100644
index 0000000..575785d
--- /dev/null
+++ b/core/java/android/hardware/hdmi/HdmiCecManager.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.hdmi;
+
+import android.os.IBinder;
+import android.os.RemoteException;
+
+/**
+ * The HdmiCecManager class is used to provide an HdmiCecClient instance,
+ * get various information on HDMI ports configuration. It is connected to actual hardware
+ * via HdmiCecService.
+ */
+public final class HdmiCecManager {
+ private final IHdmiCecService mService;
+
+ /**
+ * @hide - hide this constructor because it has a parameter of type IHdmiCecService,
+ * which is a system private class. The right way to create an instance of this class
+ * is using the factory Context.getSystemService.
+ */
+ public HdmiCecManager(IHdmiCecService service) {
+ mService = service;
+ }
+
+ /**
+ * Provide the HdmiCecClient instance of the given type. It also registers the listener
+ * for client to get the events coming to the device.
+ *
+ * @param type type of the HDMI-CEC logical device
+ * @param listener listener to be called
+ * @return {@link HdmiCecClient} instance. {@code null} on failure.
+ */
+ public HdmiCecClient getClient(int type, HdmiCecClient.Listener listener) {
+ try {
+ IBinder b = mService.allocateLogicalDevice(type, getListenerWrapper(listener));
+ return HdmiCecClient.create(mService, b);
+ } catch (RemoteException e) {
+ return null;
+ }
+ }
+
+ private IHdmiCecListener getListenerWrapper(final HdmiCecClient.Listener listener) {
+ // TODO: The message/events are not yet forwarded to client since it is not clearly
+ // defined as to how/who to handle them. Revisit it once the decision is
+ // made on what messages will have to reach the clients, what will be
+ // handled by service/manager.
+ return new IHdmiCecListener.Stub() {
+ @Override
+ public void onMessageReceived(HdmiCecMessage message) {
+ // Do nothing.
+ }
+
+ @Override
+ public void onCableStatusChanged(boolean connected) {
+ // Do nothing.
+ }
+ };
+ }
+}
diff --git a/core/java/android/hardware/hdmi/HdmiCecMessage.aidl b/core/java/android/hardware/hdmi/HdmiCecMessage.aidl
new file mode 100644
index 0000000..6687ba4
--- /dev/null
+++ b/core/java/android/hardware/hdmi/HdmiCecMessage.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.hdmi;
+
+parcelable HdmiCecMessage;
diff --git a/core/java/android/hardware/hdmi/HdmiCecMessage.java b/core/java/android/hardware/hdmi/HdmiCecMessage.java
new file mode 100644
index 0000000..be94d97
--- /dev/null
+++ b/core/java/android/hardware/hdmi/HdmiCecMessage.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.hdmi;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Arrays;
+
+/**
+ * A class to encapsulate HDMI-CEC message used for the devices connected via
+ * HDMI cable to communicate with one another. A message is defined by its
+ * source and destination address, command (or opcode), and optional parameters.
+ */
+public final class HdmiCecMessage implements Parcelable {
+
+ private static final int MAX_MESSAGE_LENGTH = 16;
+
+ private final int mSource;
+ private final int mDestination;
+
+ private final int mOpcode;
+ private final byte[] mParams;
+
+ /**
+ * Constructor.
+ */
+ public HdmiCecMessage(int source, int destination, int opcode, byte[] params) {
+ mSource = source;
+ mDestination = destination;
+ mOpcode = opcode;
+ mParams = Arrays.copyOf(params, params.length);
+ }
+
+ /**
+ * Return the source address field of the message. It is the logical address
+ * of the device which generated the message.
+ *
+ * @return source address
+ */
+ public int getSource() {
+ return mSource;
+ }
+
+ /**
+ * Return the destination address field of the message. It is the logical address
+ * of the device to which the message is sent.
+ *
+ * @return destination address
+ */
+ public int getDestination() {
+ return mDestination;
+ }
+
+ /**
+ * Return the opcode field of the message. It is the type of the message that
+ * tells the destination device what to do.
+ *
+ * @return opcode
+ */
+ public int getOpcode() {
+ return mOpcode;
+ }
+
+ /**
+ * Return the parameter field of the message. The contents of parameter varies
+ * from opcode to opcode, and is used together with opcode to describe
+ * the action for the destination device to take.
+ *
+ * @return parameter
+ */
+ public byte[] getParams() {
+ return mParams;
+ }
+
+ /**
+ * Describe the kinds of special objects contained in this Parcelable's
+ * marshalled representation.
+ */
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /**
+ * Flatten this object in to a Parcel.
+ *
+ * @param dest The Parcel in which the object should be written.
+ * @param flags Additional flags about how the object should be written.
+ * May be 0 or {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}.
+ */
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mSource);
+ dest.writeInt(mDestination);
+ dest.writeInt(mOpcode);
+ dest.writeInt(mParams.length);
+ dest.writeByteArray(mParams);
+ }
+
+ public static final Parcelable.Creator<HdmiCecMessage> CREATOR
+ = new Parcelable.Creator<HdmiCecMessage>() {
+ /**
+ * Rebuild a HdmiCecMessage previously stored with writeToParcel().
+ * @param p HdmiCecMessage object to read the Rating from
+ * @return a new HdmiCecMessage created from the data in the parcel
+ */
+ public HdmiCecMessage createFromParcel(Parcel p) {
+ int source = p.readInt();
+ int destination = p.readInt();
+ int opcode = p.readInt();
+ byte[] params = new byte[p.readInt()];
+ p.readByteArray(params);
+ return new HdmiCecMessage(source, destination, opcode, params);
+ }
+ public HdmiCecMessage[] newArray(int size) {
+ return new HdmiCecMessage[size];
+ }
+ };
+
+ @Override
+ public String toString() {
+ StringBuffer s = new StringBuffer();
+ s.append(String.format("src: %d dst: %d op: %2X params: ", mSource, mDestination, mOpcode));
+ for (byte data : mParams) {
+ s.append(String.format("%02X ", data));
+ }
+ return s.toString();
+ }
+}
+
diff --git a/core/java/android/hardware/hdmi/IHdmiCecListener.aidl b/core/java/android/hardware/hdmi/IHdmiCecListener.aidl
new file mode 100644
index 0000000..d281ce6
--- /dev/null
+++ b/core/java/android/hardware/hdmi/IHdmiCecListener.aidl
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.hdmi;
+
+import android.hardware.hdmi.HdmiCecMessage;
+
+/**
+ * Interface definition for HdmiCecService to do interprocess communcation.
+ *
+ * @hide
+ */
+oneway interface IHdmiCecListener {
+ void onMessageReceived(in HdmiCecMessage message);
+ void onCableStatusChanged(in boolean connected);
+}
diff --git a/core/java/android/hardware/hdmi/IHdmiCecService.aidl b/core/java/android/hardware/hdmi/IHdmiCecService.aidl
new file mode 100644
index 0000000..6fefcf8
--- /dev/null
+++ b/core/java/android/hardware/hdmi/IHdmiCecService.aidl
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.hdmi;
+
+import android.hardware.hdmi.HdmiCecMessage;
+import android.hardware.hdmi.IHdmiCecListener;
+import android.os.IBinder;
+
+/**
+ * Binder interface that components running in the appplication process
+ * will use to enable HDMI-CEC protocol exchange with other devices.
+ *
+ * @hide
+ */
+interface IHdmiCecService {
+ IBinder allocateLogicalDevice(int type, IHdmiCecListener listener);
+ void removeServiceListener(IBinder b, IHdmiCecListener listener);
+ void setOsdName(IBinder b, String name);
+ void sendActiveSource(IBinder b);
+ void sendInactiveSource(IBinder b);
+ void sendImageViewOn(IBinder b);
+ void sendTextViewOn(IBinder b);
+ void sendGiveDevicePowerStatus(IBinder b, int address);
+ void sendMessage(IBinder b, in HdmiCecMessage message);
+}
+
diff --git a/core/java/android/hardware/input/IInputManager.aidl b/core/java/android/hardware/input/IInputManager.aidl
index 9b6f82a..f1e7e98 100644
--- a/core/java/android/hardware/input/IInputManager.aidl
+++ b/core/java/android/hardware/input/IInputManager.aidl
@@ -16,6 +16,7 @@
package android.hardware.input;
+import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.KeyboardLayout;
import android.hardware.input.IInputDevicesChangedListener;
import android.os.IBinder;
@@ -41,13 +42,13 @@ interface IInputManager {
// Keyboard layouts configuration.
KeyboardLayout[] getKeyboardLayouts();
KeyboardLayout getKeyboardLayout(String keyboardLayoutDescriptor);
- String getCurrentKeyboardLayoutForInputDevice(String inputDeviceDescriptor);
- void setCurrentKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ String getCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier);
+ void setCurrentKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor);
- String[] getKeyboardLayoutsForInputDevice(String inputDeviceDescriptor);
- void addKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ String[] getKeyboardLayoutsForInputDevice(in InputDeviceIdentifier identifier);
+ void addKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor);
- void removeKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ void removeKeyboardLayoutForInputDevice(in InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor);
// Registers an input devices changed listener.
diff --git a/core/java/android/hardware/input/InputDeviceIdentifier.aidl b/core/java/android/hardware/input/InputDeviceIdentifier.aidl
new file mode 100644
index 0000000..7234a91
--- /dev/null
+++ b/core/java/android/hardware/input/InputDeviceIdentifier.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package android.hardware.input;
+
+parcelable InputDeviceIdentifier;
diff --git a/core/java/android/hardware/input/InputDeviceIdentifier.java b/core/java/android/hardware/input/InputDeviceIdentifier.java
new file mode 100644
index 0000000..5e832e3
--- /dev/null
+++ b/core/java/android/hardware/input/InputDeviceIdentifier.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+package android.hardware.input;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Wrapper for passing identifying information for input devices.
+ *
+ * @hide
+ */
+public final class InputDeviceIdentifier implements Parcelable {
+ private final String mDescriptor;
+ private final int mVendorId;
+ private final int mProductId;
+
+ public InputDeviceIdentifier(String descriptor, int vendorId, int productId) {
+ this.mDescriptor = descriptor;
+ this.mVendorId = vendorId;
+ this.mProductId = productId;
+ }
+
+ private InputDeviceIdentifier(Parcel src) {
+ mDescriptor = src.readString();
+ mVendorId = src.readInt();
+ mProductId = src.readInt();
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mDescriptor);
+ dest.writeInt(mVendorId);
+ dest.writeInt(mProductId);
+ }
+
+ public String getDescriptor() {
+ return mDescriptor;
+ }
+
+ public int getVendorId() {
+ return mVendorId;
+ }
+
+ public int getProductId() {
+ return mProductId;
+ }
+
+ public static final Parcelable.Creator<InputDeviceIdentifier> CREATOR =
+ new Parcelable.Creator<InputDeviceIdentifier>() {
+
+ @Override
+ public InputDeviceIdentifier createFromParcel(Parcel source) {
+ return new InputDeviceIdentifier(source);
+ }
+
+ @Override
+ public InputDeviceIdentifier[] newArray(int size) {
+ return new InputDeviceIdentifier[size];
+ }
+
+ };
+}
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index 30e69a6..a2aeafb 100644
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -26,6 +26,8 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
+import android.os.Parcel;
+import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.Vibrator;
@@ -373,20 +375,17 @@ public final class InputManager {
}
/**
- * Gets the current keyboard layout descriptor for the specified input device.
- *
- * @param inputDeviceDescriptor The input device descriptor.
- * @return The keyboard layout descriptor, or null if no keyboard layout has been set.
+ * Gets the current keyboard layout descriptor for the specified input
+ * device.
*
+ * @param identifier Identifier for the input device
+ * @return The keyboard layout descriptor, or null if no keyboard layout has
+ * been set.
* @hide
*/
- public String getCurrentKeyboardLayoutForInputDevice(String inputDeviceDescriptor) {
- if (inputDeviceDescriptor == null) {
- throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
- }
-
+ public String getCurrentKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier) {
try {
- return mIm.getCurrentKeyboardLayoutForInputDevice(inputDeviceDescriptor);
+ return mIm.getCurrentKeyboardLayoutForInputDevice(identifier);
} catch (RemoteException ex) {
Log.w(TAG, "Could not get current keyboard layout for input device.", ex);
return null;
@@ -394,28 +393,29 @@ public final class InputManager {
}
/**
- * Sets the current keyboard layout descriptor for the specified input device.
+ * Sets the current keyboard layout descriptor for the specified input
+ * device.
* <p>
- * This method may have the side-effect of causing the input device in question
- * to be reconfigured.
+ * This method may have the side-effect of causing the input device in
+ * question to be reconfigured.
* </p>
*
- * @param inputDeviceDescriptor The input device descriptor.
- * @param keyboardLayoutDescriptor The keyboard layout descriptor to use, must not be null.
- *
+ * @param identifier The identifier for the input device.
+ * @param keyboardLayoutDescriptor The keyboard layout descriptor to use,
+ * must not be null.
* @hide
*/
- public void setCurrentKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ public void setCurrentKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor) {
- if (inputDeviceDescriptor == null) {
- throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
+ if (identifier == null) {
+ throw new IllegalArgumentException("identifier must not be null");
}
if (keyboardLayoutDescriptor == null) {
throw new IllegalArgumentException("keyboardLayoutDescriptor must not be null");
}
try {
- mIm.setCurrentKeyboardLayoutForInputDevice(inputDeviceDescriptor,
+ mIm.setCurrentKeyboardLayoutForInputDevice(identifier,
keyboardLayoutDescriptor);
} catch (RemoteException ex) {
Log.w(TAG, "Could not set current keyboard layout for input device.", ex);
@@ -423,20 +423,20 @@ public final class InputManager {
}
/**
- * Gets all keyboard layout descriptors that are enabled for the specified input device.
+ * Gets all keyboard layout descriptors that are enabled for the specified
+ * input device.
*
- * @param inputDeviceDescriptor The input device descriptor.
+ * @param identifier The identifier for the input device.
* @return The keyboard layout descriptors.
- *
* @hide
*/
- public String[] getKeyboardLayoutsForInputDevice(String inputDeviceDescriptor) {
- if (inputDeviceDescriptor == null) {
+ public String[] getKeyboardLayoutsForInputDevice(InputDeviceIdentifier identifier) {
+ if (identifier == null) {
throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
}
try {
- return mIm.getKeyboardLayoutsForInputDevice(inputDeviceDescriptor);
+ return mIm.getKeyboardLayoutsForInputDevice(identifier);
} catch (RemoteException ex) {
Log.w(TAG, "Could not get keyboard layouts for input device.", ex);
return ArrayUtils.emptyArray(String.class);
@@ -446,18 +446,18 @@ public final class InputManager {
/**
* Adds the keyboard layout descriptor for the specified input device.
* <p>
- * This method may have the side-effect of causing the input device in question
- * to be reconfigured.
+ * This method may have the side-effect of causing the input device in
+ * question to be reconfigured.
* </p>
*
- * @param inputDeviceDescriptor The input device descriptor.
- * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to add.
- *
+ * @param identifier The identifier for the input device.
+ * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to
+ * add.
* @hide
*/
- public void addKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ public void addKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor) {
- if (inputDeviceDescriptor == null) {
+ if (identifier == null) {
throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
}
if (keyboardLayoutDescriptor == null) {
@@ -465,7 +465,7 @@ public final class InputManager {
}
try {
- mIm.addKeyboardLayoutForInputDevice(inputDeviceDescriptor, keyboardLayoutDescriptor);
+ mIm.addKeyboardLayoutForInputDevice(identifier, keyboardLayoutDescriptor);
} catch (RemoteException ex) {
Log.w(TAG, "Could not add keyboard layout for input device.", ex);
}
@@ -474,18 +474,18 @@ public final class InputManager {
/**
* Removes the keyboard layout descriptor for the specified input device.
* <p>
- * This method may have the side-effect of causing the input device in question
- * to be reconfigured.
+ * This method may have the side-effect of causing the input device in
+ * question to be reconfigured.
* </p>
*
- * @param inputDeviceDescriptor The input device descriptor.
- * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to remove.
- *
+ * @param identifier The identifier for the input device.
+ * @param keyboardLayoutDescriptor The descriptor of the keyboard layout to
+ * remove.
* @hide
*/
- public void removeKeyboardLayoutForInputDevice(String inputDeviceDescriptor,
+ public void removeKeyboardLayoutForInputDevice(InputDeviceIdentifier identifier,
String keyboardLayoutDescriptor) {
- if (inputDeviceDescriptor == null) {
+ if (identifier == null) {
throw new IllegalArgumentException("inputDeviceDescriptor must not be null");
}
if (keyboardLayoutDescriptor == null) {
@@ -493,7 +493,7 @@ public final class InputManager {
}
try {
- mIm.removeKeyboardLayoutForInputDevice(inputDeviceDescriptor, keyboardLayoutDescriptor);
+ mIm.removeKeyboardLayoutForInputDevice(identifier, keyboardLayoutDescriptor);
} catch (RemoteException ex) {
Log.w(TAG, "Could not remove keyboard layout for input device.", ex);
}
diff --git a/core/java/android/hardware/input/InputManagerInternal.java b/core/java/android/hardware/input/InputManagerInternal.java
new file mode 100644
index 0000000..8be94d0
--- /dev/null
+++ b/core/java/android/hardware/input/InputManagerInternal.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.hardware.input;
+
+import android.hardware.display.DisplayViewport;
+import android.view.InputEvent;
+
+/**
+ * Input manager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+public abstract class InputManagerInternal {
+ /**
+ * Sets information about the displays as needed by the input system.
+ * The input system should copy this information if required.
+ */
+ public abstract void setDisplayViewports(DisplayViewport defaultViewport,
+ DisplayViewport externalTouchViewport);
+
+ public abstract boolean injectInputEvent(InputEvent event, int displayId, int mode);
+}
diff --git a/core/java/android/hardware/usb/UsbDevice.java b/core/java/android/hardware/usb/UsbDevice.java
index 9bd38f9..d1e63f6 100644
--- a/core/java/android/hardware/usb/UsbDevice.java
+++ b/core/java/android/hardware/usb/UsbDevice.java
@@ -46,6 +46,9 @@ public class UsbDevice implements Parcelable {
private static final String TAG = "UsbDevice";
private final String mName;
+ private final String mManufacturerName;
+ private final String mProductName;
+ private final String mSerialNumber;
private final int mVendorId;
private final int mProductId;
private final int mClass;
@@ -58,13 +61,18 @@ public class UsbDevice implements Parcelable {
* @hide
*/
public UsbDevice(String name, int vendorId, int productId,
- int Class, int subClass, int protocol, Parcelable[] interfaces) {
+ int Class, int subClass, int protocol,
+ String manufacturerName, String productName, String serialNumber,
+ Parcelable[] interfaces) {
mName = name;
mVendorId = vendorId;
mProductId = productId;
mClass = Class;
mSubclass = subClass;
mProtocol = protocol;
+ mManufacturerName = manufacturerName;
+ mProductName = productName;
+ mSerialNumber = serialNumber;
mInterfaces = interfaces;
}
@@ -80,6 +88,33 @@ public class UsbDevice implements Parcelable {
}
/**
+ * Returns the manufacturer name of the device.
+ *
+ * @return the manufacturer name
+ */
+ public String getManufacturerName() {
+ return mManufacturerName;
+ }
+
+ /**
+ * Returns the product name of the device.
+ *
+ * @return the product name
+ */
+ public String getProductName() {
+ return mProductName;
+ }
+
+ /**
+ * Returns the serial number of the device.
+ *
+ * @return the serial number name
+ */
+ public String getSerialNumber() {
+ return mSerialNumber;
+ }
+
+ /**
* Returns a unique integer ID for the device.
* This is a convenience for clients that want to use an integer to represent
* the device, rather than the device name.
@@ -176,7 +211,8 @@ public class UsbDevice implements Parcelable {
return "UsbDevice[mName=" + mName + ",mVendorId=" + mVendorId +
",mProductId=" + mProductId + ",mClass=" + mClass +
",mSubclass=" + mSubclass + ",mProtocol=" + mProtocol +
- ",mInterfaces=" + mInterfaces + "]";
+ ",mManufacturerName=" + mManufacturerName + ",mProductName=" + mProductName +
+ ",mSerialNumber=" + mSerialNumber + ",mInterfaces=" + mInterfaces + "]";
}
public static final Parcelable.Creator<UsbDevice> CREATOR =
@@ -188,8 +224,12 @@ public class UsbDevice implements Parcelable {
int clasz = in.readInt();
int subClass = in.readInt();
int protocol = in.readInt();
+ String manufacturerName = in.readString();
+ String productName = in.readString();
+ String serialNumber = in.readString();
Parcelable[] interfaces = in.readParcelableArray(UsbInterface.class.getClassLoader());
- return new UsbDevice(name, vendorId, productId, clasz, subClass, protocol, interfaces);
+ return new UsbDevice(name, vendorId, productId, clasz, subClass, protocol,
+ manufacturerName, productName, serialNumber, interfaces);
}
public UsbDevice[] newArray(int size) {
@@ -208,6 +248,9 @@ public class UsbDevice implements Parcelable {
parcel.writeInt(mClass);
parcel.writeInt(mSubclass);
parcel.writeInt(mProtocol);
+ parcel.writeString(mManufacturerName);
+ parcel.writeString(mProductName);
+ parcel.writeString(mSerialNumber);
parcel.writeParcelableArray(mInterfaces, 0);
}
diff --git a/core/java/android/hardware/usb/UsbDeviceConnection.java b/core/java/android/hardware/usb/UsbDeviceConnection.java
index b2034b2..389475f 100644
--- a/core/java/android/hardware/usb/UsbDeviceConnection.java
+++ b/core/java/android/hardware/usb/UsbDeviceConnection.java
@@ -32,7 +32,7 @@ public class UsbDeviceConnection {
private final UsbDevice mDevice;
// used by the JNI code
- private int mNativeContext;
+ private long mNativeContext;
/**
* UsbDevice should only be instantiated by UsbService implementation
diff --git a/core/java/android/hardware/usb/UsbRequest.java b/core/java/android/hardware/usb/UsbRequest.java
index 3646715..ce66084 100644
--- a/core/java/android/hardware/usb/UsbRequest.java
+++ b/core/java/android/hardware/usb/UsbRequest.java
@@ -37,7 +37,7 @@ public class UsbRequest {
private static final String TAG = "UsbRequest";
// used by the JNI code
- private int mNativeContext;
+ private long mNativeContext;
private UsbEndpoint mEndpoint;
diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
index 726dcec..bbea8ff 100644
--- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
@@ -75,7 +75,15 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
@Override
public void executeMessage(Message msg) {
if (mInputMethodSession == null) {
- // The session has been finished.
+ // The session has been finished. Args needs to be recycled
+ // for cases below.
+ switch (msg.what) {
+ case DO_UPDATE_SELECTION:
+ case DO_APP_PRIVATE_COMMAND: {
+ SomeArgs args = (SomeArgs)msg.obj;
+ args.recycle();
+ }
+ }
return;
}
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 70c8750..4eecfa9 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -361,11 +361,17 @@ public class ConnectivityManager {
*/
public static final int TYPE_MOBILE_IA = 14;
+ /**
+ * The network that uses proxy to achieve connectivity.
+ * {@hide}
+ */
+ public static final int TYPE_PROXY = 16;
+
/** {@hide} */
- public static final int MAX_RADIO_TYPE = TYPE_MOBILE_IA;
+ public static final int MAX_RADIO_TYPE = TYPE_PROXY;
/** {@hide} */
- public static final int MAX_NETWORK_TYPE = TYPE_MOBILE_IA;
+ public static final int MAX_NETWORK_TYPE = TYPE_PROXY;
/**
* If you want to set the default network preference,you can directly
@@ -446,6 +452,8 @@ public class ConnectivityManager {
return "WIFI_P2P";
case TYPE_MOBILE_IA:
return "MOBILE_IA";
+ case TYPE_PROXY:
+ return "PROXY";
default:
return Integer.toString(type);
}
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java
index 501484c..cc8c771 100644
--- a/core/java/android/net/EthernetDataTracker.java
+++ b/core/java/android/net/EthernetDataTracker.java
@@ -402,7 +402,7 @@ public class EthernetDataTracker extends BaseNetworkStateTracker {
* for this network.
*/
public String getTcpBufferSizesPropName() {
- return "net.tcp.buffersize.wifi";
+ return "net.tcp.buffersize.ethernet";
}
public void setDependencyMet(boolean met) {
diff --git a/core/java/android/net/INetworkManagementEventObserver.aidl b/core/java/android/net/INetworkManagementEventObserver.aidl
index b76e4c2..5b16f8b 100644
--- a/core/java/android/net/INetworkManagementEventObserver.aidl
+++ b/core/java/android/net/INetworkManagementEventObserver.aidl
@@ -16,6 +16,8 @@
package android.net;
+import android.net.LinkAddress;
+
/**
* Callback class for receiving events from an INetworkManagementService
*
@@ -55,24 +57,20 @@ interface INetworkManagementEventObserver {
/**
- * An interface address has been added or updated
+ * An interface address has been added or updated.
*
- * @param address The address.
* @param iface The interface.
- * @param flags The address flags.
- * @param scope The address scope.
+ * @param address The address.
*/
- void addressUpdated(String address, String iface, int flags, int scope);
+ void addressUpdated(String iface, in LinkAddress address);
/**
- * An interface address has been removed
+ * An interface address has been removed.
*
- * @param address The address.
* @param iface The interface.
- * @param flags The address flags.
- * @param scope The address scope.
+ * @param address The address.
*/
- void addressRemoved(String address, String iface, int flags, int scope);
+ void addressRemoved(String iface, in LinkAddress address);
/**
* A networking quota limit has been reached. The quota might not
@@ -90,4 +88,13 @@ interface INetworkManagementEventObserver {
* @param active True if the interface is actively transmitting data, false if it is idle.
*/
void interfaceClassDataActivityChanged(String label, boolean active);
+
+ /**
+ * Information about available DNS servers has been received.
+ *
+ * @param iface The interface on which the information was received.
+ * @param lifetime The time in seconds for which the DNS servers may be used.
+ * @param servers The IP addresses of the DNS servers.
+ */
+ void interfaceDnsServerInfo(String iface, long lifetime, in String[] servers);
}
diff --git a/core/java/android/net/LinkAddress.java b/core/java/android/net/LinkAddress.java
index a390add..22543e3 100644
--- a/core/java/android/net/LinkAddress.java
+++ b/core/java/android/net/LinkAddress.java
@@ -24,8 +24,32 @@ import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.net.UnknownHostException;
+import static libcore.io.OsConstants.IFA_F_DADFAILED;
+import static libcore.io.OsConstants.IFA_F_DEPRECATED;
+import static libcore.io.OsConstants.IFA_F_TENTATIVE;
+import static libcore.io.OsConstants.RT_SCOPE_HOST;
+import static libcore.io.OsConstants.RT_SCOPE_LINK;
+import static libcore.io.OsConstants.RT_SCOPE_SITE;
+import static libcore.io.OsConstants.RT_SCOPE_UNIVERSE;
+
/**
- * Identifies an address of a network link
+ * Identifies an IP address on a network link.
+ *
+ * A {@code LinkAddress} consists of:
+ * <ul>
+ * <li>An IP address and prefix length (e.g., {@code 2001:db8::1/64} or {@code 192.0.2.1/24}).
+ * The address must be unicast, as multicast addresses cannot be assigned to interfaces.
+ * <li>Address flags: A bitmask of {@code IFA_F_*} values representing properties of the address.
+ * <li>Address scope: An integer defining the scope in which the address is unique (e.g.,
+ * {@code RT_SCOPE_LINK} or {@code RT_SCOPE_SITE}).
+ * <ul>
+ *<p>
+ * When constructing a {@code LinkAddress}, the IP address and prefix are required. The flags and
+ * scope are optional. If they are not specified, the flags are set to zero, and the scope will be
+ * determined based on the IP address (e.g., link-local addresses will be created with a scope of
+ * {@code RT_SCOPE_LINK}, global addresses with {@code RT_SCOPE_UNIVERSE}, etc.) If they are
+ * specified, they are not checked for validity.
+ *
* @hide
*/
public class LinkAddress implements Parcelable {
@@ -35,12 +59,50 @@ public class LinkAddress implements Parcelable {
private InetAddress address;
/**
- * Network prefix length
+ * Prefix length.
*/
private int prefixLength;
- private void init(InetAddress address, int prefixLength) {
- if (address == null || prefixLength < 0 ||
+ /**
+ * Address flags. A bitmask of IFA_F_* values.
+ */
+ private int flags;
+
+ /**
+ * Address scope. One of the RT_SCOPE_* constants.
+ */
+ private int scope;
+
+ /**
+ * Utility function to determines the scope of a unicast address. Per RFC 4291 section 2.5 and
+ * RFC 6724 section 3.2.
+ * @hide
+ */
+ static int scopeForUnicastAddress(InetAddress addr) {
+ if (addr.isAnyLocalAddress()) {
+ return RT_SCOPE_HOST;
+ }
+
+ if (addr.isLoopbackAddress() || addr.isLinkLocalAddress()) {
+ return RT_SCOPE_LINK;
+ }
+
+ // isSiteLocalAddress() returns true for private IPv4 addresses, but RFC 6724 section 3.2
+ // says that they are assigned global scope.
+ if (!(addr instanceof Inet4Address) && addr.isSiteLocalAddress()) {
+ return RT_SCOPE_SITE;
+ }
+
+ return RT_SCOPE_UNIVERSE;
+ }
+
+ /**
+ * Utility function for the constructors.
+ */
+ private void init(InetAddress address, int prefixLength, int flags, int scope) {
+ if (address == null ||
+ address.isMulticastAddress() ||
+ prefixLength < 0 ||
((address instanceof Inet4Address) && prefixLength > 32) ||
(prefixLength > 128)) {
throw new IllegalArgumentException("Bad LinkAddress params " + address +
@@ -48,23 +110,59 @@ public class LinkAddress implements Parcelable {
}
this.address = address;
this.prefixLength = prefixLength;
+ this.flags = flags;
+ this.scope = scope;
}
+ /**
+ * Constructs a new {@code LinkAddress} from an {@code InetAddress} and prefix length, with
+ * the specified flags and scope. Flags and scope are not checked for validity.
+ * @param address The IP address.
+ * @param prefixLength The prefix length.
+ */
+ public LinkAddress(InetAddress address, int prefixLength, int flags, int scope) {
+ init(address, prefixLength, flags, scope);
+ }
+
+ /**
+ * Constructs a new {@code LinkAddress} from an {@code InetAddress} and a prefix length.
+ * The flags are set to zero and the scope is determined from the address.
+ * @param address The IP address.
+ * @param prefixLength The prefix length.
+ */
public LinkAddress(InetAddress address, int prefixLength) {
- init(address, prefixLength);
+ this(address, prefixLength, 0, 0);
+ this.scope = scopeForUnicastAddress(address);
}
+ /**
+ * Constructs a new {@code LinkAddress} from an {@code InterfaceAddress}.
+ * The flags are set to zero and the scope is determined from the address.
+ * @param interfaceAddress The interface address.
+ */
public LinkAddress(InterfaceAddress interfaceAddress) {
- init(interfaceAddress.getAddress(),
+ this(interfaceAddress.getAddress(),
interfaceAddress.getNetworkPrefixLength());
}
/**
* Constructs a new {@code LinkAddress} from a string such as "192.0.2.5/24" or
- * "2001:db8::1/64".
+ * "2001:db8::1/64". The flags are set to zero and the scope is determined from the address.
* @param string The string to parse.
*/
public LinkAddress(String address) {
+ this(address, 0, 0);
+ this.scope = scopeForUnicastAddress(this.address);
+ }
+
+ /**
+ * Constructs a new {@code LinkAddress} from a string such as "192.0.2.5/24" or
+ * "2001:db8::1/64", with the specified flags and scope.
+ * @param string The string to parse.
+ * @param flags The address flags.
+ * @param scope The address scope.
+ */
+ public LinkAddress(String address, int flags, int scope) {
InetAddress inetAddress = null;
int prefixLength = -1;
try {
@@ -81,18 +179,22 @@ public class LinkAddress implements Parcelable {
throw new IllegalArgumentException("Bad LinkAddress params " + address);
}
- init(inetAddress, prefixLength);
+ init(inetAddress, prefixLength, flags, scope);
}
+ /**
+ * Returns a string representation of this address, such as "192.0.2.1/24" or "2001:db8::1/64".
+ * The string representation does not contain the flags and scope, just the address and prefix
+ * length.
+ */
@Override
public String toString() {
- return (address == null ? "" : (address.getHostAddress() + "/" + prefixLength));
+ return address.getHostAddress() + "/" + prefixLength;
}
/**
- * Compares this {@code LinkAddress} instance against the specified address
- * in {@code obj}. Two addresses are equal if their InetAddress and prefixLength
- * are equal
+ * Compares this {@code LinkAddress} instance against {@code obj}. Two addresses are equal if
+ * their address, prefix length, flags and scope are equal.
*
* @param obj the object to be tested for equality.
* @return {@code true} if both objects are equal, {@code false} otherwise.
@@ -104,33 +206,70 @@ public class LinkAddress implements Parcelable {
}
LinkAddress linkAddress = (LinkAddress) obj;
return this.address.equals(linkAddress.address) &&
- this.prefixLength == linkAddress.prefixLength;
+ this.prefixLength == linkAddress.prefixLength &&
+ this.flags == linkAddress.flags &&
+ this.scope == linkAddress.scope;
}
- @Override
- /*
- * generate hashcode based on significant fields
+ /**
+ * Returns a hashcode for this address.
*/
+ @Override
public int hashCode() {
- return ((null == address) ? 0 : address.hashCode()) + prefixLength;
+ return address.hashCode() + 11 * prefixLength + 19 * flags + 43 * scope;
+ }
+
+ /**
+ * Determines whether this {@code LinkAddress} and the provided {@code LinkAddress} represent
+ * the same address. Two LinkAddresses represent the same address if they have the same IP
+ * address and prefix length, even if their properties are different.
+ *
+ * @param other the {@code LinkAddress} to compare to.
+ * @return {@code true} if both objects have the same address and prefix length, {@code false}
+ * otherwise.
+ */
+ public boolean isSameAddressAs(LinkAddress other) {
+ return address.equals(other.address) && prefixLength == other.prefixLength;
}
/**
- * Returns the InetAddress for this address.
+ * Returns the InetAddress of this address.
*/
public InetAddress getAddress() {
return address;
}
/**
- * Get network prefix length
+ * Returns the prefix length of this address.
*/
public int getNetworkPrefixLength() {
return prefixLength;
}
/**
- * Implement the Parcelable interface
+ * Returns the flags of this address.
+ */
+ public int getFlags() {
+ return flags;
+ }
+
+ /**
+ * Returns the scope of this address.
+ */
+ public int getScope() {
+ return scope;
+ }
+
+ /**
+ * Returns true if this {@code LinkAddress} is global scope and preferred.
+ */
+ public boolean isGlobalPreferred() {
+ return (scope == RT_SCOPE_UNIVERSE &&
+ (flags & (IFA_F_DADFAILED | IFA_F_DEPRECATED | IFA_F_TENTATIVE)) == 0L);
+ }
+
+ /**
+ * Implement the Parcelable interface.
* @hide
*/
public int describeContents() {
@@ -142,13 +281,10 @@ public class LinkAddress implements Parcelable {
* @hide
*/
public void writeToParcel(Parcel dest, int flags) {
- if (address != null) {
- dest.writeByte((byte)1);
- dest.writeByteArray(address.getAddress());
- dest.writeInt(prefixLength);
- } else {
- dest.writeByte((byte)0);
- }
+ dest.writeByteArray(address.getAddress());
+ dest.writeInt(prefixLength);
+ dest.writeInt(this.flags);
+ dest.writeInt(scope);
}
/**
@@ -159,14 +295,17 @@ public class LinkAddress implements Parcelable {
new Creator<LinkAddress>() {
public LinkAddress createFromParcel(Parcel in) {
InetAddress address = null;
- int prefixLength = 0;
- if (in.readByte() == 1) {
- try {
- address = InetAddress.getByAddress(in.createByteArray());
- prefixLength = in.readInt();
- } catch (UnknownHostException e) { }
+ try {
+ address = InetAddress.getByAddress(in.createByteArray());
+ } catch (UnknownHostException e) {
+ // Nothing we can do here. When we call the constructor, we'll throw an
+ // IllegalArgumentException, because a LinkAddress can't have a null
+ // InetAddress.
}
- return new LinkAddress(address, prefixLength);
+ int prefixLength = in.readInt();
+ int flags = in.readInt();
+ int scope = in.readInt();
+ return new LinkAddress(address, prefixLength, flags, scope);
}
public LinkAddress[] newArray(int size) {
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index b4d07a1..4dfd3d9 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -61,10 +61,10 @@ import java.util.Hashtable;
public class LinkProperties implements Parcelable {
// The interface described by the network link.
private String mIfaceName;
- private Collection<LinkAddress> mLinkAddresses = new ArrayList<LinkAddress>();
- private Collection<InetAddress> mDnses = new ArrayList<InetAddress>();
+ private ArrayList<LinkAddress> mLinkAddresses = new ArrayList<LinkAddress>();
+ private ArrayList<InetAddress> mDnses = new ArrayList<InetAddress>();
private String mDomains;
- private Collection<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
+ private ArrayList<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
private ProxyProperties mHttpProxy;
private int mMtu;
@@ -156,28 +156,52 @@ public class LinkProperties implements Parcelable {
return addresses;
}
+ private int findLinkAddressIndex(LinkAddress address) {
+ for (int i = 0; i < mLinkAddresses.size(); i++) {
+ if (mLinkAddresses.get(i).isSameAddressAs(address)) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
/**
- * Adds a link address if it does not exist, or update it if it does.
+ * Adds a link address if it does not exist, or updates it if it does.
* @param address The {@code LinkAddress} to add.
- * @return true if the address was added, false if it already existed.
+ * @return true if {@code address} was added or updated, false otherwise.
*/
public boolean addLinkAddress(LinkAddress address) {
- // TODO: when the LinkAddress has other attributes beyond the
- // address and the prefix length, update them here.
- if (address != null && !mLinkAddresses.contains(address)) {
+ if (address == null) {
+ return false;
+ }
+ int i = findLinkAddressIndex(address);
+ if (i < 0) {
+ // Address was not present. Add it.
mLinkAddresses.add(address);
return true;
+ } else if (mLinkAddresses.get(i).equals(address)) {
+ // Address was present and has same properties. Do nothing.
+ return false;
+ } else {
+ // Address was present and has different properties. Update it.
+ mLinkAddresses.set(i, address);
+ return true;
}
- return false;
}
/**
- * Removes a link address.
- * @param address The {@code LinkAddress} to remove.
+ * Removes a link address. Specifically, removes the link address, if any, for which
+ * {@code isSameAddressAs(toRemove)} returns true.
+ * @param address A {@code LinkAddress} specifying the address to remove.
* @return true if the address was removed, false if it did not exist.
*/
public boolean removeLinkAddress(LinkAddress toRemove) {
- return mLinkAddresses.remove(toRemove);
+ int i = findLinkAddressIndex(toRemove);
+ if (i >= 0) {
+ mLinkAddresses.remove(i);
+ return true;
+ }
+ return false;
}
/**
diff --git a/core/java/android/net/NetworkIdentity.java b/core/java/android/net/NetworkIdentity.java
index 3c67bf9..36dd2fdfb 100644
--- a/core/java/android/net/NetworkIdentity.java
+++ b/core/java/android/net/NetworkIdentity.java
@@ -26,7 +26,7 @@ import android.net.wifi.WifiManager;
import android.os.Build;
import android.telephony.TelephonyManager;
-import com.android.internal.util.Objects;
+import java.util.Objects;
/**
* Network definition that includes strong identity. Analogous to combining
@@ -60,7 +60,7 @@ public class NetworkIdentity {
@Override
public int hashCode() {
- return Objects.hashCode(mType, mSubType, mSubscriberId, mNetworkId, mRoaming);
+ return Objects.hash(mType, mSubType, mSubscriberId, mNetworkId, mRoaming);
}
@Override
@@ -68,8 +68,8 @@ public class NetworkIdentity {
if (obj instanceof NetworkIdentity) {
final NetworkIdentity ident = (NetworkIdentity) obj;
return mType == ident.mType && mSubType == ident.mSubType && mRoaming == ident.mRoaming
- && Objects.equal(mSubscriberId, ident.mSubscriberId)
- && Objects.equal(mNetworkId, ident.mNetworkId);
+ && Objects.equals(mSubscriberId, ident.mSubscriberId)
+ && Objects.equals(mNetworkId, ident.mNetworkId);
}
return false;
}
diff --git a/core/java/android/net/NetworkPolicy.java b/core/java/android/net/NetworkPolicy.java
index 441db7a..10c686b 100644
--- a/core/java/android/net/NetworkPolicy.java
+++ b/core/java/android/net/NetworkPolicy.java
@@ -21,7 +21,7 @@ import static com.android.internal.util.Preconditions.checkNotNull;
import android.os.Parcel;
import android.os.Parcelable;
-import com.android.internal.util.Objects;
+import java.util.Objects;
/**
* Policy for networks matching a {@link NetworkTemplate}, including usage cycle
@@ -146,7 +146,7 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> {
@Override
public int hashCode() {
- return Objects.hashCode(template, cycleDay, cycleTimezone, warningBytes, limitBytes,
+ return Objects.hash(template, cycleDay, cycleTimezone, warningBytes, limitBytes,
lastWarningSnooze, lastLimitSnooze, metered, inferred);
}
@@ -159,8 +159,8 @@ public class NetworkPolicy implements Parcelable, Comparable<NetworkPolicy> {
&& lastWarningSnooze == other.lastWarningSnooze
&& lastLimitSnooze == other.lastLimitSnooze && metered == other.metered
&& inferred == other.inferred
- && Objects.equal(cycleTimezone, other.cycleTimezone)
- && Objects.equal(template, other.template);
+ && Objects.equals(cycleTimezone, other.cycleTimezone)
+ && Objects.equals(template, other.template);
}
return false;
}
diff --git a/core/java/android/net/NetworkStats.java b/core/java/android/net/NetworkStats.java
index 9cb904d..a7aae2a 100644
--- a/core/java/android/net/NetworkStats.java
+++ b/core/java/android/net/NetworkStats.java
@@ -23,12 +23,12 @@ import android.util.SparseBooleanArray;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
-import com.android.internal.util.Objects;
import java.io.CharArrayWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
+import java.util.Objects;
/**
* Collection of active network statistics. Can contain summary details across
@@ -337,7 +337,7 @@ public class NetworkStats implements Parcelable {
public int findIndex(String iface, int uid, int set, int tag) {
for (int i = 0; i < size; i++) {
if (uid == this.uid[i] && set == this.set[i] && tag == this.tag[i]
- && Objects.equal(iface, this.iface[i])) {
+ && Objects.equals(iface, this.iface[i])) {
return i;
}
}
@@ -362,7 +362,7 @@ public class NetworkStats implements Parcelable {
}
if (uid == this.uid[i] && set == this.set[i] && tag == this.tag[i]
- && Objects.equal(iface, this.iface[i])) {
+ && Objects.equals(iface, this.iface[i])) {
return i;
}
}
diff --git a/core/java/android/net/NetworkTemplate.java b/core/java/android/net/NetworkTemplate.java
index c189ba4..27197cc 100644
--- a/core/java/android/net/NetworkTemplate.java
+++ b/core/java/android/net/NetworkTemplate.java
@@ -34,8 +34,9 @@ import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
+import java.util.Objects;
+
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.Objects;
/**
* Template definition used to generically match {@link NetworkIdentity},
@@ -176,7 +177,7 @@ public class NetworkTemplate implements Parcelable {
@Override
public int hashCode() {
- return Objects.hashCode(mMatchRule, mSubscriberId, mNetworkId);
+ return Objects.hash(mMatchRule, mSubscriberId, mNetworkId);
}
@Override
@@ -184,8 +185,8 @@ public class NetworkTemplate implements Parcelable {
if (obj instanceof NetworkTemplate) {
final NetworkTemplate other = (NetworkTemplate) obj;
return mMatchRule == other.mMatchRule
- && Objects.equal(mSubscriberId, other.mSubscriberId)
- && Objects.equal(mNetworkId, other.mNetworkId);
+ && Objects.equals(mSubscriberId, other.mSubscriberId)
+ && Objects.equals(mNetworkId, other.mNetworkId);
}
return false;
}
@@ -235,7 +236,7 @@ public class NetworkTemplate implements Parcelable {
return true;
} else {
return ((sForceAllNetworkTypes || contains(DATA_USAGE_NETWORK_TYPES, ident.mType))
- && Objects.equal(mSubscriberId, ident.mSubscriberId));
+ && Objects.equals(mSubscriberId, ident.mSubscriberId));
}
}
@@ -280,7 +281,7 @@ public class NetworkTemplate implements Parcelable {
private boolean matchesWifi(NetworkIdentity ident) {
switch (ident.mType) {
case TYPE_WIFI:
- return Objects.equal(
+ return Objects.equals(
removeDoubleQuotes(mNetworkId), removeDoubleQuotes(ident.mNetworkId));
default:
return false;
diff --git a/core/java/android/net/ProxyDataTracker.java b/core/java/android/net/ProxyDataTracker.java
new file mode 100644
index 0000000..461e8b8
--- /dev/null
+++ b/core/java/android/net/ProxyDataTracker.java
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.net;
+
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.Messenger;
+import android.os.RemoteException;
+import android.os.UserHandle;
+import android.util.Log;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * A data tracker responsible for bringing up and tearing down the system proxy server.
+ *
+ * {@hide}
+ */
+public class ProxyDataTracker extends BaseNetworkStateTracker {
+ private static final String TAG = "ProxyDataTracker";
+ private static final String NETWORK_TYPE = "PROXY";
+
+ // TODO: investigate how to get these DNS addresses from the system.
+ private static final String DNS1 = "8.8.8.8";
+ private static final String DNS2 = "8.8.4.4";
+ private static final String REASON_ENABLED = "enabled";
+ private static final String REASON_DISABLED = "disabled";
+ private static final String REASON_PROXY_DOWN = "proxy_down";
+
+ private static final int MSG_TEAR_DOWN_REQUEST = 1;
+ private static final int MSG_SETUP_REQUEST = 2;
+
+ private static final String PERMISSION_PROXY_STATUS_SENDER =
+ "android.permission.ACCESS_NETWORK_CONDITIONS";
+ private static final String ACTION_PROXY_STATUS_CHANGE =
+ "com.android.net.PROXY_STATUS_CHANGE";
+ private static final String KEY_IS_PROXY_AVAILABLE = "is_proxy_available";
+ private static final String KEY_REPLY_TO_MESSENGER_BINDER = "reply_to_messenger_binder";
+ private static final String KEY_REPLY_TO_MESSENGER_BINDER_BUNDLE =
+ "reply_to_messenger_binder_bundle";
+
+ private Handler mTarget;
+ private Messenger mProxyStatusService;
+ private AtomicBoolean mReconnectRequested = new AtomicBoolean(false);
+ private AtomicBoolean mIsProxyAvailable = new AtomicBoolean(false);
+ private final AtomicInteger mDefaultGatewayAddr = new AtomicInteger(0);
+
+ private final BroadcastReceiver mProxyStatusServiceListener = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(ACTION_PROXY_STATUS_CHANGE)) {
+ mIsProxyAvailable.set(intent.getBooleanExtra(KEY_IS_PROXY_AVAILABLE, false));
+ if (mIsProxyAvailable.get()) {
+ Bundle bundle = intent.getBundleExtra(KEY_REPLY_TO_MESSENGER_BINDER_BUNDLE);
+ if (bundle == null || bundle.getBinder(KEY_REPLY_TO_MESSENGER_BINDER) == null) {
+ Log.e(TAG, "no messenger binder in the intent to send future requests");
+ mIsProxyAvailable.set(false);
+ return;
+ }
+ mProxyStatusService =
+ new Messenger(bundle.getBinder(KEY_REPLY_TO_MESSENGER_BINDER));
+ // If there is a pending reconnect request, do it now.
+ if (mReconnectRequested.get()) {
+ reconnect();
+ }
+ } else {
+ setDetailedState(NetworkInfo.DetailedState.DISCONNECTED,
+ REASON_PROXY_DOWN, null);
+ }
+ } else {
+ Log.d(TAG, "Unrecognized broadcast intent");
+ }
+ }
+ };
+
+ /**
+ * Create a new ProxyDataTracker
+ */
+ public ProxyDataTracker() {
+ mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_PROXY, 0, NETWORK_TYPE, "");
+ mLinkProperties = new LinkProperties();
+ mLinkCapabilities = new LinkCapabilities();
+ mNetworkInfo.setIsAvailable(true);
+ try {
+ mLinkProperties.addDns(InetAddress.getByName(DNS1));
+ mLinkProperties.addDns(InetAddress.getByName(DNS2));
+ } catch (UnknownHostException e) {
+ Log.e(TAG, "Could not add DNS address", e);
+ }
+ }
+
+ public Object Clone() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException();
+ }
+
+ @Override
+ public void startMonitoring(Context context, Handler target) {
+ mContext = context;
+ mTarget = target;
+ mContext.registerReceiver(mProxyStatusServiceListener,
+ new IntentFilter(ACTION_PROXY_STATUS_CHANGE),
+ PERMISSION_PROXY_STATUS_SENDER,
+ null);
+ }
+
+ /**
+ * Disable connectivity to the network.
+ */
+ public boolean teardown() {
+ setTeardownRequested(true);
+ mReconnectRequested.set(false);
+ try {
+ if (mIsProxyAvailable.get() && mProxyStatusService != null) {
+ mProxyStatusService.send(Message.obtain(null, MSG_TEAR_DOWN_REQUEST));
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to connect to proxy status service", e);
+ return false;
+ }
+ setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, REASON_DISABLED, null);
+ return true;
+ }
+
+ /**
+ * Re-enable proxy data connectivity after a {@link #teardown()}.
+ */
+ public boolean reconnect() {
+ mReconnectRequested.set(true);
+ setTeardownRequested(false);
+ if (!mIsProxyAvailable.get()) {
+ Log.w(TAG, "Reconnect requested even though proxy service is not up. Bailing.");
+ return false;
+ }
+ setDetailedState(NetworkInfo.DetailedState.CONNECTING, REASON_ENABLED, null);
+
+ try {
+ mProxyStatusService.send(Message.obtain(null, MSG_SETUP_REQUEST));
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to connect to proxy status service", e);
+ setDetailedState(NetworkInfo.DetailedState.DISCONNECTED, REASON_PROXY_DOWN, null);
+ return false;
+ }
+ // We'll assume proxy is set up successfully. If not, a status change broadcast will be
+ // received afterwards to indicate any failure.
+ setDetailedState(NetworkInfo.DetailedState.CONNECTED, REASON_ENABLED, null);
+ return true;
+ }
+
+ /**
+ * Fetch default gateway address for the network
+ */
+ public int getDefaultGatewayAddr() {
+ return mDefaultGatewayAddr.get();
+ }
+
+ /**
+ * Return the system properties name associated with the tcp buffer sizes
+ * for this network.
+ */
+ public String getTcpBufferSizesPropName() {
+ return "net.tcp.buffersize.wifi";
+ }
+
+ /**
+ * Record the detailed state of a network, and if it is a
+ * change from the previous state, send a notification to
+ * any listeners.
+ * @param state the new @{code DetailedState}
+ * @param reason a {@code String} indicating a reason for the state change,
+ * if one was supplied. May be {@code null}.
+ * @param extraInfo optional {@code String} providing extra information about the state change
+ */
+ private void setDetailedState(NetworkInfo.DetailedState state, String reason,
+ String extraInfo) {
+ mNetworkInfo.setDetailedState(state, reason, extraInfo);
+ Message msg = mTarget.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
+ msg.sendToTarget();
+ }
+}
diff --git a/core/java/android/net/SSLCertificateSocketFactory.java b/core/java/android/net/SSLCertificateSocketFactory.java
index 208b212..b0278d3 100644
--- a/core/java/android/net/SSLCertificateSocketFactory.java
+++ b/core/java/android/net/SSLCertificateSocketFactory.java
@@ -533,7 +533,7 @@ public class SSLCertificateSocketFactory extends SSLSocketFactory {
@Override
public String[] getDefaultCipherSuites() {
- return getDelegate().getSupportedCipherSuites();
+ return getDelegate().getDefaultCipherSuites();
}
@Override
diff --git a/core/java/android/net/arp/ArpPeer.java b/core/java/android/net/arp/ArpPeer.java
deleted file mode 100644
index 2013b11..0000000
--- a/core/java/android/net/arp/ArpPeer.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (C) 2012 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.
- */
-
-package android.net.arp;
-
-import android.net.LinkAddress;
-import android.net.LinkProperties;
-import android.net.RouteInfo;
-import android.os.SystemClock;
-import android.util.Log;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Inet6Address;
-import java.net.SocketException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Arrays;
-
-import libcore.net.RawSocket;
-
-/**
- * This class allows simple ARP exchanges over an uninitialized network
- * interface.
- *
- * @hide
- */
-public class ArpPeer {
- private static final boolean DBG = false;
- private static final String TAG = "ArpPeer";
- private String mInterfaceName;
- private final InetAddress mMyAddr;
- private final byte[] mMyMac = new byte[6];
- private final InetAddress mPeer;
- private final RawSocket mSocket;
- private final byte[] L2_BROADCAST; // TODO: refactor from DhcpClient.java
- private static final int MAX_LENGTH = 1500; // refactor from DhcpPacket.java
- private static final int ETHERNET_TYPE = 1;
- private static final int ARP_LENGTH = 28;
- private static final int MAC_ADDR_LENGTH = 6;
- private static final int IPV4_LENGTH = 4;
-
- public ArpPeer(String interfaceName, InetAddress myAddr, String mac,
- InetAddress peer) throws SocketException {
- mInterfaceName = interfaceName;
- mMyAddr = myAddr;
-
- if (mac != null) {
- for (int i = 0; i < MAC_ADDR_LENGTH; i++) {
- mMyMac[i] = (byte) Integer.parseInt(mac.substring(
- i*3, (i*3) + 2), 16);
- }
- }
-
- if (myAddr instanceof Inet6Address || peer instanceof Inet6Address) {
- throw new IllegalArgumentException("IPv6 unsupported");
- }
-
- mPeer = peer;
- L2_BROADCAST = new byte[MAC_ADDR_LENGTH];
- Arrays.fill(L2_BROADCAST, (byte) 0xFF);
-
- mSocket = new RawSocket(mInterfaceName, RawSocket.ETH_P_ARP);
- }
-
- /**
- * Returns the MAC address (or null if timeout) for the requested
- * peer.
- */
- public byte[] doArp(int timeoutMillis) {
- ByteBuffer buf = ByteBuffer.allocate(MAX_LENGTH);
- byte[] desiredIp = mPeer.getAddress();
- long timeout = SystemClock.elapsedRealtime() + timeoutMillis;
-
- // construct ARP request packet, using a ByteBuffer as a
- // convenient container
- buf.clear();
- buf.order(ByteOrder.BIG_ENDIAN);
-
- buf.putShort((short) ETHERNET_TYPE); // Ethernet type, 16 bits
- buf.putShort(RawSocket.ETH_P_IP); // Protocol type IP, 16 bits
- buf.put((byte)MAC_ADDR_LENGTH); // MAC address length, 6 bytes
- buf.put((byte)IPV4_LENGTH); // IPv4 protocol size
- buf.putShort((short) 1); // ARP opcode 1: 'request'
- buf.put(mMyMac); // six bytes: sender MAC
- buf.put(mMyAddr.getAddress()); // four bytes: sender IP address
- buf.put(new byte[MAC_ADDR_LENGTH]); // target MAC address: unknown
- buf.put(desiredIp); // target IP address, 4 bytes
- buf.flip();
- mSocket.write(L2_BROADCAST, buf.array(), 0, buf.limit());
-
- byte[] recvBuf = new byte[MAX_LENGTH];
-
- while (SystemClock.elapsedRealtime() < timeout) {
- long duration = (long) timeout - SystemClock.elapsedRealtime();
- int readLen = mSocket.read(recvBuf, 0, recvBuf.length, -1,
- (int) duration);
-
- // Verify packet details. see RFC 826
- if ((readLen >= ARP_LENGTH) // trailing bytes at times
- && (recvBuf[0] == 0) && (recvBuf[1] == ETHERNET_TYPE) // type Ethernet
- && (recvBuf[2] == 8) && (recvBuf[3] == 0) // protocol IP
- && (recvBuf[4] == MAC_ADDR_LENGTH) // mac length
- && (recvBuf[5] == IPV4_LENGTH) // IPv4 protocol size
- && (recvBuf[6] == 0) && (recvBuf[7] == 2) // ARP reply
- // verify desired IP address
- && (recvBuf[14] == desiredIp[0]) && (recvBuf[15] == desiredIp[1])
- && (recvBuf[16] == desiredIp[2]) && (recvBuf[17] == desiredIp[3]))
- {
- // looks good. copy out the MAC
- byte[] result = new byte[MAC_ADDR_LENGTH];
- System.arraycopy(recvBuf, 8, result, 0, MAC_ADDR_LENGTH);
- return result;
- }
- }
-
- return null;
- }
-
- public static boolean doArp(String myMacAddress, LinkProperties linkProperties,
- int timeoutMillis, int numArpPings, int minArpResponses) {
- String interfaceName = linkProperties.getInterfaceName();
- InetAddress inetAddress = null;
- InetAddress gateway = null;
- boolean success;
-
- for (LinkAddress la : linkProperties.getLinkAddresses()) {
- inetAddress = la.getAddress();
- break;
- }
-
- for (RouteInfo route : linkProperties.getRoutes()) {
- gateway = route.getGateway();
- break;
- }
-
- try {
- ArpPeer peer = new ArpPeer(interfaceName, inetAddress, myMacAddress, gateway);
- int responses = 0;
- for (int i=0; i < numArpPings; i++) {
- if(peer.doArp(timeoutMillis) != null) responses++;
- }
- if (DBG) Log.d(TAG, "ARP test result: " + responses + "/" + numArpPings);
- success = (responses >= minArpResponses);
- peer.close();
- } catch (SocketException se) {
- //Consider an Arp socket creation issue as a successful Arp
- //test to avoid any wifi connectivity issues
- Log.e(TAG, "ARP test initiation failure: " + se);
- success = true;
- }
- return success;
- }
-
- public void close() {
- try {
- mSocket.close();
- } catch (IOException ex) {
- }
- }
-}
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 9ada6e6..b1a9ea3 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -460,7 +460,7 @@ public abstract class BatteryStats implements Parcelable {
public byte batteryHealth;
public byte batteryPlugType;
- public char batteryTemperature;
+ public short batteryTemperature;
public char batteryVoltage;
// Constants from SCREEN_BRIGHTNESS_*
@@ -537,7 +537,7 @@ public abstract class BatteryStats implements Parcelable {
batteryHealth = (byte)((bat>>20)&0xf);
batteryPlugType = (byte)((bat>>24)&0xf);
bat = src.readInt();
- batteryTemperature = (char)(bat&0xffff);
+ batteryTemperature = (short)(bat&0xffff);
batteryVoltage = (char)((bat>>16)&0xffff);
states = src.readInt();
}
@@ -606,7 +606,7 @@ public abstract class BatteryStats implements Parcelable {
if (DEBUG) Slog.i(TAG, "WRITE DELTA: batteryToken=0x"
+ Integer.toHexString(batteryLevelInt)
+ " batteryLevel=" + batteryLevel
- + " batteryTemp=" + (int)batteryTemperature
+ + " batteryTemp=" + batteryTemperature
+ " batteryVolt=" + (int)batteryVoltage);
}
if (stateIntChanged) {
@@ -621,8 +621,8 @@ public abstract class BatteryStats implements Parcelable {
}
private int buildBatteryLevelInt() {
- return ((((int)batteryLevel)<<24)&0xff000000)
- | ((((int)batteryTemperature)<<14)&0x00ffc000)
+ return ((((int)batteryLevel)<<25)&0xfe000000)
+ | ((((int)batteryTemperature)<<14)&0x01ffc000)
| (((int)batteryVoltage)&0x00003fff);
}
@@ -658,13 +658,13 @@ public abstract class BatteryStats implements Parcelable {
if ((firstToken&DELTA_BATTERY_LEVEL_FLAG) != 0) {
int batteryLevelInt = src.readInt();
- batteryLevel = (byte)((batteryLevelInt>>24)&0xff);
- batteryTemperature = (char)((batteryLevelInt>>14)&0x3ff);
+ batteryLevel = (byte)((batteryLevelInt>>25)&0x7f);
+ batteryTemperature = (short)((batteryLevelInt<<7)>>21);
batteryVoltage = (char)(batteryLevelInt&0x3fff);
if (DEBUG) Slog.i(TAG, "READ DELTA: batteryToken=0x"
+ Integer.toHexString(batteryLevelInt)
+ " batteryLevel=" + batteryLevel
- + " batteryTemp=" + (int)batteryTemperature
+ + " batteryTemp=" + batteryTemperature
+ " batteryVolt=" + (int)batteryVoltage);
}
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index f4a8391..ba71605 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -56,7 +56,7 @@ public class Binder implements IBinder {
private static String sDumpDisabled = null;
/* mObject is used by native code, do not remove or rename */
- private int mObject;
+ private long mObject;
private IInterface mOwner;
private String mDescriptor;
@@ -390,7 +390,7 @@ public class Binder implements IBinder {
private native final void destroy();
// Entry point from android_util_Binder.cpp's onTransact
- private boolean execTransact(int code, int dataObj, int replyObj,
+ private boolean execTransact(int code, long dataObj, long replyObj,
int flags) {
Parcel data = Parcel.obtain(dataObj);
Parcel reply = Parcel.obtain(replyObj);
@@ -499,6 +499,6 @@ final class BinderProxy implements IBinder {
}
final private WeakReference mSelf;
- private int mObject;
- private int mOrgue;
+ private long mObject;
+ private long mOrgue;
}
diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java
index f9c1d31..af57507 100644
--- a/core/java/android/os/Bundle.java
+++ b/core/java/android/os/Bundle.java
@@ -380,7 +380,7 @@ public final class Bundle implements Parcelable, Cloneable {
SparseArray<? extends Parcelable> array =
(SparseArray<? extends Parcelable>) obj;
for (int n = array.size() - 1; n >= 0; n--) {
- if ((array.get(n).describeContents()
+ if ((array.valueAt(n).describeContents()
& Parcelable.CONTENTS_FILE_DESCRIPTOR) != 0) {
fdFound = true;
break;
diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java
index 974bf8d..2de1204 100644
--- a/core/java/android/os/Debug.java
+++ b/core/java/android/os/Debug.java
@@ -578,7 +578,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
* tracing.
*/
public static void startMethodTracing() {
- VMDebug.startMethodTracing(DEFAULT_TRACE_FILE_PATH, 0, 0);
+ VMDebug.startMethodTracing(DEFAULT_TRACE_FILE_PATH, 0, 0, false, 0);
}
/**
@@ -589,7 +589,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
* information about reading trace files.
*
* @param traceName Name for the trace log file to create.
- * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace".
+ * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace".
* If the files already exist, they will be truncated.
* If the trace file given does not end in ".trace", it will be appended for you.
*/
@@ -604,7 +604,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for
* information about reading trace files.
* @param traceName Name for the trace log file to create.
- * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace".
+ * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace".
* If the files already exist, they will be truncated.
* If the trace file given does not end in ".trace", it will be appended for you.
*
@@ -627,26 +627,54 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
* in relative terms (e.g. was run #1 faster than run #2). The times
* for native methods will not change, so don't try to use this to
* compare the performance of interpreted and native implementations of the
- * same method. As an alternative, consider using "native" tracing
- * in the emulator via {@link #startNativeTracing()}.
+ * same method. As an alternative, consider using sampling-based method
+ * tracing via {@link #startMethodTracingSampling(String, int, int)} or
+ * "native" tracing in the emulator via {@link #startNativeTracing()}.
* </p>
*
* @param traceName Name for the trace log file to create.
- * If no name argument is given, this value defaults to "/sdcard/dmtrace.trace".
+ * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace".
* If the files already exist, they will be truncated.
* If the trace file given does not end in ".trace", it will be appended for you.
* @param bufferSize The maximum amount of trace data we gather. If not given, it defaults to 8MB.
+ * @param flags Flags to control method tracing. The only one that is currently defined is {@link #TRACE_COUNT_ALLOCS}.
*/
public static void startMethodTracing(String traceName, int bufferSize,
int flags) {
+ VMDebug.startMethodTracing(fixTraceName(traceName), bufferSize, flags, false, 0);
+ }
+
+ /**
+ * Start sampling-based method tracing, specifying the trace log file name,
+ * the buffer size, and the sampling interval. The trace files will be put
+ * under "/sdcard" unless an absolute path is given. See <a
+ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a>
+ * for information about reading trace files.
+ *
+ * @param traceName Name for the trace log file to create.
+ * If {@code traceName} is null, this value defaults to "/sdcard/dmtrace.trace".
+ * If the files already exist, they will be truncated.
+ * If the trace file given does not end in ".trace", it will be appended for you.
+ * @param bufferSize The maximum amount of trace data we gather. If not given, it defaults to 8MB.
+ * @param intervalUs The amount of time between each sample in microseconds.
+ */
+ public static void startMethodTracingSampling(String traceName,
+ int bufferSize, int intervalUs) {
+ VMDebug.startMethodTracing(fixTraceName(traceName), bufferSize, 0, true, intervalUs);
+ }
- String pathName = traceName;
- if (pathName.charAt(0) != '/')
- pathName = DEFAULT_TRACE_PATH_PREFIX + pathName;
- if (!pathName.endsWith(DEFAULT_TRACE_EXTENSION))
- pathName = pathName + DEFAULT_TRACE_EXTENSION;
+ /**
+ * Formats name of trace log file for method tracing.
+ */
+ private static String fixTraceName(String traceName) {
+ if (traceName == null)
+ traceName = DEFAULT_TRACE_FILE_PATH;
+ if (traceName.charAt(0) != '/')
+ traceName = DEFAULT_TRACE_PATH_PREFIX + traceName;
+ if (!traceName.endsWith(DEFAULT_TRACE_EXTENSION))
+ traceName = traceName + DEFAULT_TRACE_EXTENSION;
- VMDebug.startMethodTracing(pathName, bufferSize, flags);
+ return traceName;
}
/**
@@ -660,7 +688,7 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
*/
public static void startMethodTracing(String traceName, FileDescriptor fd,
int bufferSize, int flags) {
- VMDebug.startMethodTracing(traceName, fd, bufferSize, flags);
+ VMDebug.startMethodTracing(traceName, fd, bufferSize, flags, false, 0);
}
/**
diff --git a/core/java/android/os/FactoryTest.java b/core/java/android/os/FactoryTest.java
index ec99697..7a252f9 100644
--- a/core/java/android/os/FactoryTest.java
+++ b/core/java/android/os/FactoryTest.java
@@ -25,6 +25,20 @@ package android.os;
* {@hide}
*/
public final class FactoryTest {
+ public static final int FACTORY_TEST_OFF = 0;
+ public static final int FACTORY_TEST_LOW_LEVEL = 1;
+ public static final int FACTORY_TEST_HIGH_LEVEL = 2;
+
+ /**
+ * Gets the current factory test mode.
+ *
+ * @return One of: {@link #FACTORY_TEST_OFF}, {@link #FACTORY_TEST_LOW_LEVEL},
+ * or {@link #FACTORY_TEST_HIGH_LEVEL}.
+ */
+ public static int getMode() {
+ return SystemProperties.getInt("ro.factorytest", FACTORY_TEST_OFF);
+ }
+
/**
* When true, long-press on power should immediately cause the device to
* shut down, without prompting the user.
diff --git a/core/java/android/os/MemoryFile.java b/core/java/android/os/MemoryFile.java
index e8148f7..ee7a4c6 100644
--- a/core/java/android/os/MemoryFile.java
+++ b/core/java/android/os/MemoryFile.java
@@ -43,19 +43,19 @@ public class MemoryFile
private static native FileDescriptor native_open(String name, int length) throws IOException;
// returns memory address for ashmem region
- private static native int native_mmap(FileDescriptor fd, int length, int mode)
+ private static native long native_mmap(FileDescriptor fd, int length, int mode)
throws IOException;
- private static native void native_munmap(int addr, int length) throws IOException;
+ private static native void native_munmap(long addr, int length) throws IOException;
private static native void native_close(FileDescriptor fd);
- private static native int native_read(FileDescriptor fd, int address, byte[] buffer,
+ private static native int native_read(FileDescriptor fd, long address, byte[] buffer,
int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException;
- private static native void native_write(FileDescriptor fd, int address, byte[] buffer,
+ private static native void native_write(FileDescriptor fd, long address, byte[] buffer,
int srcOffset, int destOffset, int count, boolean isUnpinned) throws IOException;
private static native void native_pin(FileDescriptor fd, boolean pin) throws IOException;
private static native int native_get_size(FileDescriptor fd) throws IOException;
private FileDescriptor mFD; // ashmem file descriptor
- private int mAddress; // address of ashmem memory
+ private long mAddress; // address of ashmem memory
private int mLength; // total length of our ashmem region
private boolean mAllowPurging = false; // true if our ashmem region is unpinned
diff --git a/core/java/android/os/MessageQueue.java b/core/java/android/os/MessageQueue.java
index 799de5c..75f9813 100644
--- a/core/java/android/os/MessageQueue.java
+++ b/core/java/android/os/MessageQueue.java
@@ -35,7 +35,7 @@ public final class MessageQueue {
private final boolean mQuitAllowed;
@SuppressWarnings("unused")
- private int mPtr; // used by native code
+ private long mPtr; // used by native code
Message mMessages;
private final ArrayList<IdleHandler> mIdleHandlers = new ArrayList<IdleHandler>();
@@ -49,11 +49,11 @@ public final class MessageQueue {
// Barriers are indicated by messages with a null target whose arg1 field carries the token.
private int mNextBarrierToken;
- private native static int nativeInit();
- private native static void nativeDestroy(int ptr);
- private native static void nativePollOnce(int ptr, int timeoutMillis);
- private native static void nativeWake(int ptr);
- private native static boolean nativeIsIdling(int ptr);
+ private native static long nativeInit();
+ private native static void nativeDestroy(long ptr);
+ private native static void nativePollOnce(long ptr, int timeoutMillis);
+ private native static void nativeWake(long ptr);
+ private native static boolean nativeIsIdling(long ptr);
/**
* Callback interface for discovering when a thread is going to block
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 94b9617..6716098 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -182,7 +182,7 @@ public final class Parcel {
private static final String TAG = "Parcel";
@SuppressWarnings({"UnusedDeclaration"})
- private int mNativePtr; // used by native code
+ private long mNativePtr; // used by native code
/**
* Flag indicating if {@link #mNativePtr} was allocated by this object,
@@ -232,47 +232,47 @@ public final class Parcel {
private static final int EX_NETWORK_MAIN_THREAD = -6;
private static final int EX_HAS_REPLY_HEADER = -128; // special; see below
- private static native int nativeDataSize(int nativePtr);
- private static native int nativeDataAvail(int nativePtr);
- private static native int nativeDataPosition(int nativePtr);
- private static native int nativeDataCapacity(int nativePtr);
- private static native void nativeSetDataSize(int nativePtr, int size);
- private static native void nativeSetDataPosition(int nativePtr, int pos);
- private static native void nativeSetDataCapacity(int nativePtr, int size);
-
- private static native boolean nativePushAllowFds(int nativePtr, boolean allowFds);
- private static native void nativeRestoreAllowFds(int nativePtr, boolean lastValue);
-
- private static native void nativeWriteByteArray(int nativePtr, byte[] b, int offset, int len);
- private static native void nativeWriteInt(int nativePtr, int val);
- private static native void nativeWriteLong(int nativePtr, long val);
- private static native void nativeWriteFloat(int nativePtr, float val);
- private static native void nativeWriteDouble(int nativePtr, double val);
- private static native void nativeWriteString(int nativePtr, String val);
- private static native void nativeWriteStrongBinder(int nativePtr, IBinder val);
- private static native void nativeWriteFileDescriptor(int nativePtr, FileDescriptor val);
-
- private static native byte[] nativeCreateByteArray(int nativePtr);
- private static native int nativeReadInt(int nativePtr);
- private static native long nativeReadLong(int nativePtr);
- private static native float nativeReadFloat(int nativePtr);
- private static native double nativeReadDouble(int nativePtr);
- private static native String nativeReadString(int nativePtr);
- private static native IBinder nativeReadStrongBinder(int nativePtr);
- private static native FileDescriptor nativeReadFileDescriptor(int nativePtr);
-
- private static native int nativeCreate();
- private static native void nativeFreeBuffer(int nativePtr);
- private static native void nativeDestroy(int nativePtr);
-
- private static native byte[] nativeMarshall(int nativePtr);
+ private static native int nativeDataSize(long nativePtr);
+ private static native int nativeDataAvail(long nativePtr);
+ private static native int nativeDataPosition(long nativePtr);
+ private static native int nativeDataCapacity(long nativePtr);
+ private static native void nativeSetDataSize(long nativePtr, int size);
+ private static native void nativeSetDataPosition(long nativePtr, int pos);
+ private static native void nativeSetDataCapacity(long nativePtr, int size);
+
+ private static native boolean nativePushAllowFds(long nativePtr, boolean allowFds);
+ private static native void nativeRestoreAllowFds(long nativePtr, boolean lastValue);
+
+ private static native void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len);
+ private static native void nativeWriteInt(long nativePtr, int val);
+ private static native void nativeWriteLong(long nativePtr, long val);
+ private static native void nativeWriteFloat(long nativePtr, float val);
+ private static native void nativeWriteDouble(long nativePtr, double val);
+ private static native void nativeWriteString(long nativePtr, String val);
+ private static native void nativeWriteStrongBinder(long nativePtr, IBinder val);
+ private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val);
+
+ private static native byte[] nativeCreateByteArray(long nativePtr);
+ private static native int nativeReadInt(long nativePtr);
+ private static native long nativeReadLong(long nativePtr);
+ private static native float nativeReadFloat(long nativePtr);
+ private static native double nativeReadDouble(long nativePtr);
+ private static native String nativeReadString(long nativePtr);
+ private static native IBinder nativeReadStrongBinder(long nativePtr);
+ private static native FileDescriptor nativeReadFileDescriptor(long nativePtr);
+
+ private static native long nativeCreate();
+ private static native void nativeFreeBuffer(long nativePtr);
+ private static native void nativeDestroy(long nativePtr);
+
+ private static native byte[] nativeMarshall(long nativePtr);
private static native void nativeUnmarshall(
- int nativePtr, byte[] data, int offest, int length);
+ long nativePtr, byte[] data, int offest, int length);
private static native void nativeAppendFrom(
- int thisNativePtr, int otherNativePtr, int offset, int length);
- private static native boolean nativeHasFileDescriptors(int nativePtr);
- private static native void nativeWriteInterfaceToken(int nativePtr, String interfaceName);
- private static native void nativeEnforceInterface(int nativePtr, String interfaceName);
+ long thisNativePtr, long otherNativePtr, int offset, int length);
+ private static native boolean nativeHasFileDescriptors(long nativePtr);
+ private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName);
+ private static native void nativeEnforceInterface(long nativePtr, String interfaceName);
public final static Parcelable.Creator<String> STRING_CREATOR
= new Parcelable.Creator<String>() {
@@ -2229,6 +2229,11 @@ public final class Parcel {
mCreators = new HashMap<ClassLoader,HashMap<String,Parcelable.Creator>>();
static protected final Parcel obtain(int obj) {
+ throw new UnsupportedOperationException();
+ }
+
+ /** @hide */
+ static protected final Parcel obtain(long obj) {
final Parcel[] pool = sHolderPool;
synchronized (pool) {
Parcel p;
@@ -2247,7 +2252,7 @@ public final class Parcel {
return new Parcel(obj);
}
- private Parcel(int nativePtr) {
+ private Parcel(long nativePtr) {
if (DEBUG_RECYCLE) {
mStack = new RuntimeException();
}
@@ -2255,7 +2260,7 @@ public final class Parcel {
init(nativePtr);
}
- private void init(int nativePtr) {
+ private void init(long nativePtr) {
if (nativePtr != 0) {
mNativePtr = nativePtr;
mOwnsNativeParcelObject = false;
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 5e0d489..86ef479 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -191,6 +191,18 @@ public final class PowerManager {
public static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 0x00000020;
/**
+ * Wake lock level: Put the screen in a low power state and allow the CPU to suspend
+ * if no other wake locks are held.
+ * <p>
+ * This is used by the dream manager to implement doze mode. It currently
+ * has no effect unless the power manager is in the dozing state.
+ * </p>
+ *
+ * {@hide}
+ */
+ public static final int DOZE_WAKE_LOCK = 0x00000040;
+
+ /**
* Mask for the wake lock level component of a combined wake lock level and flags integer.
*
* @hide
@@ -418,6 +430,7 @@ public final class PowerManager {
case SCREEN_BRIGHT_WAKE_LOCK:
case FULL_WAKE_LOCK:
case PROXIMITY_SCREEN_OFF_WAKE_LOCK:
+ case DOZE_WAKE_LOCK:
break;
default:
throw new IllegalArgumentException("Must specify a valid wake lock level.");
diff --git a/core/java/android/os/PowerManagerInternal.java b/core/java/android/os/PowerManagerInternal.java
new file mode 100644
index 0000000..cb3d528
--- /dev/null
+++ b/core/java/android/os/PowerManagerInternal.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.os;
+
+import android.view.WindowManagerPolicy;
+
+/**
+ * Power manager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+public abstract class PowerManagerInternal {
+ /**
+ * Used by the window manager to override the screen brightness based on the
+ * current foreground activity.
+ *
+ * This method must only be called by the window manager.
+ *
+ * @param brightness The overridden brightness, or -1 to disable the override.
+ */
+ public abstract void setScreenBrightnessOverrideFromWindowManager(int brightness);
+
+ /**
+ * Used by the window manager to override the button brightness based on the
+ * current foreground activity.
+ *
+ * This method must only be called by the window manager.
+ *
+ * @param brightness The overridden brightness, or -1 to disable the override.
+ */
+ public abstract void setButtonBrightnessOverrideFromWindowManager(int brightness);
+
+ /**
+ * Used by the window manager to override the user activity timeout based on the
+ * current foreground activity. It can only be used to make the timeout shorter
+ * than usual, not longer.
+ *
+ * This method must only be called by the window manager.
+ *
+ * @param timeoutMillis The overridden timeout, or -1 to disable the override.
+ */
+ public abstract void setUserActivityTimeoutOverrideFromWindowManager(long timeoutMillis);
+
+ // TODO: Remove this and retrieve as a local service instead.
+ public abstract void setPolicy(WindowManagerPolicy policy);
+}
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index cf9ddb3..057f516 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -377,7 +377,7 @@ public class Process {
* @param gids Additional group-ids associated with the process.
* @param debugFlags Additional flags.
* @param targetSdkVersion The target SDK version for the app.
- * @param seInfo null-ok SE Android information for the new process.
+ * @param seInfo null-ok SELinux information for the new process.
* @param zygoteArgs Additional arguments to supply to the zygote process.
*
* @return An object that describes the result of the attempt to start the process.
@@ -557,7 +557,7 @@ public class Process {
* new process should setgroup() to.
* @param debugFlags Additional flags.
* @param targetSdkVersion The target SDK version for the app.
- * @param seInfo null-ok SE Android information for the new process.
+ * @param seInfo null-ok SELinux information for the new process.
* @param extraArgs Additional arguments to supply to the zygote process.
* @return An object that describes the result of the attempt to start the process.
* @throws ZygoteStartFailedEx if process start failed for any reason
@@ -892,19 +892,6 @@ public class Process {
}
/**
- * Set the out-of-memory badness adjustment for a process.
- *
- * @param pid The process identifier to set.
- * @param amt Adjustment value -- linux allows -16 to +15.
- *
- * @return Returns true if the underlying system supports this
- * feature, else false.
- *
- * {@hide}
- */
- public static final native boolean setOomAdj(int pid, int amt);
-
- /**
* Adjust the swappiness level for a process.
*
* @param pid The process identifier to set.
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index 5e20dec..f671ed9 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -32,10 +32,8 @@ import java.security.GeneralSecurityException;
import java.security.PublicKey;
import java.security.Signature;
import java.security.SignatureException;
-import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
-import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
@@ -48,7 +46,7 @@ import org.apache.harmony.security.asn1.BerInputStream;
import org.apache.harmony.security.pkcs7.ContentInfo;
import org.apache.harmony.security.pkcs7.SignedData;
import org.apache.harmony.security.pkcs7.SignerInfo;
-import org.apache.harmony.security.provider.cert.X509CertImpl;
+import org.apache.harmony.security.x509.Certificate;
/**
* RecoverySystem contains methods for interacting with the Android
@@ -93,9 +91,9 @@ public class RecoverySystem {
}
/** @return the set of certs that can be used to sign an OTA package. */
- private static HashSet<Certificate> getTrustedCerts(File keystore)
+ private static HashSet<X509Certificate> getTrustedCerts(File keystore)
throws IOException, GeneralSecurityException {
- HashSet<Certificate> trusted = new HashSet<Certificate>();
+ HashSet<X509Certificate> trusted = new HashSet<X509Certificate>();
if (keystore == null) {
keystore = DEFAULT_KEYSTORE;
}
@@ -107,7 +105,7 @@ public class RecoverySystem {
ZipEntry entry = entries.nextElement();
InputStream is = zip.getInputStream(entry);
try {
- trusted.add(cf.generateCertificate(is));
+ trusted.add((X509Certificate) cf.generateCertificate(is));
} finally {
is.close();
}
@@ -201,21 +199,23 @@ public class RecoverySystem {
if (signedData == null) {
throw new IOException("signedData is null");
}
- Collection encCerts = signedData.getCertificates();
+ List<Certificate> encCerts = signedData.getCertificates();
if (encCerts.isEmpty()) {
throw new IOException("encCerts is empty");
}
// Take the first certificate from the signature (packages
// should contain only one).
- Iterator it = encCerts.iterator();
+ Iterator<Certificate> it = encCerts.iterator();
X509Certificate cert = null;
if (it.hasNext()) {
- cert = new X509CertImpl((org.apache.harmony.security.x509.Certificate)it.next());
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ InputStream is = new ByteArrayInputStream(it.next().getEncoded());
+ cert = (X509Certificate) cf.generateCertificate(is);
} else {
throw new SignatureException("signature contains no certificates");
}
- List sigInfos = signedData.getSignerInfos();
+ List<SignerInfo> sigInfos = signedData.getSignerInfos();
SignerInfo sigInfo;
if (!sigInfos.isEmpty()) {
sigInfo = (SignerInfo)sigInfos.get(0);
@@ -226,12 +226,12 @@ public class RecoverySystem {
// Check that the public key of the certificate contained
// in the package equals one of our trusted public keys.
- HashSet<Certificate> trusted = getTrustedCerts(
+ HashSet<X509Certificate> trusted = getTrustedCerts(
deviceCertsZipFile == null ? DEFAULT_KEYSTORE : deviceCertsZipFile);
PublicKey signatureKey = cert.getPublicKey();
boolean verified = false;
- for (Certificate c : trusted) {
+ for (X509Certificate c : trusted) {
if (c.getPublicKey().equals(signatureKey)) {
verified = true;
break;
@@ -338,11 +338,11 @@ public class RecoverySystem {
}
/**
- * Reboots the device and wipes the user data partition. This is
- * sometimes called a "factory reset", which is something of a
- * misnomer because the system partition is not restored to its
- * factory state.
- * Requires the {@link android.Manifest.permission#REBOOT} permission.
+ * Reboots the device and wipes the user data and cache
+ * partitions. This is sometimes called a "factory reset", which
+ * is something of a misnomer because the system partition is not
+ * restored to its factory state. Requires the
+ * {@link android.Manifest.permission#REBOOT} permission.
*
* @param context the Context to use
*
@@ -350,6 +350,28 @@ public class RecoverySystem {
* fails, or if the reboot itself fails.
*/
public static void rebootWipeUserData(Context context) throws IOException {
+ rebootWipeUserData(context, false);
+ }
+
+ /**
+ * Reboots the device and wipes the user data and cache
+ * partitions. This is sometimes called a "factory reset", which
+ * is something of a misnomer because the system partition is not
+ * restored to its factory state. Requires the
+ * {@link android.Manifest.permission#REBOOT} permission.
+ *
+ * @param context the Context to use
+ * @param shutdown if true, the device will be powered down after
+ * the wipe completes, rather than being rebooted
+ * back to the regular system.
+ *
+ * @throws IOException if writing the recovery command file
+ * fails, or if the reboot itself fails.
+ *
+ * @hide
+ */
+ public static void rebootWipeUserData(Context context, boolean shutdown)
+ throws IOException {
final ConditionVariable condition = new ConditionVariable();
Intent intent = new Intent("android.intent.action.MASTER_CLEAR_NOTIFICATION");
@@ -365,7 +387,13 @@ public class RecoverySystem {
// Block until the ordered broadcast has completed.
condition.block();
- bootCommand(context, "--wipe_data\n--locale=" + Locale.getDefault().toString());
+ String shutdownArg = "";
+ if (shutdown) {
+ shutdownArg = "--shutdown_after\n";
+ }
+
+ bootCommand(context, shutdownArg + "--wipe_data\n--locale=" +
+ Locale.getDefault().toString());
}
/**
diff --git a/core/java/android/os/SELinux.java b/core/java/android/os/SELinux.java
index c05a974..c9dd5d7 100644
--- a/core/java/android/os/SELinux.java
+++ b/core/java/android/os/SELinux.java
@@ -45,7 +45,7 @@ public class SELinux {
/**
* Set whether SELinux is permissive or enforcing.
- * @param boolean representing whether to set SELinux to enforcing
+ * @param value representing whether to set SELinux to enforcing
* @return a boolean representing whether the desired mode was set
*/
public static final native boolean setSELinuxEnforce(boolean value);
@@ -60,7 +60,7 @@ public class SELinux {
/**
* Change the security context of an existing file object.
* @param path representing the path of file object to relabel.
- * @param con new security context given as a String.
+ * @param context new security context given as a String.
* @return a boolean indicating whether the operation succeeded.
*/
public static final native boolean setFileContext(String path, String context);
@@ -87,8 +87,6 @@ public class SELinux {
/**
* Gets the security context of a given process id.
- * Use of this function is discouraged for Binder transactions.
- * Use Binder.getCallingSecctx() instead.
* @param pid an int representing the process id to check.
* @return a String representing the security context of the given pid.
*/
@@ -102,15 +100,15 @@ public class SELinux {
/**
* Gets the value for the given SELinux boolean name.
- * @param String The name of the SELinux boolean.
+ * @param name The name of the SELinux boolean.
* @return a boolean indicating whether the SELinux boolean is set.
*/
public static final native boolean getBooleanValue(String name);
/**
* Sets the value for the given SELinux boolean name.
- * @param String The name of the SELinux boolean.
- * @param Boolean The new value of the SELinux boolean.
+ * @param name The name of the SELinux boolean.
+ * @param value The new value of the SELinux boolean.
* @return a boolean indicating whether or not the operation succeeded.
*/
public static final native boolean setBooleanValue(String name, boolean value);
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index d794ca6..ea71ad8 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -1449,7 +1449,11 @@ public final class StrictMode {
if (policy.classInstanceLimit.size() == 0) {
return;
}
- Runtime.getRuntime().gc();
+
+ System.gc();
+ System.runFinalization();
+ System.gc();
+
// Note: classInstanceLimit is immutable, so this is lock-free
for (Map.Entry<Class, Integer> entry : policy.classInstanceLimit.entrySet()) {
Class klass = entry.getKey();
@@ -2005,7 +2009,10 @@ public final class StrictMode {
// noticeably less responsive during orientation changes when activities are
// being restarted. Granted, it is only a problem when StrictMode is enabled
// but it is annoying.
- Runtime.getRuntime().gc();
+
+ System.gc();
+ System.runFinalization();
+ System.gc();
long instances = VMDebug.countInstancesOfClass(klass, false);
if (instances > limit) {
diff --git a/core/java/android/os/storage/StorageVolume.java b/core/java/android/os/storage/StorageVolume.java
index 0285cb9..06565f1 100644
--- a/core/java/android/os/storage/StorageVolume.java
+++ b/core/java/android/os/storage/StorageVolume.java
@@ -216,7 +216,7 @@ public class StorageVolume implements Parcelable {
return -1;
}
try {
- return Integer.parseInt(mUuid.replace("-", ""), 16);
+ return (int)Long.parseLong(mUuid.replace("-", ""), 16);
} catch (NumberFormatException e) {
return -1;
}
diff --git a/core/java/android/service/dreams/DozeHardware.java b/core/java/android/service/dreams/DozeHardware.java
new file mode 100644
index 0000000..b5e7f43
--- /dev/null
+++ b/core/java/android/service/dreams/DozeHardware.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright (C) 2014 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.
+ */
+package android.service.dreams;
+
+import android.os.RemoteException;
+import android.util.Log;
+
+/**
+ * Provides access to low-level hardware features that a dream may use to provide
+ * a richer user experience while dozing.
+ * <p>
+ * This class contains functions that should be called by the dream to configure
+ * hardware before starting to doze and allowing the application processor to suspend.
+ * For example, the dream may provide the hardware with enough information to render
+ * some content on its own without any further assistance from the application processor.
+ * </p><p>
+ * This object is obtained by calling {@link DreamService#getDozeHardware()}.
+ * </p>
+ *
+ * @hide experimental
+ */
+public final class DozeHardware {
+ private static final String TAG = "DozeHardware";
+
+ public static final String MSG_ENABLE_MCU = "enable_mcu";
+
+ public static final byte[] VALUE_ON = "on".getBytes();
+ public static final byte[] VALUE_OFF = "off".getBytes();
+
+ private final IDozeHardware mHardware;
+
+ DozeHardware(IDozeHardware hardware) {
+ mHardware = hardware;
+ }
+
+ /**
+ * Sets whether to enable the microcontroller.
+ *
+ * @param enable If true, enables the MCU otherwise disables it.
+ */
+ public void setEnableMcu(boolean enable) {
+ sendMessage(MSG_ENABLE_MCU, enable ? VALUE_ON : VALUE_OFF);
+ }
+
+ /**
+ * Sends a message to the doze hardware module.
+ *
+ * @param msg The name of the message to send.
+ * @param arg An optional argument data blob, may be null.
+ * @return A result data blob, may be null.
+ */
+ public byte[] sendMessage(String msg, byte[] arg) {
+ if (msg == null) {
+ throw new IllegalArgumentException("msg must not be null");
+ }
+
+ try {
+ return mHardware.sendMessage(msg, arg);
+ } catch (RemoteException ex) {
+ Log.e(TAG, "Failed to send message to doze hardware module.", ex);
+ return null;
+ }
+ }
+}
diff --git a/core/java/android/service/dreams/DreamManagerInternal.java b/core/java/android/service/dreams/DreamManagerInternal.java
new file mode 100644
index 0000000..9f7ddba
--- /dev/null
+++ b/core/java/android/service/dreams/DreamManagerInternal.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.service.dreams;
+
+/**
+ * Dream manager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+public abstract class DreamManagerInternal {
+ /**
+ * Called by the power manager to start a dream.
+ */
+ public abstract void startDream(boolean doze);
+
+ /**
+ * Called by the power manager to stop a dream.
+ */
+ public abstract void stopDream();
+
+ /**
+ * Called by the power manager to determine whether a dream is running.
+ */
+ public abstract boolean isDreaming();
+}
diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java
index f6b6c89..7647c22 100644
--- a/core/java/android/service/dreams/DreamService.java
+++ b/core/java/android/service/dreams/DreamService.java
@@ -20,12 +20,14 @@ import java.io.PrintWriter;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
+import android.app.AlarmManager;
import android.app.Service;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.os.IBinder;
+import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Slog;
import android.view.ActionMode;
@@ -42,6 +44,8 @@ import android.view.WindowManager.LayoutParams;
import android.view.accessibility.AccessibilityEvent;
import com.android.internal.policy.PolicyManager;
+import com.android.internal.util.DumpUtils;
+import com.android.internal.util.DumpUtils.Dump;
/**
* Extend this class to implement a custom dream (available to the user as a "Daydream").
@@ -145,19 +149,26 @@ public class DreamService extends Service implements Window.Callback {
*/
public static final String DREAM_META_DATA = "android.service.dream";
+ private final IDreamManager mSandman;
private final Handler mHandler = new Handler();
private IBinder mWindowToken;
private Window mWindow;
private WindowManager mWindowManager;
- private IDreamManager mSandman;
private boolean mInteractive = false;
private boolean mLowProfile = true;
private boolean mFullscreen = false;
private boolean mScreenBright = true;
private boolean mFinished;
+ private boolean mCanDoze;
+ private boolean mDozing;
+ private DozeHardware mDozeHardware;
private boolean mDebug = false;
+ public DreamService() {
+ mSandman = IDreamManager.Stub.asInterface(ServiceManager.getService(DREAM_SERVICE));
+ }
+
/**
* @hide
*/
@@ -289,6 +300,10 @@ public class DreamService extends Service implements Window.Callback {
public void onDetachedFromWindow() {
}
+ @Override
+ public void onWindowDismissed() {
+ }
+
/** {@inheritDoc} */
@Override
public void onPanelClosed(int featureId, Menu menu) {
@@ -444,9 +459,11 @@ public class DreamService extends Service implements Window.Callback {
* correct interactions with it (seeing when it is cleared etc).
*/
public void setLowProfile(boolean lowProfile) {
- mLowProfile = lowProfile;
- int flag = View.SYSTEM_UI_FLAG_LOW_PROFILE;
- applySystemUiVisibilityFlags(mLowProfile ? flag : 0, flag);
+ if (mLowProfile != lowProfile) {
+ mLowProfile = lowProfile;
+ int flag = View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ applySystemUiVisibilityFlags(mLowProfile ? flag : 0, flag);
+ }
}
/**
@@ -467,9 +484,11 @@ public class DreamService extends Service implements Window.Callback {
* will be cleared.
*/
public void setFullscreen(boolean fullscreen) {
- mFullscreen = fullscreen;
- int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
- applyWindowFlags(mFullscreen ? flag : 0, flag);
+ if (mFullscreen != fullscreen) {
+ mFullscreen = fullscreen;
+ int flag = WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ applyWindowFlags(mFullscreen ? flag : 0, flag);
+ }
}
/**
@@ -487,14 +506,16 @@ public class DreamService extends Service implements Window.Callback {
* @param screenBright True to keep the screen bright while dreaming.
*/
public void setScreenBright(boolean screenBright) {
- mScreenBright = screenBright;
- int flag = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
- applyWindowFlags(mScreenBright ? flag : 0, flag);
+ if (mScreenBright != screenBright) {
+ mScreenBright = screenBright;
+ int flag = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
+ applyWindowFlags(mScreenBright ? flag : 0, flag);
+ }
}
/**
- * Returns whether or not this dream keeps the screen bright while dreaming. Defaults to false,
- * allowing the screen to dim if necessary.
+ * Returns whether or not this dream keeps the screen bright while dreaming.
+ * Defaults to false, allowing the screen to dim if necessary.
*
* @see #setScreenBright(boolean)
*/
@@ -503,6 +524,119 @@ public class DreamService extends Service implements Window.Callback {
}
/**
+ * Returns true if this dream is allowed to doze.
+ * <p>
+ * The value returned by this method is only meaningful when the dream has started.
+ * </p>
+ *
+ * @return True if this dream can doze.
+ * @see #startDozing
+ * @hide experimental
+ */
+ public boolean canDoze() {
+ return mCanDoze;
+ }
+
+ /**
+ * Starts dozing, entering a deep dreamy sleep.
+ * <p>
+ * Dozing enables the system to conserve power while the user is not actively interacting
+ * with the device. While dozing, the display will remain on in a low-power state
+ * and will continue to show its previous contents but the application processor and
+ * other system components will be allowed to suspend when possible.
+ * </p><p>
+ * While the application processor is suspended, the dream may stop executing code
+ * for long periods of time. Prior to being suspended, the dream may schedule periodic
+ * wake-ups to render new content by scheduling an alarm with the {@link AlarmManager}.
+ * The dream may also keep the CPU awake by acquiring a
+ * {@link android.os.PowerManager#PARTIAL_WAKE_LOCK partial wake lock} when necessary.
+ * Note that since the purpose of doze mode is to conserve power (especially when
+ * running on battery), the dream should not wake the CPU very often or keep it
+ * awake for very long.
+ * </p><p>
+ * It is a good idea to call this method some time after the dream's entry animation
+ * has completed and the dream is ready to doze. It is important to completely
+ * finish all of the work needed before dozing since the application processor may
+ * be suspended at any moment once this method is called unless other wake locks
+ * are being held.
+ * </p><p>
+ * Call {@link #stopDozing} or {@link #finish} to stop dozing.
+ * </p>
+ *
+ * @see #stopDozing
+ * @hide experimental
+ */
+ public void startDozing() {
+ if (mCanDoze && !mDozing) {
+ mDozing = true;
+ try {
+ mSandman.startDozing(mWindowToken);
+ } catch (RemoteException ex) {
+ // system server died
+ }
+ }
+ }
+
+ /**
+ * Stops dozing, returns to active dreaming.
+ * <p>
+ * This method reverses the effect of {@link #startDozing}. From this moment onward,
+ * the application processor will be kept awake as long as the dream is running
+ * or until the dream starts dozing again.
+ * </p>
+ *
+ * @see #startDozing
+ * @hide experimental
+ */
+ public void stopDozing() {
+ if (mDozing) {
+ mDozing = false;
+ try {
+ mSandman.stopDozing(mWindowToken);
+ } catch (RemoteException ex) {
+ // system server died
+ }
+ }
+ }
+
+ /**
+ * Returns true if the dream will allow the system to enter a low-power state while
+ * it is running without actually turning off the screen. Defaults to false,
+ * keeping the application processor awake while the dream is running.
+ *
+ * @return True if the dream is dozing.
+ *
+ * @see #setDozing(boolean)
+ * @hide experimental
+ */
+ public boolean isDozing() {
+ return mDozing;
+ }
+
+ /**
+ * Gets an object that may be used to access low-level hardware features that a
+ * dream may use to provide a richer user experience while dozing.
+ *
+ * @return An instance of {@link DozeHardware} or null if this device does not offer
+ * hardware support for dozing.
+ *
+ * @hide experimental
+ */
+ public DozeHardware getDozeHardware() {
+ if (mCanDoze && mDozeHardware == null) {
+ try {
+ IDozeHardware hardware = mSandman.getDozeHardware(mWindowToken);
+ if (hardware != null) {
+ mDozeHardware = new DozeHardware(hardware);
+ }
+ } catch (RemoteException ex) {
+ // system server died
+ }
+ }
+ return mDozeHardware;
+ }
+
+ /**
* Called when this Dream is constructed.
*/
@Override
@@ -536,7 +670,11 @@ public class DreamService extends Service implements Window.Callback {
}
/**
- * Stops the dream, detaches from the window, and wakes up.
+ * Stops the dream and detaches from the window.
+ * <p>
+ * When the dream ends, the system will be allowed to go to sleep fully unless there
+ * is a reason for it to be awake such as recent user activity or wake locks being held.
+ * </p>
*/
public final void finish() {
if (mDebug) Slog.v(TAG, "finish()");
@@ -557,10 +695,6 @@ public class DreamService extends Service implements Window.Callback {
// end public api
- private void loadSandman() {
- mSandman = IDreamManager.Stub.asInterface(ServiceManager.getService(DREAM_SERVICE));
- }
-
/**
* Called by DreamController.stopDream() when the Dream is about to be unbound and destroyed.
*
@@ -572,23 +706,16 @@ public class DreamService extends Service implements Window.Callback {
return;
}
- try {
- onDreamingStopped();
- } catch (Throwable t) {
- Slog.w(TAG, "Crashed in onDreamingStopped()", t);
- // we were going to stop anyway
- }
+ if (mDebug) Slog.v(TAG, "detach(): Calling onDreamingStopped()");
+ onDreamingStopped();
if (mDebug) Slog.v(TAG, "detach(): Removing window from window manager");
- try {
- // force our window to be removed synchronously
- mWindowManager.removeViewImmediate(mWindow.getDecorView());
- // the following will print a log message if it finds any other leaked windows
- WindowManagerGlobal.getInstance().closeAll(mWindowToken,
- this.getClass().getName(), "Dream");
- } catch (Throwable t) {
- Slog.w(TAG, "Crashed removing window view", t);
- }
+
+ // force our window to be removed synchronously
+ mWindowManager.removeViewImmediate(mWindow.getDecorView());
+ // the following will print a log message if it finds any other leaked windows
+ WindowManagerGlobal.getInstance().closeAll(mWindowToken,
+ this.getClass().getName(), "Dream");
mWindow = null;
mWindowToken = null;
@@ -601,23 +728,30 @@ public class DreamService extends Service implements Window.Callback {
*
* @param windowToken A window token that will allow a window to be created in the correct layer.
*/
- private final void attach(IBinder windowToken) {
+ private final void attach(IBinder windowToken, boolean canDoze) {
if (mWindowToken != null) {
Slog.e(TAG, "attach() called when already attached with token=" + mWindowToken);
return;
}
+ if (mFinished) {
+ Slog.w(TAG, "attach() called after dream already finished");
+ try {
+ mSandman.finishSelf(windowToken);
+ } catch (RemoteException ex) {
+ // system server died
+ }
+ return;
+ }
if (mDebug) Slog.v(TAG, "Attached on thread " + Thread.currentThread().getId());
- if (mSandman == null) {
- loadSandman();
- }
mWindowToken = windowToken;
mWindow = PolicyManager.makeNewWindow(this);
mWindow.setCallback(this);
mWindow.requestFeature(Window.FEATURE_NO_TITLE);
mWindow.setBackgroundDrawable(new ColorDrawable(0xFF000000));
mWindow.setFormat(PixelFormat.OPAQUE);
+ mCanDoze = canDoze;
if (mDebug) Slog.v(TAG, String.format("Attaching window token: %s to window of type %s",
windowToken, WindowManager.LayoutParams.TYPE_DREAM));
@@ -642,40 +776,25 @@ public class DreamService extends Service implements Window.Callback {
mWindowManager = mWindow.getWindowManager();
if (mDebug) Slog.v(TAG, "Window added on thread " + Thread.currentThread().getId());
- try {
- applySystemUiVisibilityFlags(
- (mLowProfile ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0),
- View.SYSTEM_UI_FLAG_LOW_PROFILE);
- getWindowManager().addView(mWindow.getDecorView(), mWindow.getAttributes());
- } catch (Throwable t) {
- Slog.w(TAG, "Crashed adding window view", t);
- safelyFinish();
- return;
- }
+ applySystemUiVisibilityFlags(
+ (mLowProfile ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0),
+ View.SYSTEM_UI_FLAG_LOW_PROFILE);
+ getWindowManager().addView(mWindow.getDecorView(), mWindow.getAttributes());
// start it up
mHandler.post(new Runnable() {
@Override
public void run() {
- try {
- onDreamingStarted();
- } catch (Throwable t) {
- Slog.w(TAG, "Crashed in onDreamingStarted()", t);
- safelyFinish();
- }
+ if (mDebug) Slog.v(TAG, "Calling onDreamingStarted()");
+ onDreamingStarted();
}
});
}
private void safelyFinish() {
if (mDebug) Slog.v(TAG, "safelyFinish()");
- try {
- finish();
- } catch (Throwable t) {
- Slog.w(TAG, "Crashed in safelyFinish()", t);
- finishInternal();
- return;
- }
+
+ finish();
if (!mFinished) {
Slog.w(TAG, "Bad dream, did not call super.finish()");
@@ -685,19 +804,21 @@ public class DreamService extends Service implements Window.Callback {
private void finishInternal() {
if (mDebug) Slog.v(TAG, "finishInternal() mFinished = " + mFinished);
- if (mFinished) return;
- try {
+
+ if (!mFinished) {
mFinished = true;
- if (mSandman != null) {
- mSandman.finishSelf(mWindowToken);
+ if (mWindowToken == null) {
+ Slog.w(TAG, "Finish was called before the dream was attached.");
} else {
- Slog.w(TAG, "No dream manager found");
+ try {
+ mSandman.finishSelf(mWindowToken);
+ } catch (RemoteException ex) {
+ // system server died
+ }
}
- stopSelf(); // if launched via any other means
- } catch (Throwable t) {
- Slog.w(TAG, "Crashed in finishInternal()", t);
+ stopSelf(); // if launched via any other means
}
}
@@ -732,32 +853,39 @@ public class DreamService extends Service implements Window.Callback {
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- super.dump(fd, pw, args);
-
- pw.print(TAG + ": ");
- if (mWindowToken == null) {
- pw.println("stopped");
- } else {
- pw.println("running (token=" + mWindowToken + ")");
- }
- pw.println(" window: " + mWindow);
- pw.print(" flags:");
- if (isInteractive()) pw.print(" interactive");
- if (isLowProfile()) pw.print(" lowprofile");
- if (isFullscreen()) pw.print(" fullscreen");
- if (isScreenBright()) pw.print(" bright");
- pw.println();
+ DumpUtils.dumpAsync(mHandler, new Dump() {
+ @Override
+ public void dump(PrintWriter pw) {
+ pw.print(TAG + ": ");
+ if (mWindowToken == null) {
+ pw.println("stopped");
+ } else {
+ pw.println("running (token=" + mWindowToken + ")");
+ }
+ pw.println(" window: " + mWindow);
+ pw.print(" flags:");
+ if (isInteractive()) pw.print(" interactive");
+ if (isLowProfile()) pw.print(" lowprofile");
+ if (isFullscreen()) pw.print(" fullscreen");
+ if (isScreenBright()) pw.print(" bright");
+ if (isDozing()) pw.print(" dozing");
+ pw.println();
+ }
+ }, pw, 1000);
}
- private class DreamServiceWrapper extends IDreamService.Stub {
- public void attach(final IBinder windowToken) {
+ private final class DreamServiceWrapper extends IDreamService.Stub {
+ @Override
+ public void attach(final IBinder windowToken, final boolean canDoze) {
mHandler.post(new Runnable() {
@Override
public void run() {
- DreamService.this.attach(windowToken);
+ DreamService.this.attach(windowToken, canDoze);
}
});
}
+
+ @Override
public void detach() {
mHandler.post(new Runnable() {
@Override
diff --git a/core/java/android/service/dreams/IDozeHardware.aidl b/core/java/android/service/dreams/IDozeHardware.aidl
new file mode 100644
index 0000000..f5a657b
--- /dev/null
+++ b/core/java/android/service/dreams/IDozeHardware.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.service.dreams;
+
+/**
+ * @hide
+ */
+interface IDozeHardware {
+ byte[] sendMessage(String msg, in byte[] arg);
+}
diff --git a/core/java/android/service/dreams/IDreamManager.aidl b/core/java/android/service/dreams/IDreamManager.aidl
index 1c1b390..2718e31 100644
--- a/core/java/android/service/dreams/IDreamManager.aidl
+++ b/core/java/android/service/dreams/IDreamManager.aidl
@@ -16,10 +16,11 @@
package android.service.dreams;
+import android.content.ComponentName;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
-import android.content.ComponentName;
import android.os.IBinder;
+import android.service.dreams.IDozeHardware;
/** @hide */
interface IDreamManager {
@@ -31,4 +32,7 @@ interface IDreamManager {
void testDream(in ComponentName componentName);
boolean isDreaming();
void finishSelf(in IBinder token);
+ void startDozing(in IBinder token);
+ void stopDozing(in IBinder token);
+ IDozeHardware getDozeHardware(in IBinder token);
} \ No newline at end of file
diff --git a/core/java/android/service/dreams/IDreamService.aidl b/core/java/android/service/dreams/IDreamService.aidl
index 99dc0b7..bd58f1d 100644
--- a/core/java/android/service/dreams/IDreamService.aidl
+++ b/core/java/android/service/dreams/IDreamService.aidl
@@ -20,6 +20,6 @@ package android.service.dreams;
* @hide
*/
oneway interface IDreamService {
- void attach(IBinder windowToken);
+ void attach(IBinder windowToken, boolean canDoze);
void detach();
}
diff --git a/core/java/android/service/notification/NotificationListenerService.java b/core/java/android/service/notification/NotificationListenerService.java
index 2e0e59b..cf862b8 100644
--- a/core/java/android/service/notification/NotificationListenerService.java
+++ b/core/java/android/service/notification/NotificationListenerService.java
@@ -112,6 +112,7 @@ public abstract class NotificationListenerService extends Service {
* {@link android.app.NotificationManager#notify(String, int, android.app.Notification)}.
*/
public final void cancelNotification(String pkg, String tag, int id) {
+ if (!isBound()) return;
try {
getNotificationInterface().cancelNotificationFromListener(mWrapper, pkg, tag, id);
} catch (android.os.RemoteException ex) {
@@ -131,6 +132,7 @@ public abstract class NotificationListenerService extends Service {
* {@see #cancelNotification(String, String, int)}
*/
public final void cancelAllNotifications() {
+ if (!isBound()) return;
try {
getNotificationInterface().cancelAllNotificationsFromListener(mWrapper);
} catch (android.os.RemoteException ex) {
@@ -145,6 +147,7 @@ public abstract class NotificationListenerService extends Service {
* @return An array of active notifications.
*/
public StatusBarNotification[] getActiveNotifications() {
+ if (!isBound()) return null;
try {
return getNotificationInterface().getActiveNotificationsFromListener(mWrapper);
} catch (android.os.RemoteException ex) {
@@ -161,6 +164,14 @@ public abstract class NotificationListenerService extends Service {
return mWrapper;
}
+ private boolean isBound() {
+ if (mWrapper == null) {
+ Log.w(TAG, "Notification listener service not yet bound.");
+ return false;
+ }
+ return true;
+ }
+
private class INotificationListenerWrapper extends INotificationListener.Stub {
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
diff --git a/core/java/android/speech/SpeechRecognizer.java b/core/java/android/speech/SpeechRecognizer.java
index 94aedbd..91c3799 100644
--- a/core/java/android/speech/SpeechRecognizer.java
+++ b/core/java/android/speech/SpeechRecognizer.java
@@ -409,7 +409,7 @@ public class SpeechRecognizer {
* Internal wrapper of IRecognitionListener which will propagate the results to
* RecognitionListener
*/
- private class InternalListener extends IRecognitionListener.Stub {
+ private static class InternalListener extends IRecognitionListener.Stub {
private RecognitionListener mInternalListener;
private final static int MSG_BEGINNING_OF_SPEECH = 1;
diff --git a/core/java/android/speech/srec/MicrophoneInputStream.java b/core/java/android/speech/srec/MicrophoneInputStream.java
index fab77a9..94db176 100644
--- a/core/java/android/speech/srec/MicrophoneInputStream.java
+++ b/core/java/android/speech/srec/MicrophoneInputStream.java
@@ -34,7 +34,7 @@ public final class MicrophoneInputStream extends InputStream {
}
private final static String TAG = "MicrophoneInputStream";
- private int mAudioRecord = 0;
+ private long mAudioRecord = 0;
private byte[] mOneByte = new byte[1];
/**
@@ -102,9 +102,9 @@ public final class MicrophoneInputStream extends InputStream {
//
// AudioRecord JNI interface
//
- private static native int AudioRecordNew(int sampleRate, int fifoDepth);
- private static native int AudioRecordStart(int audioRecord);
- private static native int AudioRecordRead(int audioRecord, byte[] b, int offset, int length) throws IOException;
- private static native void AudioRecordStop(int audioRecord) throws IOException;
- private static native void AudioRecordDelete(int audioRecord) throws IOException;
+ private static native long AudioRecordNew(int sampleRate, int fifoDepth);
+ private static native int AudioRecordStart(long audioRecord);
+ private static native int AudioRecordRead(long audioRecord, byte[] b, int offset, int length) throws IOException;
+ private static native void AudioRecordStop(long audioRecord) throws IOException;
+ private static native void AudioRecordDelete(long audioRecord) throws IOException;
}
diff --git a/core/java/android/speech/srec/Recognizer.java b/core/java/android/speech/srec/Recognizer.java
index db5d8fd..1396204 100644
--- a/core/java/android/speech/srec/Recognizer.java
+++ b/core/java/android/speech/srec/Recognizer.java
@@ -125,10 +125,10 @@ public final class Recognizer {
public static final String KEY_MEANING = "meaning";
// handle to SR_Vocabulary object
- private int mVocabulary = 0;
+ private long mVocabulary = 0;
// handle to SR_Recognizer object
- private int mRecognizer = 0;
+ private long mRecognizer = 0;
// Grammar currently associated with Recognizer via SR_GrammarSetupRecognizer
private Grammar mActiveGrammar = null;
@@ -174,7 +174,7 @@ public final class Recognizer {
* Represents a grammar loaded into the Recognizer.
*/
public class Grammar {
- private int mGrammar = 0;
+ private long mGrammar = 0;
/**
* Create a <code>Grammar</code> instance.
@@ -603,116 +603,116 @@ public final class Recognizer {
//
// SR_Recognizer methods
//
- private static native void SR_RecognizerStart(int recognizer);
- private static native void SR_RecognizerStop(int recognizer);
- private static native int SR_RecognizerCreate();
- private static native void SR_RecognizerDestroy(int recognizer);
- private static native void SR_RecognizerSetup(int recognizer);
- private static native void SR_RecognizerUnsetup(int recognizer);
- private static native boolean SR_RecognizerIsSetup(int recognizer);
- private static native String SR_RecognizerGetParameter(int recognizer, String key);
- private static native int SR_RecognizerGetSize_tParameter(int recognizer, String key);
- private static native boolean SR_RecognizerGetBoolParameter(int recognizer, String key);
- private static native void SR_RecognizerSetParameter(int recognizer, String key, String value);
- private static native void SR_RecognizerSetSize_tParameter(int recognizer,
+ private static native void SR_RecognizerStart(long recognizer);
+ private static native void SR_RecognizerStop(long recognizer);
+ private static native long SR_RecognizerCreate();
+ private static native void SR_RecognizerDestroy(long recognizer);
+ private static native void SR_RecognizerSetup(long recognizer);
+ private static native void SR_RecognizerUnsetup(long recognizer);
+ private static native boolean SR_RecognizerIsSetup(long recognizer);
+ private static native String SR_RecognizerGetParameter(long recognizer, String key);
+ private static native int SR_RecognizerGetSize_tParameter(long recognizer, String key);
+ private static native boolean SR_RecognizerGetBoolParameter(long recognizer, String key);
+ private static native void SR_RecognizerSetParameter(long recognizer, String key, String value);
+ private static native void SR_RecognizerSetSize_tParameter(long recognizer,
String key, int value);
- private static native void SR_RecognizerSetBoolParameter(int recognizer, String key,
+ private static native void SR_RecognizerSetBoolParameter(long recognizer, String key,
boolean value);
- private static native void SR_RecognizerSetupRule(int recognizer, int grammar,
+ private static native void SR_RecognizerSetupRule(long recognizer, long grammar,
String ruleName);
- private static native boolean SR_RecognizerHasSetupRules(int recognizer);
- private static native void SR_RecognizerActivateRule(int recognizer, int grammar,
+ private static native boolean SR_RecognizerHasSetupRules(long recognizer);
+ private static native void SR_RecognizerActivateRule(long recognizer, long grammar,
String ruleName, int weight);
- private static native void SR_RecognizerDeactivateRule(int recognizer, int grammar,
+ private static native void SR_RecognizerDeactivateRule(long recognizer, long grammar,
String ruleName);
- private static native void SR_RecognizerDeactivateAllRules(int recognizer);
- private static native boolean SR_RecognizerIsActiveRule(int recognizer, int grammar,
+ private static native void SR_RecognizerDeactivateAllRules(long recognizer);
+ private static native boolean SR_RecognizerIsActiveRule(long recognizer, long grammar,
String ruleName);
- private static native boolean SR_RecognizerCheckGrammarConsistency(int recognizer,
- int grammar);
- private static native int SR_RecognizerPutAudio(int recognizer, byte[] buffer, int offset,
+ private static native boolean SR_RecognizerCheckGrammarConsistency(long recognizer,
+ long grammar);
+ private static native int SR_RecognizerPutAudio(long recognizer, byte[] buffer, int offset,
int length, boolean isLast);
- private static native int SR_RecognizerAdvance(int recognizer);
- // private static native void SR_RecognizerLoadUtterance(int recognizer,
+ private static native int SR_RecognizerAdvance(long recognizer);
+ // private static native void SR_RecognizerLoadUtterance(long recognizer,
// const LCHAR* filename);
- // private static native void SR_RecognizerLoadWaveFile(int recognizer,
+ // private static native void SR_RecognizerLoadWaveFile(long recognizer,
// const LCHAR* filename);
- // private static native void SR_RecognizerSetLockFunction(int recognizer,
+ // private static native void SR_RecognizerSetLockFunction(long recognizer,
// SR_RecognizerLockFunction function, void* data);
- private static native boolean SR_RecognizerIsSignalClipping(int recognizer);
- private static native boolean SR_RecognizerIsSignalDCOffset(int recognizer);
- private static native boolean SR_RecognizerIsSignalNoisy(int recognizer);
- private static native boolean SR_RecognizerIsSignalTooQuiet(int recognizer);
- private static native boolean SR_RecognizerIsSignalTooFewSamples(int recognizer);
- private static native boolean SR_RecognizerIsSignalTooManySamples(int recognizer);
+ private static native boolean SR_RecognizerIsSignalClipping(long recognizer);
+ private static native boolean SR_RecognizerIsSignalDCOffset(long recognizer);
+ private static native boolean SR_RecognizerIsSignalNoisy(long recognizer);
+ private static native boolean SR_RecognizerIsSignalTooQuiet(long recognizer);
+ private static native boolean SR_RecognizerIsSignalTooFewSamples(long recognizer);
+ private static native boolean SR_RecognizerIsSignalTooManySamples(long recognizer);
// private static native void SR_Recognizer_Change_Sample_Rate (size_t new_sample_rate);
//
// SR_AcousticState native methods
//
- private static native void SR_AcousticStateReset(int recognizer);
- private static native void SR_AcousticStateSet(int recognizer, String state);
- private static native String SR_AcousticStateGet(int recognizer);
+ private static native void SR_AcousticStateReset(long recognizer);
+ private static native void SR_AcousticStateSet(long recognizer, String state);
+ private static native String SR_AcousticStateGet(long recognizer);
//
// SR_Grammar native methods
//
- private static native void SR_GrammarCompile(int grammar);
- private static native void SR_GrammarAddWordToSlot(int grammar, String slot,
+ private static native void SR_GrammarCompile(long grammar);
+ private static native void SR_GrammarAddWordToSlot(long grammar, String slot,
String word, String pronunciation, int weight, String tag);
- private static native void SR_GrammarResetAllSlots(int grammar);
- // private static native void SR_GrammarAddNametagToSlot(int grammar, String slot,
+ private static native void SR_GrammarResetAllSlots(long grammar);
+ // private static native void SR_GrammarAddNametagToSlot(long grammar, String slot,
// const struct SR_Nametag_t* nametag, int weight, String tag);
- private static native void SR_GrammarSetupVocabulary(int grammar, int vocabulary);
- // private static native void SR_GrammarSetupModels(int grammar, SR_AcousticModels* models);
- private static native void SR_GrammarSetupRecognizer(int grammar, int recognizer);
- private static native void SR_GrammarUnsetupRecognizer(int grammar);
- // private static native void SR_GrammarGetModels(int grammar,SR_AcousticModels** models);
- private static native int SR_GrammarCreate();
- private static native void SR_GrammarDestroy(int grammar);
- private static native int SR_GrammarLoad(String filename);
- private static native void SR_GrammarSave(int grammar, String filename);
- // private static native void SR_GrammarSetDispatchFunction(int grammar,
+ private static native void SR_GrammarSetupVocabulary(long grammar, long vocabulary);
+ // private static native void SR_GrammarSetupModels(long grammar, SR_AcousticModels* models);
+ private static native void SR_GrammarSetupRecognizer(long grammar, long recognizer);
+ private static native void SR_GrammarUnsetupRecognizer(long grammar);
+ // private static native void SR_GrammarGetModels(long grammar,SR_AcousticModels** models);
+ private static native long SR_GrammarCreate();
+ private static native void SR_GrammarDestroy(long grammar);
+ private static native long SR_GrammarLoad(String filename);
+ private static native void SR_GrammarSave(long grammar, String filename);
+ // private static native void SR_GrammarSetDispatchFunction(long grammar,
// const LCHAR* name, void* userData, SR_GrammarDispatchFunction function);
- // private static native void SR_GrammarSetParameter(int grammar, const
+ // private static native void SR_GrammarSetParameter(long grammar, const
// LCHAR* key, void* value);
- // private static native void SR_GrammarSetSize_tParameter(int grammar,
+ // private static native void SR_GrammarSetSize_tParameter(long grammar,
// const LCHAR* key, size_t value);
- // private static native void SR_GrammarGetParameter(int grammar, const
+ // private static native void SR_GrammarGetParameter(long grammar, const
// LCHAR* key, void** value);
- // private static native void SR_GrammarGetSize_tParameter(int grammar,
+ // private static native void SR_GrammarGetSize_tParameter(long grammar,
// const LCHAR* key, size_t* value);
- // private static native void SR_GrammarCheckParse(int grammar, const LCHAR*
+ // private static native void SR_GrammarCheckParse(long grammar, const LCHAR*
// transcription, SR_SemanticResult** result, size_t* resultCount);
- private static native void SR_GrammarAllowOnly(int grammar, String transcription);
- private static native void SR_GrammarAllowAll(int grammar);
+ private static native void SR_GrammarAllowOnly(long grammar, String transcription);
+ private static native void SR_GrammarAllowAll(long grammar);
//
// SR_Vocabulary native methods
//
// private static native int SR_VocabularyCreate();
- private static native int SR_VocabularyLoad();
+ private static native long SR_VocabularyLoad();
// private static native void SR_VocabularySave(SR_Vocabulary* self,
// const LCHAR* filename);
// private static native void SR_VocabularyAddWord(SR_Vocabulary* self,
// const LCHAR* word);
// private static native void SR_VocabularyGetLanguage(SR_Vocabulary* self,
// ESR_Locale* locale);
- private static native void SR_VocabularyDestroy(int vocabulary);
- private static native String SR_VocabularyGetPronunciation(int vocabulary, String word);
+ private static native void SR_VocabularyDestroy(long vocabulary);
+ private static native String SR_VocabularyGetPronunciation(long vocabulary, String word);
//
// SR_RecognizerResult native methods
//
- private static native byte[] SR_RecognizerResultGetWaveform(int recognizer);
- private static native int SR_RecognizerResultGetSize(int recognizer);
- private static native int SR_RecognizerResultGetKeyCount(int recognizer, int nbest);
- private static native String[] SR_RecognizerResultGetKeyList(int recognizer, int nbest);
- private static native String SR_RecognizerResultGetValue(int recognizer,
+ private static native byte[] SR_RecognizerResultGetWaveform(long recognizer);
+ private static native int SR_RecognizerResultGetSize(long recognizer);
+ private static native int SR_RecognizerResultGetKeyCount(long recognizer, int nbest);
+ private static native String[] SR_RecognizerResultGetKeyList(long recognizer, int nbest);
+ private static native String SR_RecognizerResultGetValue(long recognizer,
int nbest, String key);
- // private static native void SR_RecognizerResultGetLocale(int recognizer, ESR_Locale* locale);
+ // private static native void SR_RecognizerResultGetLocale(long recognizer, ESR_Locale* locale);
}
diff --git a/core/java/android/text/MeasuredText.java b/core/java/android/text/MeasuredText.java
index bd9310c..101d6a2 100644
--- a/core/java/android/text/MeasuredText.java
+++ b/core/java/android/text/MeasuredText.java
@@ -46,7 +46,7 @@ class MeasuredText {
}
private static final Object[] sLock = new Object[0];
- private static MeasuredText[] sCached = new MeasuredText[3];
+ private static final MeasuredText[] sCached = new MeasuredText[3];
static MeasuredText obtain() {
MeasuredText mt;
diff --git a/core/java/android/util/CharsetUtils.java b/core/java/android/util/CharsetUtils.java
deleted file mode 100644
index a763a69..0000000
--- a/core/java/android/util/CharsetUtils.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * 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.
- */
-
-package android.util;
-
-import android.os.Build;
-import android.text.TextUtils;
-
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * <p>
- * A class containing utility methods related to character sets. This
- * class is primarily useful for code that wishes to be vendor-aware
- * in its interpretation of Japanese charset names (used in DoCoMo,
- * KDDI, and SoftBank).
- * </p>
- *
- * <p>
- * <b>Note:</b> Developers will need to add an appropriate mapping for
- * each vendor-specific charset. You may need to modify the C libraries
- * like icu4c in order to let Android support an additional charset.
- * </p>
- *
- * @hide
- */
-public final class CharsetUtils {
- /**
- * name of the vendor "DoCoMo". <b>Note:</b> This isn't a public
- * constant, in order to keep this class from becoming a de facto
- * reference list of vendor names.
- */
- private static final String VENDOR_DOCOMO = "docomo";
- /**
- * Name of the vendor "KDDI".
- */
- private static final String VENDOR_KDDI = "kddi";
- /**
- * Name of the vendor "SoftBank".
- */
- private static final String VENDOR_SOFTBANK = "softbank";
-
- /**
- * Represents one-to-one mapping from a vendor name to a charset specific to the vendor.
- */
- private static final Map<String, String> sVendorShiftJisMap = new HashMap<String, String>();
-
- static {
- // These variants of Shift_JIS come from icu's mapping data (convrtrs.txt)
- sVendorShiftJisMap.put(VENDOR_DOCOMO, "docomo-shift_jis-2007");
- sVendorShiftJisMap.put(VENDOR_KDDI, "kddi-shift_jis-2007");
- sVendorShiftJisMap.put(VENDOR_SOFTBANK, "softbank-shift_jis-2007");
- }
-
- /**
- * This class is uninstantiable.
- */
- private CharsetUtils() {
- // This space intentionally left blank.
- }
-
- /**
- * Returns the name of the vendor-specific character set
- * corresponding to the given original character set name and
- * vendor. If there is no vendor-specific character set for the
- * given name/vendor pair, this returns the original character set name.
- *
- * @param charsetName the base character set name
- * @param vendor the vendor to specialize for. All characters should be lower-cased.
- * @return the specialized character set name, or {@code charsetName} if
- * there is no specialized name
- */
- public static String nameForVendor(String charsetName, String vendor) {
- if (!TextUtils.isEmpty(charsetName) && !TextUtils.isEmpty(vendor)) {
- // You can add your own mapping here.
- if (isShiftJis(charsetName)) {
- final String vendorShiftJis = sVendorShiftJisMap.get(vendor);
- if (vendorShiftJis != null) {
- return vendorShiftJis;
- }
- }
- }
-
- return charsetName;
- }
-
- /**
- * Returns the name of the vendor-specific character set
- * corresponding to the given original character set name and the
- * default vendor (that is, the targeted vendor of the device this
- * code is running on). This method merely calls through to
- * {@link #nameForVendor(String,String)}, passing the default vendor
- * as the second argument.
- *
- * @param charsetName the base character set name
- * @return the specialized character set name, or {@code charsetName} if
- * there is no specialized name
- */
- public static String nameForDefaultVendor(String charsetName) {
- return nameForVendor(charsetName, getDefaultVendor());
- }
-
- /**
- * Returns the vendor-specific character set corresponding to the
- * given original character set name and vendor. If there is no
- * vendor-specific character set for the given name/vendor pair,
- * this returns the character set corresponding to the original
- * name. The vendor name is matched case-insensitively. This
- * method merely calls {@code Charset.forName()} on a name
- * transformed by a call to {@link #nameForVendor(String,String)}.
- *
- * @param charsetName the base character set name
- * @param vendor the vendor to specialize for
- * @return the specialized character set, or the one corresponding
- * directly to {@code charsetName} if there is no specialized
- * variant
- * @throws UnsupportedCharsetException thrown if the named character
- * set is not supported by the system
- * @throws IllegalCharsetNameException thrown if {@code charsetName}
- * has invalid syntax
- */
- public static Charset charsetForVendor(String charsetName, String vendor)
- throws UnsupportedCharsetException, IllegalCharsetNameException {
- charsetName = nameForVendor(charsetName, vendor);
- return Charset.forName(charsetName);
- }
-
- /**
- * Returns the vendor-specific character set corresponding to the
- * given original character set name and default vendor (that is,
- * the targeted vendor of the device this code is running on).
- * This method merely calls through to {@link
- * #charsetForVendor(String,String)}, passing the default vendor
- * as the second argument.
- *
- * @param charsetName the base character set name
- * @return the specialized character set, or the one corresponding
- * directly to {@code charsetName} if there is no specialized
- * variant
- * @throws UnsupportedCharsetException thrown if the named character
- * set is not supported by the system
- * @throws IllegalCharsetNameException thrown if {@code charsetName}
- * has invalid syntax
- */
- public static Charset charsetForVendor(String charsetName)
- throws UnsupportedCharsetException, IllegalCharsetNameException {
- return charsetForVendor(charsetName, getDefaultVendor());
- }
-
- /**
- * Returns whether the given character set name indicates the Shift-JIS
- * encoding. Returns false if the name is null.
- *
- * @param charsetName the character set name
- * @return {@code true} if the name corresponds to Shift-JIS or
- * {@code false} if not
- */
- private static boolean isShiftJis(String charsetName) {
- // Bail quickly if the length doesn't match.
- if (charsetName == null) {
- return false;
- }
- int length = charsetName.length();
- if (length != 4 && length != 9) {
- return false;
- }
-
- return charsetName.equalsIgnoreCase("shift_jis")
- || charsetName.equalsIgnoreCase("shift-jis")
- || charsetName.equalsIgnoreCase("sjis");
- }
-
- /**
- * Gets the default vendor for this build.
- *
- * @return the default vendor name
- */
- private static String getDefaultVendor() {
- return Build.BRAND;
- }
-}
diff --git a/core/java/android/util/TypedValue.java b/core/java/android/util/TypedValue.java
index ed45298..931fb81 100644
--- a/core/java/android/util/TypedValue.java
+++ b/core/java/android/util/TypedValue.java
@@ -290,18 +290,14 @@ public class TypedValue {
return -1;
}
+ /**
+ * @hide Was accidentally exposed in API level 1 for debugging purposes.
+ * Kept for compatibility just in case although the debugging code has been removed.
+ */
+ @Deprecated
public static float complexToDimensionNoisy(int data, DisplayMetrics metrics)
{
- float res = complexToDimension(data, metrics);
- System.out.println(
- "Dimension (0x" + ((data>>TypedValue.COMPLEX_MANTISSA_SHIFT)
- & TypedValue.COMPLEX_MANTISSA_MASK)
- + "*" + (RADIX_MULTS[(data>>TypedValue.COMPLEX_RADIX_SHIFT)
- & TypedValue.COMPLEX_RADIX_MASK] / MANTISSA_MULT)
- + ")" + DIMENSION_UNIT_STRS[(data>>COMPLEX_UNIT_SHIFT)
- & COMPLEX_UNIT_MASK]
- + " = " + res);
- return res;
+ return complexToDimension(data, metrics);
}
/**
diff --git a/core/java/android/view/DisplayAdjustments.java b/core/java/android/view/DisplayAdjustments.java
index 041d9e0..35fb504 100644
--- a/core/java/android/view/DisplayAdjustments.java
+++ b/core/java/android/view/DisplayAdjustments.java
@@ -19,7 +19,7 @@ package android.view;
import android.content.res.CompatibilityInfo;
import android.os.IBinder;
-import com.android.internal.util.Objects;
+import java.util.Objects;
/** @hide */
public class DisplayAdjustments {
@@ -91,7 +91,7 @@ public class DisplayAdjustments {
return false;
}
DisplayAdjustments daj = (DisplayAdjustments)o;
- return Objects.equal(daj.mCompatInfo, mCompatInfo) &&
- Objects.equal(daj.mActivityToken, mActivityToken);
+ return Objects.equals(daj.mCompatInfo, mCompatInfo) &&
+ Objects.equals(daj.mActivityToken, mActivityToken);
}
}
diff --git a/core/java/android/view/DisplayEventReceiver.java b/core/java/android/view/DisplayEventReceiver.java
index 4dade20..de46a4a 100644
--- a/core/java/android/view/DisplayEventReceiver.java
+++ b/core/java/android/view/DisplayEventReceiver.java
@@ -36,16 +36,16 @@ public abstract class DisplayEventReceiver {
private final CloseGuard mCloseGuard = CloseGuard.get();
- private int mReceiverPtr;
+ private long mReceiverPtr;
// We keep a reference message queue object here so that it is not
// GC'd while the native peer of the receiver is using them.
private MessageQueue mMessageQueue;
- private static native int nativeInit(DisplayEventReceiver receiver,
+ private static native long nativeInit(DisplayEventReceiver receiver,
MessageQueue messageQueue);
- private static native void nativeDispose(int receiverPtr);
- private static native void nativeScheduleVsync(int receiverPtr);
+ private static native void nativeDispose(long receiverPtr);
+ private static native void nativeScheduleVsync(long receiverPtr);
/**
* Creates a display event receiver.
diff --git a/core/java/android/view/GLES20Canvas.java b/core/java/android/view/GLES20Canvas.java
index beefc21..6a15fa6 100644
--- a/core/java/android/view/GLES20Canvas.java
+++ b/core/java/android/view/GLES20Canvas.java
@@ -49,7 +49,7 @@ class GLES20Canvas extends HardwareCanvas {
private static final int MODIFIER_COLOR_FILTER = 4;
private final boolean mOpaque;
- private int mRenderer;
+ private long mRenderer;
// The native renderer will be destroyed when this object dies.
// DO NOT overwrite this reference once it is set.
@@ -92,7 +92,7 @@ class GLES20Canvas extends HardwareCanvas {
/**
* Creates a canvas to render into an FBO.
*/
- GLES20Canvas(int layer, boolean translucent) {
+ GLES20Canvas(long layer, boolean translucent) {
mOpaque = !translucent;
mRenderer = nCreateLayerRenderer(layer);
setupFinalizer();
@@ -122,16 +122,16 @@ class GLES20Canvas extends HardwareCanvas {
nResetDisplayListRenderer(mRenderer);
}
- private static native int nCreateRenderer();
- private static native int nCreateLayerRenderer(int layer);
- private static native int nCreateDisplayListRenderer();
- private static native void nResetDisplayListRenderer(int renderer);
- private static native void nDestroyRenderer(int renderer);
+ private static native long nCreateRenderer();
+ private static native long nCreateLayerRenderer(long layer);
+ private static native long nCreateDisplayListRenderer();
+ private static native void nResetDisplayListRenderer(long renderer);
+ private static native void nDestroyRenderer(long renderer);
private static final class CanvasFinalizer {
- private final int mRenderer;
+ private final long mRenderer;
- public CanvasFinalizer(int renderer) {
+ public CanvasFinalizer(long renderer) {
mRenderer = renderer;
}
@@ -151,7 +151,7 @@ class GLES20Canvas extends HardwareCanvas {
nSetName(mRenderer, name);
}
- private static native void nSetName(int renderer, String name);
+ private static native void nSetName(long renderer, String name);
///////////////////////////////////////////////////////////////////////////
// Hardware layers
@@ -177,26 +177,26 @@ class GLES20Canvas extends HardwareCanvas {
nClearLayerUpdates(mRenderer);
}
- static native int nCreateTextureLayer(boolean opaque, int[] layerInfo);
- static native int nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo);
- static native boolean nResizeLayer(int layerId, int width, int height, int[] layerInfo);
- static native void nSetOpaqueLayer(int layerId, boolean isOpaque);
- static native void nSetLayerPaint(int layerId, int nativePaint);
- static native void nSetLayerColorFilter(int layerId, int nativeColorFilter);
- static native void nUpdateTextureLayer(int layerId, int width, int height, boolean opaque,
+ static native long nCreateTextureLayer(boolean opaque, int[] layerInfo);
+ static native long nCreateLayer(int width, int height, boolean isOpaque, int[] layerInfo);
+ static native boolean nResizeLayer(long layerId, int width, int height, int[] layerInfo);
+ static native void nSetOpaqueLayer(long layerId, boolean isOpaque);
+ static native void nSetLayerPaint(long layerId, long nativePaint);
+ static native void nSetLayerColorFilter(long layerId, long nativeColorFilter);
+ static native void nUpdateTextureLayer(long layerId, int width, int height, boolean opaque,
SurfaceTexture surface);
- static native void nClearLayerTexture(int layerId);
- static native void nSetTextureLayerTransform(int layerId, int matrix);
- static native void nDestroyLayer(int layerId);
- static native void nDestroyLayerDeferred(int layerId);
- static native void nUpdateRenderLayer(int layerId, int renderer, int displayList,
+ static native void nClearLayerTexture(long layerId);
+ static native void nSetTextureLayerTransform(long layerId, long matrix);
+ static native void nDestroyLayer(long layerId);
+ static native void nDestroyLayerDeferred(long layerId);
+ static native void nUpdateRenderLayer(long layerId, long renderer, long displayList,
int left, int top, int right, int bottom);
- static native boolean nCopyLayer(int layerId, int bitmap);
+ static native boolean nCopyLayer(long layerId, long bitmap);
- private static native void nClearLayerUpdates(int renderer);
- private static native void nFlushLayerUpdates(int renderer);
- private static native void nPushLayerUpdate(int renderer, int layer);
- private static native void nCancelLayerUpdate(int renderer, int layer);
+ private static native void nClearLayerUpdates(long renderer);
+ private static native void nFlushLayerUpdates(long renderer);
+ private static native void nPushLayerUpdate(long renderer, long layer);
+ private static native void nCancelLayerUpdate(long renderer, long layer);
///////////////////////////////////////////////////////////////////////////
// Canvas management
@@ -233,7 +233,7 @@ class GLES20Canvas extends HardwareCanvas {
/**
* Returns the native OpenGLRenderer object.
*/
- int getRenderer() {
+ long getRenderer() {
return mRenderer;
}
@@ -249,7 +249,7 @@ class GLES20Canvas extends HardwareCanvas {
nSetViewport(mRenderer, width, height);
}
- private static native void nSetViewport(int renderer, int width, int height);
+ private static native void nSetViewport(long renderer, int width, int height);
@Override
public int onPreDraw(Rect dirty) {
@@ -261,8 +261,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native int nPrepare(int renderer, boolean opaque);
- private static native int nPrepareDirty(int renderer, int left, int top, int right, int bottom,
+ private static native int nPrepare(long renderer, boolean opaque);
+ private static native int nPrepareDirty(long renderer, int left, int top, int right, int bottom,
boolean opaque);
@Override
@@ -270,7 +270,7 @@ class GLES20Canvas extends HardwareCanvas {
nFinish(mRenderer);
}
- private static native void nFinish(int renderer);
+ private static native void nFinish(long renderer);
/**
* Returns the size of the stencil buffer required by the underlying
@@ -290,45 +290,45 @@ class GLES20Canvas extends HardwareCanvas {
nSetCountOverdrawEnabled(mRenderer, enabled);
}
- static native void nSetCountOverdrawEnabled(int renderer, boolean enabled);
+ static native void nSetCountOverdrawEnabled(long renderer, boolean enabled);
float getOverdraw() {
return nGetOverdraw(mRenderer);
}
- static native float nGetOverdraw(int renderer);
+ static native float nGetOverdraw(long renderer);
///////////////////////////////////////////////////////////////////////////
// Functor
///////////////////////////////////////////////////////////////////////////
@Override
- public int callDrawGLFunction(int drawGLFunction) {
+ public int callDrawGLFunction(long drawGLFunction) {
return nCallDrawGLFunction(mRenderer, drawGLFunction);
}
- private static native int nCallDrawGLFunction(int renderer, int drawGLFunction);
+ private static native int nCallDrawGLFunction(long renderer, long drawGLFunction);
@Override
public int invokeFunctors(Rect dirty) {
return nInvokeFunctors(mRenderer, dirty);
}
- private static native int nInvokeFunctors(int renderer, Rect dirty);
+ private static native int nInvokeFunctors(long renderer, Rect dirty);
@Override
- public void detachFunctor(int functor) {
+ public void detachFunctor(long functor) {
nDetachFunctor(mRenderer, functor);
}
- private static native void nDetachFunctor(int renderer, int functor);
+ private static native void nDetachFunctor(long renderer, long functor);
@Override
- public void attachFunctor(int functor) {
+ public void attachFunctor(long functor) {
nAttachFunctor(mRenderer, functor);
}
- private static native void nAttachFunctor(int renderer, int functor);
+ private static native void nAttachFunctor(long renderer, long functor);
///////////////////////////////////////////////////////////////////////////
// Memory
@@ -402,18 +402,18 @@ class GLES20Canvas extends HardwareCanvas {
// Display list
///////////////////////////////////////////////////////////////////////////
- int getDisplayList(int displayList) {
+ long getDisplayList(long displayList) {
return nGetDisplayList(mRenderer, displayList);
}
- private static native int nGetDisplayList(int renderer, int displayList);
+ private static native long nGetDisplayList(long renderer, long displayList);
@Override
void outputDisplayList(DisplayList displayList) {
nOutputDisplayList(mRenderer, ((GLES20DisplayList) displayList).getNativeDisplayList());
}
- private static native void nOutputDisplayList(int renderer, int displayList);
+ private static native void nOutputDisplayList(long renderer, long displayList);
@Override
public int drawDisplayList(DisplayList displayList, Rect dirty, int flags) {
@@ -421,7 +421,7 @@ class GLES20Canvas extends HardwareCanvas {
dirty, flags);
}
- private static native int nDrawDisplayList(int renderer, int displayList,
+ private static native int nDrawDisplayList(long renderer, long displayList,
Rect dirty, int flags);
///////////////////////////////////////////////////////////////////////////
@@ -435,7 +435,7 @@ class GLES20Canvas extends HardwareCanvas {
nDrawLayer(mRenderer, glLayer.getLayer(), x, y);
}
- private static native void nDrawLayer(int renderer, int layer, float x, float y);
+ private static native void nDrawLayer(long renderer, long layer, float x, float y);
void interrupt() {
nInterrupt(mRenderer);
@@ -445,8 +445,8 @@ class GLES20Canvas extends HardwareCanvas {
nResume(mRenderer);
}
- private static native void nInterrupt(int renderer);
- private static native void nResume(int renderer);
+ private static native void nInterrupt(long renderer);
+ private static native void nResume(long renderer);
///////////////////////////////////////////////////////////////////////////
// Support
@@ -487,14 +487,14 @@ class GLES20Canvas extends HardwareCanvas {
return nClipPath(mRenderer, path.mNativePath, op.nativeInt);
}
- private static native boolean nClipPath(int renderer, int path, int op);
+ private static native boolean nClipPath(long renderer, long path, int op);
@Override
public boolean clipRect(float left, float top, float right, float bottom) {
return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt);
}
- private static native boolean nClipRect(int renderer, float left, float top,
+ private static native boolean nClipRect(long renderer, float left, float top,
float right, float bottom, int op);
@Override
@@ -507,7 +507,7 @@ class GLES20Canvas extends HardwareCanvas {
return nClipRect(mRenderer, left, top, right, bottom, Region.Op.INTERSECT.nativeInt);
}
- private static native boolean nClipRect(int renderer, int left, int top,
+ private static native boolean nClipRect(long renderer, int left, int top,
int right, int bottom, int op);
@Override
@@ -542,21 +542,21 @@ class GLES20Canvas extends HardwareCanvas {
return nClipRegion(mRenderer, region.mNativeRegion, op.nativeInt);
}
- private static native boolean nClipRegion(int renderer, int region, int op);
+ private static native boolean nClipRegion(long renderer, long region, int op);
@Override
public boolean getClipBounds(Rect bounds) {
return nGetClipBounds(mRenderer, bounds);
}
- private static native boolean nGetClipBounds(int renderer, Rect bounds);
+ private static native boolean nGetClipBounds(long renderer, Rect bounds);
@Override
public boolean quickReject(float left, float top, float right, float bottom, EdgeType type) {
return nQuickReject(mRenderer, left, top, right, bottom);
}
- private static native boolean nQuickReject(int renderer, float left, float top,
+ private static native boolean nQuickReject(long renderer, float left, float top,
float right, float bottom);
@Override
@@ -581,35 +581,35 @@ class GLES20Canvas extends HardwareCanvas {
if (dx != 0.0f || dy != 0.0f) nTranslate(mRenderer, dx, dy);
}
- private static native void nTranslate(int renderer, float dx, float dy);
+ private static native void nTranslate(long renderer, float dx, float dy);
@Override
public void skew(float sx, float sy) {
nSkew(mRenderer, sx, sy);
}
- private static native void nSkew(int renderer, float sx, float sy);
+ private static native void nSkew(long renderer, float sx, float sy);
@Override
public void rotate(float degrees) {
nRotate(mRenderer, degrees);
}
- private static native void nRotate(int renderer, float degrees);
+ private static native void nRotate(long renderer, float degrees);
@Override
public void scale(float sx, float sy) {
nScale(mRenderer, sx, sy);
}
- private static native void nScale(int renderer, float sx, float sy);
+ private static native void nScale(long renderer, float sx, float sy);
@Override
public void setMatrix(Matrix matrix) {
nSetMatrix(mRenderer, matrix == null ? 0 : matrix.native_instance);
}
- private static native void nSetMatrix(int renderer, int matrix);
+ private static native void nSetMatrix(long renderer, long matrix);
@SuppressWarnings("deprecation")
@Override
@@ -617,14 +617,14 @@ class GLES20Canvas extends HardwareCanvas {
nGetMatrix(mRenderer, matrix.native_instance);
}
- private static native void nGetMatrix(int renderer, int matrix);
+ private static native void nGetMatrix(long renderer, long matrix);
@Override
public void concat(Matrix matrix) {
if (matrix != null) nConcatMatrix(mRenderer, matrix.native_instance);
}
- private static native void nConcatMatrix(int renderer, int matrix);
+ private static native void nConcatMatrix(long renderer, long matrix);
///////////////////////////////////////////////////////////////////////////
// State management
@@ -640,7 +640,7 @@ class GLES20Canvas extends HardwareCanvas {
return nSave(mRenderer, saveFlags);
}
- private static native int nSave(int renderer, int flags);
+ private static native int nSave(long renderer, int flags);
@Override
public int saveLayer(RectF bounds, Paint paint, int saveFlags) {
@@ -651,7 +651,7 @@ class GLES20Canvas extends HardwareCanvas {
int count;
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
count = nSaveLayer(mRenderer, nativePaint, saveFlags);
} finally {
if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier);
@@ -659,7 +659,7 @@ class GLES20Canvas extends HardwareCanvas {
return count;
}
- private static native int nSaveLayer(int renderer, int paint, int saveFlags);
+ private static native int nSaveLayer(long renderer, long paint, int saveFlags);
@Override
public int saveLayer(float left, float top, float right, float bottom, Paint paint,
@@ -668,7 +668,7 @@ class GLES20Canvas extends HardwareCanvas {
int count;
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
count = nSaveLayer(mRenderer, left, top, right, bottom, nativePaint, saveFlags);
} finally {
if (modifier != MODIFIER_NONE) nResetModifiers(mRenderer, modifier);
@@ -678,8 +678,8 @@ class GLES20Canvas extends HardwareCanvas {
return save(saveFlags);
}
- private static native int nSaveLayer(int renderer, float left, float top,
- float right, float bottom, int paint, int saveFlags);
+ private static native int nSaveLayer(long renderer, float left, float top,
+ float right, float bottom, long paint, int saveFlags);
@Override
public int saveLayerAlpha(RectF bounds, int alpha, int saveFlags) {
@@ -690,7 +690,7 @@ class GLES20Canvas extends HardwareCanvas {
return nSaveLayerAlpha(mRenderer, alpha, saveFlags);
}
- private static native int nSaveLayerAlpha(int renderer, int alpha, int saveFlags);
+ private static native int nSaveLayerAlpha(long renderer, int alpha, int saveFlags);
@Override
public int saveLayerAlpha(float left, float top, float right, float bottom, int alpha,
@@ -701,7 +701,7 @@ class GLES20Canvas extends HardwareCanvas {
return save(saveFlags);
}
- private static native int nSaveLayerAlpha(int renderer, float left, float top, float right,
+ private static native int nSaveLayerAlpha(long renderer, float left, float top, float right,
float bottom, int alpha, int saveFlags);
@Override
@@ -709,21 +709,21 @@ class GLES20Canvas extends HardwareCanvas {
nRestore(mRenderer);
}
- private static native void nRestore(int renderer);
+ private static native void nRestore(long renderer);
@Override
public void restoreToCount(int saveCount) {
nRestoreToCount(mRenderer, saveCount);
}
- private static native void nRestoreToCount(int renderer, int saveCount);
+ private static native void nRestoreToCount(long renderer, int saveCount);
@Override
public int getSaveCount() {
return nGetSaveCount(mRenderer);
}
- private static native int nGetSaveCount(int renderer);
+ private static native int nGetSaveCount(long renderer);
///////////////////////////////////////////////////////////////////////////
// Filtering
@@ -740,8 +740,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nResetPaintFilter(int renderer);
- private static native void nSetupPaintFilter(int renderer, int clearBits, int setBits);
+ private static native void nResetPaintFilter(long renderer);
+ private static native void nSetupPaintFilter(long renderer, int clearBits, int setBits);
@Override
public DrawFilter getDrawFilter() {
@@ -764,9 +764,9 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawArc(int renderer, float left, float top,
+ private static native void nDrawArc(long renderer, float left, float top,
float right, float bottom, float startAngle, float sweepAngle,
- boolean useCenter, int paint);
+ boolean useCenter, long paint);
@Override
public void drawARGB(int a, int r, int g, int b) {
@@ -780,7 +780,7 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing patches
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, patch.mNativeChunk,
dst.left, dst.top, dst.right, dst.bottom, nativePaint);
} finally {
@@ -795,7 +795,7 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing patches
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawPatch(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, patch.mNativeChunk,
dst.left, dst.top, dst.right, dst.bottom, nativePaint);
} finally {
@@ -803,8 +803,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawPatch(int renderer, int bitmap, byte[] buffer, int chunk,
- float left, float top, float right, float bottom, int paint);
+ private static native void nDrawPatch(long renderer, long bitmap, byte[] buffer, long chunk,
+ float left, float top, float right, float bottom, long paint);
@Override
public void drawBitmap(Bitmap bitmap, float left, float top, Paint paint) {
@@ -812,15 +812,15 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, left, top, nativePaint);
} finally {
if (modifiers != MODIFIER_NONE) nResetModifiers(mRenderer, modifiers);
}
}
- private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer,
- float left, float top, int paint);
+ private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer,
+ float left, float top, long paint);
@Override
public void drawBitmap(Bitmap bitmap, Matrix matrix, Paint paint) {
@@ -828,7 +828,7 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawBitmap(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer,
matrix.native_instance, nativePaint);
} finally {
@@ -836,8 +836,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer,
- int matrix, int paint);
+ private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer,
+ long matrix, long paint);
@Override
public void drawBitmap(Bitmap bitmap, Rect src, Rect dst, Paint paint) {
@@ -845,7 +845,7 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
int left, top, right, bottom;
if (src == null) {
@@ -872,7 +872,7 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing bitmaps
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
float left, top, right, bottom;
if (src == null) {
@@ -893,9 +893,9 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawBitmap(int renderer, int bitmap, byte[] buffer,
+ private static native void nDrawBitmap(long renderer, long bitmap, byte[] buffer,
float srcLeft, float srcTop, float srcRight, float srcBottom,
- float left, float top, float right, float bottom, int paint);
+ float left, float top, float right, float bottom, long paint);
@Override
public void drawBitmap(int[] colors, int offset, int stride, float x, float y,
@@ -923,7 +923,7 @@ class GLES20Canvas extends HardwareCanvas {
// Shaders are ignored when drawing bitmaps
int modifier = paint != null ? setupColorFilter(paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawBitmap(mRenderer, colors, offset, stride, x, y,
width, height, hasAlpha, nativePaint);
} finally {
@@ -931,8 +931,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawBitmap(int renderer, int[] colors, int offset, int stride,
- float x, float y, int width, int height, boolean hasAlpha, int nativePaint);
+ private static native void nDrawBitmap(long renderer, int[] colors, int offset, int stride,
+ float x, float y, int width, int height, boolean hasAlpha, long nativePaint);
@Override
public void drawBitmap(int[] colors, int offset, int stride, int x, int y,
@@ -962,7 +962,7 @@ class GLES20Canvas extends HardwareCanvas {
int modifiers = paint != null ? setupModifiers(bitmap, paint) : MODIFIER_NONE;
try {
- final int nativePaint = paint == null ? 0 : paint.mNativePaint;
+ final long nativePaint = paint == null ? 0 : paint.mNativePaint;
nDrawBitmapMesh(mRenderer, bitmap.mNativeBitmap, bitmap.mBuffer, meshWidth, meshHeight,
verts, vertOffset, colors, colorOffset, nativePaint);
} finally {
@@ -970,9 +970,9 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawBitmapMesh(int renderer, int bitmap, byte[] buffer,
+ private static native void nDrawBitmapMesh(long renderer, long bitmap, byte[] buffer,
int meshWidth, int meshHeight, float[] verts, int vertOffset,
- int[] colors, int colorOffset, int paint);
+ int[] colors, int colorOffset, long paint);
@Override
public void drawCircle(float cx, float cy, float radius, Paint paint) {
@@ -984,8 +984,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawCircle(int renderer, float cx, float cy,
- float radius, int paint);
+ private static native void nDrawCircle(long renderer, float cx, float cy,
+ float radius, long paint);
@Override
public void drawColor(int color) {
@@ -997,7 +997,7 @@ class GLES20Canvas extends HardwareCanvas {
nDrawColor(mRenderer, color, mode.nativeInt);
}
- private static native void nDrawColor(int renderer, int color, int mode);
+ private static native void nDrawColor(long renderer, int color, int mode);
@Override
public void drawLine(float startX, float startY, float stopX, float stopY, Paint paint) {
@@ -1024,8 +1024,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawLines(int renderer, float[] points,
- int offset, int count, int paint);
+ private static native void nDrawLines(long renderer, float[] points,
+ int offset, int count, long paint);
@Override
public void drawLines(float[] pts, Paint paint) {
@@ -1042,8 +1042,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawOval(int renderer, float left, float top,
- float right, float bottom, int paint);
+ private static native void nDrawOval(long renderer, float left, float top,
+ float right, float bottom, long paint);
@Override
public void drawPaint(Paint paint) {
@@ -1068,8 +1068,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawPath(int renderer, int path, int paint);
- private static native void nDrawRects(int renderer, int region, int paint);
+ private static native void nDrawPath(long renderer, long path, long paint);
+ private static native void nDrawRects(long renderer, long region, long paint);
void drawRects(float[] rects, int count, Paint paint) {
int modifiers = setupModifiers(paint, MODIFIER_COLOR_FILTER | MODIFIER_SHADER);
@@ -1080,7 +1080,7 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawRects(int renderer, float[] rects, int count, int paint);
+ private static native void nDrawRects(long renderer, float[] rects, int count, long paint);
@Override
public void drawPicture(Picture picture) {
@@ -1147,8 +1147,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawPoints(int renderer, float[] points,
- int offset, int count, int paint);
+ private static native void nDrawPoints(long renderer, float[] points,
+ int offset, int count, long paint);
@SuppressWarnings("deprecation")
@Override
@@ -1165,8 +1165,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawPosText(int renderer, char[] text, int index, int count,
- float[] pos, int paint);
+ private static native void nDrawPosText(long renderer, char[] text, int index, int count,
+ float[] pos, long paint);
@SuppressWarnings("deprecation")
@Override
@@ -1183,8 +1183,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawPosText(int renderer, String text, int start, int end,
- float[] pos, int paint);
+ private static native void nDrawPosText(long renderer, String text, int start, int end,
+ float[] pos, long paint);
@Override
public void drawRect(float left, float top, float right, float bottom, Paint paint) {
@@ -1197,8 +1197,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawRect(int renderer, float left, float top,
- float right, float bottom, int paint);
+ private static native void nDrawRect(long renderer, float left, float top,
+ float right, float bottom, long paint);
@Override
public void drawRect(Rect r, Paint paint) {
@@ -1226,8 +1226,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawRoundRect(int renderer, float left, float top,
- float right, float bottom, float rx, float y, int paint);
+ private static native void nDrawRoundRect(long renderer, float left, float top,
+ float right, float bottom, float rx, float y, long paint);
@Override
public void drawText(char[] text, int index, int count, float x, float y, Paint paint) {
@@ -1243,8 +1243,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawText(int renderer, char[] text, int index, int count,
- float x, float y, int bidiFlags, int paint);
+ private static native void nDrawText(long renderer, char[] text, int index, int count,
+ float x, float y, int bidiFlags, long paint);
@Override
public void drawText(CharSequence text, int start, int end, float x, float y, Paint paint) {
@@ -1283,8 +1283,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawText(int renderer, String text, int start, int end,
- float x, float y, int bidiFlags, int paint);
+ private static native void nDrawText(long renderer, String text, int start, int end,
+ float x, float y, int bidiFlags, long paint);
@Override
public void drawText(String text, float x, float y, Paint paint) {
@@ -1313,8 +1313,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawTextOnPath(int renderer, char[] text, int index, int count,
- int path, float hOffset, float vOffset, int bidiFlags, int nativePaint);
+ private static native void nDrawTextOnPath(long renderer, char[] text, int index, int count,
+ long path, float hOffset, float vOffset, int bidiFlags, long nativePaint);
@Override
public void drawTextOnPath(String text, Path path, float hOffset, float vOffset, Paint paint) {
@@ -1329,8 +1329,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawTextOnPath(int renderer, String text, int start, int end,
- int path, float hOffset, float vOffset, int bidiFlags, int nativePaint);
+ private static native void nDrawTextOnPath(long renderer, String text, int start, int end,
+ long path, float hOffset, float vOffset, int bidiFlags, long nativePaint);
@Override
public void drawTextRun(char[] text, int index, int count, int contextIndex, int contextCount,
@@ -1351,8 +1351,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawTextRun(int renderer, char[] text, int index, int count,
- int contextIndex, int contextCount, float x, float y, int dir, int nativePaint);
+ private static native void nDrawTextRun(long renderer, char[] text, int index, int count,
+ int contextIndex, int contextCount, float x, float y, int dir, long nativePaint);
@Override
public void drawTextRun(CharSequence text, int start, int end, int contextStart, int contextEnd,
@@ -1385,8 +1385,8 @@ class GLES20Canvas extends HardwareCanvas {
}
}
- private static native void nDrawTextRun(int renderer, String text, int start, int end,
- int contextStart, int contextEnd, float x, float y, int flags, int nativePaint);
+ private static native void nDrawTextRun(long renderer, String text, int start, int end,
+ int contextStart, int contextEnd, float x, float y, int flags, long nativePaint);
@Override
public void drawVertices(VertexMode mode, int vertexCount, float[] verts, int vertOffset,
@@ -1466,10 +1466,10 @@ class GLES20Canvas extends HardwareCanvas {
return MODIFIER_NONE;
}
- private static native void nSetupShader(int renderer, int shader);
- private static native void nSetupColorFilter(int renderer, int colorFilter);
- private static native void nSetupShadow(int renderer, float radius,
+ private static native void nSetupShader(long renderer, long shader);
+ private static native void nSetupColorFilter(long renderer, long colorFilter);
+ private static native void nSetupShadow(long renderer, float radius,
float dx, float dy, int color);
- private static native void nResetModifiers(int renderer, int modifiers);
+ private static native void nResetModifiers(long renderer, int modifiers);
}
diff --git a/core/java/android/view/GLES20DisplayList.java b/core/java/android/view/GLES20DisplayList.java
index c652bac..7f8b3bd 100644
--- a/core/java/android/view/GLES20DisplayList.java
+++ b/core/java/android/view/GLES20DisplayList.java
@@ -44,7 +44,7 @@ class GLES20DisplayList extends DisplayList {
return mValid && mFinalizer != null;
}
- int getNativeDisplayList() {
+ long getNativeDisplayList() {
if (!mValid || mFinalizer == null) {
throw new IllegalStateException("The display list is not valid.");
}
@@ -124,9 +124,9 @@ class GLES20DisplayList extends DisplayList {
return nGetDisplayListSize(mFinalizer.mNativeDisplayList);
}
- private static native void nDestroyDisplayList(int displayList);
- private static native int nGetDisplayListSize(int displayList);
- private static native void nSetDisplayListName(int displayList, String name);
+ private static native void nDestroyDisplayList(long displayList);
+ private static native int nGetDisplayListSize(long displayList);
+ private static native void nSetDisplayListName(long displayList, String name);
///////////////////////////////////////////////////////////////////////////
// Native View Properties
@@ -440,62 +440,62 @@ class GLES20DisplayList extends DisplayList {
}
}
- private static native void nReset(int displayList);
- private static native void nOffsetTopAndBottom(int displayList, float offset);
- private static native void nOffsetLeftAndRight(int displayList, float offset);
- private static native void nSetLeftTopRightBottom(int displayList, int left, int top,
+ private static native void nReset(long displayList);
+ private static native void nOffsetTopAndBottom(long displayList, float offset);
+ private static native void nOffsetLeftAndRight(long displayList, float offset);
+ private static native void nSetLeftTopRightBottom(long displayList, int left, int top,
int right, int bottom);
- private static native void nSetBottom(int displayList, int bottom);
- private static native void nSetRight(int displayList, int right);
- private static native void nSetTop(int displayList, int top);
- private static native void nSetLeft(int displayList, int left);
- private static native void nSetCameraDistance(int displayList, float distance);
- private static native void nSetPivotY(int displayList, float pivotY);
- private static native void nSetPivotX(int displayList, float pivotX);
- private static native void nSetCaching(int displayList, boolean caching);
- private static native void nSetClipToBounds(int displayList, boolean clipToBounds);
- private static native void nSetAlpha(int displayList, float alpha);
- private static native void nSetHasOverlappingRendering(int displayList,
+ private static native void nSetBottom(long displayList, int bottom);
+ private static native void nSetRight(long displayList, int right);
+ private static native void nSetTop(long displayList, int top);
+ private static native void nSetLeft(long displayList, int left);
+ private static native void nSetCameraDistance(long displayList, float distance);
+ private static native void nSetPivotY(long displayList, float pivotY);
+ private static native void nSetPivotX(long displayList, float pivotX);
+ private static native void nSetCaching(long displayList, boolean caching);
+ private static native void nSetClipToBounds(long displayList, boolean clipToBounds);
+ private static native void nSetAlpha(long displayList, float alpha);
+ private static native void nSetHasOverlappingRendering(long displayList,
boolean hasOverlappingRendering);
- private static native void nSetTranslationX(int displayList, float translationX);
- private static native void nSetTranslationY(int displayList, float translationY);
- private static native void nSetRotation(int displayList, float rotation);
- private static native void nSetRotationX(int displayList, float rotationX);
- private static native void nSetRotationY(int displayList, float rotationY);
- private static native void nSetScaleX(int displayList, float scaleX);
- private static native void nSetScaleY(int displayList, float scaleY);
- private static native void nSetTransformationInfo(int displayList, float alpha,
+ private static native void nSetTranslationX(long displayList, float translationX);
+ private static native void nSetTranslationY(long displayList, float translationY);
+ private static native void nSetRotation(long displayList, float rotation);
+ private static native void nSetRotationX(long displayList, float rotationX);
+ private static native void nSetRotationY(long displayList, float rotationY);
+ private static native void nSetScaleX(long displayList, float scaleX);
+ private static native void nSetScaleY(long displayList, float scaleY);
+ private static native void nSetTransformationInfo(long displayList, float alpha,
float translationX, float translationY, float rotation, float rotationX,
float rotationY, float scaleX, float scaleY);
- private static native void nSetStaticMatrix(int displayList, int nativeMatrix);
- private static native void nSetAnimationMatrix(int displayList, int animationMatrix);
-
- private static native boolean nHasOverlappingRendering(int displayList);
- private static native void nGetMatrix(int displayList, int matrix);
- private static native float nGetAlpha(int displayList);
- private static native float nGetLeft(int displayList);
- private static native float nGetTop(int displayList);
- private static native float nGetRight(int displayList);
- private static native float nGetBottom(int displayList);
- private static native float nGetCameraDistance(int displayList);
- private static native float nGetScaleX(int displayList);
- private static native float nGetScaleY(int displayList);
- private static native float nGetTranslationX(int displayList);
- private static native float nGetTranslationY(int displayList);
- private static native float nGetRotation(int displayList);
- private static native float nGetRotationX(int displayList);
- private static native float nGetRotationY(int displayList);
- private static native float nGetPivotX(int displayList);
- private static native float nGetPivotY(int displayList);
+ private static native void nSetStaticMatrix(long displayList, long nativeMatrix);
+ private static native void nSetAnimationMatrix(long displayList, long animationMatrix);
+
+ private static native boolean nHasOverlappingRendering(long displayList);
+ private static native void nGetMatrix(long displayList, long matrix);
+ private static native float nGetAlpha(long displayList);
+ private static native float nGetLeft(long displayList);
+ private static native float nGetTop(long displayList);
+ private static native float nGetRight(long displayList);
+ private static native float nGetBottom(long displayList);
+ private static native float nGetCameraDistance(long displayList);
+ private static native float nGetScaleX(long displayList);
+ private static native float nGetScaleY(long displayList);
+ private static native float nGetTranslationX(long displayList);
+ private static native float nGetTranslationY(long displayList);
+ private static native float nGetRotation(long displayList);
+ private static native float nGetRotationX(long displayList);
+ private static native float nGetRotationY(long displayList);
+ private static native float nGetPivotX(long displayList);
+ private static native float nGetPivotY(long displayList);
///////////////////////////////////////////////////////////////////////////
// Finalization
///////////////////////////////////////////////////////////////////////////
private static class DisplayListFinalizer {
- final int mNativeDisplayList;
+ final long mNativeDisplayList;
- public DisplayListFinalizer(int nativeDisplayList) {
+ public DisplayListFinalizer(long nativeDisplayList) {
mNativeDisplayList = nativeDisplayList;
}
diff --git a/core/java/android/view/GLES20Layer.java b/core/java/android/view/GLES20Layer.java
index 0e3311c..37154eb 100644
--- a/core/java/android/view/GLES20Layer.java
+++ b/core/java/android/view/GLES20Layer.java
@@ -24,7 +24,7 @@ import android.graphics.Paint;
* An OpenGL ES 2.0 implementation of {@link HardwareLayer}.
*/
abstract class GLES20Layer extends HardwareLayer {
- int mLayer;
+ long mLayer;
Finalizer mFinalizer;
GLES20Layer() {
@@ -39,7 +39,7 @@ abstract class GLES20Layer extends HardwareLayer {
*
* @return A pointer to the native layer object, or 0 if the object is NULL
*/
- public int getLayer() {
+ public long getLayer() {
return mLayer;
}
@@ -75,9 +75,9 @@ abstract class GLES20Layer extends HardwareLayer {
}
static class Finalizer {
- private int mLayerId;
+ private long mLayerId;
- public Finalizer(int layerId) {
+ public Finalizer(long layerId) {
mLayerId = layerId;
}
diff --git a/core/java/android/view/GLES20RecordingCanvas.java b/core/java/android/view/GLES20RecordingCanvas.java
index b6fc38d..e3e1c76 100644
--- a/core/java/android/view/GLES20RecordingCanvas.java
+++ b/core/java/android/view/GLES20RecordingCanvas.java
@@ -58,7 +58,7 @@ class GLES20RecordingCanvas extends GLES20Canvas {
mDisplayList.clearReferences();
}
- int end(int nativeDisplayList) {
+ long end(long nativeDisplayList) {
return getDisplayList(nativeDisplayList);
}
diff --git a/core/java/android/view/GraphicBuffer.java b/core/java/android/view/GraphicBuffer.java
index 30c077c..5f2a9cd 100644
--- a/core/java/android/view/GraphicBuffer.java
+++ b/core/java/android/view/GraphicBuffer.java
@@ -56,7 +56,7 @@ public class GraphicBuffer implements Parcelable {
private final int mFormat;
private final int mUsage;
// Note: do not rename, this field is used by native code
- private final int mNativeObject;
+ private final long mNativeObject;
// These two fields are only used by lock/unlockCanvas()
private Canvas mCanvas;
@@ -77,7 +77,7 @@ public class GraphicBuffer implements Parcelable {
* @return A <code>GraphicBuffer</code> instance or null
*/
public static GraphicBuffer create(int width, int height, int format, int usage) {
- int nativeObject = nCreateGraphicBuffer(width, height, format, usage);
+ long nativeObject = nCreateGraphicBuffer(width, height, format, usage);
if (nativeObject != 0) {
return new GraphicBuffer(width, height, format, usage, nativeObject);
}
@@ -87,7 +87,7 @@ public class GraphicBuffer implements Parcelable {
/**
* Private use only. See {@link #create(int, int, int, int)}.
*/
- private GraphicBuffer(int width, int height, int format, int usage, int nativeObject) {
+ private GraphicBuffer(int width, int height, int format, int usage, long nativeObject) {
mWidth = width;
mHeight = height;
mFormat = format;
@@ -271,7 +271,7 @@ public class GraphicBuffer implements Parcelable {
int height = in.readInt();
int format = in.readInt();
int usage = in.readInt();
- int nativeObject = nReadGraphicBufferFromParcel(in);
+ long nativeObject = nReadGraphicBufferFromParcel(in);
if (nativeObject != 0) {
return new GraphicBuffer(width, height, format, usage, nativeObject);
}
@@ -283,10 +283,10 @@ public class GraphicBuffer implements Parcelable {
}
};
- private static native int nCreateGraphicBuffer(int width, int height, int format, int usage);
- private static native void nDestroyGraphicBuffer(int nativeObject);
- private static native void nWriteGraphicBufferToParcel(int nativeObject, Parcel dest);
- private static native int nReadGraphicBufferFromParcel(Parcel in);
- private static native boolean nLockCanvas(int nativeObject, Canvas canvas, Rect dirty);
- private static native boolean nUnlockCanvasAndPost(int nativeObject, Canvas canvas);
+ private static native long nCreateGraphicBuffer(int width, int height, int format, int usage);
+ private static native void nDestroyGraphicBuffer(long nativeObject);
+ private static native void nWriteGraphicBufferToParcel(long nativeObject, Parcel dest);
+ private static native long nReadGraphicBufferFromParcel(Parcel in);
+ private static native boolean nLockCanvas(long nativeObject, Canvas canvas, Rect dirty);
+ private static native boolean nUnlockCanvasAndPost(long nativeObject, Canvas canvas);
}
diff --git a/core/java/android/view/HardwareCanvas.java b/core/java/android/view/HardwareCanvas.java
index 259e1cd..10f700c 100644
--- a/core/java/android/view/HardwareCanvas.java
+++ b/core/java/android/view/HardwareCanvas.java
@@ -145,7 +145,7 @@ public abstract class HardwareCanvas extends Canvas {
*
* @hide
*/
- public int callDrawGLFunction(int drawGLFunction) {
+ public int callDrawGLFunction(long drawGLFunction) {
// Noop - this is done in the display list recorder subclass
return DisplayList.STATUS_DONE;
}
@@ -170,12 +170,12 @@ public abstract class HardwareCanvas extends Canvas {
* @param functor The native functor to remove from the execution queue.
*
* @see #invokeFunctors(android.graphics.Rect)
- * @see #callDrawGLFunction(int)
- * @see #detachFunctor(int)
+ * @see #callDrawGLFunction(long)
+ * @see #detachFunctor(long)
*
* @hide
*/
- abstract void detachFunctor(int functor);
+ abstract void detachFunctor(long functor);
/**
* Attaches the specified functor to the current functor execution queue.
@@ -183,12 +183,12 @@ public abstract class HardwareCanvas extends Canvas {
* @param functor The native functor to add to the execution queue.
*
* @see #invokeFunctors(android.graphics.Rect)
- * @see #callDrawGLFunction(int)
- * @see #detachFunctor(int)
+ * @see #callDrawGLFunction(long)
+ * @see #detachFunctor(long)
*
* @hide
*/
- abstract void attachFunctor(int functor);
+ abstract void attachFunctor(long functor);
/**
* Indicates that the specified layer must be updated as soon as possible.
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java
index f215189..3781bdb 100644
--- a/core/java/android/view/HardwareRenderer.java
+++ b/core/java/android/view/HardwareRenderer.java
@@ -568,7 +568,7 @@ public abstract class HardwareRenderer {
* @see HardwareCanvas#callDrawGLFunction(int)
* @see #attachFunctor(android.view.View.AttachInfo, int)
*/
- abstract void detachFunctor(int functor);
+ abstract void detachFunctor(long functor);
/**
* Schedules the specified functor in the functors execution queue.
@@ -581,7 +581,7 @@ public abstract class HardwareRenderer {
*
* @return true if the functor was attached successfully
*/
- abstract boolean attachFunctor(View.AttachInfo attachInfo, int functor);
+ abstract boolean attachFunctor(View.AttachInfo attachInfo, long functor);
/**
* Initializes the hardware renderer for the specified surface and setup the
@@ -1712,14 +1712,14 @@ public abstract class HardwareRenderer {
}
@Override
- void detachFunctor(int functor) {
+ void detachFunctor(long functor) {
if (mCanvas != null) {
mCanvas.detachFunctor(functor);
}
}
@Override
- boolean attachFunctor(View.AttachInfo attachInfo, int functor) {
+ boolean attachFunctor(View.AttachInfo attachInfo, long functor) {
if (mCanvas != null) {
mCanvas.attachFunctor(functor);
mFunctorsRunnable.attachInfo = attachInfo;
diff --git a/core/java/android/view/InputChannel.java b/core/java/android/view/InputChannel.java
index 40ee1ad..de195ae 100644
--- a/core/java/android/view/InputChannel.java
+++ b/core/java/android/view/InputChannel.java
@@ -46,7 +46,7 @@ public final class InputChannel implements Parcelable {
};
@SuppressWarnings("unused")
- private int mPtr; // used by native code
+ private long mPtr; // used by native code
private static native InputChannel[] nativeOpenInputChannelPair(String name);
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index e829116..0b12cbe 100644
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -17,6 +17,7 @@
package android.view;
import android.content.Context;
+import android.hardware.input.InputDeviceIdentifier;
import android.hardware.input.InputManager;
import android.os.Parcel;
import android.os.Parcelable;
@@ -49,6 +50,7 @@ public final class InputDevice implements Parcelable {
private final int mVendorId;
private final int mProductId;
private final String mDescriptor;
+ private final InputDeviceIdentifier mIdentifier;
private final boolean mIsExternal;
private final int mSources;
private final int mKeyboardType;
@@ -61,7 +63,7 @@ public final class InputDevice implements Parcelable {
/**
* A mask for input source classes.
- *
+ *
* Each distinct input source constant has one or more input source class bits set to
* specify the desired interpretation for its input events.
*/
@@ -77,46 +79,46 @@ public final class InputDevice implements Parcelable {
/**
* The input source has buttons or keys.
* Examples: {@link #SOURCE_KEYBOARD}, {@link #SOURCE_DPAD}.
- *
+ *
* A {@link KeyEvent} should be interpreted as a button or key press.
- *
+ *
* Use {@link #getKeyCharacterMap} to query the device's button and key mappings.
*/
public static final int SOURCE_CLASS_BUTTON = 0x00000001;
-
+
/**
* The input source is a pointing device associated with a display.
* Examples: {@link #SOURCE_TOUCHSCREEN}, {@link #SOURCE_MOUSE}.
- *
+ *
* A {@link MotionEvent} should be interpreted as absolute coordinates in
* display units according to the {@link View} hierarchy. Pointer down/up indicated when
* the finger touches the display or when the selection button is pressed/released.
- *
+ *
* Use {@link #getMotionRange} to query the range of the pointing device. Some devices permit
* touches outside the display area so the effective range may be somewhat smaller or larger
* than the actual display size.
*/
public static final int SOURCE_CLASS_POINTER = 0x00000002;
-
+
/**
* The input source is a trackball navigation device.
* Examples: {@link #SOURCE_TRACKBALL}.
- *
+ *
* A {@link MotionEvent} should be interpreted as relative movements in device-specific
* units used for navigation purposes. Pointer down/up indicates when the selection button
* is pressed/released.
- *
+ *
* Use {@link #getMotionRange} to query the range of motion.
*/
public static final int SOURCE_CLASS_TRACKBALL = 0x00000004;
-
+
/**
* The input source is an absolute positioning device not associated with a display
* (unlike {@link #SOURCE_CLASS_POINTER}).
- *
+ *
* A {@link MotionEvent} should be interpreted as absolute coordinates in
* device-specific surface units.
- *
+ *
* Use {@link #getMotionRange} to query the range of positions.
*/
public static final int SOURCE_CLASS_POSITION = 0x00000008;
@@ -134,7 +136,7 @@ public final class InputDevice implements Parcelable {
* The input source is unknown.
*/
public static final int SOURCE_UNKNOWN = 0x00000000;
-
+
/**
* The input source is a keyboard.
*
@@ -145,10 +147,10 @@ public final class InputDevice implements Parcelable {
* @see #SOURCE_CLASS_BUTTON
*/
public static final int SOURCE_KEYBOARD = 0x00000100 | SOURCE_CLASS_BUTTON;
-
+
/**
* The input source is a DPad.
- *
+ *
* @see #SOURCE_CLASS_BUTTON
*/
public static final int SOURCE_DPAD = 0x00000200 | SOURCE_CLASS_BUTTON;
@@ -163,16 +165,16 @@ public final class InputDevice implements Parcelable {
/**
* The input source is a touch screen pointing device.
- *
+ *
* @see #SOURCE_CLASS_POINTER
*/
public static final int SOURCE_TOUCHSCREEN = 0x00001000 | SOURCE_CLASS_POINTER;
-
+
/**
* The input source is a mouse pointing device.
* This code is also used for other mouse-like pointing devices such as trackpads
* and trackpoints.
- *
+ *
* @see #SOURCE_CLASS_POINTER
*/
public static final int SOURCE_MOUSE = 0x00002000 | SOURCE_CLASS_POINTER;
@@ -199,15 +201,15 @@ public final class InputDevice implements Parcelable {
/**
* The input source is a trackball.
- *
+ *
* @see #SOURCE_CLASS_TRACKBALL
*/
public static final int SOURCE_TRACKBALL = 0x00010000 | SOURCE_CLASS_TRACKBALL;
-
+
/**
* The input source is a touch pad or digitizer tablet that is not
* associated with a display (unlike {@link #SOURCE_TOUCHSCREEN}).
- *
+ *
* @see #SOURCE_CLASS_POSITION
*/
public static final int SOURCE_TOUCHPAD = 0x00100000 | SOURCE_CLASS_POSITION;
@@ -239,7 +241,7 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_X}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_X} instead.
*/
@@ -248,7 +250,7 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_Y}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_Y} instead.
*/
@@ -257,7 +259,7 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_PRESSURE}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_PRESSURE} instead.
*/
@@ -266,7 +268,7 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_SIZE}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_SIZE} instead.
*/
@@ -275,7 +277,7 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_TOUCH_MAJOR}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_TOUCH_MAJOR} instead.
*/
@@ -284,7 +286,7 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_TOUCH_MINOR}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_TOUCH_MINOR} instead.
*/
@@ -293,7 +295,7 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_TOOL_MAJOR}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_TOOL_MAJOR} instead.
*/
@@ -302,7 +304,7 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_TOOL_MINOR}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_TOOL_MINOR} instead.
*/
@@ -311,24 +313,24 @@ public final class InputDevice implements Parcelable {
/**
* Constant for retrieving the range of values for {@link MotionEvent#AXIS_ORIENTATION}.
- *
+ *
* @see #getMotionRange
* @deprecated Use {@link MotionEvent#AXIS_ORIENTATION} instead.
*/
@Deprecated
public static final int MOTION_RANGE_ORIENTATION = MotionEvent.AXIS_ORIENTATION;
-
+
/**
* There is no keyboard.
*/
public static final int KEYBOARD_TYPE_NONE = 0;
-
+
/**
* The keyboard is not fully alphabetic. It may be a numeric keypad or an assortment
* of buttons that are not mapped as alphabetic keys suitable for text input.
*/
public static final int KEYBOARD_TYPE_NON_ALPHABETIC = 1;
-
+
/**
* The keyboard supports a complement of alphabetic keys.
*/
@@ -361,6 +363,7 @@ public final class InputDevice implements Parcelable {
mKeyCharacterMap = keyCharacterMap;
mHasVibrator = hasVibrator;
mHasButtonUnderPad = hasButtonUnderPad;
+ mIdentifier = new InputDeviceIdentifier(descriptor, vendorId, productId);
}
private InputDevice(Parcel in) {
@@ -377,6 +380,7 @@ public final class InputDevice implements Parcelable {
mKeyCharacterMap = KeyCharacterMap.CREATOR.createFromParcel(in);
mHasVibrator = in.readInt() != 0;
mHasButtonUnderPad = in.readInt() != 0;
+ mIdentifier = new InputDeviceIdentifier(mDescriptor, mVendorId, mProductId);
for (;;) {
int axis = in.readInt();
@@ -396,7 +400,7 @@ public final class InputDevice implements Parcelable {
public static InputDevice getDevice(int id) {
return InputManager.getInstance().getInputDevice(id);
}
-
+
/**
* Gets the ids of all input devices in the system.
* @return The input device ids.
@@ -441,6 +445,18 @@ public final class InputDevice implements Parcelable {
}
/**
+ * The set of identifying information for type of input device. This
+ * information can be used by the system to configure appropriate settings
+ * for the device.
+ *
+ * @return The identifier object for this device
+ * @hide
+ */
+ public InputDeviceIdentifier getIdentifier() {
+ return mIdentifier;
+ }
+
+ /**
* Gets a generation number for this input device.
* The generation number is incremented whenever the device is reconfigured and its
* properties may have changed.
@@ -553,7 +569,7 @@ public final class InputDevice implements Parcelable {
public String getName() {
return mName;
}
-
+
/**
* Gets the input sources supported by this input device as a combined bitfield.
* @return The supported input sources.
@@ -561,7 +577,7 @@ public final class InputDevice implements Parcelable {
public int getSources() {
return mSources;
}
-
+
/**
* Gets the keyboard type.
* @return The keyboard type.
@@ -569,7 +585,7 @@ public final class InputDevice implements Parcelable {
public int getKeyboardType() {
return mKeyboardType;
}
-
+
/**
* Gets the key character map associated with this input device.
* @return The key character map.
diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java
index 25972e7..91ef50d 100644
--- a/core/java/android/view/InputEventReceiver.java
+++ b/core/java/android/view/InputEventReceiver.java
@@ -34,7 +34,7 @@ public abstract class InputEventReceiver {
private final CloseGuard mCloseGuard = CloseGuard.get();
- private int mReceiverPtr;
+ private long mReceiverPtr;
// We keep references to the input channel and message queue objects here so that
// they are not GC'd while the native peer of the receiver is using them.
@@ -44,11 +44,11 @@ public abstract class InputEventReceiver {
// Map from InputEvent sequence numbers to dispatcher sequence numbers.
private final SparseIntArray mSeqMap = new SparseIntArray();
- private static native int nativeInit(WeakReference<InputEventReceiver> receiver,
+ private static native long nativeInit(WeakReference<InputEventReceiver> receiver,
InputChannel inputChannel, MessageQueue messageQueue);
- private static native void nativeDispose(int receiverPtr);
- private static native void nativeFinishInputEvent(int receiverPtr, int seq, boolean handled);
- private static native boolean nativeConsumeBatchedInputEvents(int receiverPtr,
+ private static native void nativeDispose(long receiverPtr);
+ private static native void nativeFinishInputEvent(long receiverPtr, int seq, boolean handled);
+ private static native boolean nativeConsumeBatchedInputEvents(long receiverPtr,
long frameTimeNanos);
/**
diff --git a/core/java/android/view/InputEventSender.java b/core/java/android/view/InputEventSender.java
index be6a623..304ea3f 100644
--- a/core/java/android/view/InputEventSender.java
+++ b/core/java/android/view/InputEventSender.java
@@ -33,18 +33,18 @@ public abstract class InputEventSender {
private final CloseGuard mCloseGuard = CloseGuard.get();
- private int mSenderPtr;
+ private long mSenderPtr;
// We keep references to the input channel and message queue objects here so that
// they are not GC'd while the native peer of the receiver is using them.
private InputChannel mInputChannel;
private MessageQueue mMessageQueue;
- private static native int nativeInit(WeakReference<InputEventSender> sender,
+ private static native long nativeInit(WeakReference<InputEventSender> sender,
InputChannel inputChannel, MessageQueue messageQueue);
- private static native void nativeDispose(int senderPtr);
- private static native boolean nativeSendKeyEvent(int senderPtr, int seq, KeyEvent event);
- private static native boolean nativeSendMotionEvent(int senderPtr, int seq, MotionEvent event);
+ private static native void nativeDispose(long senderPtr);
+ private static native boolean nativeSendKeyEvent(long senderPtr, int seq, KeyEvent event);
+ private static native boolean nativeSendMotionEvent(long senderPtr, int seq, MotionEvent event);
/**
* Creates an input event sender bound to the specified input channel.
diff --git a/core/java/android/view/InputQueue.java b/core/java/android/view/InputQueue.java
index e3de89d..d5cec49 100644
--- a/core/java/android/view/InputQueue.java
+++ b/core/java/android/view/InputQueue.java
@@ -23,7 +23,7 @@ import android.os.Looper;
import android.os.MessageQueue;
import android.util.Pools.Pool;
import android.util.Pools.SimplePool;
-import android.util.SparseArray;
+import android.util.LongSparseArray;
import java.lang.ref.WeakReference;
@@ -32,20 +32,20 @@ import java.lang.ref.WeakReference;
* input events. Currently only usable from native code.
*/
public final class InputQueue {
- private final SparseArray<ActiveInputEvent> mActiveEventArray =
- new SparseArray<ActiveInputEvent>(20);
+ private final LongSparseArray<ActiveInputEvent> mActiveEventArray =
+ new LongSparseArray<ActiveInputEvent>(20);
private final Pool<ActiveInputEvent> mActiveInputEventPool =
new SimplePool<ActiveInputEvent>(20);
private final CloseGuard mCloseGuard = CloseGuard.get();
- private int mPtr;
+ private long mPtr;
- private static native int nativeInit(WeakReference<InputQueue> weakQueue,
+ private static native long nativeInit(WeakReference<InputQueue> weakQueue,
MessageQueue messageQueue);
- private static native int nativeSendKeyEvent(int ptr, KeyEvent e, boolean preDispatch);
- private static native int nativeSendMotionEvent(int ptr, MotionEvent e);
- private static native void nativeDispose(int ptr);
+ private static native long nativeSendKeyEvent(long ptr, KeyEvent e, boolean preDispatch);
+ private static native long nativeSendMotionEvent(long ptr, MotionEvent e);
+ private static native void nativeDispose(long ptr);
/** @hide */
public InputQueue() {
@@ -84,7 +84,7 @@ public final class InputQueue {
}
/** @hide */
- public int getNativePtr() {
+ public long getNativePtr() {
return mPtr;
}
@@ -92,7 +92,7 @@ public final class InputQueue {
public void sendInputEvent(InputEvent e, Object token, boolean predispatch,
FinishedInputEventCallback callback) {
ActiveInputEvent event = obtainActiveInputEvent(token, callback);
- int id;
+ long id;
if (e instanceof KeyEvent) {
id = nativeSendKeyEvent(mPtr, (KeyEvent) e, predispatch);
} else {
@@ -101,7 +101,7 @@ public final class InputQueue {
mActiveEventArray.put(id, event);
}
- private void finishInputEvent(int id, boolean handled) {
+ private void finishInputEvent(long id, boolean handled) {
int index = mActiveEventArray.indexOfKey(id);
if (index >= 0) {
ActiveInputEvent e = mActiveEventArray.valueAt(index);
diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java
index 9e5f25a..55dd6bb 100644
--- a/core/java/android/view/KeyCharacterMap.java
+++ b/core/java/android/view/KeyCharacterMap.java
@@ -282,20 +282,20 @@ public class KeyCharacterMap implements Parcelable {
}
};
- private int mPtr;
+ private long mPtr;
- private static native int nativeReadFromParcel(Parcel in);
- private static native void nativeWriteToParcel(int ptr, Parcel out);
- private static native void nativeDispose(int ptr);
+ private static native long nativeReadFromParcel(Parcel in);
+ private static native void nativeWriteToParcel(long ptr, Parcel out);
+ private static native void nativeDispose(long ptr);
- private static native char nativeGetCharacter(int ptr, int keyCode, int metaState);
- private static native boolean nativeGetFallbackAction(int ptr, int keyCode, int metaState,
+ private static native char nativeGetCharacter(long ptr, int keyCode, int metaState);
+ private static native boolean nativeGetFallbackAction(long ptr, int keyCode, int metaState,
FallbackAction outFallbackAction);
- private static native char nativeGetNumber(int ptr, int keyCode);
- private static native char nativeGetMatch(int ptr, int keyCode, char[] chars, int metaState);
- private static native char nativeGetDisplayLabel(int ptr, int keyCode);
- private static native int nativeGetKeyboardType(int ptr);
- private static native KeyEvent[] nativeGetEvents(int ptr, char[] chars);
+ private static native char nativeGetNumber(long ptr, int keyCode);
+ private static native char nativeGetMatch(long ptr, int keyCode, char[] chars, int metaState);
+ private static native char nativeGetDisplayLabel(long ptr, int keyCode);
+ private static native int nativeGetKeyboardType(long ptr);
+ private static native KeyEvent[] nativeGetEvents(long ptr, char[] chars);
private KeyCharacterMap(Parcel in) {
if (in == null) {
@@ -308,7 +308,7 @@ public class KeyCharacterMap implements Parcelable {
}
// Called from native
- private KeyCharacterMap(int ptr) {
+ private KeyCharacterMap(long ptr) {
mPtr = ptr;
}
diff --git a/core/java/android/view/KeyEvent.java b/core/java/android/view/KeyEvent.java
index 5a5fc10..6a6c127 100644
--- a/core/java/android/view/KeyEvent.java
+++ b/core/java/android/view/KeyEvent.java
@@ -629,11 +629,19 @@ public class KeyEvent extends InputEvent implements Parcelable {
/** Key code constant: Brightness Up key.
* Adjusts the screen brightness up. */
public static final int KEYCODE_BRIGHTNESS_UP = 221;
- /** Key code constant: Audio Track key
+ /** Key code constant: Audio Track key.
* Switches the audio tracks. */
public static final int KEYCODE_MEDIA_AUDIO_TRACK = 222;
+ /** Key code constant: Sleep key.
+ * Puts the device to sleep. Behaves somewhat like {@link #KEYCODE_POWER} but it
+ * has no effect if the device is already asleep. */
+ public static final int KEYCODE_SLEEP = 223;
+ /** Key code constant: Wakeup key.
+ * Wakes up the device. Behaves somewhat like {@link #KEYCODE_POWER} but it
+ * has no effect if the device is already awake. */
+ public static final int KEYCODE_WAKEUP = 224;
- private static final int LAST_KEYCODE = KEYCODE_MEDIA_AUDIO_TRACK;
+ private static final int LAST_KEYCODE = KEYCODE_WAKEUP;
// NOTE: If you add a new keycode here you must also add it to:
// isSystem()
@@ -878,6 +886,8 @@ public class KeyEvent extends InputEvent implements Parcelable {
names.append(KEYCODE_BRIGHTNESS_DOWN, "KEYCODE_BRIGHTNESS_DOWN");
names.append(KEYCODE_BRIGHTNESS_UP, "KEYCODE_BRIGHTNESS_UP");
names.append(KEYCODE_MEDIA_AUDIO_TRACK, "KEYCODE_MEDIA_AUDIO_TRACK");
+ names.append(KEYCODE_SLEEP, "KEYCODE_SLEEP");
+ names.append(KEYCODE_WAKEUP, "KEYCODE_WAKEUP");
};
// Symbolic names of all metakeys in bit order from least significant to most significant.
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index db577f3..ddce3ce 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -1311,63 +1311,63 @@ public final class MotionEvent extends InputEvent implements Parcelable {
}
// Pointer to the native MotionEvent object that contains the actual data.
- private int mNativePtr;
+ private long mNativePtr;
private MotionEvent mNext;
- private static native int nativeInitialize(int nativePtr,
+ private static native long nativeInitialize(long nativePtr,
int deviceId, int source, int action, int flags, int edgeFlags,
int metaState, int buttonState,
float xOffset, float yOffset, float xPrecision, float yPrecision,
long downTimeNanos, long eventTimeNanos,
int pointerCount, PointerProperties[] pointerIds, PointerCoords[] pointerCoords);
- private static native int nativeCopy(int destNativePtr, int sourceNativePtr,
+ private static native long nativeCopy(long destNativePtr, long sourceNativePtr,
boolean keepHistory);
- private static native void nativeDispose(int nativePtr);
- private static native void nativeAddBatch(int nativePtr, long eventTimeNanos,
+ private static native void nativeDispose(long nativePtr);
+ private static native void nativeAddBatch(long nativePtr, long eventTimeNanos,
PointerCoords[] pointerCoords, int metaState);
- private static native int nativeGetDeviceId(int nativePtr);
- private static native int nativeGetSource(int nativePtr);
- private static native int nativeSetSource(int nativePtr, int source);
- private static native int nativeGetAction(int nativePtr);
- private static native void nativeSetAction(int nativePtr, int action);
- private static native boolean nativeIsTouchEvent(int nativePtr);
- private static native int nativeGetFlags(int nativePtr);
- private static native void nativeSetFlags(int nativePtr, int flags);
- private static native int nativeGetEdgeFlags(int nativePtr);
- private static native void nativeSetEdgeFlags(int nativePtr, int action);
- private static native int nativeGetMetaState(int nativePtr);
- private static native int nativeGetButtonState(int nativePtr);
- private static native void nativeOffsetLocation(int nativePtr, float deltaX, float deltaY);
- private static native float nativeGetXOffset(int nativePtr);
- private static native float nativeGetYOffset(int nativePtr);
- private static native float nativeGetXPrecision(int nativePtr);
- private static native float nativeGetYPrecision(int nativePtr);
- private static native long nativeGetDownTimeNanos(int nativePtr);
- private static native void nativeSetDownTimeNanos(int nativePtr, long downTime);
-
- private static native int nativeGetPointerCount(int nativePtr);
- private static native int nativeGetPointerId(int nativePtr, int pointerIndex);
- private static native int nativeGetToolType(int nativePtr, int pointerIndex);
- private static native int nativeFindPointerIndex(int nativePtr, int pointerId);
-
- private static native int nativeGetHistorySize(int nativePtr);
- private static native long nativeGetEventTimeNanos(int nativePtr, int historyPos);
- private static native float nativeGetRawAxisValue(int nativePtr,
+ private static native int nativeGetDeviceId(long nativePtr);
+ private static native int nativeGetSource(long nativePtr);
+ private static native int nativeSetSource(long nativePtr, int source);
+ private static native int nativeGetAction(long nativePtr);
+ private static native void nativeSetAction(long nativePtr, int action);
+ private static native boolean nativeIsTouchEvent(long nativePtr);
+ private static native int nativeGetFlags(long nativePtr);
+ private static native void nativeSetFlags(long nativePtr, int flags);
+ private static native int nativeGetEdgeFlags(long nativePtr);
+ private static native void nativeSetEdgeFlags(long nativePtr, int action);
+ private static native int nativeGetMetaState(long nativePtr);
+ private static native int nativeGetButtonState(long nativePtr);
+ private static native void nativeOffsetLocation(long nativePtr, float deltaX, float deltaY);
+ private static native float nativeGetXOffset(long nativePtr);
+ private static native float nativeGetYOffset(long nativePtr);
+ private static native float nativeGetXPrecision(long nativePtr);
+ private static native float nativeGetYPrecision(long nativePtr);
+ private static native long nativeGetDownTimeNanos(long nativePtr);
+ private static native void nativeSetDownTimeNanos(long nativePtr, long downTime);
+
+ private static native int nativeGetPointerCount(long nativePtr);
+ private static native int nativeGetPointerId(long nativePtr, int pointerIndex);
+ private static native int nativeGetToolType(long nativePtr, int pointerIndex);
+ private static native int nativeFindPointerIndex(long nativePtr, int pointerId);
+
+ private static native int nativeGetHistorySize(long nativePtr);
+ private static native long nativeGetEventTimeNanos(long nativePtr, int historyPos);
+ private static native float nativeGetRawAxisValue(long nativePtr,
int axis, int pointerIndex, int historyPos);
- private static native float nativeGetAxisValue(int nativePtr,
+ private static native float nativeGetAxisValue(long nativePtr,
int axis, int pointerIndex, int historyPos);
- private static native void nativeGetPointerCoords(int nativePtr,
+ private static native void nativeGetPointerCoords(long nativePtr,
int pointerIndex, int historyPos, PointerCoords outPointerCoords);
- private static native void nativeGetPointerProperties(int nativePtr,
+ private static native void nativeGetPointerProperties(long nativePtr,
int pointerIndex, PointerProperties outPointerProperties);
- private static native void nativeScale(int nativePtr, float scale);
- private static native void nativeTransform(int nativePtr, Matrix matrix);
+ private static native void nativeScale(long nativePtr, float scale);
+ private static native void nativeTransform(long nativePtr, Matrix matrix);
- private static native int nativeReadFromParcel(int nativePtr, Parcel parcel);
- private static native void nativeWriteToParcel(int nativePtr, Parcel parcel);
+ private static native long nativeReadFromParcel(long nativePtr, Parcel parcel);
+ private static native void nativeWriteToParcel(long nativePtr, Parcel parcel);
private MotionEvent() {
}
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 1bfda2d..91645e7 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -32,19 +32,19 @@ import dalvik.system.CloseGuard;
public class Surface implements Parcelable {
private static final String TAG = "Surface";
- private static native int nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture)
+ private static native long nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture)
throws OutOfResourcesException;
- private static native int nativeCreateFromSurfaceControl(int surfaceControlNativeObject);
+ private static native long nativeCreateFromSurfaceControl(long surfaceControlNativeObject);
- private static native int nativeLockCanvas(int nativeObject, Canvas canvas, Rect dirty)
+ private static native long nativeLockCanvas(long nativeObject, Canvas canvas, Rect dirty)
throws OutOfResourcesException;
- private static native void nativeUnlockCanvasAndPost(int nativeObject, Canvas canvas);
+ private static native void nativeUnlockCanvasAndPost(long nativeObject, Canvas canvas);
- private static native void nativeRelease(int nativeObject);
- private static native boolean nativeIsValid(int nativeObject);
- private static native boolean nativeIsConsumerRunningBehind(int nativeObject);
- private static native int nativeReadFromParcel(int nativeObject, Parcel source);
- private static native void nativeWriteToParcel(int nativeObject, Parcel dest);
+ private static native void nativeRelease(long nativeObject);
+ private static native boolean nativeIsValid(long nativeObject);
+ private static native boolean nativeIsConsumerRunningBehind(long nativeObject);
+ private static native long nativeReadFromParcel(long nativeObject, Parcel source);
+ private static native void nativeWriteToParcel(long nativeObject, Parcel dest);
public static final Parcelable.Creator<Surface> CREATOR =
new Parcelable.Creator<Surface>() {
@@ -71,8 +71,8 @@ public class Surface implements Parcelable {
// Guarded state.
final Object mLock = new Object(); // protects the native state
private String mName;
- int mNativeObject; // package scope only for SurfaceControl access
- private int mLockedObject;
+ long mNativeObject; // package scope only for SurfaceControl access
+ private long mLockedObject;
private int mGenerationId; // incremented each time mNativeObject changes
private final Canvas mCanvas = new CompatibleCanvas();
@@ -130,7 +130,7 @@ public class Surface implements Parcelable {
}
/* called from android_view_Surface_createFromIGraphicBufferProducer() */
- private Surface(int nativeObject) {
+ private Surface(long nativeObject) {
synchronized (mLock) {
setNativeObjectLocked(nativeObject);
}
@@ -261,8 +261,8 @@ public class Surface implements Parcelable {
checkNotReleasedLocked();
if (mNativeObject != mLockedObject) {
Log.w(TAG, "WARNING: Surface's mNativeObject (0x" +
- Integer.toHexString(mNativeObject) + ") != mLockedObject (0x" +
- Integer.toHexString(mLockedObject) +")");
+ Long.toHexString(mNativeObject) + ") != mLockedObject (0x" +
+ Long.toHexString(mLockedObject) +")");
}
if (mLockedObject == 0) {
throw new IllegalStateException("Surface was not locked");
@@ -307,12 +307,12 @@ public class Surface implements Parcelable {
throw new IllegalArgumentException("other must not be null");
}
- int surfaceControlPtr = other.mNativeObject;
+ long surfaceControlPtr = other.mNativeObject;
if (surfaceControlPtr == 0) {
throw new NullPointerException(
"SurfaceControl native object is null. Are you using a released SurfaceControl?");
}
- int newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr);
+ long newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr);
synchronized (mLock) {
if (mNativeObject != 0) {
@@ -334,7 +334,7 @@ public class Surface implements Parcelable {
throw new IllegalArgumentException("other must not be null");
}
if (other != this) {
- final int newPtr;
+ final long newPtr;
synchronized (other.mLock) {
newPtr = other.mNativeObject;
other.setNativeObjectLocked(0);
@@ -391,7 +391,7 @@ public class Surface implements Parcelable {
}
}
- private void setNativeObjectLocked(int ptr) {
+ private void setNativeObjectLocked(long ptr) {
if (mNativeObject != ptr) {
if (mNativeObject == 0 && ptr != 0) {
mCloseGuard.open("release");
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index b22d5cf..eea5884 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -33,11 +33,11 @@ import android.view.Surface.OutOfResourcesException;
public class SurfaceControl {
private static final String TAG = "SurfaceControl";
- private static native int nativeCreate(SurfaceSession session, String name,
+ private static native long nativeCreate(SurfaceSession session, String name,
int w, int h, int format, int flags)
throws OutOfResourcesException;
- private static native void nativeRelease(int nativeObject);
- private static native void nativeDestroy(int nativeObject);
+ private static native void nativeRelease(long nativeObject);
+ private static native void nativeDestroy(long nativeObject);
private static native Bitmap nativeScreenshot(IBinder displayToken,
int width, int height, int minLayer, int maxLayer, boolean allLayers);
@@ -48,21 +48,21 @@ public class SurfaceControl {
private static native void nativeCloseTransaction();
private static native void nativeSetAnimationTransaction();
- private static native void nativeSetLayer(int nativeObject, int zorder);
- private static native void nativeSetPosition(int nativeObject, float x, float y);
- private static native void nativeSetSize(int nativeObject, int w, int h);
- private static native void nativeSetTransparentRegionHint(int nativeObject, Region region);
- private static native void nativeSetAlpha(int nativeObject, float alpha);
- private static native void nativeSetMatrix(int nativeObject, float dsdx, float dtdx, float dsdy, float dtdy);
- private static native void nativeSetFlags(int nativeObject, int flags, int mask);
- private static native void nativeSetWindowCrop(int nativeObject, int l, int t, int r, int b);
- private static native void nativeSetLayerStack(int nativeObject, int layerStack);
+ private static native void nativeSetLayer(long nativeObject, int zorder);
+ private static native void nativeSetPosition(long nativeObject, float x, float y);
+ private static native void nativeSetSize(long nativeObject, int w, int h);
+ private static native void nativeSetTransparentRegionHint(long nativeObject, Region region);
+ private static native void nativeSetAlpha(long nativeObject, float alpha);
+ private static native void nativeSetMatrix(long nativeObject, float dsdx, float dtdx, float dsdy, float dtdy);
+ private static native void nativeSetFlags(long nativeObject, int flags, int mask);
+ private static native void nativeSetWindowCrop(long nativeObject, int l, int t, int r, int b);
+ private static native void nativeSetLayerStack(long nativeObject, int layerStack);
private static native IBinder nativeGetBuiltInDisplay(int physicalDisplayId);
private static native IBinder nativeCreateDisplay(String name, boolean secure);
private static native void nativeDestroyDisplay(IBinder displayToken);
private static native void nativeSetDisplaySurface(
- IBinder displayToken, int nativeSurfaceObject);
+ IBinder displayToken, long nativeSurfaceObject);
private static native void nativeSetDisplayLayerStack(
IBinder displayToken, int layerStack);
private static native void nativeSetDisplayProjection(
@@ -77,10 +77,7 @@ public class SurfaceControl {
private final CloseGuard mCloseGuard = CloseGuard.get();
private final String mName;
- int mNativeObject; // package visibility only for Surface.java access
-
- private static final boolean HEADLESS = "1".equals(
- SystemProperties.get("ro.config.headless", "0"));
+ long mNativeObject; // package visibility only for Surface.java access
/* flags used in constructor (keep in sync with ISurfaceComposerClient.h) */
@@ -106,18 +103,18 @@ public class SurfaceControl {
* surfaces are pre-multiplied, which means that each color component is
* already multiplied by its alpha value. In this case the blending
* equation used is:
- *
- * DEST = SRC + DEST * (1-SRC_ALPHA)
- *
+ * <p>
+ * <code>DEST = SRC + DEST * (1-SRC_ALPHA)</code>
+ * <p>
* By contrast, non pre-multiplied surfaces use the following equation:
- *
- * DEST = SRC * SRC_ALPHA * DEST * (1-SRC_ALPHA)
- *
+ * <p>
+ * <code>DEST = SRC * SRC_ALPHA * DEST * (1-SRC_ALPHA)</code>
+ * <p>
* pre-multiplied surfaces must always be used if transparent pixels are
* composited on top of each-other into the surface. A pre-multiplied
* surface can never lower the value of the alpha component of a given
* pixel.
- *
+ * <p>
* In some rare situations, a non pre-multiplied surface is preferable.
*
*/
@@ -128,7 +125,17 @@ public class SurfaceControl {
* even if its pixel format is set to translucent. This can be useful if an
* application needs full RGBA 8888 support for instance but will
* still draw every pixel opaque.
- *
+ * <p>
+ * This flag is ignored if setAlpha() is used to make the surface non-opaque.
+ * Combined effects are (assuming a buffer format with an alpha channel):
+ * <ul>
+ * <li>OPAQUE + alpha(1.0) == opaque composition
+ * <li>OPAQUE + alpha(0.x) == blended composition
+ * <li>!OPAQUE + alpha(1.0) == blended composition
+ * <li>!OPAQUE + alpha(0.x) == blended composition
+ * </ul>
+ * If the underlying buffer lacks an alpha channel, the OPAQUE flag is effectively
+ * set automatically.
*/
public static final int OPAQUE = 0x00000400;
@@ -169,9 +176,16 @@ public class SurfaceControl {
/**
* Surface flag: Hide the surface.
* Equivalent to calling hide().
+ * Updates the value set during Surface creation (see {@link #HIDDEN}).
*/
public static final int SURFACE_HIDDEN = 0x01;
+ /**
+ * Surface flag: composite without blending when possible.
+ * Updates the value set during Surface creation (see {@link #OPAQUE}).
+ */
+ public static final int SURFACE_OPAQUE = 0x02;
+
/* built-in physical display ids (keep in sync with ISurfaceComposer.h)
* these are different from the logical display ids used elsewhere in the framework */
@@ -192,14 +206,14 @@ public class SurfaceControl {
/**
* Create a surface with a name.
- *
+ * <p>
* The surface creation flags specify what kind of surface to create and
* certain options such as whether the surface can be assumed to be opaque
* and whether it should be initially hidden. Surfaces should always be
* created with the {@link #HIDDEN} flag set to ensure that they are not
* made visible prematurely before all of the surface's properties have been
* configured.
- *
+ * <p>
* Good practice is to first create the surface with the {@link #HIDDEN} flag
* specified, open a transaction, set the surface layer, layer stack, alpha,
* and position, call {@link #show} if appropriate, and close the transaction.
@@ -232,8 +246,6 @@ public class SurfaceControl {
new Throwable());
}
- checkHeadless();
-
mName = name;
mNativeObject = nativeCreate(session, name, w, h, format, flags);
if (mNativeObject == 0) {
@@ -344,6 +356,10 @@ public class SurfaceControl {
nativeSetTransparentRegionHint(mNativeObject, region);
}
+ /**
+ * Sets an alpha value for the entire Surface. This value is combined with the
+ * per-pixel alpha. It may be used with opaque Surfaces.
+ */
public void setAlpha(float alpha) {
checkNotReleased();
nativeSetAlpha(mNativeObject, alpha);
@@ -354,6 +370,13 @@ public class SurfaceControl {
nativeSetMatrix(mNativeObject, dsdx, dtdx, dsdy, dtdy);
}
+ /**
+ * Sets and clears flags, such as {@link #SURFACE_HIDDEN}. The new value will be:
+ * <p>
+ * <code>newFlags = (oldFlags & ~mask) | (flags & mask)</code>
+ * <p>
+ * Note this does not take the same set of flags as the constructor.
+ */
public void setFlags(int flags, int mask) {
checkNotReleased();
nativeSetFlags(mNativeObject, flags, mask);
@@ -374,6 +397,19 @@ public class SurfaceControl {
nativeSetLayerStack(mNativeObject, layerStack);
}
+ /**
+ * Sets the opacity of the surface. Setting the flag is equivalent to creating the
+ * Surface with the {@link #OPAQUE} flag.
+ */
+ public void setOpaque(boolean isOpaque) {
+ checkNotReleased();
+ if (isOpaque) {
+ nativeSetFlags(mNativeObject, SURFACE_OPAQUE, SURFACE_OPAQUE);
+ } else {
+ nativeSetFlags(mNativeObject, 0, SURFACE_OPAQUE);
+ }
+ }
+
/*
* set display parameters.
* needs to be inside open/closeTransaction block
@@ -619,10 +655,4 @@ public class SurfaceControl {
}
nativeScreenshot(display, consumer, width, height, minLayer, maxLayer, allLayers);
}
-
- private static void checkHeadless() {
- if (HEADLESS) {
- throw new UnsupportedOperationException("Device is headless");
- }
- }
}
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 47f7628..b78af2e 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -127,7 +127,7 @@ public class TextureView extends View {
private final Object[] mNativeWindowLock = new Object[0];
// Used from native code, do not write!
@SuppressWarnings({"UnusedDeclaration"})
- private int mNativeWindow;
+ private long mNativeWindow;
/**
* Creates a new TextureView.
@@ -816,6 +816,6 @@ public class TextureView extends View {
private native void nCreateNativeWindow(SurfaceTexture surface);
private native void nDestroyNativeWindow();
- private static native boolean nLockCanvas(int nativeWindow, Canvas canvas, Rect dirty);
- private static native void nUnlockCanvasAndPost(int nativeWindow, Canvas canvas);
+ private static native boolean nLockCanvas(long nativeWindow, Canvas canvas, Rect dirty);
+ private static native void nUnlockCanvasAndPost(long nativeWindow, Canvas canvas);
}
diff --git a/core/java/android/view/VelocityTracker.java b/core/java/android/view/VelocityTracker.java
index eb81f72..22b5cca 100644
--- a/core/java/android/view/VelocityTracker.java
+++ b/core/java/android/view/VelocityTracker.java
@@ -34,17 +34,17 @@ public final class VelocityTracker {
private static final int ACTIVE_POINTER_ID = -1;
- private int mPtr;
+ private long mPtr;
private final String mStrategy;
- private static native int nativeInitialize(String strategy);
- private static native void nativeDispose(int ptr);
- private static native void nativeClear(int ptr);
- private static native void nativeAddMovement(int ptr, MotionEvent event);
- private static native void nativeComputeCurrentVelocity(int ptr, int units, float maxVelocity);
- private static native float nativeGetXVelocity(int ptr, int id);
- private static native float nativeGetYVelocity(int ptr, int id);
- private static native boolean nativeGetEstimator(int ptr, int id, Estimator outEstimator);
+ private static native long nativeInitialize(String strategy);
+ private static native void nativeDispose(long ptr);
+ private static native void nativeClear(long ptr);
+ private static native void nativeAddMovement(long ptr, MotionEvent event);
+ private static native void nativeComputeCurrentVelocity(long ptr, int units, float maxVelocity);
+ private static native float nativeGetXVelocity(long ptr, int id);
+ private static native float nativeGetYVelocity(long ptr, int id);
+ private static native boolean nativeGetEstimator(long ptr, int id, Estimator outEstimator);
/**
* Retrieve a new VelocityTracker object to watch the velocity of a
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 5015b7e..6b73ae7 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -16499,7 +16499,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
} else {
long value = mMeasureCache.valueAt(cacheIndex);
// Casting a long to int drops the high 32 bits, no mask needed
- setMeasuredDimension((int) (value >> 32), (int) value);
+ setMeasuredDimensionRaw((int) (value >> 32), (int) value);
mPrivateFlags3 |= PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT;
}
@@ -16594,6 +16594,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
measuredWidth += optical ? opticalWidth : -opticalWidth;
measuredHeight += optical ? opticalHeight : -opticalHeight;
}
+ setMeasuredDimensionRaw(measuredWidth, measuredHeight);
+ }
+
+ /**
+ * Sets the measured dimension without extra processing for things like optical bounds.
+ * Useful for reapplying consistent values that have already been cooked with adjustments
+ * for optical bounds, etc. such as those from the measurement cache.
+ *
+ * @param measuredWidth The measured width of this view. May be a complex
+ * bit mask as defined by {@link #MEASURED_SIZE_MASK} and
+ * {@link #MEASURED_STATE_TOO_SMALL}.
+ * @param measuredHeight The measured height of this view. May be a complex
+ * bit mask as defined by {@link #MEASURED_SIZE_MASK} and
+ * {@link #MEASURED_STATE_TOO_SMALL}.
+ */
+ private void setMeasuredDimensionRaw(int measuredWidth, int measuredHeight) {
mMeasuredWidth = measuredWidth;
mMeasuredHeight = measuredHeight;
@@ -18361,7 +18377,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
static int adjust(int measureSpec, int delta) {
- return makeMeasureSpec(getSize(measureSpec + delta), getMode(measureSpec));
+ final int mode = getMode(measureSpec);
+ if (mode == UNSPECIFIED) {
+ // No need to adjust size for UNSPECIFIED mode.
+ return makeMeasureSpec(0, UNSPECIFIED);
+ }
+ int size = getSize(measureSpec) + delta;
+ if (size < 0) {
+ Log.e(VIEW_LOG_TAG, "MeasureSpec.adjust: new size would be negative! (" + size +
+ ") spec: " + toString(measureSpec) + " delta: " + delta);
+ size = 0;
+ }
+ return makeMeasureSpec(size, mode);
}
/**
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 9414237..5763e72 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -463,13 +463,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
public ViewGroup(Context context, AttributeSet attrs) {
super(context, attrs);
initViewGroup();
- initFromAttributes(context, attrs);
+ initFromAttributes(context, attrs, 0);
}
public ViewGroup(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initViewGroup();
- initFromAttributes(context, attrs);
+ initFromAttributes(context, attrs, defStyle);
}
private boolean debugDraw() {
@@ -499,9 +499,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
mPersistentDrawingCache = PERSISTENT_SCROLLING_CACHE;
}
- private void initFromAttributes(Context context, AttributeSet attrs) {
- TypedArray a = context.obtainStyledAttributes(attrs,
- R.styleable.ViewGroup);
+ private void initFromAttributes(Context context, AttributeSet attrs, int defStyle) {
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewGroup, defStyle, 0);
final int N = a.getIndexCount();
for (int i = 0; i < N; i++) {
diff --git a/core/java/android/view/Window.java b/core/java/android/view/Window.java
index b3a0699..c450f3c 100644
--- a/core/java/android/view/Window.java
+++ b/core/java/android/view/Window.java
@@ -91,10 +91,15 @@ public abstract class Window {
public static final int FEATURE_ACTION_MODE_OVERLAY = 10;
/**
+ * Flag for requesting a decoration-free window that is dismissed by swiping from the left.
+ */
+ public static final int FEATURE_SWIPE_TO_DISMISS = 11;
+
+ /**
* Max value used as a feature ID
* @hide
*/
- public static final int FEATURE_MAX = FEATURE_ACTION_MODE_OVERLAY;
+ public static final int FEATURE_MAX = FEATURE_SWIPE_TO_DISMISS;
/** Flag for setting the progress bar's visibility to VISIBLE */
public static final int PROGRESS_VISIBILITY_ON = -1;
@@ -385,6 +390,12 @@ public abstract class Window {
* @param mode The mode that was just finished.
*/
public void onActionModeFinished(ActionMode mode);
+
+ /**
+ * Called when a window is dismissed. This informs the callback that the
+ * window is gone, and it should finish itself.
+ */
+ public void onWindowDismissed();
}
public Window(Context context) {
diff --git a/core/java/android/view/WindowManagerInternal.java b/core/java/android/view/WindowManagerInternal.java
new file mode 100644
index 0000000..a1bd4bd
--- /dev/null
+++ b/core/java/android/view/WindowManagerInternal.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+package android.view;
+
+import android.hardware.display.DisplayManagerInternal;
+
+/**
+ * Window manager local system service interface.
+ *
+ * @hide Only for use within the system server.
+ */
+public abstract class WindowManagerInternal {
+ /**
+ * Request that the window manager call
+ * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager}
+ * within a surface transaction at a later time.
+ */
+ public abstract void requestTraversalFromDisplayManager();
+} \ No newline at end of file
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index c5a1b86..74dda77 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -115,20 +115,6 @@ public interface WindowManagerPolicy {
public final static int ACTION_PASS_TO_USER = 0x00000001;
/**
- * This key event should wake the device.
- * To be returned from {@link #interceptKeyBeforeQueueing}.
- * Do not return this and {@link #ACTION_GO_TO_SLEEP} or {@link #ACTION_PASS_TO_USER}.
- */
- public final static int ACTION_WAKE_UP = 0x00000002;
-
- /**
- * This key event should put the device to sleep (and engage keyguard if necessary)
- * To be returned from {@link #interceptKeyBeforeQueueing}.
- * Do not return this and {@link #ACTION_WAKE_UP} or {@link #ACTION_PASS_TO_USER}.
- */
- public final static int ACTION_GO_TO_SLEEP = 0x00000004;
-
- /**
* Interface to the Window Manager state associated with a particular
* window. You can hold on to an instance of this interface from the call
* to prepareAddWindow() until removeWindow().
@@ -751,8 +737,7 @@ public interface WindowManagerPolicy {
* @param policyFlags The policy flags associated with the key.
* @param isScreenOn True if the screen is already on
*
- * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
- * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags.
+ * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
*/
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
@@ -765,10 +750,9 @@ public interface WindowManagerPolicy {
* because it's the most fragile.
* @param policyFlags The policy flags associated with the motion.
*
- * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
- * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags.
+ * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
*/
- public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags);
+ public int interceptMotionBeforeQueueingWhenScreenOff(long whenNanos, int policyFlags);
/**
* Called from the input dispatcher thread before a key is dispatched to a window.
diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java
index 00f4adb..879e58f 100644
--- a/core/java/android/view/accessibility/AccessibilityManager.java
+++ b/core/java/android/view/accessibility/AccessibilityManager.java
@@ -177,7 +177,8 @@ public final class AccessibilityManager {
userId = UserHandle.myUserId();
}
IBinder iBinder = ServiceManager.getService(Context.ACCESSIBILITY_SERVICE);
- IAccessibilityManager service = IAccessibilityManager.Stub.asInterface(iBinder);
+ IAccessibilityManager service = iBinder == null
+ ? null : IAccessibilityManager.Stub.asInterface(iBinder);
sInstance = new AccessibilityManager(context, service, userId);
}
}
@@ -197,10 +198,14 @@ public final class AccessibilityManager {
mHandler = new MyHandler(context.getMainLooper());
mService = service;
mUserId = userId;
-
+ if (mService == null) {
+ mIsEnabled = false;
+ }
try {
- final int stateFlags = mService.addClient(mClient, userId);
- setState(stateFlags);
+ if (mService != null) {
+ final int stateFlags = mService.addClient(mClient, userId);
+ setState(stateFlags);
+ }
} catch (RemoteException re) {
Log.e(LOG_TAG, "AccessibilityManagerService is dead", re);
}
@@ -322,14 +327,16 @@ public final class AccessibilityManager {
public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() {
List<AccessibilityServiceInfo> services = null;
try {
- services = mService.getInstalledAccessibilityServiceList(mUserId);
- if (DEBUG) {
- Log.i(LOG_TAG, "Installed AccessibilityServices " + services);
+ if (mService != null) {
+ services = mService.getInstalledAccessibilityServiceList(mUserId);
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Installed AccessibilityServices " + services);
+ }
}
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error while obtaining the installed AccessibilityServices. ", re);
}
- return Collections.unmodifiableList(services);
+ return services != null ? Collections.unmodifiableList(services) : Collections.EMPTY_LIST;
}
/**
@@ -349,14 +356,16 @@ public final class AccessibilityManager {
int feedbackTypeFlags) {
List<AccessibilityServiceInfo> services = null;
try {
- services = mService.getEnabledAccessibilityServiceList(feedbackTypeFlags, mUserId);
- if (DEBUG) {
- Log.i(LOG_TAG, "Installed AccessibilityServices " + services);
+ if (mService != null) {
+ services = mService.getEnabledAccessibilityServiceList(feedbackTypeFlags, mUserId);
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Installed AccessibilityServices " + services);
+ }
}
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error while obtaining the installed AccessibilityServices. ", re);
}
- return Collections.unmodifiableList(services);
+ return services != null ? Collections.unmodifiableList(services) : Collections.EMPTY_LIST;
}
/**
@@ -466,6 +475,9 @@ public final class AccessibilityManager {
*/
public int addAccessibilityInteractionConnection(IWindow windowToken,
IAccessibilityInteractionConnection connection) {
+ if (mService == null) {
+ return View.NO_ID;
+ }
try {
return mService.addAccessibilityInteractionConnection(windowToken, connection, mUserId);
} catch (RemoteException re) {
@@ -482,7 +494,9 @@ public final class AccessibilityManager {
*/
public void removeAccessibilityInteractionConnection(IWindow windowToken) {
try {
- mService.removeAccessibilityInteractionConnection(windowToken);
+ if (mService != null) {
+ mService.removeAccessibilityInteractionConnection(windowToken);
+ }
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error while removing an accessibility interaction connection. ", re);
}
diff --git a/core/java/android/widget/CompoundButton.java b/core/java/android/widget/CompoundButton.java
index 082ff3d..abddc90 100644
--- a/core/java/android/widget/CompoundButton.java
+++ b/core/java/android/widget/CompoundButton.java
@@ -363,8 +363,6 @@ public abstract class CompoundButton extends Button implements Checkable {
@Override
public Parcelable onSaveInstanceState() {
- // Force our ancestor class to save its state
- setFreezesText(true);
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
diff --git a/core/java/android/widget/CursorTreeAdapter.java b/core/java/android/widget/CursorTreeAdapter.java
index 44d1656..405e45a 100644..100755
--- a/core/java/android/widget/CursorTreeAdapter.java
+++ b/core/java/android/widget/CursorTreeAdapter.java
@@ -497,7 +497,7 @@ public abstract class CursorTreeAdapter extends BaseExpandableListAdapter implem
@Override
public void onChange(boolean selfChange) {
- if (mAutoRequery && mCursor != null) {
+ if (mAutoRequery && mCursor != null && !mCursor.isClosed()) {
if (false) Log.v("Cursor", "Auto requerying " + mCursor +
" due to update");
mDataValid = mCursor.requery();
diff --git a/core/java/android/widget/NumberPicker.java b/core/java/android/widget/NumberPicker.java
index c0fde2e..9c6a2e3 100644
--- a/core/java/android/widget/NumberPicker.java
+++ b/core/java/android/widget/NumberPicker.java
@@ -427,12 +427,12 @@ public class NumberPicker extends LinearLayout {
* Flag whether to ignore move events - we ignore such when we show in IME
* to prevent the content from scrolling.
*/
- private boolean mIngonreMoveEvents;
+ private boolean mIgnoreMoveEvents;
/**
- * Flag whether to show soft input on tap.
+ * Flag whether to perform a click on tap.
*/
- private boolean mShowSoftInputOnTap;
+ private boolean mPerformClickOnTap;
/**
* The top of the top selection divider.
@@ -808,8 +808,8 @@ public class NumberPicker extends LinearLayout {
mInputText.setVisibility(View.INVISIBLE);
mLastDownOrMoveEventY = mLastDownEventY = event.getY();
mLastDownEventTime = event.getEventTime();
- mIngonreMoveEvents = false;
- mShowSoftInputOnTap = false;
+ mIgnoreMoveEvents = false;
+ mPerformClickOnTap = false;
// Handle pressed state before any state change.
if (mLastDownEventY < mTopSelectionDividerTop) {
if (mScrollState == OnScrollListener.SCROLL_STATE_IDLE) {
@@ -840,7 +840,7 @@ public class NumberPicker extends LinearLayout {
postChangeCurrentByOneFromLongPress(
true, ViewConfiguration.getLongPressTimeout());
} else {
- mShowSoftInputOnTap = true;
+ mPerformClickOnTap = true;
postBeginSoftInputOnLongPressCommand();
}
return true;
@@ -861,7 +861,7 @@ public class NumberPicker extends LinearLayout {
int action = event.getActionMasked();
switch (action) {
case MotionEvent.ACTION_MOVE: {
- if (mIngonreMoveEvents) {
+ if (mIgnoreMoveEvents) {
break;
}
float currentMoveY = event.getY();
@@ -893,9 +893,9 @@ public class NumberPicker extends LinearLayout {
int deltaMoveY = (int) Math.abs(eventY - mLastDownEventY);
long deltaTime = event.getEventTime() - mLastDownEventTime;
if (deltaMoveY <= mTouchSlop && deltaTime < ViewConfiguration.getTapTimeout()) {
- if (mShowSoftInputOnTap) {
- mShowSoftInputOnTap = false;
- showSoftInput();
+ if (mPerformClickOnTap) {
+ mPerformClickOnTap = false;
+ performClick();
} else {
int selectorIndexOffset = (eventY / mSelectorElementHeight)
- SELECTOR_MIDDLE_ITEM_INDEX;
@@ -1188,6 +1188,27 @@ public class NumberPicker extends LinearLayout {
setValueInternal(value, false);
}
+ @Override
+ public boolean performClick() {
+ if (!mHasSelectorWheel) {
+ return super.performClick();
+ } else if (!super.performClick()) {
+ showSoftInput();
+ }
+ return true;
+ }
+
+ @Override
+ public boolean performLongClick() {
+ if (!mHasSelectorWheel) {
+ return super.performLongClick();
+ } else if (!super.performLongClick()) {
+ showSoftInput();
+ mIgnoreMoveEvents = true;
+ }
+ return true;
+ }
+
/**
* Shows the soft input for its input text.
*/
@@ -2166,8 +2187,7 @@ public class NumberPicker extends LinearLayout {
@Override
public void run() {
- showSoftInput();
- mIngonreMoveEvents = true;
+ performLongClick();
}
}
@@ -2295,7 +2315,14 @@ public class NumberPicker extends LinearLayout {
}
case AccessibilityNodeInfo.ACTION_CLICK: {
if (NumberPicker.this.isEnabled()) {
- showSoftInput();
+ performClick();
+ return true;
+ }
+ return false;
+ }
+ case AccessibilityNodeInfo.ACTION_LONG_CLICK: {
+ if (NumberPicker.this.isEnabled()) {
+ performLongClick();
return true;
}
return false;
diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java
index 1cda631..b204dfd 100644
--- a/core/java/android/widget/SpellChecker.java
+++ b/core/java/android/widget/SpellChecker.java
@@ -731,14 +731,10 @@ public class SpellChecker implements SpellCheckerSessionListener {
}
}
- if (scheduleOtherSpellCheck && wordStart <= end) {
+ if (scheduleOtherSpellCheck) {
// Update range span: start new spell check from last wordStart
setRangeSpan(editable, wordStart, end);
} else {
- if (DBG && scheduleOtherSpellCheck) {
- Log.w(TAG, "Trying to schedule spellcheck for invalid region, from "
- + wordStart + " to " + end);
- }
removeRangeSpan(editable);
}
diff --git a/core/java/android/widget/Spinner.java b/core/java/android/widget/Spinner.java
index b75d36f..5cbabef 100644
--- a/core/java/android/widget/Spinner.java
+++ b/core/java/android/widget/Spinner.java
@@ -952,8 +952,10 @@ public class Spinner extends AbsSpinner implements OnClickListener {
private CharSequence mPrompt;
public void dismiss() {
- mPopup.dismiss();
- mPopup = null;
+ if (mPopup != null) {
+ mPopup.dismiss();
+ mPopup = null;
+ }
}
public boolean isShowing() {