2011-02-09 01:50:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 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.email.service;
|
|
|
|
|
2011-07-19 00:33:38 +00:00
|
|
|
import android.app.Service;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.IBinder;
|
|
|
|
|
2011-02-09 01:50:30 +00:00
|
|
|
import com.android.email.NotificationController;
|
|
|
|
import com.android.email.ResourceHelper;
|
2012-06-28 17:40:46 +00:00
|
|
|
import com.android.email2.ui.MailActivityEmail;
|
2011-02-11 19:17:27 +00:00
|
|
|
import com.android.emailcommon.Configuration;
|
2011-02-14 22:39:27 +00:00
|
|
|
import com.android.emailcommon.Device;
|
2012-06-29 16:42:05 +00:00
|
|
|
import com.android.emailcommon.VendorPolicyLoader;
|
2011-02-09 01:50:30 +00:00
|
|
|
import com.android.emailcommon.service.IAccountService;
|
2011-05-03 21:42:26 +00:00
|
|
|
import com.android.emailcommon.utility.EmailAsyncTask;
|
2011-02-09 01:50:30 +00:00
|
|
|
|
2011-02-14 22:39:27 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2011-02-09 01:50:30 +00:00
|
|
|
public class AccountService extends Service {
|
|
|
|
|
2011-02-14 22:39:27 +00:00
|
|
|
// Save context
|
2011-02-09 01:50:30 +00:00
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
private final IAccountService.Stub mBinder = new IAccountService.Stub() {
|
|
|
|
|
|
|
|
@Override
|
2011-05-03 21:42:26 +00:00
|
|
|
public int getAccountColor(long accountId) {
|
2011-02-09 01:50:30 +00:00
|
|
|
return ResourceHelper.getInstance(mContext).getAccountColor(accountId);
|
|
|
|
}
|
2011-02-11 19:17:27 +00:00
|
|
|
|
|
|
|
@Override
|
2011-05-03 21:42:26 +00:00
|
|
|
public Bundle getConfigurationData(String accountType) {
|
2011-02-11 19:17:27 +00:00
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putBoolean(Configuration.EXCHANGE_CONFIGURATION_USE_ALTERNATE_STRINGS,
|
|
|
|
VendorPolicyLoader.getInstance(mContext).useAlternateExchangeStrings());
|
|
|
|
return bundle;
|
|
|
|
}
|
2011-02-14 22:39:27 +00:00
|
|
|
|
|
|
|
@Override
|
2011-05-03 21:42:26 +00:00
|
|
|
public String getDeviceId() {
|
2011-02-14 22:39:27 +00:00
|
|
|
try {
|
2011-05-03 21:42:26 +00:00
|
|
|
EmailAsyncTask.runAsyncSerial(new Runnable() {
|
2011-02-27 20:08:36 +00:00
|
|
|
@Override
|
|
|
|
public void run() {
|
2012-06-28 17:40:46 +00:00
|
|
|
// Make sure remote services are running (re: lifecycle)
|
|
|
|
EmailServiceUtils.startRemoteServices(mContext);
|
2011-02-27 20:08:36 +00:00
|
|
|
// Send current logging flags
|
2012-06-28 17:40:46 +00:00
|
|
|
MailActivityEmail.updateLoggingFlags(mContext);
|
2011-02-27 20:08:36 +00:00
|
|
|
}});
|
2011-02-14 22:39:27 +00:00
|
|
|
return Device.getDeviceId(mContext);
|
|
|
|
} catch (IOException e) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2011-02-09 01:50:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBinder onBind(Intent intent) {
|
|
|
|
if (mContext == null) {
|
|
|
|
mContext = this;
|
|
|
|
}
|
2011-02-14 22:39:27 +00:00
|
|
|
// Make sure we have a valid deviceId (just retrieves a static String except first time)
|
|
|
|
try {
|
|
|
|
Device.getDeviceId(this);
|
|
|
|
} catch (IOException e) {
|
|
|
|
}
|
2011-02-09 01:50:30 +00:00
|
|
|
return mBinder;
|
|
|
|
}
|
2013-07-26 21:18:39 +00:00
|
|
|
}
|