类android.net.wifi.rtt.WifiRttManager源码实例Demo

下面列出了怎么用android.net.wifi.rtt.WifiRttManager的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
public void onCreate() {
    super.onCreate();
    mWifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    mWifiScanReceiver = new WifiScanReceiver();
    mWifiRttManager = (WifiRttManager) getSystemService(Context.WIFI_RTT_RANGING_SERVICE);
    mRttRangingResultCallback = new RttRangingResultCallback();
    configuration = new Configuration(Configuration.CONFIGURATION_TYPE.TESTING_3);
    //configuration = new Configuration(Configuration.CONFIGURATION_TYPE.TWO_DIMENSIONAL_2);
    buildingMap = configuration.getConfiguration();
    Collections.sort(buildingMap);
    historicalDistances = new HashMap<String, ArrayList<RangingResult>>();
    for (int i = 0; i < buildingMap.size(); i++)
    {
        historicalDistances.put(buildingMap.get(i).getBssid().toString(), new ArrayList<RangingResult>());
    }
}
 
源代码2 项目: android_9.0.0_r45   文件: SystemServiceRegistry.java
@Override
public RttManager createService(ContextImpl ctx) throws ServiceNotFoundException {
    IBinder b = ServiceManager.getServiceOrThrow(Context.WIFI_RTT_RANGING_SERVICE);
    IWifiRttManager service = IWifiRttManager.Stub.asInterface(b);
    return new RttManager(ctx.getOuterContext(),
            new WifiRttManager(ctx.getOuterContext(), service));
}
 
源代码3 项目: android_9.0.0_r45   文件: SystemServiceRegistry.java
@Override
public WifiRttManager createService(ContextImpl ctx)
        throws ServiceNotFoundException {
    IBinder b = ServiceManager.getServiceOrThrow(
            Context.WIFI_RTT_RANGING_SERVICE);
    IWifiRttManager service = IWifiRttManager.Stub.asInterface(b);
    return new WifiRttManager(ctx.getOuterContext(), service);
}
 
源代码4 项目: android-rttmanager-sample   文件: MainActivity.java
@SuppressLint("WrongConstant")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    setSupportActionBar(toolbar);
    permissionController = new LocationPermissionController();
    fab.setOnClickListener(view -> startWifiScan());
    wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
    wifiNetworkReceiver = new ScanWifiNetworkReceiver();
    rttManager = (WifiRttManager) getSystemService(Context.WIFI_RTT_RANGING_SERVICE);
    initUI();
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_access_point_ranging_results);

    // Initializes UI elements.
    mSsidTextView = findViewById(R.id.ssid);
    mBssidTextView = findViewById(R.id.bssid);

    mRangeTextView = findViewById(R.id.range_value);
    mRangeMeanTextView = findViewById(R.id.range_mean_value);
    mRangeSDTextView = findViewById(R.id.range_sd_value);
    mRangeSDMeanTextView = findViewById(R.id.range_sd_mean_value);
    mRssiTextView = findViewById(R.id.rssi_value);
    mSuccessesInBurstTextView = findViewById(R.id.successes_in_burst_value);
    mSuccessRatioTextView = findViewById(R.id.success_ratio_value);
    mNumberOfRequestsTextView = findViewById(R.id.number_of_requests_value);

    mSampleSizeEditText = findViewById(R.id.stats_window_size_edit_value);
    mSampleSizeEditText.setText(SAMPLE_SIZE_DEFAULT + "");

    mMillisecondsDelayBeforeNewRangingRequestEditText =
            findViewById(R.id.ranging_period_edit_value);
    mMillisecondsDelayBeforeNewRangingRequestEditText.setText(
            MILLISECONDS_DELAY_BEFORE_NEW_RANGING_REQUEST_DEFAULT + "");

    // Retrieve ScanResult from Intent.
    Intent intent = getIntent();
    mScanResult = intent.getParcelableExtra(SCAN_RESULT_EXTRA);

    if (mScanResult == null) {
        finish();
    }

    mMAC = mScanResult.BSSID;

    mSsidTextView.setText(mScanResult.SSID);
    mBssidTextView.setText(mScanResult.BSSID);

    mWifiRttManager = (WifiRttManager) getSystemService(Context.WIFI_RTT_RANGING_SERVICE);
    mRttRangingResultCallback = new RttRangingResultCallback();

    // Used to store range (distance) and rangeSd (standard deviation of the measured distance)
    // history to calculate averages.
    mStatisticRangeHistory = new ArrayList<>();
    mStatisticRangeSDHistory = new ArrayList<>();

    resetData();

    startRangingRequest();
}
 
@SuppressLint("WrongConstant")
RttRangingManager(final Context context) {
    rttManager = (WifiRttManager) context.getSystemService(Context.WIFI_RTT_RANGING_SERVICE);
    mainExecutor = context.getMainExecutor();
}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_access_point_ranging_results);

    // Initializes UI elements.
    mSsidTextView = findViewById(R.id.ssid);
    mBssidTextView = findViewById(R.id.bssid);

    mRangeTextView = findViewById(R.id.range_value);
    mRangeMeanTextView = findViewById(R.id.range_mean_value);
    mRangeSDTextView = findViewById(R.id.range_sd_value);
    mRangeSDMeanTextView = findViewById(R.id.range_sd_mean_value);
    mRssiTextView = findViewById(R.id.rssi_value);
    mSuccessesInBurstTextView = findViewById(R.id.successes_in_burst_value);
    mSuccessRatioTextView = findViewById(R.id.success_ratio_value);
    mNumberOfRequestsTextView = findViewById(R.id.number_of_requests_value);

    mSampleSizeEditText = findViewById(R.id.stats_window_size_edit_value);
    mSampleSizeEditText.setText(SAMPLE_SIZE_DEFAULT + "");

    mMillisecondsDelayBeforeNewRangingRequestEditText =
            findViewById(R.id.ranging_period_edit_value);
    mMillisecondsDelayBeforeNewRangingRequestEditText.setText(
            MILLISECONDS_DELAY_BEFORE_NEW_RANGING_REQUEST_DEFAULT + "");

    // Retrieve ScanResult from Intent.
    Intent intent = getIntent();
    mScanResult = intent.getParcelableExtra(SCAN_RESULT_EXTRA);

    if (mScanResult == null) {
        finish();
    }

    mMAC = mScanResult.BSSID;

    mSsidTextView.setText(mScanResult.SSID);
    mBssidTextView.setText(mScanResult.BSSID);

    mWifiRttManager = (WifiRttManager) getSystemService(Context.WIFI_RTT_RANGING_SERVICE);
    mRttRangingResultCallback = new RttRangingResultCallback();

    // Used to store range (distance) and rangeSd (standard deviation of the measured distance)
    // history to calculate averages.
    mStatisticRangeHistory = new ArrayList<>();
    mStatisticRangeSDHistory = new ArrayList<>();

    resetData();

    startRangingRequest();
}
 
 类所在包
 类方法
 同包方法