Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: base/android/java/src/org/chromium/base/BuildInfo.java

Issue 2845163006: Android: Add version suffix to extracted .pak files (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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.base; 5 package org.chromium.base;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.pm.ApplicationInfo; 8 import android.content.pm.ApplicationInfo;
9 import android.content.pm.PackageInfo; 9 import android.content.pm.PackageInfo;
10 import android.content.pm.PackageManager; 10 import android.content.pm.PackageManager;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 msg = ""; 102 msg = "";
103 if (pi.versionName != null) { 103 if (pi.versionName != null) {
104 msg = pi.versionName; 104 msg = pi.versionName;
105 } 105 }
106 } catch (NameNotFoundException e) { 106 } catch (NameNotFoundException e) {
107 Log.d(TAG, msg); 107 Log.d(TAG, msg);
108 } 108 }
109 return msg; 109 return msg;
110 } 110 }
111 111
112 /** Returns a string that is different each time the apk changes. */
113 @CalledByNative
114 public static String getExtractedFileSuffix() {
115 PackageManager pm = ContextUtils.getApplicationContext().getPackageManag er();
116 try {
117 PackageInfo pi =
118 pm.getPackageInfo(ContextUtils.getApplicationContext().getPa ckageName(), 0);
119 // Use lastUpdateTime when developing locally, since versionCode doe s not normally
120 // change in this case.
121 long version = pi.versionCode > 10 ? pi.versionCode : pi.lastUpdateT ime;
122 return "@" + Long.toHexString(version);
123 } catch (PackageManager.NameNotFoundException e) {
124 throw new RuntimeException(e);
125 }
126 }
127
112 @CalledByNative 128 @CalledByNative
113 public static String getPackageLabel() { 129 public static String getPackageLabel() {
114 // Third-party code does disk read on the getApplicationInfo call. http: //crbug.com/614343 130 // Third-party code does disk read on the getApplicationInfo call. http: //crbug.com/614343
115 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); 131 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
116 try { 132 try {
117 PackageManager packageManager = 133 PackageManager packageManager =
118 ContextUtils.getApplicationContext().getPackageManager(); 134 ContextUtils.getApplicationContext().getPackageManager();
119 ApplicationInfo appInfo = packageManager.getApplicationInfo( 135 ApplicationInfo appInfo = packageManager.getApplicationInfo(
120 getPackageName(), PackageManager.GET_META_DATA); 136 getPackageName(), PackageManager.GET_META_DATA);
121 CharSequence label = packageManager.getApplicationLabel(appInfo); 137 CharSequence label = packageManager.getApplicationLabel(appInfo);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 178
163 /** 179 /**
164 * @return Whether the current app targets the SDK for at least O 180 * @return Whether the current app targets the SDK for at least O
165 */ 181 */
166 public static boolean targetsAtLeastO(Context appContext) { 182 public static boolean targetsAtLeastO(Context appContext) {
167 return isAtLeastO() 183 return isAtLeastO()
168 && appContext.getApplicationInfo().targetSdkVersion 184 && appContext.getApplicationInfo().targetSdkVersion
169 == Build.VERSION_CODES.CUR_DEVELOPMENT; 185 == Build.VERSION_CODES.CUR_DEVELOPMENT;
170 } 186 }
171 } 187 }
OLDNEW
« no previous file with comments | « base/android/build_info.cc ('k') | base/android/java/src/org/chromium/base/ResourceExtractor.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698