summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/content/RestrictionEntry.java3
-rw-r--r--core/java/android/content/pm/PackageParser.java16
-rw-r--r--core/java/android/database/sqlite/SQLiteConnection.java14
-rw-r--r--core/java/android/view/Surface.java150
-rw-r--r--core/java/android/view/SurfaceControl.java10
-rw-r--r--core/java/com/android/internal/inputmethod/InputMethodUtils.java78
6 files changed, 185 insertions, 86 deletions
diff --git a/core/java/android/content/RestrictionEntry.java b/core/java/android/content/RestrictionEntry.java
index 217cf76..283a097 100644
--- a/core/java/android/content/RestrictionEntry.java
+++ b/core/java/android/content/RestrictionEntry.java
@@ -109,6 +109,7 @@ public class RestrictionEntry implements Parcelable {
*/
public RestrictionEntry(String key, String selectedString) {
this.key = key;
+ this.type = TYPE_CHOICE;
this.currentValue = selectedString;
}
@@ -119,6 +120,7 @@ public class RestrictionEntry implements Parcelable {
*/
public RestrictionEntry(String key, boolean selectedState) {
this.key = key;
+ this.type = TYPE_BOOLEAN;
setSelectedState(selectedState);
}
@@ -129,6 +131,7 @@ public class RestrictionEntry implements Parcelable {
*/
public RestrictionEntry(String key, String[] selectedStrings) {
this.key = key;
+ this.type = TYPE_MULTI_SELECT;
this.currentValues = selectedStrings;
}
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index acb3725..34e0c12 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -287,7 +287,10 @@ public class PackageParser {
pi.sharedUserLabel = p.mSharedUserLabel;
pi.applicationInfo = generateApplicationInfo(p, flags, state, userId);
pi.installLocation = p.installLocation;
- pi.requiredForAllUsers = p.mRequiredForAllUsers;
+ if ((pi.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) != 0
+ || (pi.applicationInfo.flags&ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0) {
+ pi.requiredForAllUsers = p.mRequiredForAllUsers;
+ }
pi.restrictedAccountType = p.mRestrictedAccountType;
pi.requiredAccountType = p.mRequiredAccountType;
pi.firstInstallTime = firstInstallTime;
@@ -1812,11 +1815,12 @@ public class PackageParser {
false)) {
ai.flags |= ApplicationInfo.FLAG_PERSISTENT;
}
- if (sa.getBoolean(
- com.android.internal.R.styleable.AndroidManifestApplication_requiredForAllUsers,
- false)) {
- owner.mRequiredForAllUsers = true;
- }
+ }
+
+ if (sa.getBoolean(
+ com.android.internal.R.styleable.AndroidManifestApplication_requiredForAllUsers,
+ false)) {
+ owner.mRequiredForAllUsers = true;
}
String restrictedAccountType = sa.getString(com.android.internal.R.styleable
diff --git a/core/java/android/database/sqlite/SQLiteConnection.java b/core/java/android/database/sqlite/SQLiteConnection.java
index 0017c46..4f59e8e 100644
--- a/core/java/android/database/sqlite/SQLiteConnection.java
+++ b/core/java/android/database/sqlite/SQLiteConnection.java
@@ -1077,7 +1077,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
printer.println(" isPrimaryConnection: " + mIsPrimaryConnection);
printer.println(" onlyAllowReadOnlyOperations: " + mOnlyAllowReadOnlyOperations);
- mRecentOperations.dump(printer);
+ mRecentOperations.dump(printer, verbose);
if (verbose) {
mPreparedStatementCache.dump(printer);
@@ -1376,7 +1376,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
private void logOperationLocked(int cookie, String detail) {
final Operation operation = getOperationLocked(cookie);
StringBuilder msg = new StringBuilder();
- operation.describe(msg);
+ operation.describe(msg, false);
if (detail != null) {
msg.append(", ").append(detail);
}
@@ -1399,14 +1399,14 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
final Operation operation = mOperations[mIndex];
if (operation != null && !operation.mFinished) {
StringBuilder msg = new StringBuilder();
- operation.describe(msg);
+ operation.describe(msg, false);
return msg.toString();
}
return null;
}
}
- public void dump(Printer printer) {
+ public void dump(Printer printer, boolean verbose) {
synchronized (mOperations) {
printer.println(" Most recently executed operations:");
int index = mIndex;
@@ -1418,7 +1418,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
msg.append(" ").append(n).append(": [");
msg.append(operation.getFormattedStartTime());
msg.append("] ");
- operation.describe(msg);
+ operation.describe(msg, verbose);
printer.println(msg.toString());
if (index > 0) {
@@ -1449,7 +1449,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
public Exception mException;
public int mCookie;
- public void describe(StringBuilder msg) {
+ public void describe(StringBuilder msg, boolean verbose) {
msg.append(mKind);
if (mFinished) {
msg.append(" took ").append(mEndTime - mStartTime).append("ms");
@@ -1461,7 +1461,7 @@ public final class SQLiteConnection implements CancellationSignal.OnCancelListen
if (mSql != null) {
msg.append(", sql=\"").append(trimSqlForDisplay(mSql)).append("\"");
}
- if (mBindArgs != null && mBindArgs.size() != 0) {
+ if (verbose && mBindArgs != null && mBindArgs.size() != 0) {
msg.append(", bindArgs=[");
final int count = mBindArgs.size();
for (int i = 0; i < count; i++) {
diff --git a/core/java/android/view/Surface.java b/core/java/android/view/Surface.java
index 4989c3a..e0786f7 100644
--- a/core/java/android/view/Surface.java
+++ b/core/java/android/view/Surface.java
@@ -34,19 +34,21 @@ public class Surface implements Parcelable {
private static native int nativeCreateFromSurfaceTexture(SurfaceTexture surfaceTexture)
throws OutOfResourcesException;
+ private static native int nativeCreateFromSurfaceControl(int surfaceControlNativeObject);
- private native Canvas nativeLockCanvas(int nativeObject, Rect dirty);
- private native void nativeUnlockCanvasAndPost(int nativeObject, Canvas canvas);
+ private static native void nativeLockCanvas(int nativeObject, Canvas canvas, Rect dirty)
+ throws OutOfResourcesException;
+ private static native void nativeUnlockCanvasAndPost(int 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 nativeCopyFrom(int nativeObject, int surfaceControlNativeObject);
private static native int nativeReadFromParcel(int nativeObject, Parcel source);
private static native void nativeWriteToParcel(int nativeObject, Parcel dest);
public static final Parcelable.Creator<Surface> CREATOR =
new Parcelable.Creator<Surface>() {
+ @Override
public Surface createFromParcel(Parcel source) {
try {
Surface s = new Surface();
@@ -57,26 +59,20 @@ public class Surface implements Parcelable {
return null;
}
}
+
+ @Override
public Surface[] newArray(int size) {
return new Surface[size];
}
};
private final CloseGuard mCloseGuard = CloseGuard.get();
- private String mName;
- // Note: These fields are accessed by native code.
- // The mSurfaceControl will only be present for Surfaces used by the window
- // server or system processes. When this class is parceled we defer to the
- // mSurfaceControl to do the parceling. Otherwise we parcel the
- // mNativeSurface.
+ // Guarded state.
+ final Object mLock = new Object(); // protects the native state
+ private String mName;
int mNativeObject; // package scope only for SurfaceControl access
-
- // protects the native state
- private final Object mNativeObjectLock = new Object();
-
- private int mGenerationId; // incremented each time mNativeSurface changes
- @SuppressWarnings("UnusedDeclaration")
+ private int mGenerationId; // incremented each time mNativeObject changes
private final Canvas mCanvas = new CompatibleCanvas();
// A matrix to scale the matrix set by application. This is set to null for
@@ -125,21 +121,22 @@ public class Surface implements Parcelable {
throw new IllegalArgumentException("surfaceTexture must not be null");
}
- mName = surfaceTexture.toString();
- try {
- mNativeObject = nativeCreateFromSurfaceTexture(surfaceTexture);
- } catch (OutOfResourcesException ex) {
- // We can't throw OutOfResourcesException because it would be an API change.
- throw new RuntimeException(ex);
+ synchronized (mLock) {
+ mName = surfaceTexture.toString();
+ try {
+ setNativeObjectLocked(nativeCreateFromSurfaceTexture(surfaceTexture));
+ } catch (OutOfResourcesException ex) {
+ // We can't throw OutOfResourcesException because it would be an API change.
+ throw new RuntimeException(ex);
+ }
}
-
- mCloseGuard.open("release");
}
/* called from android_view_Surface_createFromIGraphicBufferProducer() */
private Surface(int nativeObject) {
- mNativeObject = nativeObject;
- mCloseGuard.open("release");
+ synchronized (mLock) {
+ setNativeObjectLocked(nativeObject);
+ }
}
@Override
@@ -160,13 +157,11 @@ public class Surface implements Parcelable {
* This will make the surface invalid.
*/
public void release() {
- synchronized (mNativeObjectLock) {
+ synchronized (mLock) {
if (mNativeObject != 0) {
nativeRelease(mNativeObject);
- mNativeObject = 0;
- mGenerationId++;
+ setNativeObjectLocked(0);
}
- mCloseGuard.close();
}
}
@@ -187,7 +182,7 @@ public class Surface implements Parcelable {
* Otherwise returns false.
*/
public boolean isValid() {
- synchronized (mNativeObjectLock) {
+ synchronized (mLock) {
if (mNativeObject == 0) return false;
return nativeIsValid(mNativeObject);
}
@@ -201,7 +196,9 @@ public class Surface implements Parcelable {
* @hide
*/
public int getGenerationId() {
- return mGenerationId;
+ synchronized (mLock) {
+ return mGenerationId;
+ }
}
/**
@@ -211,7 +208,7 @@ public class Surface implements Parcelable {
* @hide
*/
public boolean isConsumerRunningBehind() {
- synchronized (mNativeObjectLock) {
+ synchronized (mLock) {
checkNotReleasedLocked();
return nativeIsConsumerRunningBehind(mNativeObject);
}
@@ -234,9 +231,10 @@ public class Surface implements Parcelable {
*/
public Canvas lockCanvas(Rect inOutDirty)
throws OutOfResourcesException, IllegalArgumentException {
- synchronized (mNativeObjectLock) {
+ synchronized (mLock) {
checkNotReleasedLocked();
- return nativeLockCanvas(mNativeObject, inOutDirty);
+ nativeLockCanvas(mNativeObject, mCanvas, inOutDirty);
+ return mCanvas;
}
}
@@ -247,7 +245,12 @@ public class Surface implements Parcelable {
* @param canvas The canvas previously obtained from {@link #lockCanvas}.
*/
public void unlockCanvasAndPost(Canvas canvas) {
- synchronized (mNativeObjectLock) {
+ if (canvas != mCanvas) {
+ throw new IllegalArgumentException("canvas object must be the same instance that "
+ + "was previously returned by lockCanvas");
+ }
+
+ synchronized (mLock) {
checkNotReleasedLocked();
nativeUnlockCanvasAndPost(mNativeObject, canvas);
}
@@ -273,7 +276,6 @@ public class Surface implements Parcelable {
}
}
-
/**
* Copy another surface to this one. This surface now holds a reference
* to the same data as the original surface, and is -not- the owner.
@@ -287,22 +289,24 @@ public class Surface implements Parcelable {
if (other == null) {
throw new IllegalArgumentException("other must not be null");
}
- if (other.mNativeObject == 0) {
+
+ int surfaceControlPtr = other.mNativeObject;
+ if (surfaceControlPtr == 0) {
throw new NullPointerException(
"SurfaceControl native object is null. Are you using a released SurfaceControl?");
}
- synchronized (mNativeObjectLock) {
- mNativeObject = nativeCopyFrom(mNativeObject, other.mNativeObject);
- if (mNativeObject == 0) {
- // nativeCopyFrom released our reference
- mCloseGuard.close();
+ int newNativeObject = nativeCreateFromSurfaceControl(surfaceControlPtr);
+
+ synchronized (mLock) {
+ if (mNativeObject != 0) {
+ nativeRelease(mNativeObject);
}
- mGenerationId++;
+ setNativeObjectLocked(newNativeObject);
}
}
/**
- * This is intended to be used by {@link SurfaceView.updateWindow} only.
+ * This is intended to be used by {@link SurfaceView#updateWindow} only.
* @param other access is not thread safe
* @hide
* @deprecated
@@ -313,21 +317,18 @@ public class Surface implements Parcelable {
throw new IllegalArgumentException("other must not be null");
}
if (other != this) {
- synchronized (mNativeObjectLock) {
+ final int newPtr;
+ synchronized (other.mLock) {
+ newPtr = other.mNativeObject;
+ other.setNativeObjectLocked(0);
+ }
+
+ synchronized (mLock) {
if (mNativeObject != 0) {
- // release our reference to our native object
nativeRelease(mNativeObject);
}
- // transfer the reference from other to us
- if (other.mNativeObject != 0 && mNativeObject == 0) {
- mCloseGuard.open("release");
- }
- mNativeObject = other.mNativeObject;
- mGenerationId++;
+ setNativeObjectLocked(newPtr);
}
- other.mNativeObject = 0;
- other.mGenerationId++;
- other.mCloseGuard.close();
}
}
@@ -340,14 +341,10 @@ public class Surface implements Parcelable {
if (source == null) {
throw new IllegalArgumentException("source must not be null");
}
- synchronized (mNativeObjectLock) {
+
+ synchronized (mLock) {
mName = source.readString();
- int nativeObject = nativeReadFromParcel(mNativeObject, source);
- if (nativeObject !=0 && mNativeObject == 0) {
- mCloseGuard.open("release");
- }
- mNativeObject = nativeObject;
- mGenerationId++;
+ setNativeObjectLocked(nativeReadFromParcel(mNativeObject, source));
}
}
@@ -356,7 +353,7 @@ public class Surface implements Parcelable {
if (dest == null) {
throw new IllegalArgumentException("dest must not be null");
}
- synchronized (mNativeObjectLock) {
+ synchronized (mLock) {
dest.writeString(mName);
nativeWriteToParcel(mNativeObject, dest);
}
@@ -367,7 +364,27 @@ public class Surface implements Parcelable {
@Override
public String toString() {
- return "Surface(name=" + mName + ")";
+ synchronized (mLock) {
+ return "Surface(name=" + mName + ")";
+ }
+ }
+
+ private void setNativeObjectLocked(int ptr) {
+ if (mNativeObject != ptr) {
+ if (mNativeObject == 0 && ptr != 0) {
+ mCloseGuard.open("release");
+ } else if (mNativeObject != 0 && ptr == 0) {
+ mCloseGuard.close();
+ }
+ mNativeObject = ptr;
+ mGenerationId += 1;
+ }
+ }
+
+ private void checkNotReleasedLocked() {
+ if (mNativeObject == 0) {
+ throw new IllegalStateException("Surface has already been released.");
+ }
}
/**
@@ -451,9 +468,4 @@ public class Surface implements Parcelable {
mOrigMatrix.set(m);
}
}
-
- private void checkNotReleasedLocked() {
- if (mNativeObject == 0) throw new NullPointerException(
- "mNativeObject is null. Have you called release() already?");
- }
}
diff --git a/core/java/android/view/SurfaceControl.java b/core/java/android/view/SurfaceControl.java
index e869d09..6b530ef 100644
--- a/core/java/android/view/SurfaceControl.java
+++ b/core/java/android/view/SurfaceControl.java
@@ -496,8 +496,14 @@ public class SurfaceControl {
if (displayToken == null) {
throw new IllegalArgumentException("displayToken must not be null");
}
- int nativeSurface = surface != null ? surface.mNativeObject : 0;
- nativeSetDisplaySurface(displayToken, nativeSurface);
+
+ if (surface != null) {
+ synchronized (surface.mLock) {
+ nativeSetDisplaySurface(displayToken, surface.mNativeObject);
+ }
+ } else {
+ nativeSetDisplaySurface(displayToken, 0);
+ }
}
public static IBinder createDisplay(String name, boolean secure) {
diff --git a/core/java/com/android/internal/inputmethod/InputMethodUtils.java b/core/java/com/android/internal/inputmethod/InputMethodUtils.java
index 655d148..4e21324 100644
--- a/core/java/com/android/internal/inputmethod/InputMethodUtils.java
+++ b/core/java/com/android/internal/inputmethod/InputMethodUtils.java
@@ -20,6 +20,7 @@ import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
@@ -28,6 +29,8 @@ import android.util.Pair;
import android.util.Slog;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
+import android.view.textservice.SpellCheckerInfo;
+import android.view.textservice.TextServicesManager;
import java.util.ArrayList;
import java.util.HashMap;
@@ -357,6 +360,78 @@ public class InputMethodUtils {
return !subtype.isAuxiliary();
}
+ public static void setNonSelectedSystemImesDisabledUntilUsed(
+ PackageManager packageManager, List<InputMethodInfo> enabledImis) {
+ if (DEBUG) {
+ Slog.d(TAG, "setNonSelectedSystemImesDisabledUntilUsed");
+ }
+ final String[] systemImesDisabledUntilUsed = Resources.getSystem().getStringArray(
+ com.android.internal.R.array.config_disabledUntilUsedPreinstalledImes);
+ if (systemImesDisabledUntilUsed == null || systemImesDisabledUntilUsed.length == 0) {
+ return;
+ }
+ // Only the current spell checker should be treated as an enabled one.
+ final SpellCheckerInfo currentSpellChecker =
+ TextServicesManager.getInstance().getCurrentSpellChecker();
+ for (final String packageName : systemImesDisabledUntilUsed) {
+ if (DEBUG) {
+ Slog.d(TAG, "check " + packageName);
+ }
+ boolean enabledIme = false;
+ for (int j = 0; j < enabledImis.size(); ++j) {
+ final InputMethodInfo imi = enabledImis.get(j);
+ if (packageName.equals(imi.getPackageName())) {
+ enabledIme = true;
+ break;
+ }
+ }
+ if (enabledIme) {
+ // enabled ime. skip
+ continue;
+ }
+ if (currentSpellChecker != null
+ && packageName.equals(currentSpellChecker.getPackageName())) {
+ // enabled spell checker. skip
+ if (DEBUG) {
+ Slog.d(TAG, packageName + " is the current spell checker. skip");
+ }
+ continue;
+ }
+ ApplicationInfo ai = null;
+ try {
+ ai = packageManager.getApplicationInfo(packageName,
+ PackageManager.GET_DISABLED_UNTIL_USED_COMPONENTS);
+ } catch (NameNotFoundException e) {
+ Slog.w(TAG, "NameNotFoundException: " + packageName, e);
+ }
+ if (ai == null) {
+ // No app found for packageName
+ continue;
+ }
+ final boolean isSystemPackage = (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
+ if (!isSystemPackage) {
+ continue;
+ }
+ setDisabledUntilUsed(packageManager, packageName);
+ }
+ }
+
+ private static void setDisabledUntilUsed(PackageManager packageManager, String packageName) {
+ final int state = packageManager.getApplicationEnabledSetting(packageName);
+ if (state == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
+ || state == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
+ if (DEBUG) {
+ Slog.d(TAG, "Update state(" + packageName + "): DISABLED_UNTIL_USED");
+ }
+ packageManager.setApplicationEnabledSetting(packageName,
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED, 0);
+ } else {
+ if (DEBUG) {
+ Slog.d(TAG, packageName + " is already DISABLED_UNTIL_USED");
+ }
+ }
+ }
+
/**
* Utility class for putting and getting settings for InputMethod
* TODO: Move all putters and getters of settings to this class.
@@ -405,8 +480,7 @@ public class InputMethodUtils {
public void setCurrentUserId(int userId) {
if (DEBUG) {
- Slog.d(TAG, "--- Swtich the current user from " + mCurrentUserId + " to "
- + userId + ", new ime = " + getSelectedInputMethod());
+ Slog.d(TAG, "--- Swtich the current user from " + mCurrentUserId + " to " + userId);
}
// IMMS settings are kept per user, so keep track of current user
mCurrentUserId = userId;