1 /* 2 * Copyright (C) 2012 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.dialer.interactions; 18 19 import android.app.IntentService; 20 import android.content.Context; 21 import android.content.Intent; 22 import com.android.contacts.common.database.ContactUpdateUtils; 23 24 /** Service for updating primary number on a contact. */ 25 public class ContactUpdateService extends IntentService { 26 27 public static final String EXTRA_PHONE_NUMBER_DATA_ID = "phone_number_data_id"; 28 ContactUpdateService()29 public ContactUpdateService() { 30 super(ContactUpdateService.class.getSimpleName()); 31 setIntentRedelivery(true); 32 } 33 34 /** Creates an intent that sets the selected data item as super primary (default) */ createSetSuperPrimaryIntent(Context context, long dataId)35 public static Intent createSetSuperPrimaryIntent(Context context, long dataId) { 36 Intent serviceIntent = new Intent(context, ContactUpdateService.class); 37 serviceIntent.putExtra(EXTRA_PHONE_NUMBER_DATA_ID, dataId); 38 return serviceIntent; 39 } 40 41 @Override onHandleIntent(Intent intent)42 protected void onHandleIntent(Intent intent) { 43 // Currently this service only handles one type of update. 44 long dataId = intent.getLongExtra(EXTRA_PHONE_NUMBER_DATA_ID, -1); 45 46 ContactUpdateUtils.setSuperPrimary(this, dataId); 47 } 48 } 49