微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 客制化开机向导符合Google认证要求

客制化开机向导符合Google认证要求

时间:10-02 整理:3721RD 点击:
[DESCRIPTION]
从KK版本开始,Google允许OEM在预置GMS项目中使用非GMS中的开机向导在预置GMS项目中如果使用三方开机向导,Google对此有一些认证要求,需要在开机向导中加入Google账户登录等Google服务功能界面
[SOLUTION]
首先确认为KK版本,并已预置GMS核心组件
以下是添加Google账户的接口代码:
AccountManager acctMgr = AccountManager.get(this);
Bundle options = new Bundle();
options.putBoolean("allowSkip", true);
options.putBoolean("firstRun", true);
options.putBoolean("setupWizard", true);
AccountManagerFuture futBundle = acctMgr.adDACcount(
"com.google", // Google’s account type.
null, // The authTokenType is not relevant to Google.
null, // No requiredFeatures.
options,
this, // The Activity context.
mCallback, // SIMplest just to handle an error intent directly.
null); // No callback implies no handler.
try {
Intent googleSignInWorkFlow =
futBundle.getResult().getParcelable(AccountManager.KEY_INTENT);
this.startActivityForResult(googleSignInWorkFlow, REQUEST_CODE);
} catch (Exception e) {
// AccountManager.addAccount throws various exceptions.
// Left to the implementer.
}
将以上代码加入到客制化开机向导合适位置,即可通过AccountManager的addAccount()唤起Google账户登录(注册/跳
过)界面
ps: 您可以添加addAccount()的callBack方法来handle此方法返回值判断用户操作行为(区分返回或者下一步)
callback方法可以参考如下写法:
private final AccountManagerCallback<Bundle> mCallback = new
AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
Log.i("mtkdebugGoo", "mCallback added" );
try {
Bundle bundle = future.getResult();
Log.i("mtkdebugGoo", "account added: " + bundle);
if(bundle.toString().contains("accountType=com.google"))
setResult(NEXT_ADD);
else
setResult(NEXT);
} catch (OperationCanceledException e) {
Log.v("mtkdebugGoo", "addAccount was canceled");
setResult(BACK);
mAddAccount = false;
} catch (IOException e) {
Log.v("mtkdebugGoo", "addAccount failed1: " + e);
} catch (AuthenticatorException e) {
Log.v("mtkdebugGoo", "addAccount failed2: " + e);
} finally {
finish();
}
}
};
如此即可满足Google对开机向导认证要求
如果您还需要添加Google开机向导中其它服务如分享位置信息等功能,可以继续将如下code添加到开机向导合适位置:
Intent intent = new Intent();
intent.setPackage("com.google.android.setupwizard");
intent.setClassName("com.google.android.setupwizard",
"com.google.android.setupwizard.LocationSharingActivity");
startActivityForResult(intent, REQUEST_CODE);
谢谢!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top