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

Commit

Permalink
Playストアのクラッシュを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
s1204IT committed Jan 26, 2024
1 parent a62051e commit 39e071f
Show file tree
Hide file tree
Showing 12 changed files with 263 additions and 118 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
//noinspection ExpiredTargetSdkVersion
targetSdk 22
versionCode 8
versionName "2.1.0"
versionName "3.0.0"
}

signingConfigs {
Expand All @@ -29,13 +29,13 @@ android {
signingConfig signingConfigs.android
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles += 'proguard-rules.pro'
}
release {
signingConfig signingConfigs.android
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles += 'proguard-rules.pro'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-keep class **
-keep class jp.co.benesse.dcha.dchaservice.IDchaService
53 changes: 44 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="jp.co.benesse.touch.setuplogin">
package="jp.co.benesse.touch.setuplogin"
tools:ignore="ProtectedPermissions">

<uses-permission android:name="jp.co.benesse.dcha.permission.ACCESS_SYSTEM" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission
android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

<application
android:label="DchaState Changer"
android:theme="@android:style/Theme.DeviceDefault"
android:theme="@android:style/Theme.NoDisplay"
tools:ignore="MissingApplicationIcon">

<activity
Expand Down Expand Up @@ -102,6 +102,31 @@
</intent-filter>
</activity>

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

<activity
android:name=".PlayUpgradeActivity"
android:clearTaskOnLaunch="true"
android:enabled="false"
android:exported="true"
android:icon="@android:mipmap/sym_def_app_icon"
android:label="BRPの有効化"
android:launchMode="singleInstance"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".BypassActivity"
android:enabled="false"
Expand All @@ -114,10 +139,11 @@

<service
android:name=".BypassService"
android:process=":protect"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="com.saradabar.bypassrevokepermission.data.service.BypassService"/>
<action android:name="jp.co.benesse.touch.setuplogin.BypassService" />
</intent-filter>
</service>

Expand All @@ -131,18 +157,27 @@
</receiver>

<receiver
android:name=".PackageAddedReceiver"
android:name=".PackageReceiver"
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" />
<action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>

<receiver
android:name=".DynamicReceiver"
android:enabled="false"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.ACTION_SHUTDOWN" />
<action android:name="android.intent.action.SCREEN_ON" />
</intent-filter>
</receiver>

<receiver
android:name=".DeviceAdminReceiver"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.BenesseExtension;
import android.provider.Settings;

import java.util.Objects;

public class BootCompletedReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
context.startService(new Intent(context, BypassService.class));
if (Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_BOOT_COMPLETED)) {
BenesseExtension.setDchaState(0);
Settings.System.putInt(context.getContentResolver(), "hide_navigation_bar", 0);
context.startService(new Intent(context, BypassService.class));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,96 @@
package jp.co.benesse.touch.setuplogin;

/*
Based by: Kobold831/BypassRevokePermission
*/

import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.BenesseExtension;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.widget.Toast;

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

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

public class BypassActivity extends Activity {

@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
startService(new Intent(this, BypassService.class));
run(this);
Toast.makeText(this, "実行しました", Toast.LENGTH_SHORT).show();
finishAndRemoveTask();
}

public static void run(final Context context) {
BenesseExtension.setDchaState(3);
copyAssetsFile(context);
context.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) {
IDchaService mDchaService = IDchaService.Stub.asInterface(iBinder);
try {
mDchaService.hideNavigationBar(false);
mDchaService.installApp(context.getExternalFilesDir("") + "/" + "base.apk", 2);
mDchaService.uninstallApp("a.a", 1);
} catch (Exception ignored) {
}
context.unbindService(this);
}

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

Runnable runnable = new Runnable() {
@Override
public void run() {
BenesseExtension.setDchaState(0);
}
};
new Handler().postDelayed(runnable, 800);

if (!isActiveBypassService(context)) {
context.startService(new Intent(context, BypassService.class));
}
}

public static void copyAssetsFile(Context context) {
try {
if (new File(context.getExternalFilesDir("") + "/" + "base.apk").exists()) {
return;
}
InputStream inputStream = context.getAssets().open("base.apk");
FileOutputStream fileOutputStream = new FileOutputStream(context.getExternalFilesDir("") + "/" + "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) {
}
}

public static boolean isActiveBypassService(Context context) {
for (ActivityManager.RunningServiceInfo serviceInfo : ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getRunningServices(Integer.MAX_VALUE)) {
if (BypassService.class.getName().equals(serviceInfo.service.getClassName())) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,100 +2,23 @@


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.content.IntentFilter;
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) {
}
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_SHUTDOWN);
intentFilter.addAction(Intent.ACTION_SCREEN_ON);
registerReceiver(new DynamicReceiver(), intentFilter);
return START_STICKY;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package jp.co.benesse.touch.setuplogin;

import android.annotation.SuppressLint;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import static android.os.BenesseExtension.setDchaState;
import static android.provider.Settings.System.canWrite;
import static android.provider.Settings.System.putInt;

public class DchaStateReceiver extends BroadcastReceiver {
@SuppressLint("UnsafeProtectedBroadcastReceiver")
public void onReceive(Context c, Intent i) {
setDchaState(3);
if (canWrite(c)) {
// ナビバーを表示
putInt(c.getContentResolver(), "hide_navigation_bar", 0);
// スクリーンショットを有効化
putInt(c.getContentResolver(), "allow_screen_shot", 1);
}
}
}
Loading

0 comments on commit 39e071f

Please sign in to comment.