Merge "Revert "Enable background restrictions""

This commit is contained in:
Chris Tate
2017-01-19 01:21:16 +00:00
committed by Android (Google) Code Review
28 changed files with 82 additions and 418 deletions

View File

@@ -1385,14 +1385,7 @@ class ContextImpl extends Context {
@Override
public ComponentName startService(Intent service) {
warnIfCallingFromSystemProcess();
return startServiceCommon(service, -1, null, mUser);
}
@Override
public ComponentName startServiceInForeground(Intent service,
int id, Notification notification) {
warnIfCallingFromSystemProcess();
return startServiceCommon(service, id, notification, mUser);
return startServiceCommon(service, mUser);
}
@Override
@@ -1403,24 +1396,16 @@ class ContextImpl extends Context {
@Override
public ComponentName startServiceAsUser(Intent service, UserHandle user) {
return startServiceCommon(service, -1, null, user);
return startServiceCommon(service, user);
}
@Override
public ComponentName startServiceInForegroundAsUser(Intent service,
int id, Notification notification, UserHandle user) {
return startServiceCommon(service, id, notification, user);
}
private ComponentName startServiceCommon(Intent service, int id, Notification notification,
UserHandle user) {
private ComponentName startServiceCommon(Intent service, UserHandle user) {
try {
validateServiceIntent(service);
service.prepareToLeaveProcess(this);
ComponentName cn = ActivityManager.getService().startService(
mMainThread.getApplicationThread(), service, service.resolveTypeIfNeeded(
getContentResolver()), id, notification, getOpPackageName(),
user.getIdentifier());
getContentResolver()), getOpPackageName(), user.getIdentifier());
if (cn != null) {
if (cn.getPackageName().equals("!")) {
throw new SecurityException(

View File

@@ -128,8 +128,7 @@ interface IActivityManager {
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,
in String callingPackage, int userId);
in String resolvedType, 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,

View File

@@ -24,7 +24,6 @@ import android.annotation.TestApi;
import android.app.Notification.Builder;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ParceledListSlice;
import android.graphics.drawable.Icon;
import android.net.Uri;
@@ -1086,38 +1085,4 @@ public class NotificationManager
default: return defValue;
}
}
/**
* 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 stopped. 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.
*/
@Nullable
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);
}
}

View File

@@ -35,7 +35,6 @@ import android.annotation.UserIdInt;
import android.app.IApplicationThread;
import android.app.IServiceConnection;
import android.app.LoadedApk;
import android.app.Notification;
import android.app.admin.DevicePolicyManager;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
@@ -2517,17 +2516,6 @@ public abstract class Context {
@Nullable
public abstract ComponentName startService(Intent service);
/**
* 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
*/
@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
@@ -2559,17 +2547,8 @@ public abstract class Context {
/**
* @hide like {@link #startService(Intent)} but for a specific user.
*/
@Nullable
public abstract ComponentName startServiceAsUser(Intent service, UserHandle user);
/**
* @hide like {@link #startServiceInForeground(Intent, int, Notification)}
* but for a specific user.
*/
@Nullable
public abstract ComponentName startServiceInForegroundAsUser(Intent service,
int id, Notification notification, UserHandle user);
/**
* @hide like {@link #stopService(Intent)} but for a specific user.
*/

View File

@@ -20,7 +20,6 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.IApplicationThread;
import android.app.IServiceConnection;
import android.app.Notification;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
@@ -624,13 +623,6 @@ public class ContextWrapper extends Context {
return mBase.startService(service);
}
/** @hide */
@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);
@@ -642,13 +634,6 @@ public class ContextWrapper extends Context {
return mBase.startServiceAsUser(service, user);
}
/** @hide */
@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) {

View File

@@ -138,8 +138,9 @@ public abstract class PackageManagerInternal {
* @param userId The user under which to check.
*
* @return An {@link ApplicationInfo} containing information about the
* package, or {@code null} if no application exists with that
* package name.
* package.
* @throws NameNotFoundException if a package with the given name cannot be
* found on the system.
*/
public abstract ApplicationInfo getApplicationInfo(String packageName, int userId);

View File

@@ -109,10 +109,6 @@ public class SystemConfig {
// background while in data-usage save mode, as read from the configuration files.
final ArraySet<String> mAllowInDataUsageSave = new ArraySet<>();
// These are the action strings of broadcasts which are whitelisted to
// be delivered anonymously even to apps which target O+.
final ArraySet<String> mAllowImplicitBroadcasts = new ArraySet<>();
// These are the package names of apps which should be in the 'always'
// URL-handling state upon factory reset.
final ArraySet<String> mLinkedApps = new ArraySet<>();
@@ -166,10 +162,6 @@ public class SystemConfig {
return mPermissions;
}
public ArraySet<String> getAllowImplicitBroadcasts() {
return mAllowImplicitBroadcasts;
}
public ArraySet<String> getAllowInPowerSaveExceptIdle() {
return mAllowInPowerSaveExceptIdle;
}
@@ -446,17 +438,6 @@ public class SystemConfig {
XmlUtils.skipCurrentTag(parser);
continue;
} else if ("allow-implicit-broadcast".equals(name) && allowAll) {
String action = parser.getAttributeValue(null, "action");
if (action == null) {
Slog.w(TAG, "<allow-implicit-broadcast> without action in " + permFile
+ " at " + parser.getPositionDescription());
} else {
mAllowImplicitBroadcasts.add(action);
}
XmlUtils.skipCurrentTag(parser);
continue;
} else if ("app-link".equals(name) && allowAppConfigs) {
String pkgname = parser.getAttributeValue(null, "package");
if (pkgname == null) {