OSDN Git Service

Revert "Enable background restrictions"
authorChris Tate <ctate@android.com>
Thu, 19 Jan 2017 01:09:52 +0000 (01:09 +0000)
committerChris Tate <ctate@android.com>
Thu, 19 Jan 2017 01:12:19 +0000 (01:12 +0000)
This reverts commit 21f778060badb1e78bffde05e8de7662d275003d.

Change-Id: I65586f9739da84fb32b51b0ea166b8288c41d1b3

28 files changed:
api/current.txt
api/system-current.txt
api/test-current.txt
core/java/android/app/ContextImpl.java
core/java/android/app/IActivityManager.aidl
core/java/android/app/NotificationManager.java
core/java/android/content/Context.java
core/java/android/content/ContextWrapper.java
core/java/android/content/pm/PackageManagerInternal.java
core/java/com/android/server/SystemConfig.java
data/etc/Android.mk
data/etc/framework-sysconfig.xml [deleted file]
services/core/java/com/android/server/DeviceIdleController.java
services/core/java/com/android/server/TelephonyRegistry.java
services/core/java/com/android/server/am/ActiveServices.java
services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
services/core/java/com/android/server/am/ActivityManagerService.java
services/core/java/com/android/server/am/ActivityManagerShellCommand.java
services/core/java/com/android/server/am/BroadcastQueue.java
services/core/java/com/android/server/am/UidRecord.java
services/core/java/com/android/server/am/UserController.java
services/core/java/com/android/server/pm/PackageManagerService.java
services/core/java/com/android/server/storage/DeviceStorageMonitorService.java
services/usb/java/com/android/server/usb/UsbPortManager.java
services/usb/java/com/android/server/usb/UsbProfileGroupSettingsManager.java
services/usb/java/com/android/server/usb/UsbSettingsManager.java
test-runner/src/android/test/mock/MockContext.java
tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java

index 931c310..849861a 100644 (file)
@@ -5439,7 +5439,6 @@ package android.app {
     method public boolean removeAutomaticZenRule(java.lang.String);
     method public final void setInterruptionFilter(int);
     method public void setNotificationPolicy(android.app.NotificationManager.Policy);
-    method public 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";
@@ -38983,7 +38982,6 @@ package android.test.mock {
     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);
index 9737382..683374a 100644 (file)
@@ -5624,7 +5624,6 @@ package android.app {
     method public boolean removeAutomaticZenRule(java.lang.String);
     method public final void setInterruptionFilter(int);
     method public void setNotificationPolicy(android.app.NotificationManager.Policy);
-    method public 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";
@@ -42231,7 +42230,6 @@ package android.test.mock {
     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);
index df95f12..6f8a96f 100644 (file)
@@ -5450,7 +5450,6 @@ package android.app {
     method public boolean removeAutomaticZenRule(java.lang.String);
     method public final void setInterruptionFilter(int);
     method public void setNotificationPolicy(android.app.NotificationManager.Policy);
-    method public 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";
@@ -39103,7 +39102,6 @@ package android.test.mock {
     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);
index b67e193..d08bee5 100644 (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(
index 236eb18..5824c32 100644 (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,
index c0aae6d..3551691 100644 (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);
-    }
-
 }
index b196c64..af5e643 100644 (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;
@@ -2518,17 +2517,6 @@ public abstract class Context {
     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
      * to startService() are not counted -- this stops the service no matter
@@ -2559,18 +2547,9 @@ 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.
      */
     public abstract boolean stopServiceAsUser(Intent service, UserHandle user);
index b131ecc..e437de0 100644 (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);
@@ -644,13 +636,6 @@ public class ContextWrapper extends Context {
 
     /** @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) {
         return mBase.stopServiceAsUser(name, user);
     }
index bf3aa70..2590a6b 100644 (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);
 
index fcb4c7b..168da5f 100644 (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) {
index b2c6840..6718259 100644 (file)
@@ -18,14 +18,6 @@ LOCAL_PATH := $(my-dir)
 
 ########################
 include $(CLEAR_VARS)
-LOCAL_MODULE := framework-sysconfig.xml
-LOCAL_MODULE_CLASS := ETC
-LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/sysconfig
-LOCAL_SRC_FILES := $(LOCAL_MODULE)
-include $(BUILD_PREBUILT)
-
-########################
-include $(CLEAR_VARS)
 LOCAL_MODULE := platform.xml
 LOCAL_MODULE_CLASS := ETC
 LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
@@ -39,3 +31,4 @@ LOCAL_MODULE_CLASS := ETC
 LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
 LOCAL_SRC_FILES := $(LOCAL_MODULE)
 include $(BUILD_PREBUILT)
+
diff --git a/data/etc/framework-sysconfig.xml b/data/etc/framework-sysconfig.xml
deleted file mode 100644 (file)
index 2f18de0..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
--->
-
-<!-- These are configurations that must exist on all Android devices. -->
-<config>
-
-    <!-- Broadcast actions that are currently exempted from O+ background
-         delivery restrictions. -->
-    <allow-implicit-broadcast action="android.intent.action.SIM_STATE_CHANGED" />
-    <allow-implicit-broadcast action="android.intent.action.PACKAGE_CHANGED" />
-
-</config>
index 69a2c55..9f63e30 100644 (file)
@@ -1272,11 +1272,6 @@ public class DeviceIdleController extends SystemService
             DeviceIdleController.this.setAlarmsActive(active);
         }
 
-        /** Is the app on any of the power save whitelists, whether system or user? */
-        public boolean isAppOnWhitelist(int appid) {
-            return DeviceIdleController.this.isAppOnWhitelistInternal(appid);
-        }
-
         /**
          * Returns the array of app ids whitelisted by user. Take care not to
          * modify this, as it is a reference to the original copy. But the reference
@@ -1294,12 +1289,6 @@ public class DeviceIdleController extends SystemService
         mHandler = new MyHandler(BackgroundThread.getHandler().getLooper());
     }
 
-    boolean isAppOnWhitelistInternal(int appid) {
-        synchronized (this) {
-            return Arrays.binarySearch(mPowerSaveWhitelistAllAppIdArray, appid) >= 0;
-        }
-    }
-
     int[] getPowerSaveWhitelistUserAppIds() {
         synchronized (this) {
             return mPowerSaveWhitelistUserAppIdArray;
index 0834eb8..62f4f19 100644 (file)
@@ -1360,7 +1360,6 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
         }
 
         Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
-        intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
         Bundle data = new Bundle();
         state.fillInNotifierBundle(data);
         intent.putExtras(data);
index 7406ff8..7661127 100644 (file)
@@ -305,7 +305,6 @@ public final class ActiveServices {
     }
 
     ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType,
-            int id, Notification notification,
             int callingPid, int callingUid, String callingPackage, final int userId)
             throws TransactionTooLargeException {
         if (DEBUG_DELAYED_STARTS) Slog.v(TAG_SERVICE, "startService: " + service
@@ -325,6 +324,7 @@ public final class ActiveServices {
             callerFg = true;
         }
 
+
         ServiceLookupResult res =
             retrieveServiceLocked(service, resolvedType, callingPackage,
                     callingPid, callingUid, userId, true, callerFg, false);
@@ -343,11 +343,10 @@ public final class ActiveServices {
             return null;
         }
 
-        // Non-null notification means this is a start directly into the foreground
-        if (!r.startRequested && notification == null) {
+        if (!r.startRequested) {
             final long token = Binder.clearCallingIdentity();
             try {
-                // Before going further -- if this app is not allowed to start services in the
+                // Before going further -- if this app is not allowed to run in the
                 // background, then at this point we aren't going to let it period.
                 final int allowed = mAm.checkAllowBackgroundLocked(
                         r.appInfo.uid, r.packageName, callingPid, false);
@@ -451,11 +450,7 @@ public final class ActiveServices {
             }
         }
 
-        ComponentName cmp = startServiceInnerLocked(smap, service, r, callerFg, addToStarting);
-        if (notification != null) {
-            setServiceForegroundInnerLocked(r, callingUid, notification, 0);
-        }
-        return cmp;
+        return startServiceInnerLocked(smap, service, r, callerFg, addToStarting);
     }
 
     private boolean requestStartTargetPermissionsReviewIfNeededLocked(ServiceRecord r,
@@ -600,8 +595,9 @@ public final class ActiveServices {
             for (int i=services.mServicesByName.size()-1; i>=0; i--) {
                 ServiceRecord service = services.mServicesByName.valueAt(i);
                 if (service.appInfo.uid == uid && service.startRequested) {
-                    if (mAm.checkAllowBackgroundLocked(service.appInfo.uid, service.packageName,
-                            -1, false) != ActivityManager.APP_START_MODE_NORMAL) {
+                    if (service.appInfo.isEphemeralApp() ||
+                            mAm.mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,
+                            uid, service.packageName) != AppOpsManager.MODE_ALLOWED) {
                         if (stopping == null) {
                             stopping = new ArrayList<>();
                             stopping.add(service);
@@ -700,55 +696,50 @@ public final class ActiveServices {
         try {
             ServiceRecord r = findServiceLocked(className, token, userId);
             if (r != null) {
-                setServiceForegroundInnerLocked(r, userId, notification, flags);
+                if (id != 0) {
+                    if (notification == null) {
+                        throw new IllegalArgumentException("null notification");
+                    }
+                    if (r.foregroundId != id) {
+                        cancelForegroudNotificationLocked(r);
+                        r.foregroundId = id;
+                    }
+                    notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
+                    r.foregroundNoti = notification;
+                    r.isForeground = true;
+                    r.postNotification();
+                    if (r.app != null) {
+                        updateServiceForegroundLocked(r.app, true);
+                    }
+                    getServiceMapLocked(r.userId).ensureNotStartingBackgroundLocked(r);
+                    mAm.notifyPackageUse(r.serviceInfo.packageName,
+                                         PackageManager.NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE);
+                } else {
+                    if (r.isForeground) {
+                        r.isForeground = false;
+                        if (r.app != null) {
+                            mAm.updateLruProcessLocked(r.app, false, null);
+                            updateServiceForegroundLocked(r.app, true);
+                        }
+                    }
+                    if ((flags & Service.STOP_FOREGROUND_REMOVE) != 0) {
+                        cancelForegroudNotificationLocked(r);
+                        r.foregroundId = 0;
+                        r.foregroundNoti = null;
+                    } else if (r.appInfo.targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
+                        r.stripForegroundServiceFlagFromNotification();
+                        if ((flags & Service.STOP_FOREGROUND_DETACH) != 0) {
+                            r.foregroundId = 0;
+                            r.foregroundNoti = null;
+                        }
+                    }
+                }
             }
         } finally {
             Binder.restoreCallingIdentity(origId);
         }
     }
 
-    private void setServiceForegroundInnerLocked(ServiceRecord r, int id,
-            Notification notification, int flags) {
-        if (id != 0) {
-            if (notification == null) {
-                throw new IllegalArgumentException("null notification");
-            }
-            if (r.foregroundId != id) {
-                cancelForegroudNotificationLocked(r);
-                r.foregroundId = id;
-            }
-            notification.flags |= Notification.FLAG_FOREGROUND_SERVICE;
-            r.foregroundNoti = notification;
-            r.isForeground = true;
-            r.postNotification();
-            if (r.app != null) {
-                updateServiceForegroundLocked(r.app, true);
-            }
-            getServiceMapLocked(r.userId).ensureNotStartingBackgroundLocked(r);
-            mAm.notifyPackageUse(r.serviceInfo.packageName,
-                                 PackageManager.NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE);
-        } else {
-            if (r.isForeground) {
-                r.isForeground = false;
-                if (r.app != null) {
-                    mAm.updateLruProcessLocked(r.app, false, null);
-                    updateServiceForegroundLocked(r.app, true);
-                }
-            }
-            if ((flags & Service.STOP_FOREGROUND_REMOVE) != 0) {
-                cancelForegroudNotificationLocked(r);
-                r.foregroundId = 0;
-                r.foregroundNoti = null;
-            } else if (r.appInfo.targetSdkVersion >= Build.VERSION_CODES.LOLLIPOP) {
-                r.stripForegroundServiceFlagFromNotification();
-                if ((flags & Service.STOP_FOREGROUND_DETACH) != 0) {
-                    r.foregroundId = 0;
-                    r.foregroundNoti = null;
-                }
-            }
-        }
-    }
-
     private void cancelForegroudNotificationLocked(ServiceRecord r) {
         if (r.foregroundId != 0) {
             // First check to see if this app has any other active foreground services
index 63187e4..43bb5ee 100644 (file)
@@ -48,7 +48,6 @@ class ActivityManagerDebugConfig {
     static final boolean DEBUG_ADD_REMOVE = DEBUG_ALL_ACTIVITIES || false;
     static final boolean DEBUG_ANR = false;
     static final boolean DEBUG_APP = DEBUG_ALL_ACTIVITIES || false;
-    static final boolean DEBUG_BACKGROUND = DEBUG_ALL || true;
     static final boolean DEBUG_BACKUP = DEBUG_ALL || false;
     static final boolean DEBUG_BROADCAST = DEBUG_ALL || false;
     static final boolean DEBUG_BROADCAST_BACKGROUND = DEBUG_BROADCAST || false;
index c8e1aab..7fd91cb 100644 (file)
@@ -62,7 +62,6 @@ import static com.android.internal.util.XmlUtils.writeIntAttribute;
 import static com.android.internal.util.XmlUtils.writeLongAttribute;
 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ALL;
 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ANR;
-import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_BACKGROUND;
 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_BACKUP;
 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_BROADCAST;
 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_BROADCAST_BACKGROUND;
@@ -120,7 +119,6 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_VISIBLE_B
 import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
 import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
 import static com.android.server.am.ActivityStackSupervisor.ActivityContainer.FORCE_NEW_TASK_FLAGS;
-import static com.android.server.am.ActivityStackSupervisor.CREATE_IF_NEEDED;
 import static com.android.server.am.ActivityStackSupervisor.DEFER_RESUME;
 import static com.android.server.am.ActivityStackSupervisor.FORCE_FOCUS;
 import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
@@ -312,6 +310,7 @@ import android.view.WindowManager;
 
 import com.google.android.collect.Lists;
 import com.google.android.collect.Maps;
+
 import com.android.internal.R;
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.app.AssistUtils;
@@ -342,7 +341,6 @@ import com.android.server.IntentResolver;
 import com.android.server.LocalServices;
 import com.android.server.LockGuard;
 import com.android.server.ServiceThread;
-import com.android.server.SystemConfig;
 import com.android.server.SystemService;
 import com.android.server.SystemServiceManager;
 import com.android.server.Watchdog;
@@ -386,10 +384,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 
 import dalvik.system.VMRuntime;
-
 import libcore.io.IoUtils;
 import libcore.util.EmptyArray;
 
+import static com.android.server.am.ActivityStackSupervisor.CREATE_IF_NEEDED;
 public class ActivityManagerService extends IActivityManager.Stub
         implements Watchdog.Monitor, BatteryStatsImpl.BatteryCallback {
 
@@ -760,18 +758,6 @@ public class ActivityManagerService extends IActivityManager.Stub
     ProcessRecord mHeavyWeightProcess = null;
 
     /**
-     * Non-persistent app uid whitelist for background restrictions
-     */
-    int[] mBackgroundUidWhitelist = new int[] {
-            Process.BLUETOOTH_UID
-    };
-
-    /**
-     * Broadcast actions that will always be deliverable to unlaunched/background apps
-     */
-    final ArraySet<String> mBackgroundLaunchBroadcasts;
-
-    /**
      * All of the processes we currently have running organized by pid.
      * The keys are the pid running the application.
      *
@@ -2604,17 +2590,6 @@ public class ActivityManagerService extends IActivityManager.Stub
         mPermissionReviewRequired = mContext.getResources().getBoolean(
                 com.android.internal.R.bool.config_permissionReviewRequired);
 
-        mBackgroundLaunchBroadcasts = SystemConfig.getInstance().getAllowImplicitBroadcasts();
-        if (DEBUG_BACKGROUND) {
-            StringBuilder sb = new StringBuilder(200);
-            sb.append("  ");
-            for (String a : mBackgroundLaunchBroadcasts) {
-                sb.append(' '); sb.append(a);
-            }
-            Slog.d(TAG, "Background implicit broadcasts:");
-            Slog.d(TAG, sb.toString());
-        }
-
         mHandlerThread = new ServiceThread(TAG,
                 android.os.Process.THREAD_PRIORITY_FOREGROUND, false /*allowIo*/);
         mHandlerThread.start();
@@ -4215,7 +4190,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                             validateUid = mValidateUids.get(item.uid);
                             if (validateUid == null && change != UidRecord.CHANGE_GONE
                                     && change != UidRecord.CHANGE_GONE_IDLE) {
-                                validateUid = new UidRecord(item.uid, false);
+                                validateUid = new UidRecord(item.uid);
                                 mValidateUids.put(item.uid, validateUid);
                             }
                         }
@@ -5529,7 +5504,6 @@ public class ActivityManagerService extends IActivityManager.Stub
 
                     final Intent intent = new Intent(Intent.ACTION_PACKAGE_DATA_CLEARED,
                             Uri.fromParts("package", packageName, null));
-                    intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
                     intent.putExtra(Intent.EXTRA_UID, pkgUidF);
                     intent.putExtra(Intent.EXTRA_USER_HANDLE, UserHandle.getUserId(pkgUidF));
                     broadcastIntentInPackage("android", Process.SYSTEM_UID, intent,
@@ -6305,7 +6279,7 @@ public class ActivityManagerService extends IActivityManager.Stub
         }
         UidRecord uidRec = mActiveUids.get(proc.uid);
         if (uidRec == null) {
-            uidRec = new UidRecord(proc.uid, proc.persistent);
+            uidRec = new UidRecord(proc.uid);
             // This is the first appearance of the uid, report it now!
             if (DEBUG_UID_OBSERVERS) Slog.i(TAG_UID_OBSERVERS,
                     "Creating new process uid: " + uidRec);
@@ -8052,84 +8026,6 @@ public class ActivityManagerService extends IActivityManager.Stub
         }
     }
 
-    // Unified app-op and target sdk check
-    boolean appRestrictedInBackgroundLocked(int uid, String packageName) {
-        if (packageName == null) {
-            packageName = mPackageManagerInt.getNameForUid(uid);
-            if (packageName == null) {
-                Slog.w(TAG, "No package known for uid " + uid);
-                return false;
-            }
-        }
-
-        // !!! TODO: cache the package/versionCode lookups to fast path this
-        ApplicationInfo app = getPackageManagerInternalLocked().getApplicationInfo(packageName,
-                UserHandle.getUserId(uid));
-        if (app != null) {
-            // Apps that target O+ are always subject to background check
-            if (app.targetSdkVersion >= Build.VERSION_CODES.O) {
-                if (DEBUG_BACKGROUND) {
-                    Slog.i(TAG, "App " + uid + "/" + packageName + " targets O+, restricted");
-                }
-                return true;
-            }
-            // ...and legacy apps get an AppOp check
-            int appop = mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND,
-                    uid, packageName);
-            if (DEBUG_BACKGROUND) {
-                Slog.i(TAG, "Legacy app " + uid + "/" + packageName + " bg appop " + appop);
-            }
-            return (appop != AppOpsManager.MODE_ALLOWED);
-        } else {
-            Slog.w(TAG, "Unknown app " + packageName + " / " + uid);
-        }
-        return false;
-    }
-
-    // Service launch is available to apps with run-in-background exemptions but
-    // some other background operations are not.  If we're doing a check
-    // of service-launch policy, allow those callers to proceed unrestricted.
-    boolean appServicesRestrictedInBackgroundLocked(int uid, String packageName) {
-        if (packageName == null) {
-            packageName = mPackageManagerInt.getNameForUid(uid);
-            if (packageName == null) {
-                Slog.w(TAG, "No package known for uid " + uid);
-                return false;
-            }
-        }
-
-        // Persistent app?  NB: expects that persistent uids are always active.
-        final UidRecord uidRec = mActiveUids.get(uid);
-        if (uidRec != null && uidRec.persistent) {
-            if (DEBUG_BACKGROUND) {
-                Slog.i(TAG, "App " + uid + "/" + packageName
-                        + " is persistent; not restricted in background");
-            }
-            return false;
-        }
-
-        // Non-persistent but background whitelisted?
-        if (uidOnBackgroundWhitelist(uid)) {
-            if (DEBUG_BACKGROUND) {
-                Slog.i(TAG, "App " + uid + "/" + packageName
-                        + " on background whitelist; not restricted in background");
-            }
-            return false;
-        }
-
-        // Is this app on the battery whitelist?
-        if (mLocalDeviceIdleController.isAppOnWhitelist(UserHandle.getAppId(uid))) {
-            if (DEBUG_BACKGROUND) {
-                Slog.i(TAG, "App " + uid + "/" + packageName
-                        + " on idle whitelist; not restricted in background");
-            }
-            return false;
-        }
-
-        // None of the service-policy criteria apply, so we apply the common criteria
-        return appRestrictedInBackgroundLocked(uid, packageName);
-    }
-
     int checkAllowBackgroundLocked(int uid, String packageName, int callingPid,
             boolean alwaysRestrict) {
         UidRecord uidRec = mActiveUids.get(uid);
@@ -8158,13 +8054,8 @@ public class ActivityManagerService extends IActivityManager.Stub
                         return ActivityManager.APP_START_MODE_NORMAL;
                     }
                 }
-                final boolean restricted = (alwaysRestrict)
-                        ? appRestrictedInBackgroundLocked(uid, packageName)
-                        : appServicesRestrictedInBackgroundLocked(uid, packageName);
-                if (restricted) {
-                    if (DEBUG_BACKGROUND) {
-                        Slog.i(TAG, "App " + uid + "/" + packageName + " restricted in background");
-                    }
+                if (mAppOpsService.noteOperation(AppOpsManager.OP_RUN_IN_BACKGROUND, uid,
+                        packageName) != AppOpsManager.MODE_ALLOWED) {
                     return ActivityManager.APP_START_MODE_DELAYED;
                 }
             }
@@ -11760,16 +11651,6 @@ public class ActivityManagerService extends IActivityManager.Stub
         return r;
     }
 
-    private boolean uidOnBackgroundWhitelist(final int uid) {
-        final int N = mBackgroundUidWhitelist.length;
-        for (int i = 0; i < N; i++) {
-            if (uid == mBackgroundUidWhitelist[i]) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     final ProcessRecord addAppLocked(ApplicationInfo info, boolean isolated,
             String abiOverride) {
         ProcessRecord app;
@@ -17403,8 +17284,7 @@ public class ActivityManagerService extends IActivityManager.Stub
 
     @Override
     public ComponentName startService(IApplicationThread caller, Intent service,
-            String resolvedType, int id, Notification notification,
-            String callingPackage, int userId)
+            String resolvedType, String callingPackage, int userId)
             throws TransactionTooLargeException {
         enforceNotIsolatedCaller("startService");
         // Refuse possible leaked file descriptors
@@ -17423,8 +17303,7 @@ public class ActivityManagerService extends IActivityManager.Stub
             final int callingUid = Binder.getCallingUid();
             final long origId = Binder.clearCallingIdentity();
             ComponentName res = mServices.startServiceLocked(caller, service,
-                    resolvedType, id, notification,
-                    callingPid, callingUid, callingPackage, userId);
+                    resolvedType, callingPid, callingUid, callingPackage, userId);
             Binder.restoreCallingIdentity(origId);
             return res;
         }
@@ -17438,7 +17317,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                     "startServiceInPackage: " + service + " type=" + resolvedType);
             final long origId = Binder.clearCallingIdentity();
             ComponentName res = mServices.startServiceLocked(null, service,
-                    resolvedType, 0, null, -1, uid, callingPackage, userId);
+                    resolvedType, -1, uid, callingPackage, userId);
             Binder.restoreCallingIdentity(origId);
             return res;
         }
@@ -18297,13 +18176,6 @@ public class ActivityManagerService extends IActivityManager.Stub
         }
 
         if (action != null) {
-            if (mBackgroundLaunchBroadcasts.contains(action)) {
-                if (DEBUG_BACKGROUND) {
-                    Slog.i(TAG, "Broadcast action " + action + " forcing include-background");
-                }
-                intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
-            }
-
             switch (action) {
                 case Intent.ACTION_UID_REMOVED:
                 case Intent.ACTION_PACKAGE_REMOVED:
@@ -19428,8 +19300,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                 UserHandle.USER_ALL);
         if ((changes & ActivityInfo.CONFIG_LOCALE) != 0) {
             intent = new Intent(Intent.ACTION_LOCALE_CHANGED);
-            intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND
-                    | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+            intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
             if (initLocale || !mProcessesReady) {
                 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
             }
index 414488e..29a4781 100644 (file)
@@ -490,7 +490,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
         pw.println("Starting service: " + intent);
         pw.flush();
         ComponentName cn = mInterface.startService(null, intent, intent.getType(),
-                -1, null, SHELL_PACKAGE_NAME, mUserId);
+                SHELL_PACKAGE_NAME, mUserId);
         if (cn == null) {
             err.println("Error: Not found; no service started.");
             return -1;
index 61e555b..8104a43 100644 (file)
@@ -1157,7 +1157,8 @@ public final class BroadcastQueue {
 
             if (!skip) {
                 final int allowed = mService.checkAllowBackgroundLocked(
-                        info.activityInfo.applicationInfo.uid, info.activityInfo.packageName, -1, true);
+                        info.activityInfo.applicationInfo.uid, info.activityInfo.packageName, -1,
+                        true);
                 if (allowed != ActivityManager.APP_START_MODE_NORMAL) {
                     // We won't allow this receiver to be launched if the app has been
                     // completely disabled from launches, or it was not explicitly sent
index 4ebd068..d1a15bd 100644 (file)
@@ -26,7 +26,6 @@ import android.util.TimeUtils;
  */
 public final class UidRecord {
     final int uid;
-    final boolean persistent;
     int curProcState;
     int setProcState = ActivityManager.PROCESS_STATE_NONEXISTENT;
     long lastBackgroundTime;
@@ -50,9 +49,8 @@ public final class UidRecord {
 
     ChangeItem pendingChange;
 
-    public UidRecord(int _uid, boolean _persist) {
+    public UidRecord(int _uid) {
         uid = _uid;
-        persistent = _persist;
         reset();
     }
 
index 31b7ca7..71ebad9 100644 (file)
@@ -414,8 +414,7 @@ final class UserController {
                 if (userId != UserHandle.USER_SYSTEM) {
                     Slog.d(TAG, "Initializing user #" + userId);
                     Intent intent = new Intent(Intent.ACTION_USER_INITIALIZE);
-                    intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND
-                            | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+                    intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                     mInjector.broadcastIntentLocked(intent, null,
                             new IIntentReceiver.Stub() {
                                 @Override
index c793f49..af1e007 100644 (file)
@@ -80,6 +80,7 @@ import static android.content.pm.PackageParser.isApkFile;
 import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
 import static android.system.OsConstants.O_CREAT;
 import static android.system.OsConstants.O_RDWR;
+
 import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_MANAGED_PROFILE;
 import static com.android.internal.app.IntentForwarderActivity.FORWARD_INTENT_TO_PARENT;
 import static com.android.internal.content.NativeLibraryHelper.LIB64_DIR_NAME;
@@ -5964,7 +5965,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                     int status = (int)(packedStatus >> 32);
                     int linkGeneration = (int)(packedStatus & 0xFFFFFFFF);
                     if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS) {
-                        if (DEBUG_DOMAIN_VERIFICATION || debug) {
+                        if (DEBUG_DOMAIN_VERIFICATION) {
                             Slog.i(TAG, "  + always: " + info.activityInfo.packageName
                                     + " : linkgen=" + linkGeneration);
                         }
@@ -5973,18 +5974,18 @@ public class PackageManagerService extends IPackageManager.Stub {
                         info.preferredOrder = linkGeneration;
                         alwaysList.add(info);
                     } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER) {
-                        if (DEBUG_DOMAIN_VERIFICATION || debug) {
+                        if (DEBUG_DOMAIN_VERIFICATION) {
                             Slog.i(TAG, "  + never: " + info.activityInfo.packageName);
                         }
                         neverList.add(info);
                     } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK) {
-                        if (DEBUG_DOMAIN_VERIFICATION || debug) {
+                        if (DEBUG_DOMAIN_VERIFICATION) {
                             Slog.i(TAG, "  + always-ask: " + info.activityInfo.packageName);
                         }
                         alwaysAskList.add(info);
                     } else if (status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED ||
                             status == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK) {
-                        if (DEBUG_DOMAIN_VERIFICATION || debug) {
+                        if (DEBUG_DOMAIN_VERIFICATION) {
                             Slog.i(TAG, "  + ask: " + info.activityInfo.packageName);
                         }
                         undefinedList.add(info);
@@ -12142,7 +12143,7 @@ public class PackageManagerService extends IPackageManager.Stub {
         IActivityManager am = ActivityManager.getService();
         if (am != null) {
             try {
-                am.startService(null, intent, null, -1, null, mContext.getOpPackageName(),
+                am.startService(null, intent, null, mContext.getOpPackageName(),
                         UserHandle.USER_SYSTEM);
             } catch (RemoteException e) {
             }
@@ -16626,8 +16627,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                         extras, 0, null, null, removedUsers);
                 if (dataRemoved && !isRemovedPackageSystemUpdate) {
                     sendPackageBroadcast(Intent.ACTION_PACKAGE_FULLY_REMOVED,
-                            removedPackage, extras, Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND,
-                            null, null, removedUsers);
+                            removedPackage, extras, 0, null, null, removedUsers);
                 }
             }
             if (removedAppId >= 0) {
@@ -19581,8 +19581,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
                             count = 0;
                             for (PackageSetting ps : allPackageSettings) {
                                 final long status = ps.getDomainVerificationStatusForUser(userId);
-                                if (status >> 32 == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED
-                                        && !DEBUG_DOMAIN_VERIFICATION) {
+                                if (status >> 32 == INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED) {
                                     continue;
                                 }
                                 pw.println(prefix + "Package: " + ps.name);
index a3837b2..90c711a 100644 (file)
@@ -338,11 +338,9 @@ public class DeviceStorageMonitorService extends SystemService {
         mTotalMemory = (long)mDataFileStats.getBlockCount() *
                         mDataFileStats.getBlockSize();
         mStorageLowIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_LOW);
-        mStorageLowIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
-                | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+        mStorageLowIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
         mStorageOkIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_OK);
-        mStorageOkIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
-                | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+        mStorageOkIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
         mStorageFullIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_FULL);
         mStorageFullIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
         mStorageNotFullIntent = new Intent(Intent.ACTION_DEVICE_STORAGE_NOT_FULL);
index 4aff3d5..7f182a4 100644 (file)
@@ -556,9 +556,7 @@ public class UsbPortManager {
 
     private void sendPortChangedBroadcastLocked(PortInfo portInfo) {
         final Intent intent = new Intent(UsbManager.ACTION_USB_PORT_CHANGED);
-        intent.addFlags(
-                Intent.FLAG_RECEIVER_FOREGROUND |
-                Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
         intent.putExtra(UsbManager.EXTRA_PORT, portInfo.mUsbPort);
         intent.putExtra(UsbManager.EXTRA_PORT_STATUS, portInfo.mUsbPortStatus);
 
index 2e99b6e..e03a14f 100644 (file)
@@ -971,9 +971,7 @@ class UsbProfileGroupSettingsManager {
     public void accessoryAttached(UsbAccessory accessory) {
         Intent intent = new Intent(UsbManager.ACTION_USB_ACCESSORY_ATTACHED);
         intent.putExtra(UsbManager.EXTRA_ACCESSORY, accessory);
-        intent.addFlags(
-                Intent.FLAG_ACTIVITY_NEW_TASK |
-                Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
         ArrayList<ResolveInfo> matches;
         String defaultPackage = null;
@@ -1366,9 +1364,7 @@ class UsbProfileGroupSettingsManager {
     private static Intent createDeviceAttachedIntent(UsbDevice device) {
         Intent intent = new Intent(UsbManager.ACTION_USB_DEVICE_ATTACHED);
         intent.putExtra(UsbManager.EXTRA_DEVICE, device);
-        intent.addFlags(
-                Intent.FLAG_ACTIVITY_NEW_TASK |
-                Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         return intent;
     }
 }
index 7a55be4..24d5f09 100644 (file)
@@ -182,7 +182,6 @@ class UsbSettingsManager {
         }
 
         Intent intent = new Intent(UsbManager.ACTION_USB_DEVICE_DETACHED);
-        intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
         intent.putExtra(UsbManager.EXTRA_DEVICE, device);
 
         if (DEBUG) {
@@ -205,7 +204,6 @@ class UsbSettingsManager {
         }
 
         Intent intent = new Intent(UsbManager.ACTION_USB_ACCESSORY_DETACHED);
-        intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
         intent.putExtra(UsbManager.EXTRA_ACCESSORY, accessory);
         mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
     }
index b6e701e..bcc68b3 100644 (file)
@@ -19,7 +19,6 @@ package android.test.mock;
 import android.annotation.SystemApi;
 import android.app.IApplicationThread;
 import android.app.IServiceConnection;
-import android.app.Notification;
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -514,12 +513,6 @@ public class MockContext extends Context {
     }
 
     @Override
-    public ComponentName startServiceInForeground(Intent service,
-            int id, Notification notification) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public boolean stopService(Intent service) {
         throw new UnsupportedOperationException();
     }
@@ -532,13 +525,6 @@ public class MockContext extends Context {
 
     /** @hide */
     @Override
-    public ComponentName startServiceInForegroundAsUser(Intent service,
-            int id, Notification notification, UserHandle user) {
-        throw new UnsupportedOperationException();
-    }
-
-    /** @hide */
-    @Override
     public boolean stopServiceAsUser(Intent service, UserHandle user) {
         throw new UnsupportedOperationException();
     }
index 68680d5..663e56d 100644 (file)
@@ -40,7 +40,6 @@ import org.xmlpull.v1.XmlPullParserException;
 
 import android.annotation.NonNull;
 import android.annotation.Nullable;
-import android.app.Notification;
 import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.ContentResolver;
@@ -1821,13 +1820,6 @@ public final class BridgeContext extends Context {
     }
 
     @Override
-    public ComponentName startServiceInForeground(Intent service,
-            int id, Notification notification) {
-        // pass
-        return null;
-    }
-
-    @Override
     public boolean stopService(Intent arg0) {
         // pass
         return false;
@@ -1840,13 +1832,6 @@ public final class BridgeContext extends Context {
     }
 
     @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;