diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/ActivityManager.java | 2 | ||||
| -rw-r--r-- | core/java/android/app/ActivityManagerNative.java | 6 | ||||
| -rw-r--r-- | core/java/android/app/ContextImpl.java | 14 | ||||
| -rw-r--r-- | core/java/android/app/IActivityManager.java | 2 | ||||
| -rw-r--r-- | core/java/android/hardware/Camera.java | 36 | ||||
| -rw-r--r-- | core/java/android/os/UserManager.java | 35 | ||||
| -rw-r--r-- | core/java/android/provider/Settings.java | 32 | ||||
| -rw-r--r-- | core/java/android/service/dreams/DreamService.java | 2 | ||||
| -rw-r--r-- | core/java/android/view/ScaleGestureDetector.java | 9 | ||||
| -rw-r--r-- | core/java/android/view/View.java | 18 |
10 files changed, 132 insertions, 24 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 0eda6b4..594be68 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -1981,7 +1981,7 @@ public class ActivityManager { */ public boolean isUserRunning(int userid) { try { - return ActivityManagerNative.getDefault().isUserRunning(userid); + return ActivityManagerNative.getDefault().isUserRunning(userid, false); } catch (RemoteException e) { return false; } diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index bb62c9e..7492629 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -1608,7 +1608,8 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM case IS_USER_RUNNING_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); int userid = data.readInt(); - boolean result = isUserRunning(userid); + boolean orStopping = data.readInt() != 0; + boolean result = isUserRunning(userid, orStopping); reply.writeNoException(); reply.writeInt(result ? 1 : 0); return true; @@ -3865,11 +3866,12 @@ class ActivityManagerProxy implements IActivityManager return userInfo; } - public boolean isUserRunning(int userid) throws RemoteException { + public boolean isUserRunning(int userid, boolean orStopping) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeInt(userid); + data.writeInt(orStopping ? 1 : 0); mRemote.transact(IS_USER_RUNNING_TRANSACTION, data, reply, 0); reply.readException(); boolean result = reply.readInt() != 0; diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index c324da9..3e1e358 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -1352,10 +1352,16 @@ class ContextImpl extends Context { ComponentName cn = ActivityManagerNative.getDefault().startService( mMainThread.getApplicationThread(), service, service.resolveTypeIfNeeded(getContentResolver()), user.getIdentifier()); - if (cn != null && cn.getPackageName().equals("!")) { - throw new SecurityException( - "Not allowed to start service " + service - + " without permission " + cn.getClassName()); + if (cn != null) { + if (cn.getPackageName().equals("!")) { + throw new SecurityException( + "Not allowed to start service " + service + + " without permission " + cn.getClassName()); + } else if (cn.getPackageName().equals("!!")) { + throw new SecurityException( + "Unable to start service " + service + + ": " + cn.getClassName()); + } } return cn; } catch (RemoteException e) { diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index da844ef..97250e9 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -326,7 +326,7 @@ public interface IActivityManager extends IInterface { public boolean switchUser(int userid) throws RemoteException; public int stopUser(int userid, IStopUserCallback callback) throws RemoteException; public UserInfo getCurrentUser() throws RemoteException; - public boolean isUserRunning(int userid) throws RemoteException; + public boolean isUserRunning(int userid, boolean orStopping) throws RemoteException; public int[] getRunningUserIds() throws RemoteException; public boolean removeSubTask(int taskId, int subTaskIndex) throws RemoteException; diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index 1e8671b..6624eb8 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -18,13 +18,18 @@ package android.hardware; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.content.Context; import android.graphics.ImageFormat; import android.graphics.Point; import android.graphics.Rect; import android.graphics.SurfaceTexture; +import android.media.IAudioService; import android.os.Handler; +import android.os.IBinder; import android.os.Looper; import android.os.Message; +import android.os.RemoteException; +import android.os.ServiceManager; import android.util.Log; import android.text.TextUtils; import android.view.Surface; @@ -192,7 +197,21 @@ public class Camera { * Returns the information about a particular camera. * If {@link #getNumberOfCameras()} returns N, the valid id is 0 to N-1. */ - public native static void getCameraInfo(int cameraId, CameraInfo cameraInfo); + public static void getCameraInfo(int cameraId, CameraInfo cameraInfo) { + _getCameraInfo(cameraId, cameraInfo); + IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE); + IAudioService audioService = IAudioService.Stub.asInterface(b); + try { + if (audioService.isCameraSoundForced()) { + // Only set this when sound is forced; otherwise let native code + // decide. + cameraInfo.canDisableShutterSound = false; + } + } catch (RemoteException e) { + Log.e(TAG, "Audio service is unavailable for queries"); + } + } + private native static void _getCameraInfo(int cameraId, CameraInfo cameraInfo); /** * Information about a camera @@ -1185,7 +1204,20 @@ public class Camera { * @see CameraInfo#canDisableShutterSound * @see ShutterCallback */ - public native final boolean enableShutterSound(boolean enabled); + public final boolean enableShutterSound(boolean enabled) { + if (!enabled) { + IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE); + IAudioService audioService = IAudioService.Stub.asInterface(b); + try { + if (audioService.isCameraSoundForced()) return false; + } catch (RemoteException e) { + Log.e(TAG, "Audio service is unavailable for queries"); + } + } + return _enableShutterSound(enabled); + } + + private native final boolean _enableShutterSound(boolean enabled); /** * Callback interface for zoom changes during a smooth zoom operation. diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index 83a0c78..2739cac 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -16,6 +16,8 @@ package android.os; import com.android.internal.R; + +import android.app.ActivityManagerNative; import android.content.Context; import android.content.pm.UserInfo; import android.graphics.Bitmap; @@ -82,6 +84,39 @@ public class UserManager { } /** + * Return whether the given user is actively running. This means that + * the user is in the "started" state, not "stopped" -- it is currently + * allowed to run code through scheduled alarms, receiving broadcasts, + * etc. A started user may be either the current foreground user or a + * background user; the result here does not distinguish between the two. + * @param user The user to retrieve the running state for. + */ + public boolean isUserRunning(UserHandle user) { + try { + return ActivityManagerNative.getDefault().isUserRunning( + user.getIdentifier(), false); + } catch (RemoteException e) { + return false; + } + } + + /** + * Return whether the given user is actively running <em>or</em> stopping. + * This is like {@link #isUserRunning(UserHandle)}, but will also return + * true if the user had been running but is in the process of being stopped + * (but is not yet fully stopped, and still running some code). + * @param user The user to retrieve the running state for. + */ + public boolean isUserRunningOrStopping(UserHandle user) { + try { + return ActivityManagerNative.getDefault().isUserRunning( + user.getIdentifier(), true); + } catch (RemoteException e) { + return false; + } + } + + /** * Returns the UserInfo object describing a specific user. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle the user handle of the user whose information is being requested. diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 3bbdf36..3c4a8fe 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -4052,7 +4052,20 @@ public final class Settings { * @return true if the provider is enabled */ public static final boolean isLocationProviderEnabled(ContentResolver cr, String provider) { - String allowedProviders = Settings.Secure.getString(cr, LOCATION_PROVIDERS_ALLOWED); + return isLocationProviderEnabledForUser(cr, provider, UserHandle.myUserId()); + } + + /** + * Helper method for determining if a location provider is enabled. + * @param cr the content resolver to use + * @param provider the location provider to query + * @param userId the userId to query + * @return true if the provider is enabled + * @hide + */ + public static final boolean isLocationProviderEnabledForUser(ContentResolver cr, String provider, int userId) { + String allowedProviders = Settings.Secure.getStringForUser(cr, + LOCATION_PROVIDERS_ALLOWED, userId); return TextUtils.delimitedStringContains(allowedProviders, ',', provider); } @@ -4064,6 +4077,19 @@ public final class Settings { */ public static final void setLocationProviderEnabled(ContentResolver cr, String provider, boolean enabled) { + setLocationProviderEnabledForUser(cr, provider, enabled, UserHandle.myUserId()); + } + + /** + * Thread-safe method for enabling or disabling a single location provider. + * @param cr the content resolver to use + * @param provider the location provider to enable or disable + * @param enabled true if the provider should be enabled + * @param userId the userId for which to enable/disable providers + * @hide + */ + public static final void setLocationProviderEnabledForUser(ContentResolver cr, + String provider, boolean enabled, int userId) { // to ensure thread safety, we write the provider name with a '+' or '-' // and let the SettingsProvider handle it rather than reading and modifying // the list of enabled providers. @@ -4072,7 +4098,8 @@ public final class Settings { } else { provider = "-" + provider; } - putString(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider); + putStringForUser(cr, Settings.Secure.LOCATION_PROVIDERS_ALLOWED, provider, + userId); } } @@ -5294,6 +5321,7 @@ public final class Settings { ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, WIFI_NETWORKS_AVAILABLE_NOTIFICATION_ON, WIFI_NETWORKS_AVAILABLE_REPEAT_DELAY, + WIFI_WATCHDOG_POOR_NETWORK_TEST_ENABLED, WIFI_NUM_OPEN_NETWORKS_KEPT, EMERGENCY_TONE, CALL_AUTO_RETRY, diff --git a/core/java/android/service/dreams/DreamService.java b/core/java/android/service/dreams/DreamService.java index cb78763..f865455 100644 --- a/core/java/android/service/dreams/DreamService.java +++ b/core/java/android/service/dreams/DreamService.java @@ -120,7 +120,7 @@ public class DreamService extends Service implements Window.Callback { private boolean mInteractive = false; private boolean mLowProfile = true; private boolean mFullscreen = false; - private boolean mScreenBright = false; + private boolean mScreenBright = true; private boolean mFinished; private boolean mDebug = false; diff --git a/core/java/android/view/ScaleGestureDetector.java b/core/java/android/view/ScaleGestureDetector.java index a74e438..ee3f5d8 100644 --- a/core/java/android/view/ScaleGestureDetector.java +++ b/core/java/android/view/ScaleGestureDetector.java @@ -17,6 +17,7 @@ package android.view; import android.content.Context; +import android.content.res.Resources; import android.os.SystemClock; import android.util.FloatMath; @@ -162,9 +163,11 @@ public class ScaleGestureDetector { mContext = context; mListener = listener; mSpanSlop = ViewConfiguration.get(context).getScaledTouchSlop() * 2; - mTouchMinMajor = - (int) (context.getResources().getDisplayMetrics().density * TOUCH_MIN_MAJOR + 0.5f); - mMinSpan = context.getResources().getDimensionPixelSize( + + final Resources res = context.getResources(); + mTouchMinMajor = res.getDimensionPixelSize( + com.android.internal.R.dimen.config_minScalingTouchMajor); + mMinSpan = res.getDimensionPixelSize( com.android.internal.R.dimen.config_minScalingSpan); } diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index ae51c1d..0d76eac 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6858,12 +6858,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Performs the specified accessibility action on the view. For * possible accessibility actions look at {@link AccessibilityNodeInfo}. - * <p> - * If an {@link AccessibilityDelegate} has been specified via calling - * {@link #setAccessibilityDelegate(AccessibilityDelegate)} its - * {@link AccessibilityDelegate#performAccessibilityAction(View, int, Bundle)} - * is responsible for handling this call. - * </p> + * <p> + * If an {@link AccessibilityDelegate} has been specified via calling + * {@link #setAccessibilityDelegate(AccessibilityDelegate)} its + * {@link AccessibilityDelegate#performAccessibilityAction(View, int, Bundle)} + * is responsible for handling this call. + * </p> * * @param action The action to perform. * @param arguments Optional action arguments. @@ -6886,12 +6886,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, switch (action) { case AccessibilityNodeInfo.ACTION_CLICK: { if (isClickable()) { - return performClick(); + performClick(); + return true; } } break; case AccessibilityNodeInfo.ACTION_LONG_CLICK: { if (isLongClickable()) { - return performLongClick(); + performLongClick(); + return true; } } break; case AccessibilityNodeInfo.ACTION_FOCUS: { |
