Skip to content

Commit

Permalink
feat(android): add ability to use hex sha1 signature string in valida…
Browse files Browse the repository at this point in the history
…teSignature (resolves #10)
  • Loading branch information
marchbold committed Jan 9, 2024
1 parent fef08ee commit ac0758e
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 45 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
###### 2024.01.09 [v3.4.1]

```
feat(android): add ability to use hex sha1 signature string in validateSignature (resolves #10)
```

###### 2023.07.20 [v3.4.0]

```
Expand Down
3 changes: 2 additions & 1 deletion example/starling/src/TestPackageManager-app.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/50.1">
<application xmlns="http://ns.adobe.com/air/application/50.2">
<id>com.distriqt.test</id>
<filename>TestPackageManager</filename>
<name>TestPackageManager</name>
Expand Down Expand Up @@ -88,6 +88,7 @@
<extensionID>com.distriqt.Core</extensionID>
<extensionID>com.distriqt.PackageManager</extensionID>
<extensionID>androidx.core</extensionID>
<extensionID>com.jetbrains.kotlin</extensionID>
</extensions>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ package com.distriqt.test.packagemanager
addAction( "Show Install Settings", _tests.showManageUnknownAppSourcesSettings );

addAction( "Kill Process", _tests.killProcess );


addAction( "Validate Signature", _tests.validateSignature );


addChild( _tests );
addChild( _text );
addChild( _container );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,31 @@ package com.distriqt.test.packagemanager
import com.distriqt.extension.packagemanager.PackageInfo;
import com.distriqt.extension.packagemanager.PackageManager;
import com.distriqt.extension.packagemanager.events.PackageManagerEvent;

import flash.filesystem.File;
import flash.utils.getTimer;

import starling.display.Sprite;



/**
*/
public class PackageManagerTests extends Sprite
{
public static const TAG:String = "";

private var _l:ILogger;


private function log( log:String ):void
{
_l.log( TAG, log );
}


////////////////////////////////////////////////////////
// FUNCTIONALITY
//

public function PackageManagerTests( logger:ILogger )
{
_l = logger;
Expand All @@ -59,39 +58,39 @@ package com.distriqt.test.packagemanager
trace( e );
}
}


////////////////////////////////////////////////////////
//
//

public function listen():void
{
log( "listen()" );
PackageManager.service.addEventListener( PackageManagerEvent.PACKAGE_REMOVED, packageRemovedHandler );
}


private function packageRemovedHandler( event:PackageManagerEvent ):void
{
log( event.type + "::" + event.packageName );
}


//
// INSTALLER
//

public function getInstaller():void
{
log( "getInstaller() = " + PackageManager.service.getInstallerPackageName() );
}


//
// INSTALLED APPLICATIONS
//

public function getInstalledApplications():void
{
log( "getInstalledApplications()" );
Expand All @@ -108,19 +107,19 @@ package com.distriqt.test.packagemanager
}
log( "getInstalledApplications(): print complete: " + String( getTimer() - startTime ) );
}


public function getInstalledApplicationsAsync():void
{
log( "getInstalledApplicationsAsync()" );
var startTime:int = getTimer();

//
// You can use either a callback function or the event (or both)
//

PackageManager.service.addEventListener( PackageManagerEvent.GET_INSTALLED_APPLICATIONS, getInstalledApplicationsHandler );

PackageManager.service.getInstalledApplicationsAsync(
function ( installedPackages:Array ):void
{
Expand All @@ -130,14 +129,14 @@ package com.distriqt.test.packagemanager
);
log( "getInstalledApplicationsAsync(): complete: " + String( getTimer() - startTime ) );
}


private function getInstalledApplicationsHandler( event:PackageManagerEvent ):void
{
printPackages( event.data );
}


private function printPackages( installedPackages:Array ):void
{
if (installedPackages != null)
Expand All @@ -148,12 +147,12 @@ package com.distriqt.test.packagemanager
}
}
}


//
// APP INSTALL
//

public function appInstall():void
{
log( "appInstall()" );
Expand All @@ -166,7 +165,7 @@ package com.distriqt.test.packagemanager
File.applicationDirectory.resolvePath( "assets/Main.apk" ).copyTo( apkFile );
log( "copying apk complete" );
}

log( "installApplication( " + apkFile.nativePath + " )" );
PackageManager.service.installApplication( apkFile.nativePath );
}
Expand All @@ -175,27 +174,40 @@ package com.distriqt.test.packagemanager
log( "canRequestApplicationInstalls() = false" );
}
}


public function showManageUnknownAppSourcesSettings():void
{
log( "showManageUnknownAppSourcesSettings()" );
PackageManager.service.showManageUnknownAppSourcesSettings();
}


//
// KILL PROCESS
//


public function killProcess():void
{
var processName:String = "";
var success:Boolean = PackageManager.service.killProcess( processName );
log( "killProcess(" + processName + ") = " + success );
}



//
// SIGNATURES
//

public function validateSignature():void
{
var signature:String = "SHA1SIGNATUREFROMKEYTOOLWITHNOCOLONS".replace( /:/g, "" );
var valid:Boolean = PackageManager.service.validateSignature( signature );
log( "validateSignature(" + signature + "): " + valid );
}


}

}
2 changes: 1 addition & 1 deletion lib/VERSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

| Extension | Version | Android Lib | iOS Lib |
| --- | --- | --- | --- |
| com.distriqt.PackageManager | 3.4.0 | | |
| com.distriqt.PackageManager | 3.4.1 | | |
Binary file modified lib/com.distriqt.PackageManager.ane
Binary file not shown.
Binary file modified lib/swc/com.distriqt.PackageManager.swc
Binary file not shown.

0 comments on commit ac0758e

Please sign in to comment.