1 /* 2 * Copyright (C) 2018 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 17 package com.android.settings.fuelgauge.batterytip; 18 19 import android.app.StatsManager; 20 import android.content.BroadcastReceiver; 21 import android.content.Context; 22 import android.content.Intent; 23 import android.os.Bundle; 24 import android.util.Log; 25 26 /** 27 * Receive the anomaly info from {@link StatsManager} 28 */ 29 public class AnomalyDetectionReceiver extends BroadcastReceiver { 30 private static final String TAG = "SettingsAnomalyReceiver"; 31 32 public static final String KEY_ANOMALY_TIMESTAMP = "key_anomaly_timestamp"; 33 34 @Override 35 public void onReceive(Context context, Intent intent) { 36 final long configUid = intent.getLongExtra(StatsManager.EXTRA_STATS_CONFIG_UID, -1); 37 final long configKey = intent.getLongExtra(StatsManager.EXTRA_STATS_CONFIG_KEY, -1); 38 final long subscriptionId = intent.getLongExtra(StatsManager.EXTRA_STATS_SUBSCRIPTION_ID, 39 -1); 40 Log.i(TAG, "Anomaly intent received. configUid = " + configUid + " configKey = " 41 + configKey + " subscriptionId = " + subscriptionId); 42 43 final Bundle bundle = intent.getExtras(); 44 bundle.putLong(KEY_ANOMALY_TIMESTAMP, System.currentTimeMillis()); 45 46 AnomalyDetectionJobService.scheduleAnomalyDetection(context, intent); 47 } 48 } 49