エキスパート / エキスパート ハッカーの皆さん、こんにちは。
AndroidにGoogle Playアプリケーションのサイレントインストール機能(appbrain高速Webインストーラーに似ています)を実装しようとしています。
これまでのところ、次のことを達成できました。
Google Play Auth Token を取得する方法を見つけます (これにより、アプリケーションが電話で Google Play アプリケーションと通信する許可を与えます)。以下に、これに使用したコードをリストしました。
Log.i(TAG,"Getting the Google Play Auth Token Using Account Manager : START"); AccountManager accountManager = AccountManager.get(getApplicationContext()); Account[] accArr = accountManager.getAccountsByType("com.google"); for (Account acc : accArr) { Log.i(TAG, "For Account Name : " + acc.name + " - "+ "Account Type : " + acc.type); accountManager.getAuthToken(acc, "googleplay", null, this,new AccountManagerCallback<Bundle>() { public void run( AccountManagerFuture<Bundle> paramAccountManagerFuture) { try { Bundle localBundle = (Bundle) paramAccountManagerFuture.getResult(); String authToken = localBundle.get("authtoken") + ""; Log.i(TAG, "Got AuthToken : " + authToken); } catch (Exception ex) { StackTraceElement[] starray = ex.getStackTrace(); StringBuffer bf = new StringBuffer(); bf.append("Error : " + ex.getMessage()).append("\n"); for (StackTraceElement ste : starray) { bf.append(ste.toString()).append("\n"); } Log.e(TAG, bf.toString()); } } }, null); } Log.i(TAG,"Getting the Google Play Auth Token Using Account Manager : END")
電話の Android-Id を取得する方法を確認します (この ID は、appInstall リクエストを GPlay サーバーまたは Android 電話の Gplay/vending アプリケーションに送信するときに使用する必要があると思われます)。
Log.i(TAG, "Getting the Android ID Of the Phone : START"); Uri localUri = Uri.parse("content://com.google.android.gsf.gservices"); ContentResolver localContentResolver = getContentResolver(); String[] arrayOfString = new String[1]; arrayOfString[0] = "android_id"; Cursor localCursor = localContentResolver.query(localUri, null,null, arrayOfString, null); Log.i(TAG, "Column Count : " + localCursor.getColumnCount()); if ((localCursor != null) && (localCursor.moveToFirst())) { String androidId = Long.toHexString(Long.parseLong(localCursor.getString(1))); Log.i(TAG, "Received Android ID : " + androidId); Log.i(TAG,"Other Value in Column : " + localCursor.getString(0)); } Log.i(TAG,"Getting the Android ID of the Phone : END");
サイレント アプリケーションのダウンロードとインストール プロセスを開始するために、Google Play サーバーまたは電話の Gplay/自動販売アプリケーションに送信されるプロトコル バッファ リクエストを見つけます。
message InstallRequest { optional string appId = 1; } message RequestContext { required string authSubToken = 1; required bool isSecure = 2; required int32 version = 3; required string androidId = 4; optional string deviceAndSdkVersion = 5; optional string userLanguage = 6; optional string userCountry = 7; optional string operatorAlpha = 8; optional string simOperatorAlpha = 9; optional string operatorNumeric = 10; optional string simOperatorNumeric = 11; } message Request { optional RequestContext context = 1; repeated group RequestGroup = 2 { optional InstallRequest installRequest = 10; } }
4.protobuf コンパイラを使用して、上記のプロトコル バッファ要求を操作するための Java クラスを生成し、上記のプロトコル バッファ フィールドにサンプル データを入力しました。以下のコードを参照してください。
public void buildAndSendSilentInstallProtoBuffMessage(String gplayAuthToken, String deviceAndroidId){
try{
/*
* The Root Request Object Assumed to be Holding the Silent Install Request
*/
Request.Builder request = Request.newBuilder();
//Populating the ReequestContext Object
RequestContext.Builder context = RequestContext.newBuilder();
context.setAndroidId(deviceAndroidId);
context.setAuthSubToken(gplayAuthToken);
context.setIsSecure(true);
context.setVersion(1002);
context.setDeviceAndSdkVersion("dream:4");
context.setUserLanguage("en");
context.setUserCountry("us");
context.setOperatorAlpha("Android");
context.setOperatorNumeric("310260");
context.setSimOperatorNumeric("310260");
//Building the Install Request
InstallRequest.Builder installRequest = InstallRequest.newBuilder();
installRequest.setAppId("-2564446724934482383");
//Setting the Install Request to the Request Group
RequestGroup.Builder requestGroup = RequestGroup.newBuilder();
requestGroup.setInstallRequest(installRequest);
//Setting the Request Context to the Main Request Object
request.setContext(context);
//Setting the Request Group to the Request Object
request.addRequestGroup(requestGroup);
GPlay トークンと Android ID のサンプル データは次のとおりです。
- Android_ID :
3a0f901831a0f402
- Google Play 認証トークン :
DQAAAMgAAACpOyPf6apRbb0i4qhTVaf0yYoikTAb4TYlHCRLrW 4mu5f14j-H35KGmO9TQKUDYCfj3-b-QIH5chfXT3bS02Uxljg7vYt4I-kgXLEJwPcynjugDcJ9fYPOh1c2FnOnywFXXxXw6hcqs5sVnJEt 5zW2ditoB5VeeXG9Zfodj9dXKobObi50-XnHoGfWi2b64Uf3EHGdQTsDCMzfZrE4mb22fr9LCW1oZG5tkzw S4KhPBHWMN2fO7w-1IZ4UK5LOI80vPBLjxBaavKAXHoVUHSNV
- また、Gplay アプリケーションのサイレント インストール中に、ルート化された Galaxy nexus フォンを使用してスニッフィングを行ったところ、HTTP GET リクエストが 2 つしか見つかりませんでした。
ルートに Shark を使用してキャプチャした 2 つの Http GET リクエストを再現しようとしましたが (ルート化された Android Galaxy nexus 電話を使用)、最初のリクエストはマーケット ファイル自体をダウンロードするだけです (これは電話の SD カードに保存できました。しかし、その後2 番目の要求では何も返されませんが、不明なソース アプリケーションと同じようにインストールする必要があります。
キャプチャされた 2 つの get 要求を以下に示します。
GET リクエスト 1 :
21 0.827240 192.168.135.102 173.194.36.4 HTTP 535 GET /market/download/Download? packageName=com.gau.go.launcherex.theme.appwidget.gopowermaster.futureworld&versionCode=1&token=AOTCm0QRnH3rmypWtCGoAL_SU1BSt311wpyz-_LZTodkUSAlc- f5SrdMiz5WDRDUKMMm6S3plBI9Jbh1tukT1jyCYXLgP4QhVvZvn5JLtZQ&downloadId=-165214892049282883 HTTP/1.1 Which has the following http headers : Cookie: MarketDA=17214805622679635526\r\n Host: android.clients.google.com\r\n Connection: Keep-Alive\r\n User-Agent: AndroidDownloadManager/4.1.1 (Linux; U; Android 4.1.1; Galaxy Nexus Build/JRO03C)\r\n
GET リクエスト 2 :
44 6.595093 192.168.135.102 222.165.163.15 HTTP 608 GET /market/GetBinary/com.gau.go.launcherex.theme.appwidget.gopowermaster.futureworld/1?expire=1346838270&ipbits=0&ip=0.0.0.0&cp=SnpybWlzSFk6OTYzMzg0MTE2NzA1ODEwOTYxMjE&sparams=expire,ipbits,ip,q:,cp&signature=2C0778C4635F6F8AE1DA8479FB08DCB9BC04C2E9.60202D8D4D2FDDA70609A3862A25852F0BAA2766&key=am2 HTTP/1.1 Which has the following http headers : Cookie: MarketDA=17214805622679635526\r\n Host: o-o.preferred.slt-cmb2.v12.lscache4.c.android.clients.google.com\r\n Connection: Keep-Alive\r\n User-Agent: AndroidDownloadManager/4.1.1 (Linux; U; Android 4.1.1; Galaxy Nexus Build/JRO03C)\r\n
これを約2週間調べていますが、まだ次のものが見つかりませんでした。
AppBrain 高速 Web インストーラーがプロトコル バッファーを使用して、電話または Gplay サーバーで Gplay (自動販売アプリケーション) を呼び出すかどうか?. もしそうなら、上記の Protocol Buffer Request フォーマットは正しいですか??.
上記のプロトコル バッファ リクエストの形式が正しい場合は、電話または Gplay サーバーのどこにプロトコル バッファ リクエストを送信して、サイレント アプリケーションのダウンロードとインストール手順を呼び出す必要がありますか?.
また、このタスクに関して C2DM (現在は GCM) サーバーとクライアントのセットアップも行っています。誰かが私を正しい方向に向けたり、これを解決するための手がかりを教えてくれませんか?. どんな助けでも大歓迎です。