本文整理汇总了C++中AutoPtr::AddAction方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoPtr::AddAction方法的具体用法?C++ AutoPtr::AddAction怎么用?C++ AutoPtr::AddAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoPtr
的用法示例。
在下文中一共展示了AutoPtr::AddAction方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartMonitoring
ECode DataConnectionStats::StartMonitoring()
{
AutoPtr<IInterface> obj;
mContext->GetSystemService(IContext::TELEPHONY_SERVICE, (IInterface**)&obj);
AutoPtr<ITelephonyManager> phone = ITelephonyManager::Probe(obj);
if (phone != NULL) {
phone->Listen(mPhoneStateListener,
IPhoneStateListener::LISTEN_SERVICE_STATE
| IPhoneStateListener::LISTEN_SIGNAL_STRENGTHS
| IPhoneStateListener::LISTEN_DATA_CONNECTION_STATE
| IPhoneStateListener::LISTEN_DATA_ACTIVITY);
}
else {
Logger::E(TAG, "TELEPHONY_SERVICE is not ok");
return E_NOT_IMPLEMENTED;
}
AutoPtr<IIntentFilter> filter;
CIntentFilter::New((IIntentFilter**)&filter);
filter->AddAction(ITelephonyIntents::ACTION_SIM_STATE_CHANGED);
filter->AddAction(IConnectivityManager::CONNECTIVITY_ACTION);
filter->AddAction(IConnectivityManager::INET_CONDITION_ACTION);
AutoPtr<IIntent> intent;
mContext->RegisterReceiver(this, filter, (IIntent**)&intent);
return NOERROR;
}
示例2: OnStart
ECode TwilightService::OnStart()
{
mUpdateLocationReceiver = new UpdateLocationReceiver(this);
mEmptyLocationListener = new EmptyLocationListener();
mLocationListener = new MyLocationListener(this);
AutoPtr<IContext> context;
GetContext((IContext**)&context);
AutoPtr<IInterface> service;
context->GetSystemService(IContext::ALARM_SERVICE, (IInterface**)&service);
mAlarmManager = IAlarmManager::Probe(service);
service = NULL;
context->GetSystemService(IContext::LOCATION_SERVICE, (IInterface**)&service);
mLocationManager = ILocationManager::Probe(service);
mLocationHandler = new LocationHandler(this);
AutoPtr<IIntentFilter> filter;
CIntentFilter::New(IIntent::ACTION_AIRPLANE_MODE_CHANGED,(IIntentFilter**)&filter);
filter->AddAction(IIntent::ACTION_TIME_CHANGED);
filter->AddAction(IIntent::ACTION_TIMEZONE_CHANGED);
filter->AddAction(ACTION_UPDATE_TWILIGHT_STATE);
AutoPtr<IIntent> intent;
context->RegisterReceiver((IBroadcastReceiver*)mUpdateLocationReceiver, filter, (IIntent**)&intent);
PublishLocalService(EIID_ITwilightManager, mService);
return NOERROR;
}
示例3: OnAttachedToWindow
ECode AdapterViewFlipper::OnAttachedToWindow()
{
// ==================before translated======================
// super.onAttachedToWindow();
//
// // Listen for broadcasts related to user-presence
// final IntentFilter filter = new IntentFilter();
// filter.addAction(Intent.ACTION_SCREEN_OFF);
// filter.addAction(Intent.ACTION_USER_PRESENT);
//
// // OK, this is gross but needed. This class is supported by the
// // remote views machanism and as a part of that the remote views
// // can be inflated by a context for another user without the app
// // having interact users permission - just for loading resources.
// // For exmaple, when adding widgets from a user profile to the
// // home screen. Therefore, we register the receiver as the current
// // user not the one the context is for.
// getContext().registerReceiverAsUser(mReceiver, android.os.Process.myUserHandle(),
// filter, null, mHandler);
//
//
// if (mAutoStart) {
// // Automatically start when requested
// startFlipping();
// }
AdapterViewAnimator::OnAttachedToWindow();
// Listen for broadcasts related to user-presence
AutoPtr<IIntentFilter> filter;
CIntentFilter::New((IIntentFilter**)&filter);
filter->AddAction(IIntent::ACTION_SCREEN_OFF);
filter->AddAction(IIntent::ACTION_USER_PRESENT);
// OK, this is gross but needed. This class is supported by the
// remote views machanism and as a part of that the remote views
// can be inflated by a context for another user without the app
// having interact users permission - just for loading resources.
// For exmaple, when adding widgets from a user profile to the
// home screen. Therefore, we register the receiver as the current
// user not the one the context is for.
AutoPtr<IContext> context;
GetContext((IContext**)&context);
AutoPtr<IUserHandle> userHandle;
Process::MyUserHandle((IUserHandle**)&userHandle);
AutoPtr<IIntent> intent;
context->RegisterReceiverAsUser(mReceiver, userHandle, filter, String(""), mHandler, (IIntent**)&intent);
if (mAutoStart) {
// Automatically start when requested
StartFlipping();
}
return NOERROR;
}
示例4: String
ECode CPowerUI::Receiver::Init()
{
// Register for Intent broadcasts for...
AutoPtr<IIntentFilter> filter;
CIntentFilter::New((IIntentFilter**)&filter);
filter->AddAction(IIntent::ACTION_BATTERY_CHANGED);
filter->AddAction(IIntent::ACTION_SCREEN_OFF);
filter->AddAction(IIntent::ACTION_SCREEN_ON);
filter->AddAction(IPowerManager::ACTION_POWER_SAVE_MODE_CHANGING);
filter->AddAction(IPowerManager::ACTION_POWER_SAVE_MODE_CHANGED);
AutoPtr<IIntent> i;
mHost->mContext->RegisterReceiver(this, filter, String(NULL), mHost->mHandler, (IIntent**)&i);
UpdateSaverMode();
return NOERROR;
}
示例5: constructor
ECode RegisteredServicesCache::constructor(
/* [in] */ IContext* context,
/* [in] */ const String& interfaceName,
/* [in] */ const String& metaDataName,
/* [in] */ const String& attributeName,
/* [in] */ IXmlSerializerAndParser* serializerAndParser)
{
mContext = context;
mInterfaceName = interfaceName;
mMetaDataName = metaDataName;
mAttributesName = attributeName;
mSerializerAndParser = serializerAndParser;
mPackageReceiver = (IBroadcastReceiver*)new RegisteredServicesCache::PackageReceiver(this);
mPackageReceiver = (IBroadcastReceiver*)new RegisteredServicesCache::ExternalReceiver(this);
AutoPtr<IEnvironment> env;
CEnvironment::AcquireSingleton((IEnvironment**)&env);
AutoPtr<IFile> dataDir;
env->GetDataDirectory((IFile**)&dataDir);
AutoPtr<IFile> systemDir, syncDir, interFile;
CFile::New(dataDir, String("system"), (IFile**)&systemDir);
CFile::New(systemDir, String("registered_services"), (IFile**)&syncDir);
CFile::New(syncDir, interfaceName + String(".xml"), (IFile**)&interFile);
CAtomicFile::New(interFile, (IAtomicFile**)&mPersistentServicesFile);
// Load persisted services from disk
ReadPersistentServicesLocked();
AutoPtr<IIntentFilter> intentFilter;
CIntentFilter::New((IIntentFilter**)&intentFilter);
intentFilter->AddAction(IIntent::ACTION_PACKAGE_ADDED);
intentFilter->AddAction(IIntent::ACTION_PACKAGE_CHANGED);
intentFilter->AddAction(IIntent::ACTION_PACKAGE_REMOVED);
intentFilter->AddDataScheme(String("package"));
AutoPtr<IIntent> intent;
mContext->RegisterReceiverAsUser(mPackageReceiver, UserHandle::ALL, intentFilter, String(NULL), NULL, (IIntent**)&intent);
// Register for events related to sdcard installation.
AutoPtr<IIntentFilter> sdFilter;
CIntentFilter::New((IIntentFilter**)&sdFilter);
sdFilter->AddAction(IIntent::ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
sdFilter->AddAction(IIntent::ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
intent = NULL;
mContext->RegisterReceiver(mExternalReceiver, sdFilter, (IIntent**)&intent);
return NOERROR;
}
示例6: OnAttachedToWindow
ECode ViewFlipper::OnAttachedToWindow()
{
ViewAnimator::OnAttachedToWindow();
// Listen for broadcasts related to user-presence
AutoPtr<IIntentFilter> filter;
CIntentFilter::New((IIntentFilter**)&filter);
filter->AddAction(IIntent::ACTION_SCREEN_OFF);
filter->AddAction(IIntent::ACTION_USER_PRESENT);
AutoPtr<IIntent> intent;
GetContext()->RegisterReceiver(mReceiver, filter, (IIntent**)&intent);
if (mAutoStart) {
// Automatically start when requested
StartFlipping();
}
return NOERROR;
}
示例7: OnAttachedToWindow
ECode CSplitClockView::OnAttachedToWindow()
{
LinearLayout::OnAttachedToWindow();
AutoPtr<IIntentFilter> filter;
CIntentFilter::New((IIntentFilter**)&filter);
filter->AddAction(IIntent::ACTION_TIME_CHANGED);
filter->AddAction(IIntent::ACTION_TIMEZONE_CHANGED);
filter->AddAction(IIntent::ACTION_LOCALE_CHANGED);
AutoPtr<IContext> context;
GetContext((IContext**)&context);
AutoPtr<IIntent> i;
context->RegisterReceiver(mIntentReceiver, filter, String(NULL), NULL, (IIntent**)&i);
UpdatePatterns();
return NOERROR;
}
示例8: constructor
ECode ProfileManagerService::constructor(
/* [in] */ IContext* context)
{
mContext = context;
assert(0 && "TODO");
// CBackupManager::New(mContext.Get(), (IBackupManager**)&mBackupManager);
mTriggerHelper = new ProfileTriggerHelper(mContext, this);
String str;
context->GetString(R::string::wildcardProfile, &str);
CNotificationGroup::New(str, R::string::wildcardProfile, mWildcardUUID, (INotificationGroup**)&mWildcardGroup);
Initialize();
AutoPtr<IIntentFilter> filter;
CIntentFilter::New((IIntentFilter**)&filter);
filter->AddAction(IIntent::ACTION_LOCALE_CHANGED);
filter->AddAction(IIntent::ACTION_SHUTDOWN);
mIntentReceiver = new MyBroadcastReceiver(this);
AutoPtr<IIntent> intent;
return mContext->RegisterReceiver(mIntentReceiver.Get(), filter.Get(), (IIntent**)&intent);
}
示例9: OnCreate
ECode RestrictedSettingsFragment::OnCreate(
/* [in] */ IBundle* icicle)
{
SettingsPreferenceFragment::OnCreate(icicle);
AutoPtr<IInterface> obj = GetSystemService(IContext::RESTRICTIONS_SERVICE);
mRestrictionsManager = IRestrictionsManager::Probe(obj);
obj = GetSystemService(IContext::USER_SERVICE);
mUserManager = IUserManager::Probe(obj);
if (icicle != NULL) {
icicle->GetBoolean(KEY_CHALLENGE_SUCCEEDED, FALSE, &mChallengeSucceeded);
icicle->GetBoolean(KEY_CHALLENGE_REQUESTED, FALSE, &mChallengeRequested);
}
AutoPtr<IIntentFilter> offFilter;
CIntentFilter::New(IIntent::ACTION_SCREEN_OFF, (IIntentFilter**)&offFilter);
offFilter->AddAction(IIntent::ACTION_USER_PRESENT);
AutoPtr<IActivity> activity;
GetActivity((IActivity**)&activity);
AutoPtr<IIntent> resIntent;
IContext::Probe(activity)->RegisterReceiver(mScreenOffReceiver, offFilter, (IIntent**)&resIntent);
return NOERROR;
}
示例10: HandleUpdateNotification
// Runs on the handler.
void WifiDisplayAdapter::HandleUpdateNotification()
{
Boolean isConnected;
{
AutoLock lock(GetSyncRoot());
if (!mPendingNotificationUpdate) {
return;
}
mPendingNotificationUpdate = FALSE;
isConnected = (mDisplayDevice != NULL);
}
AutoPtr<IUserHandle> all;
AutoPtr<IUserHandleHelper> helper;
CUserHandleHelper::AcquireSingleton((IUserHandleHelper**)&helper);
helper->GetALL((IUserHandle**)&all);
// Cancel the old notification if there is one.
String nullStr;
mNotificationManager->CancelAsUser(nullStr,
R::string::wifi_display_notification_title, all);
if (isConnected) {
AutoPtr<IContext> context = GetContext();
AutoPtr<IPendingIntentHelper> piHelper;
CPendingIntentHelper::AcquireSingleton((IPendingIntentHelper**)&piHelper);
AutoPtr<IUserHandle> current;
helper->GetCURRENT((IUserHandle**)¤t);
// Initialize pending intents for the notification outside of the lock because
// creating a pending intent requires a call into the activity manager.
if (mSettingsPendingIntent == NULL) {
AutoPtr<IIntent> settingsIntent;
CIntent::New(ISettings::ACTION_WIFI_DISPLAY_SETTINGS, (IIntent**)&settingsIntent);
settingsIntent->SetFlags(IIntent::FLAG_ACTIVITY_NEW_TASK
| IIntent::FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| IIntent::FLAG_ACTIVITY_CLEAR_TOP);
piHelper->GetActivityAsUser(
context, 0, settingsIntent, 0, NULL, current,
(IPendingIntent**)&mSettingsPendingIntent);
}
if (mDisconnectPendingIntent == NULL) {
AutoPtr<IIntent> disconnectIntent;
CIntent::New(ACTION_DISCONNECT, (IIntent**)&disconnectIntent);
piHelper->GetBroadcastAsUser(
context, 0, disconnectIntent, 0, current,
(IPendingIntent**)&mDisconnectPendingIntent);
}
// Post the notification.
AutoPtr<IResources> r;
context->GetResources((IResources**)&r);
AutoPtr<INotification> notification;
AutoPtr<INotificationBuilder> builder;
CNotificationBuilder::New(context, (INotificationBuilder**)&builder);
String str;
r->GetString(R::string::wifi_display_notification_title, &str);
AutoPtr<ICharSequence> seq;
CStringWrapper::New(str, (ICharSequence**)&seq);
builder->SetContentTitle(seq);
r->GetString(R::string::wifi_display_notification_message, &str);
seq = NULL;
CStringWrapper::New(str, (ICharSequence**)&seq);
builder->SetContentText(seq);
builder->SetContentIntent(mSettingsPendingIntent);
builder->SetSmallIcon(R::drawable::ic_notify_wifidisplay);
builder->SetOngoing(TRUE);
r->GetString(R::string::wifi_display_notification_disconnect, &str);
seq = NULL;
CStringWrapper::New(str, (ICharSequence**)&seq);
builder->AddAction(R::drawable::ic_menu_close_clear_cancel,
seq, mDisconnectPendingIntent);
builder->Build((INotification**)¬ification);
mNotificationManager->NotifyAsUser(nullStr,
R::string::wifi_display_notification_title,
notification, all);
}
}