Skip to content

Commit

Permalink
CHANGELOG: Initial Support OOS13
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Apr 24, 2024
1 parent 3b01dd0 commit 67d831b
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 107 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/crowdin_download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Crowdin Download

on:
schedule:
- cron: '0 0 * * 0'
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:

synchronize-with-crowdin:
name: Download translations from Crowdin
if: github.repository_owner == 'DHD2280'
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Download translations
uses: crowdin/github-action@v1
with:
upload_translations: false
upload_sources: false
download_translations: true
localization_branch_name: beta-localization
create_pull_request: true
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.DownloadManager;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand Down Expand Up @@ -75,6 +77,7 @@ public class UpdateFragment extends Fragment {

final BroadcastReceiver downloadCompletionReceiver = new BroadcastReceiver() {

@SuppressLint("MissingPermission")
@Override
public void onReceive(Context context, Intent intent) {
if (getContext() != null)
Expand Down Expand Up @@ -109,16 +112,6 @@ public void onReceive(Context context, Intent intent) {
.setContentText(requireContext().getText(R.string.try_again_later))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);

if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
ShellUtils.execCommand(String.format("pm grant %s android.permission.POST_NOTIFICATIONS", BuildConfig.APPLICATION_ID), true); //will ask root if not granted yet
}
NotificationManagerCompat.from(requireContext()).notify(2, builder.build());
}
}
Expand Down Expand Up @@ -176,6 +169,8 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
//Android 13 requires notification permission to be granted or it won't allow it
ShellUtils.execCommand(String.format("pm grant %s android.permission.POST_NOTIFICATIONS", BuildConfig.APPLICATION_ID), true); //will ask root if not granted yet

createChannels();

if (!ShellUtils.checkRootPermission()) {
currentVersionName = getString(R.string.root_not_here);
currentVersionType = -1;
Expand Down Expand Up @@ -285,6 +280,18 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
new ChangelogReceiver(URL, callback).start();
}*/

private void createChannels() {
if (getContext() == null) {
Log.w("UpdateFragment", "createChannels: context is null");
return;
}

NotificationManager notificationManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(getContext().getString(R.string.notification_channel_update), getContext().getString(R.string.notification_channel_update), NotificationManager.IMPORTANCE_DEFAULT);
channel.setDescription(getContext().getString(R.string.notification_channel_update_desc));
notificationManager.createNotificationChannel(channel);
}

private void getCurrentVersion() {
rebootPending = false;
currentVersionName = BuildConfig.VERSION_NAME;
Expand Down Expand Up @@ -317,6 +324,7 @@ public void onDestroyView() {
binding = null;
}

@SuppressLint("MissingPermission")
public void notifyInstall() {
if (getContext() == null) {
Log.w("UpdateFragment", "notifyInstall: context is null");
Expand All @@ -341,9 +349,6 @@ public void notifyInstall() {
.setContentIntent(pendingIntent)
.setAutoCancel(true);

if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
ShellUtils.execCommand(String.format("pm grant %s android.permission.POST_NOTIFICATIONS", BuildConfig.APPLICATION_ID), true); //will ask root if not granted yet
}
NotificationManagerCompat.from(getContext()).notify(1, builder.build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class FeatureEnabler extends XposedMods {
private int centerY;
private int radius;
private Class<?> SystemUIDialogClass;
private Class<?> OplusThemeSystemUiDialog;
private boolean broadcastRegistered = false;

final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
Expand Down Expand Up @@ -97,11 +96,15 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
mContext.registerReceiver(broadcastReceiver, intentFilter, RECEIVER_EXPORTED); //for Android 14, receiver flag is mandatory
}

Class<?> ShutdownViewControl = findClass("com.oplus.systemui.shutdown.ShutdownViewControl", lpparam.classLoader);
//Class<?> ShutdownViewControl = findClass("com.oplus.systemui.shutdown.ShutdownViewControl", lpparam.classLoader);
SystemUIDialogClass = findClass("com.android.systemui.statusbar.phone.SystemUIDialog", lpparam.classLoader);
OplusThemeSystemUiDialog = findClass("com.oplus.systemui.common.dialog.OplusThemeSystemUiDialog", lpparam.classLoader);

Class<?> ShutdownView = findClass("com.oplus.systemui.shutdown.OplusShutdownView", lpparam.classLoader);
Class<?> ShutdownView;
try {
ShutdownView = findClass("com.oplus.systemui.shutdown.OplusShutdownView", lpparam.classLoader);
} catch (Throwable t) {
ShutdownView = findClass("com.oplusos.systemui.controls.OplusShutdownView", lpparam.classLoader); // OOS 13
}

findAndHookMethod(ShutdownView, "onDraw", Canvas.class, new XC_MethodHook() {
@Override
Expand Down Expand Up @@ -146,7 +149,12 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});

Class<?> FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader);
Class<?> FeatureOptions;
try {
FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader);
} catch (Throwable t) {
FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader);
}


hookAllMethods(FeatureOptions, "isOplusVolumeKeyInRight", new XC_MethodHook() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,17 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
});

// Stole Screen Pinning
hookAllMethods(NavigationBarView, "setInScreenPinning", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (PulseControllerImpl.hasInstance()) {
//log(TAG + "Screen pinning: " + (boolean)param.args[0]);
PulseControllerImpl.getInstance().setScreenPinning((boolean) param.args[0]);
try {
hookAllMethods(NavigationBarView, "setInScreenPinning", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
if (PulseControllerImpl.hasInstance()) {
//log(TAG + "Screen pinning: " + (boolean)param.args[0]);
PulseControllerImpl.getInstance().setScreenPinning((boolean) param.args[0]);
}
}
}
});
});
} catch (Throwable ignored){}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public static int getColorAttrDefaultColor(Context context, int resID) {

try {
return (int) callStaticMethod(UtilsClass, "getColorAttrDefaultColor", context, resID, 0);
} catch (Throwable ignored) { //13 QPR1
return (int) callStaticMethod(UtilsClass, "getColorAttrDefaultColor", resID, context);
} catch (Throwable ignored) { //OOS 13
return (int) callStaticMethod(UtilsClass, "getColorAttrDefaultColor", context, resID);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,18 @@ public void updatePrefs(String... Key) {
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if (!lpparam.packageName.equals(listenPackage)) return;

Class<?> SideGestureDetector = findClass("com.oplus.systemui.navigationbar.gesture.sidegesture.SideGestureDetector", lpparam.classLoader);
Class<?> SideGestureNavView = findClass("com.oplus.systemui.navigationbar.gesture.sidegesture.SideGestureNavView", lpparam.classLoader);
Class<?> ScreenShotRunnable = findClass("com.oplus.systemui.qs.tiles.ScreenshotTile$ScreenShotRunnable", lpparam.classLoader);
Class<?> SideGestureDetector;
try {
SideGestureDetector = findClass("com.oplus.systemui.navigationbar.gesture.sidegesture.SideGestureDetector", lpparam.classLoader);
} catch (Throwable t) {
SideGestureDetector = findClass("com.oplusos.systemui.navigationbar.gesture.sidegesture.SideGestureDetector", lpparam.classLoader); // OOS 13
}
Class<?> SideGestureNavView;
try {
SideGestureNavView = findClass("com.oplus.systemui.navigationbar.gesture.sidegesture.SideGestureNavView", lpparam.classLoader);
} catch (Throwable t) {
SideGestureNavView = findClass("com.oplusos.systemui.navigationbar.gesture.sidegesture.SideGestureNavView", lpparam.classLoader); // OOS 13
}


hookAllConstructors(SideGestureDetector, new XC_MethodHook() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ private void notifyUpdate() {
}
updating = true;
ShellUtils.execCommand("settings put system display_battery_style 2", true);
Thread.sleep(750);
Thread.sleep(500);
ShellUtils.execCommand("settings put system display_battery_style 3", true);

Thread.sleep(500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ public void updatePrefs(String... Key) {

@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
final Class<?> QuickStatusBarHeader = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader);
Class<?> QuickStatusBarHeader;
try { QuickStatusBarHeader = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader);
} catch (Throwable t) {
QuickStatusBarHeader = findClass("com.android.systemui.qs.QuickStatusBarHeader", lpparam.classLoader);
}

mClockChipDrawale = new GradientDrawable();
mDateChipDrawale = new GradientDrawable();
Expand All @@ -239,7 +243,12 @@ protected void afterHookedMethod(MethodHookParam param) {
});

//OplusQSFooterImpl
Class<?> OplusQSFooterImpl = findClass("com.oplus.systemui.qs.OplusQSFooterImpl", lpparam.classLoader);
Class<?> OplusQSFooterImpl;
try {
OplusQSFooterImpl = findClass("com.oplus.systemui.qs.OplusQSFooterImpl", lpparam.classLoader);
} catch (Throwable t) {
OplusQSFooterImpl = findClass("com.oplusos.systemui.qs.OplusQSFooterImpl", lpparam.classLoader);
}
hookAllMethods(OplusQSFooterImpl, "onFinishInflate", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
Expand Down Expand Up @@ -284,7 +293,12 @@ protected void afterHookedMethod(MethodHookParam param) {
}
});

Class<?> QsFragmentHelper = findClass("com.oplus.systemui.qs.helper.QSFragmentHelper", lpparam.classLoader);
Class<?> QsFragmentHelper;
try {
QsFragmentHelper = findClass("com.oplus.systemui.qs.helper.QSFragmentHelper", lpparam.classLoader);
} catch (Throwable t) {
QsFragmentHelper = findClass("com.oplusos.systemui.qs.helper.QSFragmentHelper", lpparam.classLoader);
}

hookAllMethods(QsFragmentHelper, "onFractionUpdated", new XC_MethodHook() {
@Override
Expand All @@ -304,7 +318,12 @@ protected void afterHookedMethod(MethodHookParam param) {
}
});

Class<?> OplusClockExImpl = findClass("com.oplus.systemui.common.clock.OplusClockExImpl", lpparam.classLoader);
Class<?> OplusClockExImpl ;
try {
OplusClockExImpl = findClass("com.oplus.systemui.common.clock.OplusClockExImpl", lpparam.classLoader);
} catch (Throwable t) {
OplusClockExImpl = findClass("com.oplusos.systemui.ext.BaseClockExt", lpparam.classLoader);
}
hookAllMethods(OplusClockExImpl, "setTextWithRedOneStyleInternal", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) {
Expand Down Expand Up @@ -342,18 +361,6 @@ protected void beforeHookedMethod(MethodHookParam param) {
}
});

/*hookAllMethods(OplusQSFooterImpl, "updateQsClockView", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
log("updateQsClockView");
boolean z;
ConstraintSet set = new ConstraintSet();
set.setTranslation(mQsClockContainer.getId(), 10f, 10f);
set.applyTo((ConstraintLayout) mQsClockContainer.getParent());
//z = ConstraintSetExt.updateScaleY(this.mTmpConstraintSet, this.mClockView.getId(), 1.0f) | ConstraintSetExt.updateTranslationX(this.mTmpConstraintSet, this.mClockView.getId(), 0.0f) | false | ConstraintSetExt.updateTranslationY(this.mTmpConstraintSet, this.mClockView.getId(), 0.0f) | ConstraintSetExt.updateScaleX(this.mTmpConstraintSet, this.mClockView.getId(), 1.0f);
}
});*/

hookAllMethods(QuickStatusBarHeader, "updateResources", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,17 @@ public void updatePrefs(String... Key) {

@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
Class<?> OplusQSContainerImpl = findClass("com.oplus.systemui.qs.OplusQSContainerImpl", lpparam.classLoader);;
Class<?> QuickStatusBarHeader = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader);;

Class<?> OplusQSContainerImpl;
try {
OplusQSContainerImpl = findClass("com.oplus.systemui.qs.OplusQSContainerImpl", lpparam.classLoader);
} catch (Throwable t) {
OplusQSContainerImpl = findClass("com.oplusos.systemui.qs.OplusQSContainerImpl", lpparam.classLoader); // OOS 13
}
Class<?> QuickStatusBarHeader = null;
try {
QuickStatusBarHeader = findClass("com.oplus.systemui.qs.OplusQuickStatusBarHeader", lpparam.classLoader);;
} catch (Throwable ignored){}

try {
log(TAG + "Hooking");
Expand All @@ -129,7 +138,6 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
protected void afterHookedMethod(MethodHookParam param) {
log(TAG + "onFinishInflate");
FrameLayout mQuickStatusBarHeader = (FrameLayout) param.thisObject;
mQuickStatusBarHeader.setBackgroundColor(Color.TRANSPARENT);

mQsHeaderLayout = new FadingEdgeLayout(mContext);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, qshiHeightPortrait, mContext.getResources().getDisplayMetrics()));
Expand Down Expand Up @@ -158,18 +166,23 @@ protected void afterHookedMethod(MethodHookParam param) {
}
});

hookAllMethods(QuickStatusBarHeader, "onMeasure", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
View mDatePrivacyView = (View) getObjectField(param.thisObject, "mPrivacyContainer");
int mTopViewMeasureHeight = getIntField(param.thisObject, "mTopViewMeasureHeight");
} catch (Throwable ignored) {}

if ((int) callMethod(mDatePrivacyView, "getMeasuredHeight") != mTopViewMeasureHeight) {
setObjectField(param.thisObject, "mTopViewMeasureHeight", callMethod(mDatePrivacyView, "getMeasuredHeight"));
callMethod(param.thisObject, "updateAnimators");
try {
if (QuickStatusBarHeader != null) {
hookAllMethods(QuickStatusBarHeader, "onMeasure", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) {
View mDatePrivacyView = (View) getObjectField(param.thisObject, "mPrivacyContainer");
int mTopViewMeasureHeight = getIntField(param.thisObject, "mTopViewMeasureHeight");

if ((int) callMethod(mDatePrivacyView, "getMeasuredHeight") != mTopViewMeasureHeight) {
setObjectField(param.thisObject, "mTopViewMeasureHeight", callMethod(mDatePrivacyView, "getMeasuredHeight"));
callMethod(param.thisObject, "updateAnimators");
}
}
}
});
});
}
} catch (Throwable ignored) {}
}

Expand Down
Loading

0 comments on commit 67d831b

Please sign in to comment.