From ff67c256f52b904bdabe17e755194149da9b219f Mon Sep 17 00:00:00 2001 From: volzhs Date: Tue, 24 May 2016 11:22:35 +0900 Subject: [PATCH] fix compatibility for Android API 14 with supporting API 23 using ``NotificationCompat`` in ``support-v4`` library will increase APK filesize a little bit, but it guarantees to run OK with API 4+ tested with API 19 and 23 devices --- platform/android/AndroidManifest.xml.template | 2 +- platform/android/build.gradle.template | 2 +- .../com/android/vending/licensing/LicenseChecker.java | 6 +++--- .../expansion/downloader/impl/DownloadNotification.java | 9 +++++---- .../expansion/downloader/impl/V14CustomNotification.java | 7 ++++--- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/platform/android/AndroidManifest.xml.template b/platform/android/AndroidManifest.xml.template index 37dee4a9a55..852a821c65a 100644 --- a/platform/android/AndroidManifest.xml.template +++ b/platform/android/AndroidManifest.xml.template @@ -200,6 +200,6 @@ $$ADD_PERMISSION_CHUNKS$$ - + diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template index b960d396eea..411f7789346 100644 --- a/platform/android/build.gradle.template +++ b/platform/android/build.gradle.template @@ -17,7 +17,7 @@ allprojects { } dependencies { - + compile 'com.android.support:support-v4:23.+' $$GRADLE_DEPENDENCIES$$ } diff --git a/platform/android/java/src/com/android/vending/licensing/LicenseChecker.java b/platform/android/java/src/com/android/vending/licensing/LicenseChecker.java index 0b1c4b6cca0..531cb22f8cb 100644 --- a/platform/android/java/src/com/android/vending/licensing/LicenseChecker.java +++ b/platform/android/java/src/com/android/vending/licensing/LicenseChecker.java @@ -146,11 +146,11 @@ public class LicenseChecker implements ServiceConnection { if (mService == null) { Log.i(TAG, "Binding to licensing service."); try { + Intent serviceIntent = new Intent(new String(Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))); + serviceIntent.setPackage("com.android.vending"); boolean bindResult = mContext .bindService( - new Intent( - new String( - Base64.decode("Y29tLmFuZHJvaWQudmVuZGluZy5saWNlbnNpbmcuSUxpY2Vuc2luZ1NlcnZpY2U="))), + serviceIntent, this, // ServiceConnection. Context.BIND_AUTO_CREATE); diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java index a9f674803cb..c754754ff58 100644 --- a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java +++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/DownloadNotification.java @@ -27,6 +27,7 @@ import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.os.Messenger; +import android.support.v4.app.NotificationCompat; /** * This class handles displaying the notification associated with the download @@ -48,8 +49,8 @@ public class DownloadNotification implements IDownloaderClient { private IDownloaderClient mClientProxy; final ICustomNotification mCustomNotification; - private Notification.Builder mNotificationBuilder; - private Notification.Builder mCurrentNotificationBuilder; + private NotificationCompat.Builder mNotificationBuilder; + private NotificationCompat.Builder mCurrentNotificationBuilder; private CharSequence mLabel; private String mCurrentText; private PendingIntent mContentIntent; @@ -185,7 +186,7 @@ public class DownloadNotification implements IDownloaderClient { void setTimeRemaining(long timeRemaining); - Notification.Builder updateNotification(Context c); + NotificationCompat.Builder updateNotification(Context c); } /** @@ -218,7 +219,7 @@ public class DownloadNotification implements IDownloaderClient { mContext.getSystemService(Context.NOTIFICATION_SERVICE); mCustomNotification = CustomNotificationFactory .createCustomNotification(); - mNotificationBuilder = new Notification.Builder(ctx); + mNotificationBuilder = new NotificationCompat.Builder(ctx); mCurrentNotificationBuilder = mNotificationBuilder; } diff --git a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java index 56b2331e310..ab1d0ff84ad 100644 --- a/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java +++ b/platform/android/java/src/com/google/android/vending/expansion/downloader/impl/V14CustomNotification.java @@ -22,6 +22,7 @@ import com.google.android.vending.expansion.downloader.Helpers; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; +import android.support.v4.app.NotificationCompat; public class V14CustomNotification implements DownloadNotification.ICustomNotification { @@ -53,13 +54,13 @@ public class V14CustomNotification implements DownloadNotification.ICustomNotifi mCurrentKB = currentBytes; } - void setProgress(Notification.Builder builder) { + void setProgress(NotificationCompat.Builder builder) { } @Override - public Notification.Builder updateNotification(Context c) { - Notification.Builder builder = new Notification.Builder(c); + public NotificationCompat.Builder updateNotification(Context c) { + NotificationCompat.Builder builder = new NotificationCompat.Builder(c); builder.setContentTitle(mTitle); if (mTotalKB > 0 && -1 != mCurrentKB) { builder.setProgress((int) (mTotalKB >> 8), (int) (mCurrentKB >> 8), false);