summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/ActivityManagerNative.java22
-rw-r--r--core/java/android/app/IActivityManager.java2
-rwxr-xr-xcore/java/android/hardware/input/InputManager.java3
-rw-r--r--core/java/android/provider/Settings.java6
-rw-r--r--core/java/android/text/SpannableStringBuilder.java67
-rwxr-xr-xcore/java/android/view/InputDevice.java20
6 files changed, 93 insertions, 27 deletions
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index 000abc5..a3fdf3e 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -867,6 +867,16 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
return true;
}
+ case GET_UID_FOR_INTENT_SENDER_TRANSACTION: {
+ data.enforceInterface(IActivityManager.descriptor);
+ IIntentSender r = IIntentSender.Stub.asInterface(
+ data.readStrongBinder());
+ int res = getUidForIntentSender(r);
+ reply.writeNoException();
+ reply.writeInt(res);
+ return true;
+ }
+
case SET_PROCESS_LIMIT_TRANSACTION: {
data.enforceInterface(IActivityManager.descriptor);
int max = data.readInt();
@@ -2714,6 +2724,18 @@ class ActivityManagerProxy implements IActivityManager
reply.recycle();
return res;
}
+ public int getUidForIntentSender(IIntentSender sender) throws RemoteException {
+ Parcel data = Parcel.obtain();
+ Parcel reply = Parcel.obtain();
+ data.writeInterfaceToken(IActivityManager.descriptor);
+ data.writeStrongBinder(sender.asBinder());
+ mRemote.transact(GET_UID_FOR_INTENT_SENDER_TRANSACTION, data, reply, 0);
+ reply.readException();
+ int res = reply.readInt();
+ data.recycle();
+ reply.recycle();
+ return res;
+ }
public void setProcessLimit(int max) throws RemoteException
{
Parcel data = Parcel.obtain();
diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java
index 0f287c1..c71b186 100644
--- a/core/java/android/app/IActivityManager.java
+++ b/core/java/android/app/IActivityManager.java
@@ -175,6 +175,7 @@ public interface IActivityManager extends IInterface {
public boolean clearApplicationUserData(final String packageName,
final IPackageDataObserver observer, int userId) throws RemoteException;
public String getPackageForIntentSender(IIntentSender sender) throws RemoteException;
+ public int getUidForIntentSender(IIntentSender sender) throws RemoteException;
public void setProcessLimit(int max) throws RemoteException;
public int getProcessLimit() throws RemoteException;
@@ -531,6 +532,7 @@ public interface IActivityManager extends IInterface {
int START_BACKUP_AGENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+89;
int BACKUP_AGENT_CREATED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+90;
int UNBIND_BACKUP_AGENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+91;
+ int GET_UID_FOR_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+92;
int START_ACTIVITY_IN_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+94;
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java
index ba64035..5ead1f4 100755
--- a/core/java/android/hardware/input/InputManager.java
+++ b/core/java/android/hardware/input/InputManager.java
@@ -39,12 +39,9 @@ import android.os.ServiceManager;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.util.Log;
-import android.view.Display;
-import android.view.IWindowManager;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.KeyCharacterMap;
-import android.view.WindowManagerPolicy;
import android.view.KeyCharacterMap.UnavailableException;
import java.util.ArrayList;
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 371e2a1..2aaf548 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -37,6 +37,7 @@ import android.net.wifi.WifiManager;
import android.os.BatteryManager;
import android.os.Bundle;
import android.os.IBinder;
+import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
@@ -2260,6 +2261,7 @@ public final class Settings {
private static ILockSettings sLockSettings = null;
+ private static boolean sIsSystemProcess;
private static final HashSet<String> MOVED_TO_LOCK_SETTINGS;
static {
MOVED_TO_LOCK_SETTINGS = new HashSet<String>(3);
@@ -2283,8 +2285,10 @@ public final class Settings {
if (sLockSettings == null) {
sLockSettings = ILockSettings.Stub.asInterface(
(IBinder) ServiceManager.getService("lock_settings"));
+ sIsSystemProcess = Process.myUid() == Process.SYSTEM_UID;
}
- if (sLockSettings != null && MOVED_TO_LOCK_SETTINGS.contains(name)) {
+ if (sLockSettings != null && !sIsSystemProcess
+ && MOVED_TO_LOCK_SETTINGS.contains(name)) {
try {
return sLockSettings.getString(name, "0", UserId.getCallingUserId());
} catch (RemoteException re) {
diff --git a/core/java/android/text/SpannableStringBuilder.java b/core/java/android/text/SpannableStringBuilder.java
index bb4b282..f7a7eb8 100644
--- a/core/java/android/text/SpannableStringBuilder.java
+++ b/core/java/android/text/SpannableStringBuilder.java
@@ -50,8 +50,6 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
public SpannableStringBuilder(CharSequence text, int start, int end) {
int srclen = end - start;
- if (srclen < 0) throw new StringIndexOutOfBoundsException();
-
int len = ArrayUtils.idealCharArraySize(srclen + 1);
mText = new char[len];
mGapStart = srclen;
@@ -155,7 +153,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
if (where == mGapStart)
return;
- boolean atEnd = (where == length());
+ boolean atend = (where == length());
if (where < mGapStart) {
int overlap = mGapStart - where;
@@ -181,7 +179,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
else if (start == where) {
int flag = (mSpanFlags[i] & START_MASK) >> START_SHIFT;
- if (flag == POINT || (atEnd && flag == PARAGRAPH))
+ if (flag == POINT || (atend && flag == PARAGRAPH))
start += mGapLength;
}
@@ -192,7 +190,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
else if (end == where) {
int flag = (mSpanFlags[i] & END_MASK);
- if (flag == POINT || (atEnd && flag == PARAGRAPH))
+ if (flag == POINT || (atend && flag == PARAGRAPH))
end += mGapLength;
}
@@ -399,7 +397,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
// Documentation from interface
public SpannableStringBuilder replace(final int start, final int end,
- CharSequence tb, int tbstart, int tbend) {
+ CharSequence tb, int tbstart, int tbend) {
int filtercount = mFilters.length;
for (int i = 0; i < filtercount; i++) {
CharSequence repl = mFilters[i].filter(tb, tbstart, tbend, this, start, end);
@@ -421,26 +419,53 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
TextWatcher[] textWatchers = getSpans(start, start + origLen, TextWatcher.class);
sendBeforeTextChanged(textWatchers, start, origLen, newLen);
- // Try to keep the cursor / selection at the same relative position during
- // a text replacement. If replaced or replacement text length is zero, this
- // is already taken care of.
- boolean adjustSelection = origLen != 0 && newLen != 0;
- int selstart = 0;
- int selend = 0;
- if (adjustSelection) {
- selstart = Selection.getSelectionStart(this);
- selend = Selection.getSelectionEnd(this);
- }
+ if (origLen == 0 || newLen == 0) {
+ change(start, end, tb, tbstart, tbend);
+ } else {
+ int selstart = Selection.getSelectionStart(this);
+ int selend = Selection.getSelectionEnd(this);
- checkRange("replace", start, end);
+ // XXX just make the span fixups in change() do the right thing
+ // instead of this madness!
+
+ checkRange("replace", start, end);
+ moveGapTo(end);
+
+ if (mGapLength < 2)
+ resizeFor(length() + 1);
- change(start, end, tb, tbstart, tbend);
+ for (int i = mSpanCount - 1; i >= 0; i--) {
+ if (mSpanStarts[i] == mGapStart)
+ mSpanStarts[i]++;
+
+ if (mSpanEnds[i] == mGapStart)
+ mSpanEnds[i]++;
+ }
+
+ mText[mGapStart] = ' ';
+ mGapStart++;
+ mGapLength--;
+
+ if (mGapLength < 1) {
+ new Exception("mGapLength < 1").printStackTrace();
+ }
- if (adjustSelection) {
+ change(start + 1, start + 1, tb, tbstart, tbend);
+ change(start, start + 1, "", 0, 0);
+ change(start + newLen, start + newLen + origLen, "", 0, 0);
+
+ /*
+ * Special case to keep the cursor in the same position
+ * if it was somewhere in the middle of the replaced region.
+ * If it was at the start or the end or crossing the whole
+ * replacement, it should already be where it belongs.
+ * TODO: Is there some more general mechanism that could
+ * accomplish this?
+ */
if (selstart > start && selstart < end) {
long off = selstart - start;
- off = off * newLen / origLen;
+ off = off * newLen / (end - start);
selstart = (int) off + start;
setSpan(false, Selection.SELECTION_START, selstart, selstart,
@@ -449,7 +474,7 @@ public class SpannableStringBuilder implements CharSequence, GetChars, Spannable
if (selend > start && selend < end) {
long off = selend - start;
- off = off * newLen / origLen;
+ off = off * newLen / (end - start);
selend = (int) off + start;
setSpan(false, Selection.SELECTION_END, selend, selend, Spanned.SPAN_POINT_POINT);
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index 93a0185..6f8d09b 100755
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -41,6 +41,7 @@ import java.util.List;
public final class InputDevice implements Parcelable {
private int mId;
private String mName;
+ private String mDescriptor;
private int mSources;
private int mKeyboardType;
private String mKeyCharacterMapFile;
@@ -334,12 +335,24 @@ public final class InputDevice implements Parcelable {
* An input device descriptor uniquely identifies an input device. Its value
* is intended to be persistent across system restarts, and should not change even
* if the input device is disconnected, reconnected or reconfigured at any time.
+ * </p><p>
+ * It is possible for there to be multiple {@link InputDevice} instances that have the
+ * same input device descriptor. This might happen in situations where a single
+ * human input device registers multiple {@link InputDevice} instances (HID collections)
+ * that describe separate features of the device, such as a keyboard that also
+ * has a trackpad. Alternately, it may be that the input devices are simply
+ * indistinguishable, such as two keyboards made by the same manufacturer.
+ * </p><p>
+ * The input device descriptor returned by {@link #getDescriptor} should only bt
+ * used when an application needs to remember settings associated with a particular
+ * input device. For all other purposes when referring to a logical
+ * {@link InputDevice} instance at runtime use the id returned by {@link #getId()}.
* </p>
*
* @return The input device descriptor.
*/
public String getDescriptor() {
- return "PLACEHOLDER"; // TODO: implement for real
+ return mDescriptor;
}
/**
@@ -548,6 +561,7 @@ public final class InputDevice implements Parcelable {
private void readFromParcel(Parcel in) {
mId = in.readInt();
mName = in.readString();
+ mDescriptor = in.readString();
mSources = in.readInt();
mKeyboardType = in.readInt();
mKeyCharacterMapFile = in.readString();
@@ -566,6 +580,7 @@ public final class InputDevice implements Parcelable {
public void writeToParcel(Parcel out, int flags) {
out.writeInt(mId);
out.writeString(mName);
+ out.writeString(mDescriptor);
out.writeInt(mSources);
out.writeInt(mKeyboardType);
out.writeString(mKeyCharacterMapFile);
@@ -592,7 +607,8 @@ public final class InputDevice implements Parcelable {
public String toString() {
StringBuilder description = new StringBuilder();
description.append("Input Device ").append(mId).append(": ").append(mName).append("\n");
-
+ description.append(" Descriptor: ").append(mDescriptor).append("\n");
+
description.append(" Keyboard Type: ");
switch (mKeyboardType) {
case KEYBOARD_TYPE_NONE: