Migrate to official API getWifiActivityEnergyInfoAsync()

getControllerActivityEnergyInfo() is an @hide API,
migrate to getWifiActivityEnergyInfoAsync() which is an
@SystemApi.

Bug: 145244073
Test: m Development && adb install Development.apk,
open Dev Tools app, go to Connectivity page, tap on
Link Stats button, ensure link stats printed in text
box below.

Change-Id: I0a9edfff7d924a31c5a3470a89e03bd161f1a8fb
This commit is contained in:
David Su
2019-12-04 16:36:03 -08:00
parent 3c48b7354e
commit 6e08a584fb

View File

@@ -699,13 +699,13 @@ public class Connectivity extends Activity {
private void onLinkStats() {
Log.e(TAG, "LINK STATS: ");
try {
WifiActivityEnergyInfo info =
mWm.getControllerActivityEnergyInfo();
if (info != null) {
mLinkStatsResults.setText(" power " + info.toString());
} else {
mLinkStatsResults.setText(" null! ");
}
mWm.getWifiActivityEnergyInfoAsync(getMainExecutor(), info -> {
if (info != null) {
mLinkStatsResults.setText(" power " + info.toString());
} else {
mLinkStatsResults.setText(" null! ");
}
});
} catch (Exception e) {
mLinkStatsResults.setText(" failed! " + e.toString());
}