Merge "Move the 'pretend idle jobs can run now' broadcast into AMS" into nyc-dev
This commit is contained in:
@@ -1598,10 +1598,10 @@ public class Am extends BaseCommand {
|
||||
}
|
||||
|
||||
System.out.println("Performing idle maintenance...");
|
||||
Intent intent = new Intent(
|
||||
"com.android.server.task.controllers.IdleController.ACTION_TRIGGER_IDLE");
|
||||
mAm.broadcastIntent(null, intent, null, null, 0, null, null, null,
|
||||
android.app.AppOpsManager.OP_NONE, null, true, false, UserHandle.USER_ALL);
|
||||
try {
|
||||
mAm.sendIdleJobTrigger();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private void runScreenCompat() throws Exception {
|
||||
|
||||
@@ -2970,6 +2970,12 @@ public abstract class ActivityManagerNative extends Binder implements IActivityM
|
||||
reply.writeNoException();
|
||||
return true;
|
||||
}
|
||||
case SEND_IDLE_JOB_TRIGGER_TRANSACTION: {
|
||||
data.enforceInterface(IActivityManager.descriptor);
|
||||
sendIdleJobTrigger();
|
||||
reply.writeNoException();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.onTransact(code, data, reply, flags);
|
||||
@@ -6247,6 +6253,16 @@ class ActivityManagerProxy implements IActivityManager
|
||||
reply.recycle();
|
||||
}
|
||||
|
||||
public void sendIdleJobTrigger() throws RemoteException {
|
||||
Parcel data = Parcel.obtain();
|
||||
Parcel reply = Parcel.obtain();
|
||||
data.writeInterfaceToken(IActivityManager.descriptor);
|
||||
mRemote.transact(SEND_IDLE_JOB_TRIGGER_TRANSACTION, data, reply, 0);
|
||||
reply.readException();
|
||||
data.recycle();
|
||||
reply.recycle();
|
||||
}
|
||||
|
||||
public IActivityContainer createVirtualActivityContainer(IBinder parentActivityToken,
|
||||
IActivityContainerCallback callback) throws RemoteException {
|
||||
Parcel data = Parcel.obtain();
|
||||
|
||||
@@ -546,6 +546,8 @@ public interface IActivityManager extends IInterface {
|
||||
|
||||
public void performIdleMaintenance() throws RemoteException;
|
||||
|
||||
public void sendIdleJobTrigger() throws RemoteException;
|
||||
|
||||
public IActivityContainer createVirtualActivityContainer(IBinder parentActivityToken,
|
||||
IActivityContainerCallback callback) throws RemoteException;
|
||||
|
||||
@@ -1035,4 +1037,5 @@ public interface IActivityManager extends IInterface {
|
||||
int SWAP_DOCKED_AND_FULLSCREEN_STACK = IBinder.FIRST_CALL_TRANSACTION + 372;
|
||||
int NOTIFY_LOCKED_PROFILE = IBinder.FIRST_CALL_TRANSACTION + 373;
|
||||
int START_CONFIRM_DEVICE_CREDENTIAL_INTENT = IBinder.FIRST_CALL_TRANSACTION + 374;
|
||||
int SEND_IDLE_JOB_TRIGGER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION + 375;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@
|
||||
<protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_START" />
|
||||
<protected-broadcast android:name="android.intent.action.ACTION_IDLE_MAINTENANCE_END" />
|
||||
|
||||
<protected-broadcast android:name="com.android.server.task.controllers.IdleController.ACTION_TRIGGER_IDLE" />
|
||||
<protected-broadcast android:name="com.android.server.ACTION_TRIGGER_IDLE" />
|
||||
|
||||
<protected-broadcast android:name="android.intent.action.HDMI_PLUGGED" />
|
||||
|
||||
|
||||
@@ -390,6 +390,11 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
private static final String TAG_VISIBILITY = TAG + POSTFIX_VISIBILITY;
|
||||
private static final String TAG_VISIBLE_BEHIND = TAG + POSTFIX_VISIBLE_BEHIND;
|
||||
|
||||
// Mock "pretend we're idle now" broadcast action to the job scheduler; declared
|
||||
// here so that while the job scheduler can depend on AMS, the other way around
|
||||
// need not be the case.
|
||||
public static final String ACTION_TRIGGER_IDLE = "com.android.server.ACTION_TRIGGER_IDLE";
|
||||
|
||||
/** Control over CPU and battery monitoring */
|
||||
// write battery stats every 30 minutes.
|
||||
static final long BATTERY_STATS_TIME = 30 * 60 * 1000;
|
||||
@@ -12658,6 +12663,26 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendIdleJobTrigger() {
|
||||
if (checkCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException("Requires permission "
|
||||
+ android.Manifest.permission.SET_ACTIVITY_WATCHER);
|
||||
}
|
||||
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_TRIGGER_IDLE)
|
||||
.setPackage("android")
|
||||
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
|
||||
broadcastIntent(null, intent, null, null, 0, null, null, null,
|
||||
android.app.AppOpsManager.OP_NONE, null, true, false, UserHandle.USER_ALL);
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(ident);
|
||||
}
|
||||
}
|
||||
|
||||
private void retrieveSettings() {
|
||||
final ContentResolver resolver = mContext.getContentResolver();
|
||||
final boolean freeformWindowManagement =
|
||||
|
||||
@@ -28,15 +28,13 @@ import android.content.IntentFilter;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Slog;
|
||||
|
||||
import com.android.server.am.ActivityManagerService;
|
||||
import com.android.server.job.JobSchedulerService;
|
||||
import com.android.server.job.StateChangedListener;
|
||||
|
||||
public class IdleController extends StateController {
|
||||
private static final String TAG = "IdleController";
|
||||
|
||||
private static final String ACTION_TRIGGER_IDLE =
|
||||
"com.android.server.task.controllers.IdleController.ACTION_TRIGGER_IDLE";
|
||||
|
||||
// Policy: we decide that we're "idle" if the device has been unused /
|
||||
// screen off or dreaming for at least this long
|
||||
private long mInactivityIdleThreshold;
|
||||
@@ -113,7 +111,7 @@ public class IdleController extends StateController {
|
||||
public IdlenessTracker() {
|
||||
mAlarm = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
|
||||
|
||||
Intent intent = new Intent(ACTION_TRIGGER_IDLE)
|
||||
Intent intent = new Intent(ActivityManagerService.ACTION_TRIGGER_IDLE)
|
||||
.setPackage("android")
|
||||
.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
|
||||
mIdleTriggerIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
|
||||
@@ -140,7 +138,7 @@ public class IdleController extends StateController {
|
||||
filter.addAction(Intent.ACTION_DREAMING_STOPPED);
|
||||
|
||||
// Debugging/instrumentation
|
||||
filter.addAction(ACTION_TRIGGER_IDLE);
|
||||
filter.addAction(ActivityManagerService.ACTION_TRIGGER_IDLE);
|
||||
|
||||
mContext.registerReceiver(this, filter);
|
||||
}
|
||||
@@ -176,7 +174,7 @@ public class IdleController extends StateController {
|
||||
mScreenOn = false;
|
||||
mAlarm.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||
when, mIdleWindowSlop, mIdleTriggerIntent);
|
||||
} else if (action.equals(ACTION_TRIGGER_IDLE)) {
|
||||
} else if (action.equals(ActivityManagerService.ACTION_TRIGGER_IDLE)) {
|
||||
// idle time starts now. Do not set mIdle if screen is on.
|
||||
if (!mIdle && !mScreenOn) {
|
||||
if (DEBUG) {
|
||||
|
||||
Reference in New Issue
Block a user