| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.apkminter; | 5 package org.chromium.apkminter; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; | 8 import android.content.Intent; |
| 9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
| 10 import android.graphics.BitmapFactory; | 10 import android.graphics.BitmapFactory; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 tmpUnzipDir.mkdir(); | 242 tmpUnzipDir.mkdir(); |
| 243 } | 243 } |
| 244 unzip(tmpApkFile, tmpUnzipDir); | 244 unzip(tmpApkFile, tmpUnzipDir); |
| 245 // Modify the template APK. | 245 // Modify the template APK. |
| 246 Log.i(TAG, "Updating AndroidManifest.xml"); | 246 Log.i(TAG, "Updating AndroidManifest.xml"); |
| 247 Log.i(TAG, "- appName = " + info.mAppName); | 247 Log.i(TAG, "- appName = " + info.mAppName); |
| 248 Log.i(TAG, "- packageName = " + info.mPackageName); | 248 Log.i(TAG, "- packageName = " + info.mPackageName); |
| 249 Log.i(TAG, "- hostUrl = " + info.mHostUrl); | 249 Log.i(TAG, "- hostUrl = " + info.mHostUrl); |
| 250 Log.i(TAG, "- scope = " + info.mScope); | 250 Log.i(TAG, "- scope = " + info.mScope); |
| 251 Log.i(TAG, "- mac = " + info.mMac); | 251 Log.i(TAG, "- mac = " + info.mMac); |
| 252 Log.i(TAG, "- runtimeHost = " + context.getPackageName()); |
| 252 | 253 |
| 253 BinaryXMLParser parser = new BinaryXMLParser( | 254 BinaryXMLParser parser = new BinaryXMLParser( |
| 254 tmpUnzipDirPath + "/AndroidManifest.xml"); | 255 tmpUnzipDirPath + "/AndroidManifest.xml"); |
| 255 parser.parseXML(); | 256 parser.parseXML(); |
| 256 parser.changeString(parser.getPackageName(), info.mPackageName); | 257 parser.changeString(parser.getPackageName(), info.mPackageName); |
| 257 parser.changeString(parser.getHostUrl(), info.mHostUrl); | 258 parser.changeString(parser.getHostUrl(), info.mHostUrl); |
| 259 parser.changeString(parser.getRuntimeHost(), context.getPackageN
ame()); |
| 258 | 260 |
| 259 if (info.mMac != null) { | 261 if (info.mMac != null) { |
| 260 parser.changeString(parser.getMac(), info.mMac); | 262 parser.changeString(parser.getMac(), info.mMac); |
| 261 } | 263 } |
| 262 parser.changeString(parser.getAppName(), info.mAppName); | 264 parser.changeString(parser.getAppName(), info.mAppName); |
| 263 | 265 |
| 264 URL scopeUrl = null; | 266 URL scopeUrl = null; |
| 265 try { | 267 try { |
| 266 scopeUrl = new URL(ensureProtocol(info.mScope)); | 268 scopeUrl = new URL(ensureProtocol(info.mScope)); |
| 267 } catch (MalformedURLException e) { | 269 } catch (MalformedURLException e) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 try { | 453 try { |
| 452 int read = 0; | 454 int read = 0; |
| 453 while ((read = inputStream.read(buffer)) > 0) { | 455 while ((read = inputStream.read(buffer)) > 0) { |
| 454 outputStream.write(buffer, 0, read); | 456 outputStream.write(buffer, 0, read); |
| 455 } | 457 } |
| 456 } finally { | 458 } finally { |
| 457 outputStream.close(); | 459 outputStream.close(); |
| 458 } | 460 } |
| 459 } | 461 } |
| 460 } | 462 } |
| OLD | NEW |