android8.0 cts认证,Android8.0 CtsVerifier Wifi Direct Test

In Android8.0, using CtsVerifier.apk of Android 8.0, it version is 26.

when test Go Negotiation Requester Test-> failed.

And I try test CtsVerifier.apk of Android 6.0, it's version is 23. it is test pass。 In android 8.0,using CtsVerifier.apk of Android 8.0. wifi direct test--> Go Negotiation Test So, I find the root cause, the analysis is as follows: 1) CtsVerifier.apk -> RequesterTestActivity.java private void searchTarget() { 。。。。。。。 mTimer.schedule(new TimerTask() { @Override public void run() { mP2pMgr.requestPeers(mChannel, new PeerListListener() { @Override public void onPeersAvailable(WifiP2pDeviceList _peers) { final WifiP2pDeviceList peers = _peers; /* * Need to show dialog in GUI thread. */ mHandler.post(new Runnable() { @Override public void run() { mProgress.setVisibility(ProgressBar.INVISIBLE); // get list is null, so it test failed, show " the target responder device was not found" if (peers.getDeviceList().size() == 0) { mTextView.setText( R.string.p2p_target_not_found_error); } else { showSelectTargetDialog(peers); } } }); } }); 。。。。。 } 2) in WifiP2pServiceImpl.java --> recivce REQUEST_PEERS --> getPeers((Bundle) message.obj, message.sendingUid)) private WifiP2pDeviceList getPeers(Bundle pkg, int uid) { ........ scanPermission = wifiPermissionsUtil.canAccessScanResults(pkgName, uid, Build.VERSION_CODES.O); ................. // but this scanPermission is false, mPeers can not set. // So CtsVerifier.apk get peers is null,it's size is 0, last it is test failed...

if (scanPermission) {

return new WifiP2pDeviceList(mPeers);

} else {

return new WifiP2pDeviceList();

}

.......

}

3)

In canAccessScanResults() of WifiPermissionsUtil.java

public boolean canAccessScanResults(String pkgName, int uid,

int minVersion) throws SecurityException {

mAppOps.checkPackage(uid, pkgName);

// Check if the calling Uid has CAN_READ_PEER_MAC_ADDRESS

// permission or is an Active Nw scorer. boolean canCallingUidAccessLocation = checkCallerHasPeersMacAddressPermission(uid) || isCallerActiveNwScorer(uid); // LocationAccess by App: For AppVersion older than minVersion, // it is sufficient to check if the App is foreground. // Otherwise, Location Mode must be enabled and caller must have // Coarse Location permission to have access to location information. boolean canAppPackageUseLocation = isLegacyForeground(pkgName, minVersion) || (isLocationModeEnabled(pkgName) && checkCallersLocationPermission(pkgName, uid)); // If neither caller or app has location access, there is no need to check // any other permissions. Deny access to scan results. // pkgName=com.android.cts.verifier mLog.tC("icecream Denied: pkgName="+pkgName); // uid=10063, minVersion=26 mLog.tC("icecream Denied: uid="+uid+", minVersion="+minVersion); // false mLog.tC("icecream Denied: checkCallerHasPeersMacAddressPermission(uid)=" +checkCallerHasPeersMacAddressPermission(uid)); // false mLog.tC("icecream Denied: isCallerActiveNwScorer(uid)=" +isCallerActiveNwScorer(uid)); // false mLog.tC("icecream Denied: canCallingUidAccessLocation=" +canCallingUidAccessLocation); // false mLog.tC("icecream Denied: isLegacyForeground(pkgName, minVersion)=" +isLegacyForeground(pkgName, minVersion)); //false mLog.tC("icecream Denied: isLocationModeEnabled(pkgName)=" +isLocationModeEnabled(pkgName)); // false mLog.tC("icecream Denied: checkCallersLocationPermission(pkgName, uid)=" +checkCallersLocationPermission(pkgName, uid)); // true mLog.tC("icecream Denied: canAppPackageUseLocation=" +canAppPackageUseLocation); // false if (!canCallingUidAccessLocation && !canAppPackageUseLocation) { mLog.tC("icecream Denied: no location permission"); // here, it will return, so scanPermission had set false. return false; } ....... } 4) I use CtsVerifier.apk of Android 6.0, it can test pass, but the CtsVerifier.apk of Android 8.0 is test failed. 5) I check the isLegacyForeground(), it is private boolean isLegacyForeground(String pkgName, int version) { return isLegacyVersion(pkgName, version) && isForegroundApp(pkgName); } I add some log, isLegacyVersion(pkgName, version) is false isForegroundApp(pkgName) is true. 6) isLegacyVersion private boolean isLegacyVersion(String pkgName, int minVersion) { mLog.tC("icecream isLegacyVersion---------------- pkgName="+pkgName+", minVersion="+minVersion); try { mLog.tC("icecream isLegacyVersion mContext.getPackageManager().getApplicationInfo(pkgName, 0).targetSdkVersion= "+mContext.getPackageManager().getApplicationInfo(pkgName, 0).targetSdkVersion); // targetSdkVersion is 26, and minVersion is 26, // so it return false. and then test failed, // So this is root case for CtsVerifier.apk of Android 6.0 test pass, // but Android 8.0 test failed if (mContext.getPackageManager().getApplicationInfo(pkgName, 0) .targetSdkVersion < minVersion) { return true; } } catch (PackageManager.NameNotFoundException e) { // In case of exception, assume known app (more strict checking) // Note: This case will never happen since checkPackage is // called to verify valididity before checking App's version. } return false; } 7) isLocationModeEnabled(pkgName) this function will get database, Settings.Secure.LOCATION_MODE, and it's default is Settings.Secure.LOCATION_MODE_OFF, So if it is Settings.Secure.LOCATION_MODE_ON, this test will pass.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值