diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/Activity.java | 2 | ||||
-rw-r--r-- | core/java/android/app/ActivityManagerNative.java | 56 | ||||
-rw-r--r-- | core/java/android/app/AppOpsManager.java | 94 | ||||
-rw-r--r-- | core/java/android/app/ContextImpl.java | 2 | ||||
-rw-r--r-- | core/java/android/app/IActivityManager.java | 14 | ||||
-rw-r--r-- | core/java/android/app/INotificationManager.aidl | 2 | ||||
-rw-r--r-- | core/java/android/app/Instrumentation.java | 13 | ||||
-rw-r--r-- | core/java/android/app/NotificationManager.java | 8 | ||||
-rw-r--r-- | core/java/android/hardware/input/InputManager.java | 16 | ||||
-rw-r--r-- | core/java/android/os/IVibratorService.aidl | 4 | ||||
-rw-r--r-- | core/java/android/os/NullVibrator.java | 16 | ||||
-rw-r--r-- | core/java/android/os/SystemVibrator.java | 25 | ||||
-rw-r--r-- | core/java/android/os/Vibrator.java | 14 | ||||
-rw-r--r-- | core/java/android/view/WindowManagerPolicy.java | 10 |
14 files changed, 215 insertions, 61 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java index 18ccd53..87c2d8c 100644 --- a/core/java/android/app/Activity.java +++ b/core/java/android/app/Activity.java @@ -3740,7 +3740,7 @@ public class Activity extends ContextThemeWrapper try { intent.setAllowFds(false); result = ActivityManagerNative.getDefault() - .startActivity(mMainThread.getApplicationThread(), + .startActivity(mMainThread.getApplicationThread(), getBasePackageName(), intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken, mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED, null, null, diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java index d8e2239..c9930e9 100644 --- a/core/java/android/app/ActivityManagerNative.java +++ b/core/java/android/app/ActivityManagerNative.java @@ -116,6 +116,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM data.enforceInterface(IActivityManager.descriptor); IBinder b = data.readStrongBinder(); IApplicationThread app = ApplicationThreadNative.asInterface(b); + String callingPackage = data.readString(); Intent intent = Intent.CREATOR.createFromParcel(data); String resolvedType = data.readString(); IBinder resultTo = data.readStrongBinder(); @@ -127,7 +128,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM ? data.readFileDescriptor() : null; Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; - int result = startActivity(app, intent, resolvedType, + int result = startActivity(app, callingPackage, intent, resolvedType, resultTo, resultWho, requestCode, startFlags, profileFile, profileFd, options); reply.writeNoException(); @@ -140,6 +141,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM data.enforceInterface(IActivityManager.descriptor); IBinder b = data.readStrongBinder(); IApplicationThread app = ApplicationThreadNative.asInterface(b); + String callingPackage = data.readString(); Intent intent = Intent.CREATOR.createFromParcel(data); String resolvedType = data.readString(); IBinder resultTo = data.readStrongBinder(); @@ -152,7 +154,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); - int result = startActivityAsUser(app, intent, resolvedType, + int result = startActivityAsUser(app, callingPackage, intent, resolvedType, resultTo, resultWho, requestCode, startFlags, profileFile, profileFd, options, userId); reply.writeNoException(); @@ -165,6 +167,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM data.enforceInterface(IActivityManager.descriptor); IBinder b = data.readStrongBinder(); IApplicationThread app = ApplicationThreadNative.asInterface(b); + String callingPackage = data.readString(); Intent intent = Intent.CREATOR.createFromParcel(data); String resolvedType = data.readString(); IBinder resultTo = data.readStrongBinder(); @@ -177,7 +180,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); - WaitResult result = startActivityAndWait(app, intent, resolvedType, + WaitResult result = startActivityAndWait(app, callingPackage, intent, resolvedType, resultTo, resultWho, requestCode, startFlags, profileFile, profileFd, options, userId); reply.writeNoException(); @@ -190,6 +193,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM data.enforceInterface(IActivityManager.descriptor); IBinder b = data.readStrongBinder(); IApplicationThread app = ApplicationThreadNative.asInterface(b); + String callingPackage = data.readString(); Intent intent = Intent.CREATOR.createFromParcel(data); String resolvedType = data.readString(); IBinder resultTo = data.readStrongBinder(); @@ -200,7 +204,7 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); - int result = startActivityWithConfig(app, intent, resolvedType, + int result = startActivityWithConfig(app, callingPackage, intent, resolvedType, resultTo, resultWho, requestCode, startFlags, config, options, userId); reply.writeNoException(); reply.writeInt(result); @@ -1526,13 +1530,14 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM data.enforceInterface(IActivityManager.descriptor); IBinder b = data.readStrongBinder(); IApplicationThread app = ApplicationThreadNative.asInterface(b); + String callingPackage = data.readString(); Intent[] intents = data.createTypedArray(Intent.CREATOR); String[] resolvedTypes = data.createStringArray(); IBinder resultTo = data.readStrongBinder(); Bundle options = data.readInt() != 0 ? Bundle.CREATOR.createFromParcel(data) : null; int userId = data.readInt(); - int result = startActivities(app, intents, resolvedTypes, resultTo, + int result = startActivities(app, callingPackage, intents, resolvedTypes, resultTo, options, userId); reply.writeNoException(); reply.writeInt(result); @@ -1784,6 +1789,15 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM return true; } + case GET_LAUNCHED_FROM_PACKAGE_TRANSACTION: { + data.enforceInterface(IActivityManager.descriptor); + IBinder token = data.readStrongBinder(); + String res = getLaunchedFromPackage(token); + reply.writeNoException(); + reply.writeString(res); + return true; + } + case REGISTER_USER_SWITCH_OBSERVER_TRANSACTION: { data.enforceInterface(IActivityManager.descriptor); IUserSwitchObserver observer = IUserSwitchObserver.Stub.asInterface( @@ -1873,7 +1887,7 @@ class ActivityManagerProxy implements IActivityManager return mRemote; } - public int startActivity(IApplicationThread caller, Intent intent, + public int startActivity(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, String profileFile, ParcelFileDescriptor profileFd, Bundle options) throws RemoteException { @@ -1881,6 +1895,7 @@ class ActivityManagerProxy implements IActivityManager Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(caller != null ? caller.asBinder() : null); + data.writeString(callingPackage); intent.writeToParcel(data, 0); data.writeString(resolvedType); data.writeStrongBinder(resultTo); @@ -1908,7 +1923,7 @@ class ActivityManagerProxy implements IActivityManager return result; } - public int startActivityAsUser(IApplicationThread caller, Intent intent, + public int startActivityAsUser(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException { @@ -1916,6 +1931,7 @@ class ActivityManagerProxy implements IActivityManager Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(caller != null ? caller.asBinder() : null); + data.writeString(callingPackage); intent.writeToParcel(data, 0); data.writeString(resolvedType); data.writeStrongBinder(resultTo); @@ -1943,14 +1959,15 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); return result; } - public WaitResult startActivityAndWait(IApplicationThread caller, Intent intent, - String resolvedType, IBinder resultTo, String resultWho, + public WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage, + Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(caller != null ? caller.asBinder() : null); + data.writeString(callingPackage); intent.writeToParcel(data, 0); data.writeString(resolvedType); data.writeStrongBinder(resultTo); @@ -1978,14 +1995,15 @@ class ActivityManagerProxy implements IActivityManager data.recycle(); return result; } - public int startActivityWithConfig(IApplicationThread caller, Intent intent, - String resolvedType, IBinder resultTo, String resultWho, + public int startActivityWithConfig(IApplicationThread caller, String callingPackage, + Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, Configuration config, Bundle options, int userId) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(caller != null ? caller.asBinder() : null); + data.writeString(callingPackage); intent.writeToParcel(data, 0); data.writeString(resolvedType); data.writeStrongBinder(resultTo); @@ -3771,13 +3789,14 @@ class ActivityManagerProxy implements IActivityManager return res; } - public int startActivities(IApplicationThread caller, + public int startActivities(IApplicationThread caller, String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle options, int userId) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); data.writeInterfaceToken(IActivityManager.descriptor); data.writeStrongBinder(caller != null ? caller.asBinder() : null); + data.writeString(callingPackage); data.writeTypedArray(intents, 0); data.writeStringArray(resolvedTypes); data.writeStrongBinder(resultTo); @@ -4123,6 +4142,19 @@ class ActivityManagerProxy implements IActivityManager return result; } + public String getLaunchedFromPackage(IBinder activityToken) throws RemoteException { + Parcel data = Parcel.obtain(); + Parcel reply = Parcel.obtain(); + data.writeInterfaceToken(IActivityManager.descriptor); + data.writeStrongBinder(activityToken); + mRemote.transact(GET_LAUNCHED_FROM_PACKAGE_TRANSACTION, data, reply, 0); + reply.readException(); + String result = reply.readString(); + data.recycle(); + reply.recycle(); + return result; + } + public void registerUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java index a1fdef8..a81b6fe 100644 --- a/core/java/android/app/AppOpsManager.java +++ b/core/java/android/app/AppOpsManager.java @@ -16,6 +16,7 @@ package android.app; +import android.Manifest; import com.android.internal.app.IAppOpsService; import java.util.ArrayList; @@ -48,37 +49,82 @@ public class AppOpsManager { public static final int OP_WRITE_CALENDAR = 9; public static final int OP_WIFI_SCAN = 10; public static final int OP_POST_NOTIFICATION = 11; + public static final int OP_NEIGHBORING_CELLS = 12; + public static final int OP_CALL_PHONE = 13; + /** @hide */ + public static final int _NUM_OP = 14; + + /** + * This maps each operation to the operation that serves as the + * switch to determine whether it is allowed. Generally this is + * a 1:1 mapping, but for some things (like location) that have + * multiple low-level operations being tracked that should be + * presented to hte user as one switch then this can be used to + * make them all controlled by the same single operation. + */ + private static int[] sOpToSwitch = new int[] { + OP_COARSE_LOCATION, + OP_COARSE_LOCATION, + OP_COARSE_LOCATION, + OP_VIBRATE, + OP_READ_CONTACTS, + OP_WRITE_CONTACTS, + OP_READ_CALL_LOG, + OP_WRITE_CALL_LOG, + OP_READ_CALENDAR, + OP_WRITE_CALENDAR, + OP_COARSE_LOCATION, + OP_POST_NOTIFICATION, + OP_COARSE_LOCATION, + OP_CALL_PHONE, + }; + /** + * This provides a simple name for each operation to be used + * in debug output. + */ private static String[] sOpNames = new String[] { - "COARSE_LOCATION", - "FINE_LOCATION", - "GPS", - "VIBRATE", - "READ_CONTACTS", - "WRITE_CONTACTS", - "READ_CALL_LOG", - "WRITE_CALL_LOG", - "READ_CALENDAR", - "WRITE_CALENDAR", - "WIFI_SCAN", - "POST_NOTIFICATION", + "COARSE_LOCATION", + "FINE_LOCATION", + "GPS", + "VIBRATE", + "READ_CONTACTS", + "WRITE_CONTACTS", + "READ_CALL_LOG", + "WRITE_CALL_LOG", + "READ_CALENDAR", + "WRITE_CALENDAR", + "WIFI_SCAN", + "POST_NOTIFICATION", + "NEIGHBORING_CELLS", + "CALL_PHONE", }; + /** + * This optionally maps a permission to an operation. If there + * is no permission associated with an operation, it is null. + */ private static String[] sOpPerms = new String[] { - android.Manifest.permission.ACCESS_COARSE_LOCATION, - android.Manifest.permission.ACCESS_FINE_LOCATION, - android.Manifest.permission.ACCESS_FINE_LOCATION, - android.Manifest.permission.VIBRATE, - android.Manifest.permission.READ_CONTACTS, - android.Manifest.permission.WRITE_CONTACTS, - android.Manifest.permission.READ_CALL_LOG, - android.Manifest.permission.WRITE_CALL_LOG, - android.Manifest.permission.READ_CALENDAR, - android.Manifest.permission.WRITE_CALENDAR, - android.Manifest.permission.ACCESS_WIFI_STATE, - null, // no permission required for notifications + android.Manifest.permission.ACCESS_COARSE_LOCATION, + android.Manifest.permission.ACCESS_FINE_LOCATION, + null, + android.Manifest.permission.VIBRATE, + android.Manifest.permission.READ_CONTACTS, + android.Manifest.permission.WRITE_CONTACTS, + android.Manifest.permission.READ_CALL_LOG, + 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, // neighboring cells shares the coarse location perm + android.Manifest.permission.CALL_PHONE, }; + public static int opToSwitch(int op) { + return sOpToSwitch[op]; + } + public static String opToName(int op) { return op < sOpNames.length ? sOpNames[op] : ("Unknown(" + op + ")"); } diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index e03d3fd..2cf9f59 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -963,7 +963,7 @@ class ContextImpl extends Context { public void startActivityAsUser(Intent intent, Bundle options, UserHandle user) { try { ActivityManagerNative.getDefault().startActivityAsUser( - mMainThread.getApplicationThread(), intent, + mMainThread.getApplicationThread(), getBasePackageName(), intent, intent.resolveTypeIfNeeded(getContentResolver()), null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, null, options, user.getIdentifier()); diff --git a/core/java/android/app/IActivityManager.java b/core/java/android/app/IActivityManager.java index 5a49329..e58ff62 100644 --- a/core/java/android/app/IActivityManager.java +++ b/core/java/android/app/IActivityManager.java @@ -51,19 +51,19 @@ import java.util.List; * {@hide} */ public interface IActivityManager extends IInterface { - public int startActivity(IApplicationThread caller, + public int startActivity(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flags, String profileFile, ParcelFileDescriptor profileFd, Bundle options) throws RemoteException; - public int startActivityAsUser(IApplicationThread caller, + public int startActivityAsUser(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flags, String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException; - public WaitResult startActivityAndWait(IApplicationThread caller, + public WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int flags, String profileFile, ParcelFileDescriptor profileFd, Bundle options, int userId) throws RemoteException; - public int startActivityWithConfig(IApplicationThread caller, + public int startActivityWithConfig(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode, int startFlags, Configuration newConfig, Bundle options, int userId) throws RemoteException; @@ -310,7 +310,7 @@ public interface IActivityManager extends IInterface { public boolean dumpHeap(String process, int userId, boolean managed, String path, ParcelFileDescriptor fd) throws RemoteException; - public int startActivities(IApplicationThread caller, + public int startActivities(IApplicationThread caller, String callingPackage, Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle options, int userId) throws RemoteException; @@ -357,9 +357,10 @@ public interface IActivityManager extends IInterface { public boolean navigateUpTo(IBinder token, Intent target, int resultCode, Intent resultData) throws RemoteException; - // This is not public because you need to be very careful in how you + // These are not public because you need to be very careful in how you // manage your activity to make sure it is always the uid you expect. public int getLaunchedFromUid(IBinder activityToken) throws RemoteException; + public String getLaunchedFromPackage(IBinder activityToken) throws RemoteException; public void registerUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException; public void unregisterUserSwitchObserver(IUserSwitchObserver observer) throws RemoteException; @@ -630,4 +631,5 @@ public interface IActivityManager extends IInterface { int GET_INTENT_FOR_INTENT_SENDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+160; int GET_TOP_ACTIVITY_EXTRAS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+161; int REPORT_TOP_ACTIVITY_EXTRAS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+162; + int GET_LAUNCHED_FROM_PACKAGE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+163; } diff --git a/core/java/android/app/INotificationManager.aidl b/core/java/android/app/INotificationManager.aidl index b4c222f..d400eba 100644 --- a/core/java/android/app/INotificationManager.aidl +++ b/core/java/android/app/INotificationManager.aidl @@ -28,7 +28,7 @@ interface INotificationManager void enqueueToast(String pkg, ITransientNotification callback, int duration); void cancelToast(String pkg, ITransientNotification callback); - void enqueueNotificationWithTag(String pkg, String tag, int id, + void enqueueNotificationWithTag(String pkg, String basePkg, String tag, int id, in Notification notification, inout int[] idReceived, int userId); void cancelNotificationWithTag(String pkg, String tag, int id, int userId); diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java index a2eeddd..e7bf305 100644 --- a/core/java/android/app/Instrumentation.java +++ b/core/java/android/app/Instrumentation.java @@ -1413,7 +1413,7 @@ public class Instrumentation { intent.setAllowFds(false); intent.migrateExtraStreamToClipData(); int result = ActivityManagerNative.getDefault() - .startActivity(whoThread, intent, + .startActivity(whoThread, who.getBasePackageName(), intent, intent.resolveTypeIfNeeded(who.getContentResolver()), token, target != null ? target.mEmbeddedID : null, requestCode, 0, null, null, options); @@ -1471,15 +1471,16 @@ public class Instrumentation { resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver()); } int result = ActivityManagerNative.getDefault() - .startActivities(whoThread, intents, resolvedTypes, token, options, - userId); + .startActivities(whoThread, who.getBasePackageName(), intents, resolvedTypes, + token, options, userId); checkStartActivityResult(result, intents[0]); } catch (RemoteException e) { } } /** - * Like {@link #execStartActivity(Context, IBinder, IBinder, Activity, Intent, int)}, + * Like {@link #execStartActivity(android.content.Context, android.os.IBinder, + * android.os.IBinder, Fragment, android.content.Intent, int, android.os.Bundle)}, * but for calls from a {#link Fragment}. * * @param who The Context from which the activity is being started. @@ -1528,7 +1529,7 @@ public class Instrumentation { intent.setAllowFds(false); intent.migrateExtraStreamToClipData(); int result = ActivityManagerNative.getDefault() - .startActivity(whoThread, intent, + .startActivity(whoThread, who.getBasePackageName(), intent, intent.resolveTypeIfNeeded(who.getContentResolver()), token, target != null ? target.mWho : null, requestCode, 0, null, null, options); @@ -1588,7 +1589,7 @@ public class Instrumentation { intent.setAllowFds(false); intent.migrateExtraStreamToClipData(); int result = ActivityManagerNative.getDefault() - .startActivityAsUser(whoThread, intent, + .startActivityAsUser(whoThread, who.getBasePackageName(), intent, intent.resolveTypeIfNeeded(who.getContentResolver()), token, target != null ? target.mEmbeddedID : null, requestCode, 0, null, null, options, user.getIdentifier()); diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java index 0acad75..5e69128 100644 --- a/core/java/android/app/NotificationManager.java +++ b/core/java/android/app/NotificationManager.java @@ -129,8 +129,8 @@ public class NotificationManager } if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")"); try { - service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut, - UserHandle.myUserId()); + service.enqueueNotificationWithTag(pkg, mContext.getBasePackageName(), tag, id, + notification, idOut, UserHandle.myUserId()); if (id != idOut[0]) { Log.w(TAG, "notify: id corrupted: sent " + id + ", got back " + idOut[0]); } @@ -151,8 +151,8 @@ public class NotificationManager } if (localLOGV) Log.v(TAG, pkg + ": notify(" + id + ", " + notification + ")"); try { - service.enqueueNotificationWithTag(pkg, tag, id, notification, idOut, - user.getIdentifier()); + service.enqueueNotificationWithTag(pkg, mContext.getBasePackageName(), tag, id, + notification, idOut, user.getIdentifier()); if (id != idOut[0]) { Log.w(TAG, "notify: id corrupted: sent " + id + ", got back " + idOut[0]); } diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index 6b00c58..761faaf 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -813,6 +813,22 @@ public final class InputManager { } } + /** + * @hide + */ + @Override + public void vibrate(int owningUid, String owningPackage, long milliseconds) { + vibrate(milliseconds); + } + + /** + * @hide + */ + @Override + public void vibrate(int owningUid, String owningPackage, long[] pattern, int repeat) { + vibrate(pattern, repeat); + } + @Override public void cancel() { try { diff --git a/core/java/android/os/IVibratorService.aidl b/core/java/android/os/IVibratorService.aidl index 15cedf9..456ffb1 100644 --- a/core/java/android/os/IVibratorService.aidl +++ b/core/java/android/os/IVibratorService.aidl @@ -20,8 +20,8 @@ package android.os; interface IVibratorService { boolean hasVibrator(); - void vibrate(String packageName, long milliseconds, IBinder token); - void vibratePattern(String packageName, in long[] pattern, int repeat, IBinder token); + void vibrate(int uid, String packageName, long milliseconds, IBinder token); + void vibratePattern(int uid, String packageName, in long[] pattern, int repeat, IBinder token); void cancelVibrate(IBinder token); } diff --git a/core/java/android/os/NullVibrator.java b/core/java/android/os/NullVibrator.java index 8de4e06..ac6027f 100644 --- a/core/java/android/os/NullVibrator.java +++ b/core/java/android/os/NullVibrator.java @@ -49,6 +49,22 @@ public class NullVibrator extends Vibrator { } } + /** + * @hide + */ + @Override + public void vibrate(int owningUid, String owningPackage, long milliseconds) { + vibrate(milliseconds); + } + + /** + * @hide + */ + @Override + public void vibrate(int owningUid, String owningPackage, long[] pattern, int repeat) { + vibrate(pattern, repeat); + } + @Override public void cancel() { } diff --git a/core/java/android/os/SystemVibrator.java b/core/java/android/os/SystemVibrator.java index 08eba4f..e66fb28 100644 --- a/core/java/android/os/SystemVibrator.java +++ b/core/java/android/os/SystemVibrator.java @@ -16,6 +16,7 @@ package android.os; +import android.app.ActivityThread; import android.content.Context; import android.util.Log; @@ -32,7 +33,7 @@ public class SystemVibrator extends Vibrator { private final Binder mToken = new Binder(); public SystemVibrator() { - mPackageName = null; + mPackageName = ActivityThread.currentPackageName(); mService = IVibratorService.Stub.asInterface( ServiceManager.getService("vibrator")); } @@ -58,19 +59,35 @@ public class SystemVibrator extends Vibrator { @Override public void vibrate(long milliseconds) { + vibrate(Process.myUid(), mPackageName, milliseconds); + } + + @Override + public void vibrate(long[] pattern, int repeat) { + vibrate(Process.myUid(), mPackageName, pattern, repeat); + } + + /** + * @hide + */ + @Override + public void vibrate(int owningUid, String owningPackage, long milliseconds) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; } try { - mService.vibrate(mPackageName, milliseconds, mToken); + mService.vibrate(owningUid, owningPackage, milliseconds, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } } + /** + * @hide + */ @Override - public void vibrate(long[] pattern, int repeat) { + public void vibrate(int owningUid, String owningPackage, long[] pattern, int repeat) { if (mService == null) { Log.w(TAG, "Failed to vibrate; no vibrator service."); return; @@ -80,7 +97,7 @@ public class SystemVibrator extends Vibrator { // anyway if (repeat < pattern.length) { try { - mService.vibratePattern(mPackageName, pattern, repeat, mToken); + mService.vibratePattern(owningUid, owningPackage, pattern, repeat, mToken); } catch (RemoteException e) { Log.w(TAG, "Failed to vibrate.", e); } diff --git a/core/java/android/os/Vibrator.java b/core/java/android/os/Vibrator.java index b67be4b..6650fca 100644 --- a/core/java/android/os/Vibrator.java +++ b/core/java/android/os/Vibrator.java @@ -73,6 +73,20 @@ public abstract class Vibrator { public abstract void vibrate(long[] pattern, int repeat); /** + * @hide + * Like {@link #vibrate(long)}, but allowing the caller to specify that + * the vibration is owned by someone else. + */ + public abstract void vibrate(int owningUid, String owningPackage, long milliseconds); + + /** + * @hide + * Like {@link #vibrate(long[], int)}, but allowing the caller to specify that + * the vibration is owned by someone else. + */ + public abstract void vibrate(int owningUid, String owningPackage, long[] pattern, int repeat); + + /** * Turn the vibrator off. * <p>This method requires the caller to hold the permission * {@link android.Manifest.permission#VIBRATE}. diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 02be4db..bd28abc 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -135,6 +135,16 @@ public interface WindowManagerPolicy { */ public interface WindowState { /** + * Return the uid of the app that owns this window. + */ + int getOwningUid(); + + /** + * Return the package name of the app that owns this window. + */ + String getOwningPackage(); + + /** * Perform standard frame computation. The result can be obtained with * getFrame() if so desired. Must be called with the window manager * lock held. |