Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
be03611
imp: updated dependencies & gradle
juliansteenbakker Sep 2, 2021
81d3e30
imp: fixed library importing not working correctly
juliansteenbakker Sep 2, 2021
afa7e92
imp: removed deprecated embedding v1
juliansteenbakker Sep 2, 2021
1a2a88e
imp: fixed packageManager deprecation & other minor improvements
juliansteenbakker Sep 2, 2021
8b76998
test: fix integration test
juliansteenbakker Sep 2, 2021
c8bdda8
imp: update gradle
juliansteenbakker Sep 10, 2021
343e5e4
style: format
juliansteenbakker Sep 10, 2021
31918a7
imp: upgrade test and dependencies
juliansteenbakker Sep 28, 2021
90454f9
imp: upgrade gradle and android compile version
juliansteenbakker Sep 28, 2021
a738e1a
refactor: reverted embedding v1 function + annotation, bumped version…
juliansteenbakker Oct 1, 2021
c371e9a
bug: added registry import
juliansteenbakker Oct 1, 2021
5b33f18
Merge branch 'main' into deprecation
juliansteenbakker Oct 1, 2021
90e8bf5
Merge branch 'main' into deprecation
juliansteenbakker Oct 2, 2021
44fc543
Merge branch 'main' into deprecation
juliansteenbakker Oct 3, 2021
eefc14c
imp: bump version
juliansteenbakker Oct 3, 2021
d4cc7d7
bug: removed double integration test declaration
juliansteenbakker Oct 3, 2021
03b3575
Merge branch 'main' into deprecation
juliansteenbakker Oct 3, 2021
a9c2669
imp: fix test
juliansteenbakker Oct 3, 2021
98b2705
test: removed unused test import
juliansteenbakker Oct 3, 2021
ca3d1bf
test: downgrade because of version mismatch
juliansteenbakker Oct 3, 2021
7c1db24
imp: removed v1 embedding as discussed in #461
juliansteenbakker Oct 4, 2021
48683c4
bump version to 1.3.0 and updated changelog
juliansteenbakker Oct 4, 2021
f1ea833
imp: removed unused import
juliansteenbakker Oct 4, 2021
2c0cfb5
Merge branch 'fluttercommunity:main' into deprecation
juliansteenbakker Oct 4, 2021
5d8e932
Merge branch 'main' into deprecation
juliansteenbakker Oct 5, 2021
d82c81b
style: reformat file
juliansteenbakker Oct 5, 2021
3e8465c
style: reformat file
juliansteenbakker Oct 5, 2021
61879c6
style: reformat file
juliansteenbakker Oct 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/package_info_plus/package_info_plus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.3.0

- Removed deprecated embeddingV1 function
- Upgraded gradle and Android API version

## 1.2.1

- Windows: Annotate int with external in preparation of Flutter 2.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:7.0.2'
}
}

Expand All @@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 28
compileSdkVersion 31

defaultConfig {
minSdkVersion 16
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.fluttercommunity.plus.packageinfo">
<manifest package="dev.fluttercommunity.plus.packageinfo">
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

package dev.fluttercommunity.plus.packageinfo;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import androidx.annotation.NonNull;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
Expand All @@ -25,43 +25,45 @@ public class PackageInfoPlugin implements MethodCallHandler, FlutterPlugin {
private Context applicationContext;
private MethodChannel methodChannel;

/** Plugin registration. */
public static void registerWith(Registrar registrar) {
final PackageInfoPlugin instance = new PackageInfoPlugin();
instance.onAttachedToEngine(registrar.context(), registrar.messenger());
@SuppressWarnings("deprecation")
private static long getLongVersionCode(PackageInfo info) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return info.getLongVersionCode();
}
return info.versionCode;
}

/** Plugin registration. */
@Override
public void onAttachedToEngine(FlutterPluginBinding binding) {
onAttachedToEngine(binding.getApplicationContext(), binding.getBinaryMessenger());
}

private void onAttachedToEngine(Context applicationContext, BinaryMessenger messenger) {
this.applicationContext = applicationContext;
methodChannel = new MethodChannel(messenger, "dev.fluttercommunity.plus/package_info");
this.applicationContext = binding.getApplicationContext();
methodChannel =
new MethodChannel(binding.getBinaryMessenger(), "dev.fluttercommunity.plus/package_info");
methodChannel.setMethodCallHandler(this);
}

@Override
public void onDetachedFromEngine(FlutterPluginBinding binding) {
public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
applicationContext = null;
methodChannel.setMethodCallHandler(null);
methodChannel = null;
}

@Override
public void onMethodCall(MethodCall call, Result result) {
public void onMethodCall(MethodCall call, @NonNull Result result) {
try {
if (call.method.equals("getAll")) {
PackageManager pm = applicationContext.getPackageManager();
PackageInfo info = pm.getPackageInfo(applicationContext.getPackageName(), 0);

String buildSignature = getBuildSignature(pm);

Map<String, String> map = new HashMap<>();
map.put("appName", info.applicationInfo.loadLabel(pm).toString());
map.put("packageName", applicationContext.getPackageName());
map.put("version", info.versionName);
map.put("buildNumber", String.valueOf(getLongVersionCode(info)));
map.put("buildSignature", getBuildSignature(pm));
if (buildSignature != null) map.put("buildSignature", buildSignature);

result.success(map);
} else {
Expand All @@ -73,24 +75,33 @@ public void onMethodCall(MethodCall call, Result result) {
}

@SuppressWarnings("deprecation")
private static long getLongVersionCode(PackageInfo info) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return info.getLongVersionCode();
}
return info.versionCode;
}

private String getBuildSignature(PackageManager pm) {
try {
PackageInfo packageInfo =
pm.getPackageInfo(applicationContext.getPackageName(), PackageManager.GET_SIGNATURES);
if (packageInfo == null
|| packageInfo.signatures == null
|| packageInfo.signatures.length == 0
|| packageInfo.signatures[0] == null) {
return null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
PackageInfo packageInfo =
pm.getPackageInfo(
applicationContext.getPackageName(), PackageManager.GET_SIGNING_CERTIFICATES);
if (packageInfo == null || packageInfo.signingInfo == null) {
return null;
}
if (packageInfo.signingInfo.hasMultipleSigners()) {
return signatureToSha1(packageInfo.signingInfo.getApkContentsSigners()[0].toByteArray());
} else {
return signatureToSha1(
packageInfo.signingInfo.getSigningCertificateHistory()[0].toByteArray());
}
} else {
@SuppressLint("PackageManagerGetSignatures")
PackageInfo packageInfo =
pm.getPackageInfo(applicationContext.getPackageName(), PackageManager.GET_SIGNATURES);
if (packageInfo == null
|| packageInfo.signatures == null
|| packageInfo.signatures.length == 0
|| packageInfo.signatures[0] == null) {
return null;
}
return signatureToSha1(packageInfo.signatures[0].toByteArray());
}
return signatureToSha1(packageInfo.signatures[0].toByteArray());
} catch (PackageManager.NameNotFoundException | NoSuchAlgorithmException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28
compileSdkVersion 31

lintOptions {
disable 'InvalidPackage'
Expand All @@ -34,7 +34,7 @@ android {
defaultConfig {
applicationId "io.flutter.plugins.packageinfoexample"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -53,7 +53,7 @@ flutter {
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".EmbedderV1Activity"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
</activity>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.android.tools.build:gradle:7.0.2'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.enableJetifier=true
android.enableR8=true
android.useAndroidX=true
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withInputStream { stream -> plugins.load(stream) }
}
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ environment:
sdk: '>=2.12.0 <3.0.0'

dependencies:
universal_io: ^2.0.4
flutter:
sdk: flutter
package_info_plus:
path: ../
universal_io: ^1.0.1

dev_dependencies:
flutter_driver:
sdk: flutter
integration_test:
sdk: flutter
test: any
flutter_driver:
sdk: flutter
pedantic: ^1.10.0

flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
Expand All @@ -19,9 +17,9 @@ void main() {
// These tests are based on the example app. The tests should be updated if any related info changes.
if (Platform.isAndroid) {
expect(info.appName, 'package_info_example');
expect(info.buildNumber, '1');
expect(info.buildNumber, '4');
expect(info.packageName, 'io.flutter.plugins.packageinfoexample');
expect(info.version, '1.0');
expect(info.version, '1.2.3');
} else if (Platform.isIOS) {
expect(info.appName, 'Package Info Example');
expect(info.buildNumber, '1');
Expand Down Expand Up @@ -52,10 +50,10 @@ void main() {
await tester.pumpAndSettle();
if (Platform.isAndroid) {
expect(find.text('package_info_example'), findsOneWidget);
expect(find.text('1'), findsOneWidget);
expect(find.text('4'), findsOneWidget);
expect(
find.text('io.flutter.plugins.packageinfoexample'), findsOneWidget);
expect(find.text('1.0'), findsOneWidget);
expect(find.text('1.2.3'), findsOneWidget);
} else if (Platform.isIOS) {
expect(find.text('Package Info Example'), findsOneWidget);
expect(find.text('1'), findsOneWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=2.9

import 'dart:convert';
import 'dart:io';

Expand Down
2 changes: 1 addition & 1 deletion packages/package_info_plus/package_info_plus/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: package_info_plus
description: Flutter plugin for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android.
version: 1.2.1
version: 1.3.0
homepage: https://plus.fluttercommunity.dev/
repository: https://github.com/fluttercommunity/plus_plugins/tree/main/packages/

Expand Down