Merge "Turn down the preliminary foreground service API" into oc-dev
diff --git a/api/current.txt b/api/current.txt
index d3184d6..4fc4bfc 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -5604,7 +5604,6 @@
method public boolean removeAutomaticZenRule(java.lang.String);
method public final void setInterruptionFilter(int);
method public void setNotificationPolicy(android.app.NotificationManager.Policy);
- method public deprecated android.content.ComponentName startServiceInForeground(android.content.Intent, int, android.app.Notification);
method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
@@ -40906,7 +40905,6 @@
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int) throws android.content.IntentSender.SendIntentException;
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
method public android.content.ComponentName startService(android.content.Intent);
- method public android.content.ComponentName startServiceInForeground(android.content.Intent, int, android.app.Notification);
method public boolean stopService(android.content.Intent);
method public void unbindService(android.content.ServiceConnection);
method public void unregisterReceiver(android.content.BroadcastReceiver);
diff --git a/api/system-current.txt b/api/system-current.txt
index b216832..db3792b 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -5806,7 +5806,6 @@
method public boolean removeAutomaticZenRule(java.lang.String);
method public final void setInterruptionFilter(int);
method public void setNotificationPolicy(android.app.NotificationManager.Policy);
- method public deprecated android.content.ComponentName startServiceInForeground(android.content.Intent, int, android.app.Notification);
method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
@@ -44462,7 +44461,6 @@
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int) throws android.content.IntentSender.SendIntentException;
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
method public android.content.ComponentName startService(android.content.Intent);
- method public android.content.ComponentName startServiceInForeground(android.content.Intent, int, android.app.Notification);
method public boolean stopService(android.content.Intent);
method public void unbindService(android.content.ServiceConnection);
method public void unregisterReceiver(android.content.BroadcastReceiver);
diff --git a/api/test-current.txt b/api/test-current.txt
index e3292f9..f8a04d2 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -5618,7 +5618,6 @@
method public boolean removeAutomaticZenRule(java.lang.String);
method public final void setInterruptionFilter(int);
method public void setNotificationPolicy(android.app.NotificationManager.Policy);
- method public deprecated android.content.ComponentName startServiceInForeground(android.content.Intent, int, android.app.Notification);
method public boolean updateAutomaticZenRule(java.lang.String, android.app.AutomaticZenRule);
field public static final java.lang.String ACTION_INTERRUPTION_FILTER_CHANGED = "android.app.action.INTERRUPTION_FILTER_CHANGED";
field public static final java.lang.String ACTION_NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED = "android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED";
@@ -41101,7 +41100,6 @@
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int) throws android.content.IntentSender.SendIntentException;
method public void startIntentSender(android.content.IntentSender, android.content.Intent, int, int, int, android.os.Bundle) throws android.content.IntentSender.SendIntentException;
method public android.content.ComponentName startService(android.content.Intent);
- method public android.content.ComponentName startServiceInForeground(android.content.Intent, int, android.app.Notification);
method public boolean stopService(android.content.Intent);
method public void unbindService(android.content.ServiceConnection);
method public void unregisterReceiver(android.content.BroadcastReceiver);
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 6cc8a14..80de64b 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1447,21 +1447,13 @@
@Override
public ComponentName startService(Intent service) {
warnIfCallingFromSystemProcess();
- return startServiceCommon(service, -1, null, false, mUser);
+ return startServiceCommon(service, false, mUser);
}
@Override
public ComponentName startForegroundService(Intent service) {
warnIfCallingFromSystemProcess();
- return startServiceCommon(service, -1, null, true, mUser);
- }
-
- // STOPSHIP: remove when NotificationManager.startServiceInForeground() is retired
- @Override
- public ComponentName startServiceInForeground(Intent service,
- int id, Notification notification) {
- warnIfCallingFromSystemProcess();
- return startServiceCommon(service, id, notification, false, mUser);
+ return startServiceCommon(service, true, mUser);
}
@Override
@@ -1472,29 +1464,22 @@
@Override
public ComponentName startServiceAsUser(Intent service, UserHandle user) {
- return startServiceCommon(service, -1, null, false, user);
+ return startServiceCommon(service, false, user);
}
@Override
public ComponentName startForegroundServiceAsUser(Intent service, UserHandle user) {
- return startServiceCommon(service, -1, null, true, user);
+ return startServiceCommon(service, true, user);
}
- // STOPSHIP: remove when NotificationManager.startServiceInForeground() is retired
- @Override
- public ComponentName startServiceInForegroundAsUser(Intent service,
- int id, Notification notification, UserHandle user) {
- return startServiceCommon(service, id, notification, false, user);
- }
-
- private ComponentName startServiceCommon(Intent service, int id, Notification notification,
- boolean requireForeground, UserHandle user) {
+ private ComponentName startServiceCommon(Intent service, boolean requireForeground,
+ UserHandle user) {
try {
validateServiceIntent(service);
service.prepareToLeaveProcess(this);
ComponentName cn = ActivityManager.getService().startService(
mMainThread.getApplicationThread(), service, service.resolveTypeIfNeeded(
- getContentResolver()), id, notification, requireForeground,
+ getContentResolver()), requireForeground,
getOpPackageName(), user.getIdentifier());
if (cn != null) {
if (cn.getPackageName().equals("!")) {
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl
index 4210d2e..d270244 100644
--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -129,8 +129,7 @@
void finishSubActivity(in IBinder token, in String resultWho, int requestCode);
PendingIntent getRunningServiceControlPanel(in ComponentName service);
ComponentName startService(in IApplicationThread caller, in Intent service,
- in String resolvedType, int id, in Notification notification,
- boolean requireForeground, in String callingPackage, int userId);
+ in String resolvedType, boolean requireForeground, in String callingPackage, int userId);
int stopService(in IApplicationThread caller, in Intent service,
in String resolvedType, int userId);
int bindService(in IApplicationThread caller, in IBinder token, in Intent service,
diff --git a/core/java/android/app/NotificationManager.java b/core/java/android/app/NotificationManager.java
index 72c5978..242d4a5 100644
--- a/core/java/android/app/NotificationManager.java
+++ b/core/java/android/app/NotificationManager.java
@@ -1155,40 +1155,4 @@
}
}
- /**
- * Start a service directly into the "foreground service" state. Unlike
- * {@link android.content.Context#startService(Intent)}, this method
- * can be used from within background operations like broadcast receivers
- * or scheduled jobs.
- *
- * @param service Description of the service to be started. The Intent must be either
- * fully explicit (supplying a component name) or specify a specific package
- * name it is targeted to.
- * @param id The identifier for this notification as per
- * {@link #notify(int, Notification) NotificationManager.notify(int, Notification)};
- * must not be 0.
- * @param notification The Notification to be displayed.
- * @return If the service is being started or is already running, the
- * {@link ComponentName} of the actual service that was started is
- * returned; else if the service does not exist null is returned.
- *
- * @deprecated STOPSHIP transition away from this for O
- */
- @Nullable
- @Deprecated
- public ComponentName startServiceInForeground(Intent service,
- int id, Notification notification) {
- return mContext.startServiceInForeground(service, id, notification);
- }
-
- /**
- * @hide like {@link #startServiceInForeground(Intent, int, Notification)}
- * but for a specific user.
- */
- @Nullable
- public ComponentName startServiceInForegroundAsUser(Intent service,
- int id, Notification notification, UserHandle user) {
- return mContext.startServiceInForegroundAsUser(service, id, notification, user);
- }
-
}
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 18120c7..0adab1a 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -2647,18 +2647,6 @@
public abstract ComponentName startForegroundServiceAsUser(Intent service, UserHandle user);
/**
- * Start a service directly into the "foreground service" state. Unlike {@link #startService},
- * this method can be used from within background operations like broadcast receivers
- * or scheduled jobs. The API entry point for this is in NotificationManager in order to
- * preserve appropriate public package layering.
- * @hide
- * @deprecated STOPSHIP remove in favor of two-step startForegroundService() + startForeground()
- */
- @Nullable
- public abstract ComponentName startServiceInForeground(Intent service,
- int id, Notification notification);
-
- /**
* Request that a given application service be stopped. If the service is
* not running, nothing happens. Otherwise it is stopped. Note that calls
* to startService() are not counted -- this stops the service no matter
@@ -2696,16 +2684,6 @@
public abstract ComponentName startServiceAsUser(Intent service, UserHandle user);
/**
- * @hide like {@link #startServiceInForeground(Intent, int, Notification)}
- * but for a specific user.
- * @deprecated STOPSHIP remove when trial API is turned off
- */
- @Deprecated
- @Nullable
- public abstract ComponentName startServiceInForegroundAsUser(Intent service,
- int id, Notification notification, UserHandle user);
-
- /**
* @hide like {@link #stopService(Intent)} but for a specific user.
*/
public abstract boolean stopServiceAsUser(Intent service, UserHandle user);
diff --git a/core/java/android/content/ContextWrapper.java b/core/java/android/content/ContextWrapper.java
index 53b021c..b59fc3dd 100644
--- a/core/java/android/content/ContextWrapper.java
+++ b/core/java/android/content/ContextWrapper.java
@@ -649,13 +649,6 @@
return mBase.startForegroundService(service);
}
- /** @hide STOPSHIP remove when trial API is turned down */
- @Override
- public ComponentName startServiceInForeground(Intent service,
- int id, Notification notification) {
- return mBase.startServiceInForeground(service, id, notification);
- }
-
@Override
public boolean stopService(Intent name) {
return mBase.stopService(name);
@@ -673,13 +666,6 @@
return mBase.startForegroundServiceAsUser(service, user);
}
- /** @hide STOPSHIP removed when trial API is turned down */
- @Override
- public ComponentName startServiceInForegroundAsUser(Intent service,
- int id, Notification notification, UserHandle user) {
- return mBase.startServiceInForegroundAsUser(service, id, notification, user);
- }
-
/** @hide */
@Override
public boolean stopServiceAsUser(Intent name, UserHandle user) {
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index c77820b..2cd14e9 100644
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -312,8 +312,7 @@
}
ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType,
- int id, Notification notification, int callingPid, int callingUid,
- boolean fgRequired, String callingPackage, final int userId)
+ int callingPid, int callingUid, boolean fgRequired, String callingPackage, final int userId)
throws TransactionTooLargeException {
if (DEBUG_DELAYED_STARTS) Slog.v(TAG_SERVICE, "startService: " + service
+ " type=" + resolvedType + " args=" + service.getExtras());
@@ -464,10 +463,6 @@
}
ComponentName cmp = startServiceInnerLocked(smap, service, r, callerFg, addToStarting);
- // STOPSHIP deprecated; remove when NotificationManager.startServiceInForeground is retired
- if (notification != null) {
- setServiceForegroundInnerLocked(r, id, notification, 0);
- }
return cmp;
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 946ba0d..d43fa01 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -17931,8 +17931,7 @@
@Override
public ComponentName startService(IApplicationThread caller, Intent service,
- String resolvedType, int id, Notification notification, boolean requireForeground,
- String callingPackage, int userId)
+ String resolvedType, boolean requireForeground, String callingPackage, int userId)
throws TransactionTooLargeException {
enforceNotIsolatedCaller("startService");
// Refuse possible leaked file descriptors
@@ -17953,7 +17952,7 @@
ComponentName res;
try {
res = mServices.startServiceLocked(caller, service,
- resolvedType, id, notification, callingPid, callingUid,
+ resolvedType, callingPid, callingUid,
requireForeground, callingPackage, userId);
} finally {
Binder.restoreCallingIdentity(origId);
@@ -17972,7 +17971,7 @@
ComponentName res;
try {
res = mServices.startServiceLocked(null, service,
- resolvedType, 0, null, -1, uid, fgRequired, callingPackage, userId);
+ resolvedType, -1, uid, fgRequired, callingPackage, userId);
} finally {
Binder.restoreCallingIdentity(origId);
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index 0fcf3e6..b6bfb00 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -524,7 +524,7 @@
pw.println("Starting service: " + intent);
pw.flush();
ComponentName cn = mInterface.startService(null, intent, intent.getType(),
- -1, null, asForeground, SHELL_PACKAGE_NAME, mUserId);
+ asForeground, SHELL_PACKAGE_NAME, mUserId);
if (cn == null) {
err.println("Error: Not found; no service started.");
return -1;
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index 95b4903..312c310 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -13202,7 +13202,7 @@
if (dcsUid > 0) {
am.backgroundWhitelistUid(dcsUid);
}
- am.startService(null, intent, null, -1, null, false, mContext.getOpPackageName(),
+ am.startService(null, intent, null, false, mContext.getOpPackageName(),
UserHandle.USER_SYSTEM);
} catch (RemoteException e) {
}
diff --git a/test-runner/src/android/test/mock/MockContext.java b/test-runner/src/android/test/mock/MockContext.java
index a8eb986..b4e3a47 100644
--- a/test-runner/src/android/test/mock/MockContext.java
+++ b/test-runner/src/android/test/mock/MockContext.java
@@ -530,13 +530,6 @@
throw new UnsupportedOperationException();
}
- /** STOPSHIP remove when trial API is turned down */
- @Override
- public ComponentName startServiceInForeground(Intent service,
- int id, Notification notification) {
- throw new UnsupportedOperationException();
- }
-
@Override
public boolean stopService(Intent service) {
throw new UnsupportedOperationException();
@@ -554,13 +547,6 @@
throw new UnsupportedOperationException();
}
- /** @hide STOPSHIP removed when trial API is turned down */
- @Override
- public ComponentName startServiceInForegroundAsUser(Intent service,
- int id, Notification notification, UserHandle user) {
- throw new UnsupportedOperationException();
- }
-
/** @hide */
@Override
public boolean stopServiceAsUser(Intent service, UserHandle user) {
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 328fc0a..1e77ac1 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -1865,13 +1865,6 @@
}
@Override
- public ComponentName startServiceInForeground(Intent service,
- int id, Notification notification) {
- // pass
- return null;
- }
-
- @Override
public boolean stopService(Intent arg0) {
// pass
return false;
@@ -1884,13 +1877,6 @@
}
@Override
- public ComponentName startServiceInForegroundAsUser(Intent service,
- int id, Notification notification, UserHandle user) {
- // pass
- return null;
- }
-
- @Override
public boolean stopServiceAsUser(Intent arg0, UserHandle arg1) {
// pass
return false;