@@ -35,26 +35,10 @@ public class ManifestInfo {
3535 private static final String TAG = "com.parse.ManifestInfo" ;
3636
3737 private static final Object lock = new Object ();
38- private static long lastModified = -1 ;
3938 /* package */ static int versionCode = -1 ;
4039 /* package */ static String versionName = null ;
4140 private static int iconId = 0 ;
4241 private static String displayName = null ;
43-
44- /**
45- * Returns the last time this application's APK was modified on disk. This is a proxy for both
46- * version changes and if the APK has been restored from backup onto a different device.
47- */
48- public static long getLastModified () {
49- synchronized (lock ) {
50- if (lastModified == -1 ) {
51- File apkPath = new File (getContext ().getApplicationInfo ().sourceDir );
52- lastModified = apkPath .lastModified ();
53- }
54- }
55-
56- return lastModified ;
57- }
5842
5943 /**
6044 * Returns the version code for this app, as specified by the android:versionCode attribute in the
@@ -151,15 +135,6 @@ public static int getIconId() {
151135 }
152136 return list ;
153137 }
154-
155- /*
156- * Returns a message that can be written to the system log if an app expects push to be enabled,
157- * but push isn't actually enabled because the manifest is misconfigured.
158- */
159- static String getPushDisabledMessage () {
160- return "Push is not configured for this app" ;
161- }
162-
163138
164139 private static Context getContext () {
165140 return Parse .getApplicationContext ();
@@ -187,114 +162,4 @@ public static Bundle getApplicationMetadata(Context context) {
187162 }
188163 return null ;
189164 }
190-
191- private static PackageInfo getPackageInfo (String name ) {
192- PackageInfo info = null ;
193-
194- try {
195- info = getPackageManager ().getPackageInfo (name , 0 );
196- } catch (NameNotFoundException e ) {
197- // do nothing
198- }
199-
200- return info ;
201- }
202-
203- static ServiceInfo getServiceInfo (Class <? extends Service > clazz ) {
204- ServiceInfo info = null ;
205- try {
206- info = getPackageManager ().getServiceInfo (new ComponentName (getContext (), clazz ), 0 );
207- } catch (NameNotFoundException e ) {
208- // do nothing
209- }
210-
211- return info ;
212- }
213-
214- private static ActivityInfo getReceiverInfo (Class <? extends BroadcastReceiver > clazz ) {
215- ActivityInfo info = null ;
216- try {
217- info = getPackageManager ().getReceiverInfo (new ComponentName (getContext (), clazz ), 0 );
218- } catch (NameNotFoundException e ) {
219- // do nothing
220- }
221-
222- return info ;
223- }
224-
225- /**
226- * Returns {@code true} if this package has requested all of the listed permissions.
227- * <p />
228- * <strong>Note:</strong> This package might have requested all the permissions, but may not
229- * be granted all of them.
230- */
231- public static boolean hasRequestedPermissions (Context context , String ... permissions ) {
232- String packageName = context .getPackageName ();
233- try {
234- PackageInfo pi = context .getPackageManager ().getPackageInfo (
235- packageName , PackageManager .GET_PERMISSIONS );
236- if (pi .requestedPermissions == null ) {
237- return false ;
238- }
239- return Arrays .asList (pi .requestedPermissions ).containsAll (Arrays .asList (permissions ));
240- } catch (NameNotFoundException e ) {
241- PLog .e (TAG , "Couldn't find info about own package" , e );
242- return false ;
243- }
244- }
245-
246- /**
247- * Returns {@code true} if this package has been granted all of the listed permissions.
248- * <p />
249- * <strong>Note:</strong> This package might have requested all the permissions, but may not
250- * be granted all of them.
251- */
252- public static boolean hasGrantedPermissions (Context context , String ... permissions ) {
253- String packageName = context .getPackageName ();
254- PackageManager packageManager = context .getPackageManager ();
255- for (String permission : permissions ) {
256- if (packageManager .checkPermission (permission , packageName ) != PackageManager .PERMISSION_GRANTED ) {
257- return false ;
258- }
259- }
260-
261- return true ;
262- }
263-
264- private static boolean checkResolveInfo (Class <? extends BroadcastReceiver > clazz , List <ResolveInfo > infoList , String permission ) {
265- for (ResolveInfo info : infoList ) {
266- if (info .activityInfo != null ) {
267- final Class resolveInfoClass ;
268- try {
269- resolveInfoClass = Class .forName (info .activityInfo .name );
270- } catch (ClassNotFoundException e ) {
271- break ;
272- }
273- if (clazz .isAssignableFrom (resolveInfoClass ) && (permission == null || permission .equals (info .activityInfo .permission ))) {
274- return true ;
275- }
276- }
277- }
278-
279- return false ;
280- }
281-
282- public static boolean checkReceiver (Class <? extends BroadcastReceiver > clazz , String permission , Intent [] intents ) {
283- for (Intent intent : intents ) {
284- List <ResolveInfo > receivers = getPackageManager ().queryBroadcastReceivers (intent , 0 );
285- if (receivers .isEmpty ()) {
286- return false ;
287- }
288-
289- if (!checkResolveInfo (clazz , receivers , permission )) {
290- return false ;
291- }
292- }
293-
294- return true ;
295- }
296-
297- public static boolean isGooglePlayServicesAvailable () {
298- return getPackageInfo ("com.google.android.gsf" ) != null ;
299- }
300165}
0 commit comments