Java Code Examples for org.chromium.base.ApplicationStatus#registerApplicationStateListener()

The following examples show how to use org.chromium.base.ApplicationStatus#registerApplicationStateListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultMediaRouteController.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public boolean initialize() {
    if (mediaRouterInitializationFailed()) return false;

    ApplicationStatus.registerApplicationStateListener(mApplicationStateListener);

    if (mSessionStatusUpdateIntent == null) {
        Intent sessionStatusUpdateIntent = new Intent(ACTION_RECEIVE_SESSION_STATUS_UPDATE);
        sessionStatusUpdateIntent.addCategory(mIntentCategory);
        mSessionStatusUpdateIntent = PendingIntent.getBroadcast(getContext(), 0,
                sessionStatusUpdateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    if (mMediaStatusUpdateIntent == null) {
        Intent mediaStatusUpdateIntent = new Intent(ACTION_RECEIVE_MEDIA_STATUS_UPDATE);
        mediaStatusUpdateIntent.addCategory(mIntentCategory);
        mMediaStatusUpdateIntent = PendingIntent.getBroadcast(getContext(), 0,
                mediaStatusUpdateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    return true;
}
 
Example 2
Source File: DefaultMediaRouteController.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean initialize() {
    if (mediaRouterInitializationFailed()) return false;

    ApplicationStatus.registerApplicationStateListener(mApplicationStateListener);

    if (mSessionStatusUpdateIntent == null) {
        Intent sessionStatusUpdateIntent = new Intent(ACTION_RECEIVE_SESSION_STATUS_UPDATE);
        sessionStatusUpdateIntent.addCategory(mIntentCategory);
        mSessionStatusUpdateIntent = PendingIntent.getBroadcast(getContext(), 0,
                sessionStatusUpdateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    if (mMediaStatusUpdateIntent == null) {
        Intent mediaStatusUpdateIntent = new Intent(ACTION_RECEIVE_MEDIA_STATUS_UPDATE);
        mediaStatusUpdateIntent.addCategory(mIntentCategory);
        mMediaStatusUpdateIntent = PendingIntent.getBroadcast(getContext(), 0,
                mediaStatusUpdateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    return true;
}
 
Example 3
Source File: DefaultMediaRouteController.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public boolean initialize() {
    if (mediaRouterInitializationFailed()) return false;

    ApplicationStatus.registerApplicationStateListener(mApplicationStateListener);

    if (mSessionStatusUpdateIntent == null) {
        Intent sessionStatusUpdateIntent = new Intent(ACTION_RECEIVE_SESSION_STATUS_UPDATE);
        sessionStatusUpdateIntent.addCategory(mIntentCategory);
        mSessionStatusUpdateIntent = PendingIntent.getBroadcast(getContext(), 0,
                sessionStatusUpdateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    if (mMediaStatusUpdateIntent == null) {
        Intent mediaStatusUpdateIntent = new Intent(ACTION_RECEIVE_MEDIA_STATUS_UPDATE);
        mediaStatusUpdateIntent.addCategory(mIntentCategory);
        mMediaStatusUpdateIntent = PendingIntent.getBroadcast(getContext(), 0,
                mediaStatusUpdateIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    }

    return true;
}
 
Example 4
Source File: InvalidationController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance using {@code context} to send intents.
 */
@VisibleForTesting
InvalidationController(Context context, boolean canDisableSessionInvalidations) {
    Context appContext = context.getApplicationContext();
    if (appContext == null) throw new NullPointerException("Unable to get application context");
    mContext = appContext;
    mCanDisableSessionInvalidations = canDisableSessionInvalidations;
    mSessionInvalidationsEnabled = !mCanDisableSessionInvalidations;
    mEnableSessionInvalidationsTimer = new Timer();

    ApplicationStatus.registerApplicationStateListener(this);
}
 
Example 5
Source File: ExternalDataUseObserver.java    From delion with Apache License 2.0 5 votes vote down vote up
ControlAppManager(String controlAppPackageName) {
    mControlAppPackageName = controlAppPackageName;
    mInstalled = false;
    ApplicationStatus.registerApplicationStateListener(this);
    checkAndNotifyPackageInstallState();
    if (!mInstalled) {
        // Notify the state when the control app is not installed on startup.
        nativeOnControlAppInstallStateChange(mNativeExternalDataUseObserverBridge, false);
    }
}
 
Example 6
Source File: GoogleServicesManager.java    From delion with Apache License 2.0 5 votes vote down vote up
private GoogleServicesManager(Context context) {
    try {
        TraceEvent.begin("GoogleServicesManager.GoogleServicesManager");
        ThreadUtils.assertOnUiThread();
        // We should store the application context, as we outlive any activity which may create
        // us.
        mContext = context.getApplicationContext();

        mChromeSigninController = ChromeSigninController.get(mContext);
        mSigninHelper = SigninHelper.get(mContext);

        // The sign out flow starts by clearing the signed in user in the ChromeSigninController
        // on the Java side, and then performs a sign out on the native side. If there is a
        // crash on the native side then the signin state may get out of sync. Make sure that
        // the native side is signed out if the Java side doesn't have a currently signed in
        // user.
        SigninManager signinManager = SigninManager.get(mContext);
        if (!mChromeSigninController.isSignedIn() && signinManager.isSignedInOnNative()) {
            Log.w(TAG, "Signed in state got out of sync, forcing native sign out");
            signinManager.signOut();
        }

        // Initialize sync.
        SyncController.get(context);

        ApplicationStatus.registerApplicationStateListener(this);
    } finally {
        TraceEvent.end("GoogleServicesManager.GoogleServicesManager");
    }
}
 
Example 7
Source File: InvalidationController.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance using {@code context} to send intents.
 */
@VisibleForTesting
InvalidationController(
        Context context, boolean canDisableSessionInvalidations, boolean canUseGcmUpstream) {
    Context appContext = context.getApplicationContext();
    if (appContext == null) throw new NullPointerException("Unable to get application context");
    mContext = appContext;
    mUseGcmUpstream = canUseGcmUpstream;
    mCanDisableSessionInvalidations = canDisableSessionInvalidations;
    mSessionInvalidationsEnabled = !mCanDisableSessionInvalidations;
    mEnableSessionInvalidationsTimer = new Timer();

    ApplicationStatus.registerApplicationStateListener(this);
}
 
Example 8
Source File: ExternalDataUseObserver.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
ControlAppManager(String controlAppPackageName) {
    mControlAppPackageName = controlAppPackageName;
    mInstalled = false;
    ApplicationStatus.registerApplicationStateListener(this);
    checkAndNotifyPackageInstallState();
    if (!mInstalled) {
        // Notify the state when the control app is not installed on startup.
        nativeOnControlAppInstallStateChange(mNativeExternalDataUseObserverBridge, false);
    }
}
 
Example 9
Source File: GoogleServicesManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private GoogleServicesManager(Context context) {
    try {
        TraceEvent.begin("GoogleServicesManager.GoogleServicesManager");
        ThreadUtils.assertOnUiThread();
        // We should store the application context, as we outlive any activity which may create
        // us.
        mContext = context.getApplicationContext();

        mChromeSigninController = ChromeSigninController.get(mContext);
        mSigninHelper = SigninHelper.get(mContext);

        // The sign out flow starts by clearing the signed in user in the ChromeSigninController
        // on the Java side, and then performs a sign out on the native side. If there is a
        // crash on the native side then the signin state may get out of sync. Make sure that
        // the native side is signed out if the Java side doesn't have a currently signed in
        // user.
        SigninManager signinManager = SigninManager.get(mContext);
        if (!mChromeSigninController.isSignedIn() && signinManager.isSignedInOnNative()) {
            Log.w(TAG, "Signed in state got out of sync, forcing native sign out");
            signinManager.signOut();
        }

        // Initialize sync.
        SyncController.get(context);

        ApplicationStatus.registerApplicationStateListener(this);
    } finally {
        TraceEvent.end("GoogleServicesManager.GoogleServicesManager");
    }
}
 
Example 10
Source File: AndroidCellularSignalStrength.java    From cronet with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
CellStateListener() {
    ThreadUtils.assertOnBackgroundThread();

    mTelephonyManager =
            (TelephonyManager) ContextUtils.getApplicationContext().getSystemService(
                    Context.TELEPHONY_SERVICE);

    if (mTelephonyManager.getSimState() != TelephonyManager.SIM_STATE_READY) return;

    ApplicationStatus.registerApplicationStateListener(this);
    onApplicationStateChange(ApplicationStatus.getStateForApplication());
}
 
Example 11
Source File: GoogleServicesManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private GoogleServicesManager(Context context) {
    try {
        TraceEvent.begin("GoogleServicesManager.GoogleServicesManager");
        ThreadUtils.assertOnUiThread();
        // We should store the application context, as we outlive any activity which may create
        // us.
        mContext = context.getApplicationContext();

        mChromeSigninController = ChromeSigninController.get();
        mSigninHelper = SigninHelper.get(mContext);

        // The sign out flow starts by clearing the signed in user in the ChromeSigninController
        // on the Java side, and then performs a sign out on the native side. If there is a
        // crash on the native side then the signin state may get out of sync. Make sure that
        // the native side is signed out if the Java side doesn't have a currently signed in
        // user.
        SigninManager signinManager = SigninManager.get(mContext);
        if (!mChromeSigninController.isSignedIn() && signinManager.isSignedInOnNative()) {
            Log.w(TAG, "Signed in state got out of sync, forcing native sign out");
            signinManager.signOut();
        }

        // Initialize sync.
        SyncController.get(context);

        ApplicationStatus.registerApplicationStateListener(this);
    } finally {
        TraceEvent.end("GoogleServicesManager.GoogleServicesManager");
    }
}
 
Example 12
Source File: InvalidationController.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance using {@code context} to send intents.
 */
@VisibleForTesting
InvalidationController(
        Context context, boolean canDisableSessionInvalidations, boolean canUseGcmUpstream) {
    Context appContext = context.getApplicationContext();
    if (appContext == null) throw new NullPointerException("Unable to get application context");
    mContext = appContext;
    mUseGcmUpstream = canUseGcmUpstream;
    mCanDisableSessionInvalidations = canDisableSessionInvalidations;
    mSessionInvalidationsEnabled = !mCanDisableSessionInvalidations;
    mEnableSessionInvalidationsTimer = new Timer();

    ApplicationStatus.registerApplicationStateListener(this);
}
 
Example 13
Source File: ExternalDataUseObserver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
ControlAppManager(String controlAppPackageName) {
    mControlAppPackageName = controlAppPackageName;
    mInstalled = false;
    ApplicationStatus.registerApplicationStateListener(this);
    checkAndNotifyPackageInstallState();
    if (!mInstalled) {
        // Notify the state when the control app is not installed on startup.
        nativeOnControlAppInstallStateChange(mNativeExternalDataUseObserverBridge, false);
    }
}
 
Example 14
Source File: RegistrationPolicyApplicationStatus.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
protected void init(NetworkChangeNotifierAutoDetect notifier) {
    super.init(notifier);
    ApplicationStatus.registerApplicationStateListener(this);
    onApplicationStateChange(getApplicationState());
}
 
Example 15
Source File: LifecycleHook.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private LifecycleHook() {
    mClientHelpers = new HashSet<GoogleApiClientHelper>();
    mIsApplicationVisible = ApplicationStatus.hasVisibleActivities();
    ApplicationStatus.registerApplicationStateListener(this);
    Log.d(TAG, "lifecycle hook registered.");
}
 
Example 16
Source File: AppBannerInfoBarDelegateAndroid.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private AppBannerInfoBarDelegateAndroid(long nativePtr) {
    mNativePointer = nativePtr;
    mListener = createApplicationStateListener();
    ApplicationStatus.registerApplicationStateListener(mListener);
}
 
Example 17
Source File: LifecycleHook.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private LifecycleHook() {
    mClientHelpers = new HashSet<GoogleApiClientHelper>();
    mIsApplicationVisible = ApplicationStatus.hasVisibleActivities();
    ApplicationStatus.registerApplicationStateListener(this);
    Log.d(TAG, "lifecycle hook registered.");
}
 
Example 18
Source File: AppBannerInfoBarDelegateAndroid.java    From delion with Apache License 2.0 4 votes vote down vote up
private AppBannerInfoBarDelegateAndroid(long nativePtr) {
    mNativePointer = nativePtr;
    mListener = createApplicationStateListener();
    ApplicationStatus.registerApplicationStateListener(mListener);
}
 
Example 19
Source File: LifecycleHook.java    From delion with Apache License 2.0 4 votes vote down vote up
private LifecycleHook() {
    mClientHelpers = new HashSet<GoogleApiClientHelper>();
    mIsApplicationVisible = ApplicationStatus.hasVisibleActivities();
    ApplicationStatus.registerApplicationStateListener(this);
    Log.d(TAG, "lifecycle hook registered.");
}
 
Example 20
Source File: RegistrationPolicyApplicationStatus.java    From cronet with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void init(NetworkChangeNotifierAutoDetect notifier) {
    super.init(notifier);
    ApplicationStatus.registerApplicationStateListener(this);
    onApplicationStateChange(getApplicationState());
}