Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
BypassRevokePermission を統合
Browse files Browse the repository at this point in the history
  • Loading branch information
s1204IT committed Jan 25, 2024
1 parent c34fc6a commit a62051e
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 39 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
minSdk 24
//noinspection ExpiredTargetSdkVersion
targetSdk 22
versionCode 7
versionName "2.0.1"
versionCode 8
versionName "2.1.0"
}

signingConfigs {
Expand Down
45 changes: 37 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@
android:label="ファイルコピー"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>

Expand All @@ -99,21 +98,51 @@
android:label="APKインストーラー"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>

<receiver
android:name=".DchaStateReceiver"
<activity
android:name=".BypassActivity"
android:enabled="false"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<service
android:name=".BypassService"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="com.saradabar.bypassrevokepermission.data.service.BypassService"/>
</intent-filter>
</service>

<receiver
android:name=".BootCompletedReceiver"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

<receiver
android:name=".PackageAddedReceiver"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<action android:name="android.intent.action.PACKAGE_CHANGED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>

<receiver
android:name=".DeviceAdminReceiver"
android:exported="false"
Expand Down
Binary file added app/src/main/assets/base.apk
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package jp.co.benesse.touch.setuplogin;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootCompletedReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context, BypassService.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package jp.co.benesse.touch.setuplogin;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

public class BypassActivity extends Activity {

@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
startService(new Intent(this, BypassService.class));
Toast.makeText(this, "実行しました", Toast.LENGTH_SHORT).show();
finishAndRemoveTask();
}
}
101 changes: 101 additions & 0 deletions app/src/main/java/jp/co/benesse/touch/setuplogin/BypassService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package jp.co.benesse.touch.setuplogin;


import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import jp.co.benesse.dcha.dchaservice.IDchaService;

/*
Based by: Kobold831/BypassRevokePermission
*/

public class BypassService extends Service {

IDchaService mDchaService;
final int DelayMillis = 800;

@Override
public IBinder onBind(Intent intent) {
return null;
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
bindService(new Intent("jp.co.benesse.dcha.dchaservice.DchaService").setPackage("jp.co.benesse.dcha.dchaservice"), new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
mDchaService = IDchaService.Stub.asInterface(iBinder);
}

@Override
public void onServiceDisconnected(ComponentName componentName) {
}
}, Context.BIND_AUTO_CREATE);

Runnable runnable = new Runnable() {
@Override
public void run() {
try {
mDchaService.setSetupStatus(3);
} catch (RemoteException ignored) {
}
}
};
new Handler().postDelayed(runnable, DelayMillis);

copyAssetsFile();

Runnable runnable2 = new Runnable() {
@Override
public void run() {
try {
mDchaService.hideNavigationBar(false);
mDchaService.installApp(Environment.getExternalStorageDirectory() + "/" + "base.apk", 2);
mDchaService.uninstallApp("a.a", 1);
} catch (RemoteException ignored) {
}
}
};
new Handler().postDelayed(runnable2, DelayMillis);

Runnable runnable3 = new Runnable() {
@Override
public void run() {
try {
mDchaService.setSetupStatus(0);
} catch (RemoteException ignored) {
}
}
};
new Handler().postDelayed(runnable3, DelayMillis);
stopSelf();
return START_NOT_STICKY;
}

private void copyAssetsFile() {
try {
InputStream inputStream = getAssets().open("base.apk");
FileOutputStream fileOutputStream = new FileOutputStream(Environment.getExternalStorageDirectory() + "/" + "base.apk", false);
byte[] buffer = new byte[1024];
int length;
while ((length = inputStream.read(buffer)) >= 0) {
fileOutputStream.write(buffer, 0, length);
}
fileOutputStream.close();
inputStream.close();
} catch (IOException ignored) {
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.widget.Toast;

import static android.content.pm.PackageManager.*;
import static android.os.Build.MODEL;
Expand Down Expand Up @@ -100,16 +101,17 @@ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
// アクティビティを無効化
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), DchaCopyFile.class), COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP);
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), DchaInstallApp.class), COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP);
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), DevelopmentOptions.class), COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP);
// 有効化
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), DchaStateReceiver.class), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
// DchaState を 3 にする
mDchaService.setSetupStatus(DIGICHALIZED);
// Googleサービス
for (String pkg : GApps) {
mDchaService.copyFile(SD_PATH + pkg + APK_EXT, LOCAL_PATH + pkg + APK_EXT);
mDchaService.installApp(LOCAL_PATH + pkg + APK_EXT, INSTALL_FLAG);
new File(LOCAL_PATH + pkg + APK_EXT).delete();
if (mDchaService.copyFile(SD_PATH + pkg + APK_EXT, LOCAL_PATH + pkg + APK_EXT)) {
Toast.makeText(getApplicationContext(), pkg + " をインストールしています", Toast.LENGTH_SHORT).show();
mDchaService.installApp(LOCAL_PATH + pkg + APK_EXT, INSTALL_FLAG);
new File(LOCAL_PATH + pkg + APK_EXT).delete();
} else {
Toast.makeText(getApplicationContext(), "ファイルが見つかりません:" + SD_PATH + pkg + APK_EXT, Toast.LENGTH_LONG).show();
}
}
}
}
Expand All @@ -120,6 +122,12 @@ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
// DchaState を 0 にする
if (!MODEL.equals(CTZ)) {
mDchaService.setSetupStatus(UNDIGICHALIZE);
} else {
// CTZ専用のアクティビティ等を有効化
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), BypassService.class), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), BootCompletedReceiver.class), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), PackageAddedReceiver.class), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), BypassActivity.class), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
}
// このアクティビティを無効化
getPackageManager().setComponentEnabledSetting(new ComponentName(getApplicationContext(), LoginSettingActivity.class), COMPONENT_ENABLED_STATE_DISABLED, DONT_KILL_APP);
Expand All @@ -131,7 +139,6 @@ public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
unbindService(this);
}
}, BIND_ADJUST_WITH_ACTIVITY);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package jp.co.benesse.touch.setuplogin;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class PackageAddedReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
if (!intent.getData().toString().replace("package:", "").equals("a.a")) {
switch (intent.getAction()) {
case Intent.ACTION_PACKAGE_ADDED:
case Intent.ACTION_PACKAGE_REMOVED:
case Intent.ACTION_PACKAGE_CHANGED:
case Intent.ACTION_PACKAGE_REPLACED:
context.startService(new Intent(context, BypassService.class));
break;
}
}
}
}

0 comments on commit a62051e

Please sign in to comment.