summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-03-17 11:28:36 -0700
committerDianne Hackborn <hackbod@google.com>2014-03-17 11:28:36 -0700
commit10ad98223fd1fabb7b893de55d1384fd012aed7b (patch)
treef7a80b28fcca1a14f5eb2a9568da8124f483fad5
parent47e6d5d2748087f9fa861e6e2d3a2270748f72e5 (diff)
downloadframeworks_base-10ad98223fd1fabb7b893de55d1384fd012aed7b.zip
frameworks_base-10ad98223fd1fabb7b893de55d1384fd012aed7b.tar.gz
frameworks_base-10ad98223fd1fabb7b893de55d1384fd012aed7b.tar.bz2
Start enforcing explicit intents for Context.bindService()
No longer prints a warning, now throws an exception. Also fix a bug in UserManagerService that was causing an exception while booting. Change-Id: I3b43cfe08067da840b6850b9bed58664d36d34f1
-rw-r--r--api/current.txt1
-rw-r--r--core/java/android/app/ContextImpl.java10
-rw-r--r--core/java/android/os/Build.java13
-rw-r--r--services/core/java/com/android/server/pm/UserManagerService.java8
4 files changed, 22 insertions, 10 deletions
diff --git a/api/current.txt b/api/current.txt
index 4f71a80..579f0c7 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -18617,6 +18617,7 @@ package android.os {
field public static final int JELLY_BEAN_MR1 = 17; // 0x11
field public static final int JELLY_BEAN_MR2 = 18; // 0x12
field public static final int KITKAT = 19; // 0x13
+ field public static final int L = 10000; // 0x2710
}
public final class Bundle implements java.lang.Cloneable android.os.Parcelable {
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 0351292..344c3b2 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1479,13 +1479,13 @@ class ContextImpl extends Context {
private void validateServiceIntent(Intent service) {
if (service.getComponent() == null && service.getPackage() == null) {
- if (true || getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.KITKAT) {
+ if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.L) {
+ IllegalArgumentException ex = new IllegalArgumentException(
+ "Service Intent must be explicit: " + service);
+ throw ex;
+ } else {
Log.w(TAG, "Implicit intents with startService are not safe: " + service
+ " " + Debug.getCallers(2, 3));
- //IllegalArgumentException ex = new IllegalArgumentException(
- // "Service Intent must be explicit: " + service);
- //Log.e(TAG, "This will become an error", ex);
- //throw ex;
}
}
}
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 22e1476..c8051aa 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -467,6 +467,19 @@ public class Build {
* </ul>
*/
public static final int KITKAT = 19;
+
+ /**
+ * L!
+ *
+ * <p>Applications targeting this or a later release will get these
+ * new changes in behavior:</p>
+ * <ul>
+ * <li> {@link android.content.Context#bindService Context.bindService} now
+ * requires an explicit Intent, and will throw an exception if given an explicit
+ * Intent.</li>
+ * </ul>
+ */
+ public static final int L = CUR_DEVELOPMENT;
}
/** The type of build, like "user" or "eng". */
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index fc98c4e..7f55464 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -234,9 +234,7 @@ public class UserManagerService extends IUserManager.Stub {
}
void systemReady() {
- final Context context = ActivityThread.systemMain().getSystemContext();
- mUserPackageMonitor.register(context,
- null, UserHandle.ALL, false);
+ mUserPackageMonitor.register(mContext, null, UserHandle.ALL, false);
userForeground(UserHandle.USER_OWNER);
}
@@ -457,7 +455,7 @@ public class UserManagerService extends IUserManager.Stub {
/**
* Enforces that only the system UID or root's UID or apps that have the
- * {@link android.Manifest.permission.MANAGE_USERS MANAGE_USERS}
+ * {@link android.Manifest.permission#MANAGE_USERS MANAGE_USERS}
* permission can make certain calls to the UserManager.
*
* @param message used as message if SecurityException is thrown
@@ -1046,7 +1044,7 @@ public class UserManagerService extends IUserManager.Stub {
/**
* Removes a user and all data directories created for that user. This method should be called
* after the user's processes have been terminated.
- * @param id the user's id
+ * @param userHandle the user's id
*/
public boolean removeUser(int userHandle) {
checkManageUsersPermission("Only the system can remove users");