blob: 8b1932143eabfdf74cdf750df712681288c657e0 [file] [log] [blame]
/*
* Copyright (C) 2014 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.
*/
package com.android.server;
import android.app.maintenance.IdleService;
import android.util.Slog;
public class MountServiceIdler extends IdleService {
private static final String TAG = "MountServiceIdler";
private Runnable mFinishCallback = new Runnable() {
@Override
public void run() {
Slog.i(TAG, "Got mount service completion callback");
finishIdle();
}
};
@Override
public boolean onIdleStart() {
// The mount service will run an fstrim operation asynchronously
// on a designated separate thread, so we provide it with a callback
// that lets us cleanly end our idle timeslice. It's safe to call
// finishIdle() from any thread.
MountService ms = MountService.sSelf;
if (ms != null) {
ms.runIdleMaintenance(mFinishCallback);
}
return ms != null;
}
@Override
public void onIdleStop() {
}
}