@@ -26,9 +26,9 @@ import android.content.Intent
26
26
import android.content.pm.PackageInfo
27
27
import android.content.pm.PackageManager
28
28
import android.net.Uri
29
+ import android.os.Build
29
30
import android.os.Parcel
30
31
import android.util.Base64
31
- import com.dropbox.core.android.DropboxUidNotInitializedException
32
32
import com.dropbox.core.android.internal.DropboxAuthIntent
33
33
34
34
/* *
@@ -152,15 +152,15 @@ public class DbxOfficialAppConnector(uid: String?) {
152
152
public const val EXTRA_DROPBOX_UID : String = " com.dropbox.android.intent.extra.DROPBOX_UID"
153
153
public const val EXTRA_CALLING_PACKAGE : String = " com.dropbox.android.intent.extra.CALLING_PACKAGE"
154
154
155
- // OpenWith intent definitions. You won't need to use this unless you are our official partner in openwith.
155
+ // OpenWith intent definitions. You won't need to use this unless you are our official partner in openwith.
156
156
// from Dropbox actions
157
157
public const val ACTION_DBXC_EDIT : String = " com.dropbox.android.intent.action.DBXC_EDIT"
158
158
public const val ACTION_DBXC_VIEW : String = " com.dropbox.android.intent.action.DBXC_VIEW"
159
159
160
160
// to Dropbox actions
161
161
public const val ACTION_SHOW_DROPBOX_PREVIEW : String = " com.dropbox.android.intent.action.SHOW_PREVIEW"
162
162
163
- // extras (used either dirction)
163
+ // extras (used either dirction)
164
164
public const val EXTRA_DROPBOX_PATH : String = " com.dropbox.android.intent.extra.DROPBOX_PATH"
165
165
public const val EXTRA_DROPBOX_READ_ONLY : String = " com.dropbox.android.intent.extra.READ_ONLY"
166
166
public const val EXTRA_DROPBOX_REV : String = " com.dropbox.android.intent.extra.DROPBOX_REV"
@@ -173,7 +173,6 @@ public class DbxOfficialAppConnector(uid: String?) {
173
173
*/
174
174
@JvmStatic
175
175
public fun isInstalled (context : Context ): DbxOfficialAppInstallInfo ? {
176
-
177
176
// For now, use dAuth intent
178
177
val authIntent = DropboxAuthIntent .buildActionAuthenticateIntent()
179
178
val dropboxPackage = getDropboxAppPackage(context, authIntent) ? : return null
@@ -281,23 +280,37 @@ public class DbxOfficialAppConnector(uid: String?) {
281
280
// The official app doesn't exist, or only an older version
282
281
// is available, or multiple activities are confusing us.
283
282
return null
284
- } else {
285
- // The official app exists. Make sure it's the correct one by
286
- // checking signing keys.
287
- val resolveInfo = manager.resolveActivity(intent, 0 ) ? : return null
288
- val packageInfo: PackageInfo = try {
289
- manager.getPackageInfo(
290
- resolveInfo.activityInfo.packageName,
291
- PackageManager .GET_SIGNATURES
292
- )
283
+ }
284
+ // The official app exists. Make sure it's the correct one by
285
+ // checking signing keys.
286
+ val resolveInfo = manager.resolveActivity(intent, 0 ) ? : return null
287
+ val packageInfo: PackageInfo =
288
+ try {
289
+ if (Build .VERSION .SDK_INT >= 28 ) {
290
+ manager.getPackageInfo(
291
+ resolveInfo.activityInfo.packageName,
292
+ PackageManager .GET_SIGNING_CERTIFICATES ,
293
+ )
294
+ } else {
295
+ manager.getPackageInfo(
296
+ resolveInfo.activityInfo.packageName,
297
+ PackageManager .GET_SIGNATURES
298
+ )
299
+ }
293
300
} catch (e: PackageManager .NameNotFoundException ) {
294
301
return null
295
302
}
296
- for (signature in packageInfo.signatures) {
297
- for (dbSignature in DROPBOX_APP_SIGNATURES ) {
298
- if (dbSignature == signature.toCharsString()) {
299
- return packageInfo
300
- }
303
+
304
+ val signatures = if (Build .VERSION .SDK_INT >= 28 ) {
305
+ packageInfo.signingInfo?.signingCertificateHistory
306
+ } else {
307
+ packageInfo.signatures
308
+ } ? : return null
309
+
310
+ for (signature in signatures) {
311
+ for (dbSignature in DROPBOX_APP_SIGNATURES ) {
312
+ if (dbSignature == signature.toCharsString()) {
313
+ return packageInfo
301
314
}
302
315
}
303
316
}
@@ -352,4 +365,4 @@ public class DbxOfficialAppConnector(uid: String?) {
352
365
return openWithIntent
353
366
}
354
367
}
355
- }
368
+ }
0 commit comments