Search in sources :

Example 1 with SimpleClock

use of android.os.SimpleClock in project android_packages_apps_Settings by omnirom.

the class NetworkRequestDialogFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mWorkerThread = new HandlerThread(TAG + "{" + Integer.toHexString(System.identityHashCode(this)) + "}", Process.THREAD_PRIORITY_BACKGROUND);
    mWorkerThread.start();
    final Clock elapsedRealtimeClock = new SimpleClock(ZoneOffset.UTC) {

        @Override
        public long millis() {
            return SystemClock.elapsedRealtime();
        }
    };
    final Context context = getContext();
    mWifiPickerTracker = FeatureFactory.getFactory(context).getWifiTrackerLibProvider().createWifiPickerTracker(getSettingsLifecycle(), context, new Handler(Looper.getMainLooper()), mWorkerThread.getThreadHandler(), elapsedRealtimeClock, MAX_SCAN_AGE_MILLIS, SCAN_INTERVAL_MILLIS, this);
}
Also used : Context(android.content.Context) HandlerThread(android.os.HandlerThread) SimpleClock(android.os.SimpleClock) Handler(android.os.Handler) SystemClock(android.os.SystemClock) Clock(java.time.Clock) SimpleClock(android.os.SimpleClock)

Example 2 with SimpleClock

use of android.os.SimpleClock in project android_packages_apps_Settings by omnirom.

the class WifiSettings method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final Context context = getContext();
    mWorkerThread = new HandlerThread(TAG + "{" + Integer.toHexString(System.identityHashCode(this)) + "}", Process.THREAD_PRIORITY_BACKGROUND);
    mWorkerThread.start();
    final Clock elapsedRealtimeClock = new SimpleClock(ZoneOffset.UTC) {

        @Override
        public long millis() {
            return SystemClock.elapsedRealtime();
        }
    };
    mWifiPickerTracker = FeatureFactory.getFactory(context).getWifiTrackerLibProvider().createWifiPickerTracker(getSettingsLifecycle(), context, new Handler(Looper.getMainLooper()), mWorkerThread.getThreadHandler(), elapsedRealtimeClock, MAX_SCAN_AGE_MILLIS, SCAN_INTERVAL_MILLIS, this);
    final Activity activity = getActivity();
    if (activity != null) {
        mWifiManager = getActivity().getSystemService(WifiManager.class);
    }
    mConnectListener = new WifiConnectListener(getActivity());
    mSaveListener = new WifiManager.ActionListener() {

        @Override
        public void onSuccess() {
        }

        @Override
        public void onFailure(int reason) {
            Activity activity = getActivity();
            if (activity != null) {
                Toast.makeText(activity, R.string.wifi_failed_save_message, Toast.LENGTH_SHORT).show();
            }
        }
    };
    mForgetListener = new WifiManager.ActionListener() {

        @Override
        public void onSuccess() {
        }

        @Override
        public void onFailure(int reason) {
            Activity activity = getActivity();
            if (activity != null) {
                Toast.makeText(activity, R.string.wifi_failed_forget_message, Toast.LENGTH_SHORT).show();
            }
        }
    };
    registerForContextMenu(getListView());
    setHasOptionsMenu(true);
    if (savedInstanceState != null) {
        mDialogMode = savedInstanceState.getInt(SAVE_DIALOG_MODE);
        mDialogWifiEntryKey = savedInstanceState.getString(SAVE_DIALOG_WIFIENTRY_KEY);
    }
    // If we're supposed to enable/disable the Next button based on our current connection
    // state, start it off in the right state.
    final Intent intent = getActivity().getIntent();
    mEnableNextOnConnection = intent.getBooleanExtra(EXTRA_ENABLE_NEXT_ON_CONNECT, false);
    if (intent.hasExtra(EXTRA_START_CONNECT_SSID)) {
        mOpenSsid = intent.getStringExtra(EXTRA_START_CONNECT_SSID);
    }
    // After rebooting the device, the Wi-Fi state will not be called back in the airplane
    // mode, need to call onWifiStateChanged() to update the initial state of the UI.
    onWifiStateChanged();
}
Also used : Context(android.content.Context) WifiManager(android.net.wifi.WifiManager) HandlerThread(android.os.HandlerThread) SimpleClock(android.os.SimpleClock) Handler(android.os.Handler) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) Intent(android.content.Intent) SimpleClock(android.os.SimpleClock) SystemClock(android.os.SystemClock) Clock(java.time.Clock)

Example 3 with SimpleClock

use of android.os.SimpleClock in project android_packages_apps_Settings by omnirom.

the class AddAppNetworksFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mActivity = getActivity();
    mWifiManager = mActivity.getSystemService(WifiManager.class);
    mWorkerThread = new HandlerThread(TAG + "{" + Integer.toHexString(System.identityHashCode(this)) + "}", Process.THREAD_PRIORITY_BACKGROUND);
    mWorkerThread.start();
    final Clock elapsedRealtimeClock = new SimpleClock(ZoneOffset.UTC) {

        @Override
        public long millis() {
            return SystemClock.elapsedRealtime();
        }
    };
    mWifiPickerTracker = FeatureFactory.getFactory(mActivity.getApplicationContext()).getWifiTrackerLibProvider().createWifiPickerTracker(getSettingsLifecycle(), mActivity, new Handler(Looper.getMainLooper()), mWorkerThread.getThreadHandler(), elapsedRealtimeClock, MAX_SCAN_AGE_MILLIS, SCAN_INTERVAL_MILLIS, this);
    return inflater.inflate(R.layout.wifi_add_app_networks, container, false);
}
Also used : WifiManager(android.net.wifi.WifiManager) HandlerThread(android.os.HandlerThread) SimpleClock(android.os.SimpleClock) Handler(android.os.Handler) SystemClock(android.os.SystemClock) Clock(java.time.Clock) SimpleClock(android.os.SimpleClock) Nullable(androidx.annotation.Nullable)

Example 4 with SimpleClock

use of android.os.SimpleClock in project android_packages_apps_Settings by omnirom.

the class WifiDialogActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mIntent = getIntent();
    if (WizardManagerHelper.isSetupWizardIntent(mIntent)) {
        setTheme(SetupWizardUtils.getTransparentTheme(this, mIntent));
    }
    super.onCreate(savedInstanceState);
    mIsWifiTrackerLib = !TextUtils.isEmpty(mIntent.getStringExtra(KEY_CHOSEN_WIFIENTRY_KEY));
    if (mIsWifiTrackerLib) {
        mWorkerThread = new HandlerThread(TAG + "{" + Integer.toHexString(System.identityHashCode(this)) + "}", Process.THREAD_PRIORITY_BACKGROUND);
        mWorkerThread.start();
        final Clock elapsedRealtimeClock = new SimpleClock(ZoneOffset.UTC) {

            @Override
            public long millis() {
                return SystemClock.elapsedRealtime();
            }
        };
        mNetworkDetailsTracker = FeatureFactory.getFactory(this).getWifiTrackerLibProvider().createNetworkDetailsTracker(getLifecycle(), this, new Handler(Looper.getMainLooper()), mWorkerThread.getThreadHandler(), elapsedRealtimeClock, MAX_SCAN_AGE_MILLIS, SCAN_INTERVAL_MILLIS, mIntent.getStringExtra(KEY_CHOSEN_WIFIENTRY_KEY));
    } else {
        final Bundle accessPointState = mIntent.getBundleExtra(KEY_ACCESS_POINT_STATE);
        if (accessPointState != null) {
            mAccessPoint = new AccessPoint(this, accessPointState);
        }
    }
}
Also used : HandlerThread(android.os.HandlerThread) SimpleClock(android.os.SimpleClock) Bundle(android.os.Bundle) AccessPoint(com.android.settingslib.wifi.AccessPoint) Handler(android.os.Handler) SystemClock(android.os.SystemClock) Clock(java.time.Clock) SimpleClock(android.os.SimpleClock)

Example 5 with SimpleClock

use of android.os.SimpleClock in project android_packages_apps_Settings by omnirom.

the class WifiDppQrCodeScannerFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mWorkerThread = new HandlerThread(TAG + "{" + Integer.toHexString(System.identityHashCode(this)) + "}", Process.THREAD_PRIORITY_BACKGROUND);
    mWorkerThread.start();
    final Clock elapsedRealtimeClock = new SimpleClock(ZoneOffset.UTC) {

        @Override
        public long millis() {
            return SystemClock.elapsedRealtime();
        }
    };
    final Context context = getContext();
    mWifiPickerTracker = FeatureFactory.getFactory(context).getWifiTrackerLibProvider().createWifiPickerTracker(getSettingsLifecycle(), context, new Handler(Looper.getMainLooper()), mWorkerThread.getThreadHandler(), elapsedRealtimeClock, MAX_SCAN_AGE_MILLIS, SCAN_INTERVAL_MILLIS, null);
    // setTitle for TalkBack
    if (mIsConfiguratorMode) {
        getActivity().setTitle(R.string.wifi_dpp_add_device_to_network);
    } else {
        getActivity().setTitle(R.string.wifi_dpp_scan_qr_code);
    }
}
Also used : Context(android.content.Context) HandlerThread(android.os.HandlerThread) SimpleClock(android.os.SimpleClock) Handler(android.os.Handler) SystemClock(android.os.SystemClock) Clock(java.time.Clock) SimpleClock(android.os.SimpleClock)

Aggregations

Handler (android.os.Handler)9 HandlerThread (android.os.HandlerThread)9 SimpleClock (android.os.SimpleClock)9 SystemClock (android.os.SystemClock)9 Clock (java.time.Clock)9 Context (android.content.Context)7 WifiManager (android.net.wifi.WifiManager)3 Activity (android.app.Activity)2 SavedNetworkTracker (com.android.wifitrackerlib.SavedNetworkTracker)2 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Nullable (androidx.annotation.Nullable)1 SettingsActivity (com.android.settings.SettingsActivity)1 AccessPoint (com.android.settingslib.wifi.AccessPoint)1