summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuK1337 <priv.luk@gmail.com>2017-12-21 15:20:24 +0100
committerLuK1337 <priv.luk@gmail.com>2019-10-21 21:50:32 +0200
commit1bbe43b15b209c894a92be338685082bdd5799c6 (patch)
tree8fc7336edaa4f3b84af2228c1029b40368e4f652
parenta0fc8cf117775234260255bed2e611450c612821 (diff)
downloadandroid_packages_apps_Gallery2-1bbe43b15b209c894a92be338685082bdd5799c6.tar.gz
android_packages_apps_Gallery2-1bbe43b15b209c894a92be338685082bdd5799c6.tar.bz2
android_packages_apps_Gallery2-1bbe43b15b209c894a92be338685082bdd5799c6.zip
Gallery2: Get rid of packages monitor
* Oreo doesn't allow background services anymore and we don't really need this service anyway. Change-Id: I919326b431b76398decdc4ed82288c2674018963
-rwxr-xr-xAndroidManifest.xml9
-rwxr-xr-xsrc/com/android/gallery3d/app/PackagesMonitor.java94
-rw-r--r--src/com/android/gallery3d/util/GalleryUtils.java12
-rw-r--r--src_pd/com/android/gallery3d/picasasource/PicasaSource.java6
4 files changed, 9 insertions, 112 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 005657f14..2fb9e9f30 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -359,15 +359,6 @@
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
- <receiver android:name="com.android.gallery3d.app.PackagesMonitor">
- <intent-filter>
- <action android:name="android.intent.action.PACKAGE_ADDED"/>
- <action android:name="android.intent.action.PACKAGE_REMOVED"/>
- <action android:name="android.intent.action.PACKAGE_CHANGED"/>
- <data android:scheme="package"/>
- </intent-filter>
- </receiver>
- <service android:name="com.android.gallery3d.app.PackagesMonitor$AsyncService"/>
<service android:name="com.android.gallery3d.gadget.WidgetService"
android:permission="android.permission.BIND_REMOTEVIEWS"/>
<activity android:name="com.android.gallery3d.gadget.WidgetConfigure"
diff --git a/src/com/android/gallery3d/app/PackagesMonitor.java b/src/com/android/gallery3d/app/PackagesMonitor.java
deleted file mode 100755
index 7fc0059b5..000000000
--- a/src/com/android/gallery3d/app/PackagesMonitor.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.app;
-
-import android.app.IntentService;
-import android.app.Notification;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Build;
-import android.preference.PreferenceManager;
-
-import com.android.gallery3d.picasasource.PicasaSource;
-import com.android.gallery3d.util.LightCycleHelper;
-
-public class PackagesMonitor extends BroadcastReceiver {
- public static final String KEY_PACKAGES_VERSION = "packages-version";
-
- public synchronized static int getPackagesVersion(Context context) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- return prefs.getInt(KEY_PACKAGES_VERSION, 1);
- }
-
- @Override
- public void onReceive(final Context context, final Intent intent) {
- intent.setClass(context, AsyncService.class);
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- context.startForegroundService(intent);
- } else {
- context.startService(intent);
- }
- }
-
- public static class AsyncService extends IntentService {
- public AsyncService() {
- super("GalleryPackagesMonitorAsync");
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
- if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- String channelId = "GalleryPackagesMonitorAsync";
- NotificationChannel channel = new NotificationChannel(channelId, channelId,
- NotificationManager.IMPORTANCE_LOW);
- NotificationManager manager =
- (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- manager.createNotificationChannel(channel);
- startForeground(KEY_PACKAGES_VERSION.hashCode(),
- new Notification.Builder(getApplicationContext(), channelId).build());
- }
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- onReceiveAsync(this, intent);
- }
- }
-
- // Runs in a background thread.
- private static void onReceiveAsync(Context context, Intent intent) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
-
- int version = prefs.getInt(KEY_PACKAGES_VERSION, 1);
- prefs.edit().putInt(KEY_PACKAGES_VERSION, version + 1).commit();
-
- String action = intent.getAction();
- String packageName = intent.getData().getSchemeSpecificPart();
- if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
- PicasaSource.onPackageAdded(context, packageName);
- } else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
- PicasaSource.onPackageRemoved(context, packageName);
- } else if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) {
- PicasaSource.onPackageChanged(context, packageName);
- }
- }
-}
diff --git a/src/com/android/gallery3d/util/GalleryUtils.java b/src/com/android/gallery3d/util/GalleryUtils.java
index c62442d9a..3507b089e 100644
--- a/src/com/android/gallery3d/util/GalleryUtils.java
+++ b/src/com/android/gallery3d/util/GalleryUtils.java
@@ -42,7 +42,6 @@ import android.widget.Toast;
import org.codeaurora.gallery.R;
import com.android.gallery3d.app.GalleryActivity;
-import com.android.gallery3d.app.PackagesMonitor;
import com.android.gallery3d.common.ApiHelper;
import com.android.gallery3d.data.DataManager;
import com.android.gallery3d.data.MediaItem;
@@ -75,6 +74,8 @@ public class GalleryUtils {
private static final String KEY_CAMERA_UPDATE = "camera-update";
private static final String KEY_HAS_CAMERA = "has-camera";
+ private static final String KEY_PACKAGES_VERSION = "packages-version";
+
private static float sPixelDensity = -1f;
private static boolean sCameraAvailableInitialized = false;
private static boolean sCameraAvailable;
@@ -204,7 +205,7 @@ public class GalleryUtils {
}
public static boolean isEditorAvailable(Context context, String mimeType) {
- int version = PackagesMonitor.getPackagesVersion(context);
+ int version = getPackagesVersion(context);
String updateKey = PREFIX_PHOTO_EDITOR_UPDATE + mimeType;
String hasKey = PREFIX_HAS_PHOTO_EDITOR + mimeType;
@@ -223,7 +224,7 @@ public class GalleryUtils {
}
public static boolean isAnyCameraAvailable(Context context) {
- int version = PackagesMonitor.getPackagesVersion(context);
+ int version = getPackagesVersion(context);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getInt(KEY_CAMERA_UPDATE, 0) != version) {
PackageManager packageManager = context.getPackageManager();
@@ -470,4 +471,9 @@ public class GalleryUtils {
(TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
return telephonyManager.getCallState() != TelephonyManager.CALL_STATE_IDLE;
}
+
+ public static int getPackagesVersion(Context context) {
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ return prefs.getInt(KEY_PACKAGES_VERSION, 1);
+ }
}
diff --git a/src_pd/com/android/gallery3d/picasasource/PicasaSource.java b/src_pd/com/android/gallery3d/picasasource/PicasaSource.java
index 5e800e23b..fce670b69 100644
--- a/src_pd/com/android/gallery3d/picasasource/PicasaSource.java
+++ b/src_pd/com/android/gallery3d/picasasource/PicasaSource.java
@@ -136,12 +136,6 @@ public class PicasaSource extends MediaSource {
public static void showSignInReminder(Activity context) {/*do nothing*/}
- public static void onPackageAdded(Context context, String packageName) {/*do nothing*/}
-
- public static void onPackageRemoved(Context context, String packageName) {/*do nothing*/}
-
- public static void onPackageChanged(Context context, String packageName) {/*do nothing*/}
-
public static Dialog getVersionCheckDialog(Activity activity){
return null;
}