Vitalii Tomkiv | 901c024 | 2016-08-19 13:13:16 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package com.android.car.monitoring; |
| 17 | |
| 18 | import android.annotation.SystemApi; |
| 19 | import android.content.Context; |
| 20 | import android.util.Log; |
| 21 | |
| 22 | import com.android.car.CarLog; |
| 23 | import com.android.car.CarServiceBase; |
| 24 | import com.android.car.SystemActivityMonitoringService; |
| 25 | |
| 26 | import java.io.PrintWriter; |
| 27 | |
| 28 | /** |
| 29 | * Service that monitors applications resource usage. |
| 30 | * @hide |
| 31 | */ |
| 32 | @SystemApi |
| 33 | public class CarMonitoringService implements CarServiceBase { |
| 34 | private static final String TAG = CarLog.TAG_MONITORING; |
| 35 | private static final Boolean DBG = true; |
| 36 | |
| 37 | private static final int MONITORING_SLEEP_TIME_MS = 30000; // Run monitoring every 30s. |
| 38 | |
| 39 | private final Context mContext; |
| 40 | |
| 41 | private final SystemActivityMonitoringService mSystemActivityMonitoringService; |
| 42 | |
| 43 | public CarMonitoringService(Context context, |
| 44 | SystemActivityMonitoringService systemActivityMonitoringService) { |
| 45 | mContext = context; |
| 46 | mSystemActivityMonitoringService = systemActivityMonitoringService; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public void init() { |
| 51 | if (DBG) { |
| 52 | Log.d(TAG, "init"); |
| 53 | } |
| 54 | // TODO: add periodic update to setAppPriority to monitoring native service. |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public void release() { |
| 59 | if (DBG) { |
| 60 | Log.d(TAG, "release"); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public void dump(PrintWriter writer) { |
| 66 | writer.println("**" + getClass().getSimpleName() + "**"); |
| 67 | // TODO |
| 68 | } |
| 69 | } |