twrpbuilder_plugin 1.0.2 copy "twrpbuilder_plugin: ^1.0.2" to clipboard
twrpbuilder_plugin: ^1.0.2 copied to clipboard

discontinued
outdated

A new Flutter plugin for TwrpBuilder App. With this library you can request root access and also execute Shell commands

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:twrpbuilder_plugin/twrpbuilder_plugin.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _rootAccess = false;
  String dirStatus = "";
  ///These are to test the output
  ///
  String loog2;
  String loog3;
  String loog4;
  String loog5;
  String loog6;
  String loog7;
  bool loog8;
  String loog9;

  @override
  void initState() {
    super.initState();
    initRootRequest();
  }

  Future<void> initRootRequest() async {
    bool rootAccess = await TwrpbuilderPlugin.rootAccess;

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _rootAccess = rootAccess;
    });
  }

  Future<void> _createDir() async {
    if(_rootAccess){
      dirStatus = await TwrpbuilderPlugin.mkDir('TWRPBU'); ///TWRPBU is the name of the directory to be created
      await TwrpbuilderPlugin.cp('/system/build.prop', 'TWRPBU/build.prop');
      String log = await TwrpbuilderPlugin.command('ls');
      String log2 = await TwrpbuilderPlugin.getBuildBrand;
      String log3 = await TwrpbuilderPlugin.getBuildBoard;
      String log4 = await TwrpbuilderPlugin.getBuildAbi;
      String log5 = await TwrpbuilderPlugin.getBuildFingerprint;
      String log6 = await TwrpbuilderPlugin.getBuildModel;
      String log7 = await TwrpbuilderPlugin.getBuildProduct;
      bool log8 = await TwrpbuilderPlugin.isOldMtk;
      String log9 = await TwrpbuilderPlugin.suCommand('find /dev/block/platform -type d -name by-name');
      String log10 = await TwrpbuilderPlugin.getRecoveryMount();

      setState(() {
        loog2 = log2;
        loog3 = log3;
        loog4 = log4;
        loog5 = log5;
        loog6 = log6;
        loog7 = log7;
        loog8 = log8;
        loog9 = log9;
      });

      print(dirStatus);
      print(log);
      print(log2);
      print(log3);
      print(log4);
      print(log5);
      print(log6);
      print(log7);
      print(log8);
      print(log9);
      print(log10);
    }
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        ),
        body: new Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text('Root status: $_rootAccess'),
              Text('Directory status: $dirStatus'),
              Text('Brand: $loog2'),
              Text('Board: $loog3'),
              Text('Abi: $loog4'),
              Text('Fingerprint: $loog5'),
              Text('Model: $loog6'),
              Text('Product: $loog7'),
              Text('Is old mtk: $loog8'),
              Text('Recovery path: $loog9'),
              MaterialButton(onPressed: _createDir, color: Colors.blue, child: Text('Backup'),),
            ],
          ),
        ),
      ),
    );
  }

}
1
likes
0
pub points
0%
popularity

Publisher

verified publisheramitkhairnar.dev

A new Flutter plugin for TwrpBuilder App. With this library you can request root access and also execute Shell commands

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on twrpbuilder_plugin