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

Commit

Permalink
ベネッセのサービスで完全統合
Browse files Browse the repository at this point in the history
  • Loading branch information
s1204IT committed Oct 9, 2023
1 parent e7c6638 commit 2cad308
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* text=auto eol=lf
*.bat text eol=crlf
*.jar binary
*.png binary
26 changes: 5 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@ on:
- 'app/**'
- 'gradle/**'
- '*.gradle'
- 'gradle.properties'
workflow_dispatch:
inputs:
release:
description: 'Release'
type: boolean
required: true
default: false

jobs:
build:
name: Build
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:

- name: Checkout
Expand All @@ -30,7 +23,7 @@ jobs:
with:
distribution: 'temurin'
java-version: '8'

- name: Cache
uses: actions/cache@v3
with:
Expand All @@ -40,22 +33,13 @@ jobs:
key: ${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}

- name: Build with Gradle
run: |
./gradlew aR
run: |
./gradlew aR --no-daemon
echo "version=$(grep versionName app/build.gradle | awk '{print $2}' | tr -d \")" >> $GITHUB_ENV
echo "commit=$(echo ${{ github.sha }} | cut -c -7)" >> $GITHUB_ENV
echo "commit=$(echo ${{ github.sha }} | cut -c-7)" >> $GITHUB_ENV
- name: Upload APK
uses: actions/upload-artifact@v3
with:
name: DchaStateChanger(v${{ env.version }}@${{ env.commit }})
path: app/build/outputs/apk/release/app-release.apk

- name: Release
uses: softprops/action-gh-release@v1
if: github.event.inputs.release == 'true'
with:
tag_name: v${{ env.version }}
draft: true
prerelease: false
files: app/build/outputs/apk/release/app-release.apk
9 changes: 6 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ plugins {
}

android {
compileSdk 28
compileSdk 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId 'jp.co.benesse.touch.setuplogin'
minSdk 28
//noinspection ExpiredTargetSdkVersion
targetSdk 22
versionCode 25
versionName "2.5.0"
versionCode 26
versionName "2.6.0"
}

signingConfigs {
Expand All @@ -38,6 +39,8 @@ android {
}
}
}

dependencies {
compileOnly files('libs/BenesseExtension.jar')
implementation files('libs/DchaService.jar')
}
1 change: 1 addition & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class jp.co.benesse.dcha.dchaservice.IDchaService
18 changes: 13 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="jp.co.benesse.touch.setuplogin">

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

<application
android:label="DchaState Changer"
Expand All @@ -25,15 +24,24 @@

<activity
android:name=".DchaStateChanger"
android:enabled="false"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@android:mipmap/sym_def_app_icon"
android:launchMode="singleInstance"
android:noHistory="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
</intent-filter>
</activity>

<activity
android:name=".Dev"
android:enabled="false"
android:excludeFromRecents="true"
android:exported="true"
android:icon="@drawable/ic_settings_development_alpha"
android:label="開発者向けオプション">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/java/jp/co/benesse/touch/setuplogin/Dev.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package jp.co.benesse.touch.setuplogin;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import static android.os.BenesseExtension.setDchaState;
import static android.provider.Settings.*;
import static android.provider.Settings.Global.*;

public class Dev extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setDchaState(3);
finishAndRemoveTask();
startActivity(new Intent(ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
try {
if ((getInt(getContentResolver(), ADB_ENABLED) == 1) && (getInt(getContentResolver(), DEVELOPMENT_SETTINGS_ENABLED) == 1)) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
setDchaState(0);
}
}, 1000);
}
} catch (SettingNotFoundException ignored) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

import static android.app.admin.DevicePolicyManager.*;
import static android.content.pm.PackageManager.*;
import static android.provider.Settings.System.*;
import static android.util.TypedValue.*;
import static android.view.Gravity.*;
import static android.widget.LinearLayout.LayoutParams.*;

import jp.co.benesse.dcha.dchaservice.IDchaService;
import static android.os.BenesseExtension.*;

public class LoginSettingActivity extends Activity {

IDchaService mDchaService;

public void onBackPressed() {
}

Expand All @@ -29,11 +34,26 @@ public void onCreate(Bundle savedInstanceState) {
String msg;
float fontSize = 50.0F;

if (COUNT_DCHA_COMPLETED_FILE.exists() && canWrite(this)) {
setDchaState(3);
getPackageManager().setComponentEnabledSetting(new ComponentName(this, DchaStateChanger.class), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
if (COUNT_DCHA_COMPLETED_FILE.exists()) {
getPackageManager().setComponentEnabledSetting(new ComponentName(this, Dev.class), COMPONENT_ENABLED_STATE_ENABLED, DONT_KILL_APP);
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);
try {
mDchaService.setSetupStatus(3);
mDchaService.hideNavigationBar(false);
} catch (RemoteException ignored) {
}
unbindService(this);
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
unbindService(this);
}
}, BIND_AUTO_CREATE);

msg = "DchaState を 3 に設定しました";
putInt(getContentResolver(), "hide_navigation_bar", 0);
startActivity(new Intent(ACTION_ADD_DEVICE_ADMIN).putExtra(EXTRA_DEVICE_ADMIN, new ComponentName(this, DeviceAdminReceiver.class)).putExtra(EXTRA_ADD_EXPLANATION,
"「端末管理アプリ」を有効にする事で、 DchaService による自動アンインストールをブロックします。\n\nNova Launcher等のサードパーティ製のランチャーをインストールしていない場合は、\n設定アプリ→「アプリと通知」→「DchaState Changer」 (無い場合は「〇〇個のアプリを全て表示」から選択)→「詳細設定」→「アプリ内のその他の設定」から DchaState を変更できます。"
));
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2cad308

Please sign in to comment.