public PlatformConfiguration CreatePlatformConfiguration() { var config = AndroidPlatformConfiguration.Create(); using (var activity = AndroidTokenClient.GetActivity()) { config.SetActivity(activity.GetRawObject()); config.SetOptionalIntentHandlerForUI((intent) => { // Capture a global reference to the intent we are to show. This is required // since we are launching the intent from the game thread, and this callback // will return before this happens. If we do not hold onto a durable reference, // the code calling us will clean up the intent before we have a chance to display // it. var intentRef = AndroidJNI.NewGlobalRef(intent); PlayGamesHelperObject.RunOnGameThread(() => { try { LaunchBridgeIntent(intentRef); } finally { // Now that we've launched the intent, release the global reference. AndroidJNI.DeleteGlobalRef(intentRef); } }); }); } return(config); }
// Must be launched from the game thread (otherwise the classloader cannot locate the unity // java classes we require). private static void LaunchBridgeIntent(IntPtr bridgedIntent) { var objectArray = new object[2]; var jArgs = AndroidJNIHelper.CreateJNIArgArray(objectArray); try { using (var bridgeClass = new AndroidJavaClass(BridgeActivityClass)) { using (var currentActivity = AndroidTokenClient.GetActivity()) { // Unity no longer supports constructing an AndroidJavaObject using an IntPtr, // so I have to manually munge with JNI here. var methodId = AndroidJNI.GetStaticMethodID(bridgeClass.GetRawClass(), LaunchBridgeMethod, LaunchBridgeSignature); jArgs[0].l = currentActivity.GetRawObject(); jArgs[1].l = bridgedIntent; AndroidJNI.CallStaticVoidMethod(bridgeClass.GetRawClass(), methodId, jArgs); } } } catch (Exception e) { GooglePlayGames.OurUtils.Logger.e("Exception launching bridge intent: " + e.Message); GooglePlayGames.OurUtils.Logger.e(e.ToString()); } finally { AndroidJNIHelper.DeleteJNIArgArray(objectArray, jArgs); } }
public PlatformConfiguration CreatePlatformConfiguration(PlayGamesClientConfiguration clientConfig) { AndroidPlatformConfiguration androidPlatformConfiguration = AndroidPlatformConfiguration.Create(); AndroidJavaObject activity = AndroidTokenClient.GetActivity(); try { androidPlatformConfiguration.SetActivity(activity.GetRawObject()); androidPlatformConfiguration.SetOptionalIntentHandlerForUI(delegate(IntPtr intent) { IntPtr intentRef = AndroidJNI.NewGlobalRef(intent); PlayGamesHelperObject.RunOnGameThread(delegate { try { LaunchBridgeIntent(intentRef); } finally { AndroidJNI.DeleteGlobalRef(intentRef); } }); }); if (!clientConfig.IsHidingPopups) { return(androidPlatformConfiguration); } androidPlatformConfiguration.SetOptionalViewForPopups(CreateHiddenView(activity.GetRawObject())); return(androidPlatformConfiguration); } finally { ((IDisposable)activity)?.Dispose(); } }
// Must be launched from the game thread (otherwise the classloader cannot locate the unity // java classes we require). private static void LaunchBridgeIntent(IntPtr bridgedIntent) { object[] objectArray = new object[2]; jvalue[] jArgs = AndroidJNIHelper.CreateJNIArgArray(objectArray); try { using (var bridgeClass = new AndroidJavaClass(BridgeActivityClass)) { using (var currentActivity = AndroidTokenClient.GetActivity()) { // Unity no longer supports constructing an AndroidJavaObject using an IntPtr, // so I have to manually munge with JNI here. IntPtr methodId = AndroidJNI.GetStaticMethodID(bridgeClass.GetRawClass(), LaunchBridgeMethod, LaunchBridgeSignature); jArgs[0].l = currentActivity.GetRawObject(); jArgs[1].l = bridgedIntent; AndroidJNI.CallStaticVoidMethod(bridgeClass.GetRawClass(), methodId, jArgs); } } } finally { AndroidJNIHelper.DeleteJNIArgArray(objectArray, jArgs); } }
public PlatformConfiguration CreatePlatformConfiguration() { AndroidPlatformConfiguration configuration = AndroidPlatformConfiguration.Create(); using (AndroidJavaObject obj2 = AndroidTokenClient.GetActivity()) { configuration.SetActivity(obj2.GetRawObject()); if (< > f__am$cache1 == null) {
internal void DoFetchToken(Action callback) { object[] objectArray = new object[9]; jvalue[] jArgs = AndroidJNIHelper.CreateJNIArgArray(objectArray); try { using (var bridgeClass = new AndroidJavaClass(TokenFragmentClass)) { using (var currentActivity = AndroidTokenClient.GetActivity()) { // Unity no longer supports constructing an AndroidJavaObject using an IntPtr, // so I have to manually munge with JNI here. IntPtr methodId = AndroidJNI.GetStaticMethodID(bridgeClass.GetRawClass(), FetchTokenMethod, FetchTokenSignature); jArgs[0].l = currentActivity.GetRawObject(); jArgs[1].z = requestAuthCode; jArgs[2].z = requestEmail; jArgs[3].z = requestIdToken; jArgs[4].l = AndroidJNI.NewStringUTF(webClientId); jArgs[5].z = forceRefresh; jArgs[6].l = AndroidJNIHelper.ConvertToJNIArray(oauthScopes.ToArray()); jArgs[7].z = hidePopups; jArgs[8].l = AndroidJNI.NewStringUTF(accountName); IntPtr ptr = AndroidJNI.CallStaticObjectMethod(bridgeClass.GetRawClass(), methodId, jArgs); PendingResult <TokenResult> pr = new PendingResult <TokenResult>(ptr); pr.setResultCallback(new TokenResultCallback((rc, authCode, email, idToken) => { this.authCode = authCode; this.email = email; this.idToken = idToken; callback(); })); } } } catch (Exception e) { OurUtils.Logger.e("Exception launching token request: " + e.Message); OurUtils.Logger.e(e.ToString()); } finally { AndroidJNIHelper.DeleteJNIArgArray(objectArray, jArgs); } }
public string GetAccessToken() { string str1 = (string)null; string str2 = this.GetAccountName() ?? "NULL"; string str3 = "oauth2:https://www.googleapis.com/auth/plus.me"; using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.google.android.gms.auth.GoogleAuthUtil")) str1 = (string)((AndroidJavaObject)androidJavaClass).CallStatic <string>("getToken", new object[3] { (object)AndroidTokenClient.GetActivity(), (object)str2, (object)str3 }); Debug.Log((object)("Access Token " + str1)); return(str1); }
public PlatformConfiguration CreatePlatformConfiguration() { AndroidPlatformConfiguration platformConfiguration = AndroidPlatformConfiguration.Create(); platformConfiguration.EnableAppState(); using (AndroidJavaObject activity = AndroidTokenClient.GetActivity()) { platformConfiguration.SetActivity(activity.GetRawObject()); // ISSUE: object of a compiler-generated type is created // ISSUE: reference to a compiler-generated method platformConfiguration.SetOptionalIntentHandlerForUI((Action <IntPtr>)(intent => PlayGamesHelperObject.RunOnGameThread(new Action(new AndroidClient.\u003CCreatePlatformConfiguration\u003Ec__AnonStorey100() { intentRef = AndroidJNI.NewGlobalRef(intent) }.\u003C\u003Em__D)))); } return((PlatformConfiguration)platformConfiguration); }
internal static void FetchToken(string scope, string rationale, bool fetchEmail, bool fetchAccessToken, bool fetchIdToken, Action <int, string, string, string> callback) { object[] objectArray = new object[6]; jvalue[] jArgs = AndroidJNIHelper.CreateJNIArgArray(objectArray); try { using (var bridgeClass = new AndroidJavaClass(TokenFragmentClass)) { using (var currentActivity = AndroidTokenClient.GetActivity()) { // Unity no longer supports constructing an AndroidJavaObject using an IntPtr, // so I have to manually munge with JNI here. IntPtr methodId = AndroidJNI.GetStaticMethodID(bridgeClass.GetRawClass(), FetchTokenMethod, FetchTokenSignature); jArgs[0].l = currentActivity.GetRawObject(); jArgs[1].l = AndroidJNI.NewStringUTF(rationale); jArgs[2].z = fetchEmail; jArgs[3].z = fetchAccessToken; jArgs[4].z = fetchIdToken; jArgs[5].l = AndroidJNI.NewStringUTF(scope); GooglePlayGames.OurUtils.Logger.d("---->> Calling Fetch: " + methodId + " scope: " + scope); IntPtr ptr = AndroidJNI.CallStaticObjectMethod(bridgeClass.GetRawClass(), methodId, jArgs); GooglePlayGames.OurUtils.Logger.d("<<<------- Got return of " + ptr); PendingResult <TokenResult> pr = new PendingResult <TokenResult>(ptr); pr.setResultCallback(new TokenResultCallback(callback)); } } } catch (Exception e) { GooglePlayGames.OurUtils.Logger.e("Exception launching token request: " + e.Message); GooglePlayGames.OurUtils.Logger.e(e.ToString()); } finally { AndroidJNIHelper.DeleteJNIArgArray(objectArray, jArgs); } }
internal static void FetchToken(bool fetchAuthCode, bool fetchEmail, bool fetchIdToken, string webClientId, bool forceRefresh, Action <int, string, string, string> callback) { object[] objectArray = new object[7]; jvalue[] jArgs = AndroidJNIHelper.CreateJNIArgArray(objectArray); try { using (var bridgeClass = new AndroidJavaClass(TokenFragmentClass)) { using (var currentActivity = AndroidTokenClient.GetActivity()) { // Unity no longer supports constructing an AndroidJavaObject using an IntPtr, // so I have to manually munge with JNI here. IntPtr methodId = AndroidJNI.GetStaticMethodID(bridgeClass.GetRawClass(), FetchTokenMethod, FetchTokenSignature); jArgs[0].l = currentActivity.GetRawObject(); jArgs[1].z = fetchAuthCode; jArgs[2].z = fetchEmail; jArgs[3].z = fetchIdToken; jArgs[4].l = AndroidJNI.NewStringUTF(webClientId); jArgs[5].z = forceRefresh; IntPtr ptr = AndroidJNI.CallStaticObjectMethod(bridgeClass.GetRawClass(), methodId, jArgs); PendingResult <TokenResult> pr = new PendingResult <TokenResult>(ptr); pr.setResultCallback(new TokenResultCallback(callback)); } } } catch (Exception e) { OurUtils.Logger.e("Exception launching token request: " + e.Message); OurUtils.Logger.e(e.ToString()); } finally { AndroidJNIHelper.DeleteJNIArgArray(objectArray, jArgs); } }
public AndroidJavaObject GetApiClient(bool getServerAuthCode = false, string serverClientID = null) { Debug.Log((object)"Calling GetApiClient...."); using (AndroidJavaObject activity = AndroidTokenClient.GetActivity()) { using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.google.android.gms.plus.Plus")) { using (AndroidJavaObject androidJavaObject1 = new AndroidJavaObject("com.google.android.gms.common.api.GoogleApiClient$Builder", new object[1] { (object)activity })) { androidJavaObject1.Call <AndroidJavaObject>("addApi", new object[1] { (object)((AndroidJavaObject)androidJavaClass).GetStatic <AndroidJavaObject>("API") }); androidJavaObject1.Call <AndroidJavaObject>("addScope", new object[1] { (object)((AndroidJavaObject)androidJavaClass).GetStatic <AndroidJavaObject>("SCOPE_PLUS_LOGIN") }); if (getServerAuthCode) { androidJavaObject1.Call <AndroidJavaObject>("requestServerAuthCode", new object[2] { (object)serverClientID, (object)androidJavaObject1 }); } AndroidJavaObject androidJavaObject2 = (AndroidJavaObject)androidJavaObject1.Call <AndroidJavaObject>("build", new object[0]); androidJavaObject2.Call("connect", new object[0]); int num = 100; while (androidJavaObject2.Call <bool>("isConnected", new object[0]) == null && num-- != 0) { Thread.Sleep(100); } Debug.Log((object)("Done GetApiClient is " + (object)androidJavaObject2)); return(androidJavaObject2); } } } }
private static void LaunchBridgeIntent(IntPtr bridgedIntent) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown object[] array = new object[2]; jvalue[] array2 = AndroidJNIHelper.CreateJNIArgArray(array); try { AndroidJavaClass val = new AndroidJavaClass("com.google.games.bridge.NativeBridgeActivity"); try { AndroidJavaObject activity = AndroidTokenClient.GetActivity(); try { IntPtr staticMethodID = AndroidJNI.GetStaticMethodID(val.GetRawClass(), "launchBridgeIntent", "(Landroid/app/Activity;Landroid/content/Intent;)V"); array2[0].l = activity.GetRawObject(); array2[1].l = bridgedIntent; AndroidJNI.CallStaticVoidMethod(val.GetRawClass(), staticMethodID, array2); } finally { ((IDisposable)activity)?.Dispose(); } } finally { ((IDisposable)val)?.Dispose(); } } catch (Exception ex) { Logger.e("Exception launching bridge intent: " + ex.Message); Logger.e(ex.ToString()); } finally { AndroidJNIHelper.DeleteJNIArgArray(array, array2); } }
private static void LaunchBridgeIntent(IntPtr bridgedIntent) { object[] objArray = new object[2]; jvalue[] jniArgArray = AndroidJNIHelper.CreateJNIArgArray(objArray); try { using (AndroidJavaClass androidJavaClass = new AndroidJavaClass("com.google.games.bridge.NativeBridgeActivity")) { using (AndroidJavaObject activity = AndroidTokenClient.GetActivity()) { IntPtr staticMethodId = AndroidJNI.GetStaticMethodID(((AndroidJavaObject)androidJavaClass).GetRawClass(), "launchBridgeIntent", "(Landroid/app/Activity;Landroid/content/Intent;)V"); jniArgArray[0].l = (__Null)activity.GetRawObject(); jniArgArray[1].l = (__Null)bridgedIntent; AndroidJNI.CallStaticVoidMethod(((AndroidJavaObject)androidJavaClass).GetRawClass(), staticMethodId, jniArgArray); } } } finally { AndroidJNIHelper.DeleteJNIArgArray(objArray, jniArgArray); } }