Archive-AndroidBackup

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "Subclass of Archive::Tar that deals with Android Backup files (adb backup / adb restore)",
   "author" : [
      "Nathaniel Lally <nll@cpan.org>"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 6.86, CPAN::Meta::Converter version 2.133380",
   "license" : [
      "unknown"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Subclass of Archive::Tar that deals with Android Backup files (adb backup / adb restore)'
author:
  - 'Nathaniel Lally <nll@cpan.org>'
build_requires:
  ExtUtils::MakeMaker: 0
configure_requires:
  ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.86, CPAN::Meta::Converter version 2.133380'
license: unknown
meta-spec:

Makefile.PL  view on Meta::CPAN

    'Moose::Util::TypeConstraints' => '0',
	},
	dist => { COMPRESS => 'gzip', SUFFIX   => 'gz' },
	clean =>
	{
		FILES => 'blib/* Makefile MANIFEST MANIFEST.bak Archive-AndroidBackup-*'
	},
	($] ge '5.005') ?
	(
		AUTHOR   => 'Nathaniel Lally <nll@cpan.org>',
		ABSTRACT => 'Subclass of Archive::Tar that deals with Android Backup files (adb backup / adb restore)',
    LICENSE => 'GPL-3',
	) : (),
);

if ($ExtUtils::MakeMaker::VERSION ge '6.46')
{
	$params{META_MERGE} =
	{
		resources =>
		{

README  view on Meta::CPAN

android backup utility
modelled after tar
repo: git@github.com:NathanielLLally/AndroidBackup.git

the motivation to this project stemmed from the evil that is motorola's moto-x 
tyranny in their bootlocker and filesystem security
I simply love games that get ported to android and maintain the same save game
format
one can then easily transfer their progress between devices
this utility makes that simple

there is a java utility named the Android Backup Extractor which can be found
here:
http://sourceforge.net/projects/adbextractor/

and another java tool here:
https://github.com/nelenkov/android-backup-extractor

however, despising graphical applications and deriving enjoyment from perl
programming as i do, you now have abk
(apache people took 'ab' with the benchmarking tool, and mr Elenkov's tool is
  'abe')

  abk [op] file [dir]
    -t list table of contents
    -c create android backup named file from dir
    -x extract
    -v and list toc 

for those not yet aquainted with this android afterthought and wonderfully
clandestine way of transferring private application files, see the following
sample windows session:

NOTE: obtaining and setting up android developer bridge (adb) is out of scope
yet can be known from the listed references below

1: obtain the program's namespace

  adb shell pm list packages | find /I "baldur"

2: create a backup (see xda-devs article below for more info)

  adb backup -f bgeesave.ab com.beamdog.baldursgateenhancededition

3: extract

  abk -xv bgeesave.ab

...

4: create a new ab file from filesystem
  
  abk -c newsave.ab apps/

5: restore the backup

  adb restore newsave.ab

further reading:

http://nelenkov.blogspot.jp/2012/06/unpacking-android-backups.html
http://blog.shvetsov.com/2013/02/access-android-app-data-without-root.html
http://forum.xda-developers.com/showthread.php?t=2011811

lib/Archive/AndroidBackup.pm  view on Meta::CPAN

use IO::Zlib;
use IO::Handle '_IOLBF';
use Archive::AndroidBackup::TarIndex;
extends 'Archive::Tar';

our $VERSION = '1.14';

has 'file' => (
  is => 'rw',
  isa => 'Str',
  default => 'backup.ab',
);

#  defaults to invalid values to ensure
#  explicit setting read_header and write_header
#
subtype 'HdrMagic'
  => as 'Str'
  => where { $_ eq "ANDROID BACKUP" }
  => message {"Invalid Header"};

lib/Archive/AndroidBackup.pm  view on Meta::CPAN


  #  suppress error output
  #
  $Archive::Tar::WARN = 0;

  $self->$orig($tmpFHin);
  
  map { close $_; } $inFH, $tmpFHout, $tmpFHin;

  if ($self->error) {
    die "Invalid Tar file within backup!\n".$self->error;
  }
};

around 'write' => sub 
{
  my ($orig, $self, @args) = @_;
  my $file = shift @args;
  if (not defined $file) {
    $file = $self->file;
  }

lib/Archive/AndroidBackup.pm  view on Meta::CPAN

=head1 SYNOPSIS

=head1 METHODS

=head2 list_files($file)

  prints 

=head2 write($file)

 writes in memory archive to $file in android backup format

=head 2 read($file)

  performs validation while reading $file into memory

=head 2 extract

  performs validation while reading $file into memory

=head2 add_dir($dir)

emulate tar -cf dir

  will correctly sort directory index the way android backup needs it
  (aka the implementation peculiarity that spawned this whole project)

=head1 LICENSE

This package is free software; you can redistribute it and/or modify it
under the terms of the "GNU General Public License v3".

Please refer to the file "COPYING" for details.

=head1 AUTHOR

lib/Archive/AndroidBackup/TarIndex.pm  view on Meta::CPAN

extends 'Archive::AndroidBackup::DirTree';

our $VERSION = '2.1';

=head1 NAME

  Archive::AndroidBackup::TarIndex

=head1 DESCRIPTION

  build a properly sorted and culled archive manifest for android backup
  will infer namespace from _manifest entry

=head1 SYNOPSIS
  
  open (CMD, 'find apps/', '|') || die "no find?!";
  my $tree = new Archive::AndroidBackup::TarIndex;
  while (<CMD>) { 
    chomp;
    $tree->build_from_str($_);
  };

lib/Archive/AndroidBackup/TarIndex.pm  view on Meta::CPAN

  is => 'rw',
  isa => 'Str',
  predicate => 'has_namespace',
  lazy => 1,
  default => sub { ''; },
);

sub as_array
{
  my $self = shift;
  return "invalid android backup: missing _manifest"
    unless ($self->root->has_namespace);

  #  adb restore will break if you try to 
  #  create an exiting private directory (at least on moto x)
  #
  my $ns = $self->root->namespace;
  my %specialDirs = (
      apps => 0,
      "apps/$ns" => 0,
      "apps/$ns/_manifest" => 0,



( run in 0.839 second using v1.01-cache-2.11-cpan-49f99fa48dc )